<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[14618] PyKerberos/trunk/src/kerberos.c</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/14618">14618</a></dd>
<dt>Author</dt> <dd>wsanchez@apple.com</dd>
<dt>Date</dt> <dd>2015-03-26 14:28:46 -0700 (Thu, 26 Mar 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>cleanup</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#PyKerberostrunksrckerberosc">PyKerberos/trunk/src/kerberos.c</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="PyKerberostrunksrckerberosc"></a>
<div class="modfile"><h4>Modified: PyKerberos/trunk/src/kerberos.c (14617 => 14618)</h4>
<pre class="diff"><span>
<span class="info">--- PyKerberos/trunk/src/kerberos.c        2015-03-26 21:11:48 UTC (rev 14617)
+++ PyKerberos/trunk/src/kerberos.c        2015-03-26 21:28:46 UTC (rev 14618)
</span><span class="lines">@@ -42,18 +42,18 @@
</span><span class="cx"> #endif
</span><span class="cx"> // Handle differences in module definition syntax and interface
</span><span class="cx"> #if PY_MAJOR_VERSION &gt;= 3
</span><del>-  #define MOD_ERROR_VAL NULL
-  #define MOD_SUCCESS_VAL(val) val
-  #define MOD_INIT(name) PyMODINIT_FUNC PyInit_##name(void)
-  #define MOD_DEF(ob, name, doc, methods) \
</del><ins>+    #define MOD_ERROR_VAL NULL
+    #define MOD_SUCCESS_VAL(val) val
+    #define MOD_INIT(name) PyMODINIT_FUNC PyInit_##name(void)
+    #define MOD_DEF(ob, name, doc, methods) \
</ins><span class="cx">           static struct PyModuleDef moduledef = { \
</span><span class="cx">             PyModuleDef_HEAD_INIT, name, doc, -1, methods, }; \
</span><span class="cx">           ob = PyModule_Create(&amp;moduledef);
</span><span class="cx"> #else
</span><del>-  #define MOD_ERROR_VAL
-  #define MOD_SUCCESS_VAL(val)
-  #define MOD_INIT(name) void init##name(void)
-  #define MOD_DEF(ob, name, doc, methods) \
</del><ins>+    #define MOD_ERROR_VAL
+    #define MOD_SUCCESS_VAL(val)
+    #define MOD_INIT(name) void init##name(void)
+    #define MOD_DEF(ob, name, doc, methods) \
</ins><span class="cx">           ob = Py_InitModule3(name, methods, doc);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -71,15 +71,17 @@
</span><span class="cx">     const char *default_realm = NULL;
</span><span class="cx">     int result = 0;
</span><span class="cx"> 
</span><del>-    if (!PyArg_ParseTuple(args, &quot;ssss&quot;, &amp;user, &amp;pswd, &amp;service, &amp;default_realm))
</del><ins>+    if (! PyArg_ParseTuple(args, &quot;ssss&quot;, &amp;user, &amp;pswd, &amp;service, &amp;default_realm)) {
</ins><span class="cx">         return NULL;
</span><ins>+    }
</ins><span class="cx"> 
</span><span class="cx">     result = authenticate_user_krb5pwd(user, pswd, service, default_realm);
</span><span class="cx"> 
</span><del>-    if (result)
</del><ins>+    if (result) {
</ins><span class="cx">         return Py_INCREF(Py_True), Py_True;
</span><del>-    else
</del><ins>+    } else {
</ins><span class="cx">         return NULL;
</span><ins>+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static PyObject *changePassword(PyObject *self, PyObject *args)
</span><span class="lines">@@ -89,15 +91,17 @@
</span><span class="cx">     const char *user = NULL;
</span><span class="cx">     int result = 0;
</span><span class="cx"> 
</span><del>-    if (!PyArg_ParseTuple(args, &quot;sss&quot;, &amp;user, &amp;oldpswd, &amp;newpswd))
</del><ins>+    if (! PyArg_ParseTuple(args, &quot;sss&quot;, &amp;user, &amp;oldpswd, &amp;newpswd)) {
</ins><span class="cx">         return NULL;
</span><ins>+    }
</ins><span class="cx"> 
</span><span class="cx">     result = change_user_krb5pwd(user, oldpswd, newpswd);
</span><span class="cx"> 
</span><del>-    if (result)
-        return Py_INCREF(Py_True), Py_True;
-    else
-        return NULL;
</del><ins>+    if (result) {
+        return Py_INCREF(Py_True), Py_True;
+    } else {
+        return NULL;
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static PyObject *getServerPrincipalDetails(PyObject *self, PyObject *args)
</span><span class="lines">@@ -106,19 +110,19 @@
</span><span class="cx">     const char *hostname = NULL;
</span><span class="cx">     char* result;
</span><span class="cx"> 
</span><del>-    if (!PyArg_ParseTuple(args, &quot;ss&quot;, &amp;service, &amp;hostname))
</del><ins>+    if (! PyArg_ParseTuple(args, &quot;ss&quot;, &amp;service, &amp;hostname)) {
</ins><span class="cx">         return NULL;
</span><ins>+    }
</ins><span class="cx"> 
</span><span class="cx">     result = server_principal_details(service, hostname);
</span><span class="cx"> 
</span><del>-    if (result != NULL)
-    {
</del><ins>+    if (result != NULL) {
</ins><span class="cx">         PyObject* pyresult = Py_BuildValue(&quot;s&quot;, result);
</span><span class="cx">         free(result);
</span><span class="cx">         return pyresult;
</span><ins>+    } else {
+        return NULL;
</ins><span class="cx">     }
</span><del>-    else
-        return NULL;
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static PyObject* authGSSClientInit(PyObject* self, PyObject* args, PyObject* keywds)
</span><span class="lines">@@ -129,22 +133,33 @@
</span><span class="cx">     PyObject *pystate;
</span><span class="cx">     gss_server_state *delegatestate = NULL;
</span><span class="cx">     PyObject *pydelegatestate;
</span><del>-    static char *kwlist[] = {&quot;service&quot;, &quot;principal&quot;, &quot;gssflags&quot;, &quot;delegated&quot;, NULL};
</del><ins>+    static char *kwlist[] = {
+        &quot;service&quot;, &quot;principal&quot;, &quot;gssflags&quot;, &quot;delegated&quot;, NULL
+    };
</ins><span class="cx">     long int gss_flags = GSS_C_MUTUAL_FLAG | GSS_C_SEQUENCE_FLAG;
</span><span class="cx">     int result = 0;
</span><span class="cx"> 
</span><del>-    if (!PyArg_ParseTupleAndKeywords(args, keywds, &quot;s|slO&quot;, kwlist, &amp;service, &amp;principal, &amp;gss_flags, &amp;pydelegatestate))
</del><ins>+    if (! PyArg_ParseTupleAndKeywords(
+        args, keywds, &quot;s|slO&quot;, kwlist,
+        &amp;service, &amp;principal, &amp;gss_flags, &amp;pydelegatestate
+    )) {
</ins><span class="cx">         return NULL;
</span><ins>+    }
</ins><span class="cx"> 
</span><span class="cx">     state = (gss_client_state *) malloc(sizeof(gss_client_state));
</span><span class="cx">     pystate = PyCObject_FromVoidPtr(state, NULL);
</span><span class="cx"> 
</span><del>-    if (PyCObject_Check(pydelegatestate))
</del><ins>+    if (PyCObject_Check(pydelegatestate)) {
</ins><span class="cx">         delegatestate = PyCObject_AsVoidPtr(pydelegatestate);
</span><ins>+    }
</ins><span class="cx"> 
</span><del>-    result = authenticate_gss_client_init(service, principal, gss_flags, delegatestate, state);
-    if (result == AUTH_GSS_ERROR)
</del><ins>+    result = authenticate_gss_client_init(
+        service, principal, gss_flags, delegatestate, state
+    );
+
+    if (result == AUTH_GSS_ERROR) {
</ins><span class="cx">         return NULL;
</span><ins>+    }
</ins><span class="cx"> 
</span><span class="cx">     return Py_BuildValue(&quot;(iO)&quot;, result, pystate);
</span><span class="cx"> }
</span><span class="lines">@@ -155,8 +170,9 @@
</span><span class="cx">     PyObject *pystate;
</span><span class="cx">     int result = 0;
</span><span class="cx"> 
</span><del>-    if (!PyArg_ParseTuple(args, &quot;O&quot;, &amp;pystate))
</del><ins>+    if (! PyArg_ParseTuple(args, &quot;O&quot;, &amp;pystate)) {
</ins><span class="cx">         return NULL;
</span><ins>+    }
</ins><span class="cx"> 
</span><span class="cx">     if (!PyCObject_Check(pystate)) {
</span><span class="cx">         PyErr_SetString(PyExc_TypeError, &quot;Expected a context object&quot;);
</span><span class="lines">@@ -164,8 +180,8 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     state = (gss_client_state *)PyCObject_AsVoidPtr(pystate);
</span><del>-    if (state != NULL)
-    {
</del><ins>+
+    if (state != NULL) {
</ins><span class="cx">         result = authenticate_gss_client_clean(state);
</span><span class="cx"> 
</span><span class="cx">         free(state);
</span><span class="lines">@@ -182,21 +198,26 @@
</span><span class="cx">     char *challenge = NULL;
</span><span class="cx">     int result = 0;
</span><span class="cx"> 
</span><del>-    if (!PyArg_ParseTuple(args, &quot;Os&quot;, &amp;pystate, &amp;challenge))
</del><ins>+    if (! PyArg_ParseTuple(args, &quot;Os&quot;, &amp;pystate, &amp;challenge)) {
</ins><span class="cx">         return NULL;
</span><ins>+    }
</ins><span class="cx"> 
</span><del>-    if (!PyCObject_Check(pystate)) {
</del><ins>+    if (! PyCObject_Check(pystate)) {
</ins><span class="cx">         PyErr_SetString(PyExc_TypeError, &quot;Expected a context object&quot;);
</span><span class="cx">         return NULL;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     state = (gss_client_state *)PyCObject_AsVoidPtr(pystate);
</span><del>-    if (state == NULL)
</del><ins>+
+    if (state == NULL) {
</ins><span class="cx">         return NULL;
</span><ins>+    }
</ins><span class="cx"> 
</span><span class="cx">     result = authenticate_gss_client_step(state, challenge);
</span><del>-    if (result == AUTH_GSS_ERROR)
</del><ins>+
+    if (result == AUTH_GSS_ERROR) {
</ins><span class="cx">         return NULL;
</span><ins>+    }
</ins><span class="cx"> 
</span><span class="cx">     return Py_BuildValue(&quot;i&quot;, result);
</span><span class="cx"> }
</span><span class="lines">@@ -206,17 +227,20 @@
</span><span class="cx">     gss_client_state *state;
</span><span class="cx">     PyObject *pystate;
</span><span class="cx"> 
</span><del>-    if (!PyArg_ParseTuple(args, &quot;O&quot;, &amp;pystate))
</del><ins>+    if (! PyArg_ParseTuple(args, &quot;O&quot;, &amp;pystate)) {
</ins><span class="cx">         return NULL;
</span><ins>+    }
</ins><span class="cx"> 
</span><del>-    if (!PyCObject_Check(pystate)) {
</del><ins>+    if (! PyCObject_Check(pystate)) {
</ins><span class="cx">         PyErr_SetString(PyExc_TypeError, &quot;Expected a context object&quot;);
</span><span class="cx">         return NULL;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     state = (gss_client_state *)PyCObject_AsVoidPtr(pystate);
</span><del>-    if (state == NULL)
</del><ins>+
+    if (state == NULL) {
</ins><span class="cx">         return NULL;
</span><ins>+    }
</ins><span class="cx"> 
</span><span class="cx">     return Py_BuildValue(&quot;i&quot;, state-&gt;responseConf);
</span><span class="cx"> }
</span><span class="lines">@@ -226,17 +250,20 @@
</span><span class="cx">     gss_server_state *state;
</span><span class="cx">     PyObject *pystate;
</span><span class="cx"> 
</span><del>-    if (!PyArg_ParseTuple(args, &quot;O&quot;, &amp;pystate))
</del><ins>+    if (! PyArg_ParseTuple(args, &quot;O&quot;, &amp;pystate)) {
</ins><span class="cx">         return NULL;
</span><ins>+    }
</ins><span class="cx"> 
</span><del>-    if (!PyCObject_Check(pystate)) {
</del><ins>+    if (! PyCObject_Check(pystate)) {
</ins><span class="cx">         PyErr_SetString(PyExc_TypeError, &quot;Expected a context object&quot;);
</span><span class="cx">         return NULL;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     state = (gss_server_state *)PyCObject_AsVoidPtr(pystate);
</span><del>-    if (state == NULL)
</del><ins>+
+    if (state == NULL) {
</ins><span class="cx">         return NULL;
</span><ins>+    }
</ins><span class="cx"> 
</span><span class="cx">     return PyBool_FromLong(authenticate_gss_server_has_delegated(state));
</span><span class="cx"> }
</span><span class="lines">@@ -246,17 +273,20 @@
</span><span class="cx">     gss_client_state *state;
</span><span class="cx">     PyObject *pystate;
</span><span class="cx"> 
</span><del>-    if (!PyArg_ParseTuple(args, &quot;O&quot;, &amp;pystate))
</del><ins>+    if (! PyArg_ParseTuple(args, &quot;O&quot;, &amp;pystate)) {
</ins><span class="cx">         return NULL;
</span><ins>+    }
</ins><span class="cx"> 
</span><del>-    if (!PyCObject_Check(pystate)) {
</del><ins>+    if (! PyCObject_Check(pystate)) {
</ins><span class="cx">         PyErr_SetString(PyExc_TypeError, &quot;Expected a context object&quot;);
</span><span class="cx">         return NULL;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     state = (gss_client_state *)PyCObject_AsVoidPtr(pystate);
</span><del>-    if (state == NULL)
</del><ins>+
+    if (state == NULL) {
</ins><span class="cx">         return NULL;
</span><ins>+    }
</ins><span class="cx"> 
</span><span class="cx">     return Py_BuildValue(&quot;s&quot;, state-&gt;response);
</span><span class="cx"> }
</span><span class="lines">@@ -266,17 +296,20 @@
</span><span class="cx">     gss_client_state *state;
</span><span class="cx">     PyObject *pystate;
</span><span class="cx"> 
</span><del>-    if (!PyArg_ParseTuple(args, &quot;O&quot;, &amp;pystate))
</del><ins>+    if (! PyArg_ParseTuple(args, &quot;O&quot;, &amp;pystate)) {
</ins><span class="cx">         return NULL;
</span><ins>+    }
</ins><span class="cx"> 
</span><del>-    if (!PyCObject_Check(pystate)) {
</del><ins>+    if (! PyCObject_Check(pystate)) {
</ins><span class="cx">         PyErr_SetString(PyExc_TypeError, &quot;Expected a context object&quot;);
</span><span class="cx">         return NULL;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     state = (gss_client_state *)PyCObject_AsVoidPtr(pystate);
</span><del>-    if (state == NULL)
</del><ins>+
+    if (state == NULL) {
</ins><span class="cx">         return NULL;
</span><ins>+    }
</ins><span class="cx"> 
</span><span class="cx">     return Py_BuildValue(&quot;s&quot;, state-&gt;username);
</span><span class="cx"> }
</span><span class="lines">@@ -288,21 +321,26 @@
</span><span class="cx">         char *challenge = NULL;
</span><span class="cx">         int result = 0;
</span><span class="cx"> 
</span><del>-        if (!PyArg_ParseTuple(args, &quot;Os&quot;, &amp;pystate, &amp;challenge))
</del><ins>+        if (! PyArg_ParseTuple(args, &quot;Os&quot;, &amp;pystate, &amp;challenge)) {
</ins><span class="cx">                 return NULL;
</span><ins>+    }
</ins><span class="cx"> 
</span><del>-        if (!PyCObject_Check(pystate)) {
</del><ins>+        if (! PyCObject_Check(pystate)) {
</ins><span class="cx">                 PyErr_SetString(PyExc_TypeError, &quot;Expected a context object&quot;);
</span><span class="cx">                 return NULL;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         state = (gss_client_state *)PyCObject_AsVoidPtr(pystate);
</span><del>-        if (state == NULL)
</del><ins>+
+        if (state == NULL) {
</ins><span class="cx">                 return NULL;
</span><ins>+    }
</ins><span class="cx"> 
</span><span class="cx">         result = authenticate_gss_client_unwrap(state, challenge);
</span><del>-        if (result == AUTH_GSS_ERROR)
</del><ins>+
+        if (result == AUTH_GSS_ERROR) {
</ins><span class="cx">                 return NULL;
</span><ins>+    }
</ins><span class="cx"> 
</span><span class="cx">         return Py_BuildValue(&quot;i&quot;, result);
</span><span class="cx"> }
</span><span class="lines">@@ -316,21 +354,28 @@
</span><span class="cx">         int protect = 0;
</span><span class="cx">         int result = 0;
</span><span class="cx"> 
</span><del>-        if (!PyArg_ParseTuple(args, &quot;Os|zi&quot;, &amp;pystate, &amp;challenge, &amp;user, &amp;protect))
</del><ins>+        if (! PyArg_ParseTuple(
+        args, &quot;Os|zi&quot;, &amp;pystate, &amp;challenge, &amp;user, &amp;protect
+    )) {
</ins><span class="cx">                 return NULL;
</span><ins>+    }
</ins><span class="cx"> 
</span><del>-        if (!PyCObject_Check(pystate)) {
</del><ins>+        if (! PyCObject_Check(pystate)) {
</ins><span class="cx">                 PyErr_SetString(PyExc_TypeError, &quot;Expected a context object&quot;);
</span><span class="cx">                 return NULL;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         state = (gss_client_state *)PyCObject_AsVoidPtr(pystate);
</span><del>-        if (state == NULL)
</del><ins>+
+        if (state == NULL) {
</ins><span class="cx">                 return NULL;
</span><ins>+    }
</ins><span class="cx"> 
</span><span class="cx">         result = authenticate_gss_client_wrap(state, challenge, user, protect);
</span><del>-        if (result == AUTH_GSS_ERROR)
</del><ins>+
+        if (result == AUTH_GSS_ERROR) {
</ins><span class="cx">                 return NULL;
</span><ins>+    }
</ins><span class="cx"> 
</span><span class="cx">         return Py_BuildValue(&quot;i&quot;, result);
</span><span class="cx"> }
</span><span class="lines">@@ -342,15 +387,18 @@
</span><span class="cx">     PyObject *pystate;
</span><span class="cx">     int result = 0;
</span><span class="cx"> 
</span><del>-    if (!PyArg_ParseTuple(args, &quot;s&quot;, &amp;service))
</del><ins>+    if (! PyArg_ParseTuple(args, &quot;s&quot;, &amp;service)) {
</ins><span class="cx">         return NULL;
</span><ins>+    }
</ins><span class="cx"> 
</span><span class="cx">     state = (gss_server_state *) malloc(sizeof(gss_server_state));
</span><span class="cx">     pystate = PyCObject_FromVoidPtr(state, NULL);
</span><span class="cx"> 
</span><span class="cx">     result = authenticate_gss_server_init(service, state);
</span><del>-    if (result == AUTH_GSS_ERROR)
</del><ins>+
+    if (result == AUTH_GSS_ERROR) {
</ins><span class="cx">         return NULL;
</span><ins>+    }
</ins><span class="cx"> 
</span><span class="cx">     return Py_BuildValue(&quot;(iO)&quot;, result, pystate);
</span><span class="cx"> }
</span><span class="lines">@@ -361,17 +409,18 @@
</span><span class="cx">     PyObject *pystate;
</span><span class="cx">     int result = 0;
</span><span class="cx"> 
</span><del>-    if (!PyArg_ParseTuple(args, &quot;O&quot;, &amp;pystate))
</del><ins>+    if (! PyArg_ParseTuple(args, &quot;O&quot;, &amp;pystate)) {
</ins><span class="cx">         return NULL;
</span><ins>+    }
</ins><span class="cx"> 
</span><del>-    if (!PyCObject_Check(pystate)) {
</del><ins>+    if (! PyCObject_Check(pystate)) {
</ins><span class="cx">         PyErr_SetString(PyExc_TypeError, &quot;Expected a context object&quot;);
</span><span class="cx">         return NULL;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     state = (gss_server_state *)PyCObject_AsVoidPtr(pystate);
</span><del>-    if (state != NULL)
-    {
</del><ins>+
+    if (state != NULL) {
</ins><span class="cx">         result = authenticate_gss_server_clean(state);
</span><span class="cx"> 
</span><span class="cx">         free(state);
</span><span class="lines">@@ -388,21 +437,26 @@
</span><span class="cx">     char *challenge = NULL;
</span><span class="cx">     int result = 0;
</span><span class="cx"> 
</span><del>-    if (!PyArg_ParseTuple(args, &quot;Os&quot;, &amp;pystate, &amp;challenge))
</del><ins>+    if (! PyArg_ParseTuple(args, &quot;Os&quot;, &amp;pystate, &amp;challenge)) {
</ins><span class="cx">         return NULL;
</span><ins>+    }
</ins><span class="cx"> 
</span><del>-    if (!PyCObject_Check(pystate)) {
</del><ins>+    if (! PyCObject_Check(pystate)) {
</ins><span class="cx">         PyErr_SetString(PyExc_TypeError, &quot;Expected a context object&quot;);
</span><span class="cx">         return NULL;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     state = (gss_server_state *)PyCObject_AsVoidPtr(pystate);
</span><del>-    if (state == NULL)
</del><ins>+
+    if (state == NULL) {
</ins><span class="cx">         return NULL;
</span><ins>+    }
</ins><span class="cx"> 
</span><span class="cx">     result = authenticate_gss_server_step(state, challenge);
</span><del>-    if (result == AUTH_GSS_ERROR)
</del><ins>+
+    if (result == AUTH_GSS_ERROR) {
</ins><span class="cx">         return NULL;
</span><ins>+    }
</ins><span class="cx"> 
</span><span class="cx">     return Py_BuildValue(&quot;i&quot;, result);
</span><span class="cx"> }
</span><span class="lines">@@ -413,21 +467,26 @@
</span><span class="cx">     PyObject *pystate;
</span><span class="cx">     int result = 0;
</span><span class="cx"> 
</span><del>-    if (!PyArg_ParseTuple(args, &quot;O&quot;, &amp;pystate))
</del><ins>+    if (! PyArg_ParseTuple(args, &quot;O&quot;, &amp;pystate)) {
</ins><span class="cx">         return NULL;
</span><ins>+    }
</ins><span class="cx"> 
</span><del>-    if (!PyCObject_Check(pystate)) {
</del><ins>+    if (! PyCObject_Check(pystate)) {
</ins><span class="cx">         PyErr_SetString(PyExc_TypeError, &quot;Expected a context object&quot;);
</span><span class="cx">         return NULL;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     state = (gss_server_state *)PyCObject_AsVoidPtr(pystate);
</span><del>-    if (state == NULL)
</del><ins>+
+    if (state == NULL) {
</ins><span class="cx">         return NULL;
</span><ins>+    }
</ins><span class="cx"> 
</span><span class="cx">     result = authenticate_gss_server_store_delegate(state);
</span><del>-    if (result == AUTH_GSS_ERROR)
</del><ins>+
+    if (result == AUTH_GSS_ERROR) {
</ins><span class="cx">         return NULL;
</span><ins>+    }
</ins><span class="cx">     
</span><span class="cx">     return Py_BuildValue(&quot;i&quot;, result);
</span><span class="cx"> }
</span><span class="lines">@@ -437,17 +496,20 @@
</span><span class="cx">     gss_server_state *state;
</span><span class="cx">     PyObject *pystate;
</span><span class="cx"> 
</span><del>-    if (!PyArg_ParseTuple(args, &quot;O&quot;, &amp;pystate))
</del><ins>+    if (! PyArg_ParseTuple(args, &quot;O&quot;, &amp;pystate)) {
</ins><span class="cx">         return NULL;
</span><ins>+    }
</ins><span class="cx"> 
</span><del>-    if (!PyCObject_Check(pystate)) {
</del><ins>+    if (! PyCObject_Check(pystate)) {
</ins><span class="cx">         PyErr_SetString(PyExc_TypeError, &quot;Expected a context object&quot;);
</span><span class="cx">         return NULL;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     state = (gss_server_state *)PyCObject_AsVoidPtr(pystate);
</span><del>-    if (state == NULL)
</del><ins>+
+    if (state == NULL) {
</ins><span class="cx">         return NULL;
</span><ins>+    }
</ins><span class="cx"> 
</span><span class="cx">     return Py_BuildValue(&quot;s&quot;, state-&gt;response);
</span><span class="cx"> }
</span><span class="lines">@@ -457,17 +519,20 @@
</span><span class="cx">     gss_server_state *state;
</span><span class="cx">     PyObject *pystate;
</span><span class="cx">     
</span><del>-    if (!PyArg_ParseTuple(args, &quot;O&quot;, &amp;pystate))
</del><ins>+    if (! PyArg_ParseTuple(args, &quot;O&quot;, &amp;pystate)) {
</ins><span class="cx">         return NULL;
</span><ins>+    }
</ins><span class="cx">     
</span><del>-    if (!PyCObject_Check(pystate)) {
</del><ins>+    if (! PyCObject_Check(pystate)) {
</ins><span class="cx">         PyErr_SetString(PyExc_TypeError, &quot;Expected a context object&quot;);
</span><span class="cx">         return NULL;
</span><span class="cx">     }
</span><span class="cx">     
</span><span class="cx">     state = (gss_server_state *)PyCObject_AsVoidPtr(pystate);
</span><del>-    if (state == NULL)
</del><ins>+
+    if (state == NULL) {
</ins><span class="cx">         return NULL;
</span><ins>+    }
</ins><span class="cx">     
</span><span class="cx">     return Py_BuildValue(&quot;s&quot;, state-&gt;username);
</span><span class="cx"> }
</span><span class="lines">@@ -477,18 +542,21 @@
</span><span class="cx">     gss_server_state *state;
</span><span class="cx">     PyObject *pystate;
</span><span class="cx">     
</span><del>-    if (!PyArg_ParseTuple(args, &quot;O&quot;, &amp;pystate))
</del><ins>+    if (! PyArg_ParseTuple(args, &quot;O&quot;, &amp;pystate)) {
</ins><span class="cx">         return NULL;
</span><ins>+    }
</ins><span class="cx">     
</span><del>-    if (!PyCObject_Check(pystate)) {
</del><ins>+    if (! PyCObject_Check(pystate)) {
</ins><span class="cx">         PyErr_SetString(PyExc_TypeError, &quot;Expected a context object&quot;);
</span><span class="cx">         return NULL;
</span><span class="cx">     }
</span><span class="cx">     
</span><span class="cx">     state = (gss_server_state *)PyCObject_AsVoidPtr(pystate);
</span><del>-    if (state == NULL)
</del><ins>+
+    if (state == NULL) {
</ins><span class="cx">         return NULL;
</span><del>-    
</del><ins>+    }
+
</ins><span class="cx">     return Py_BuildValue(&quot;s&quot;, state-&gt;ccname);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -497,62 +565,125 @@
</span><span class="cx">     gss_server_state *state;
</span><span class="cx">     PyObject *pystate;
</span><span class="cx">     
</span><del>-    if (!PyArg_ParseTuple(args, &quot;O&quot;, &amp;pystate))
</del><ins>+    if (! PyArg_ParseTuple(args, &quot;O&quot;, &amp;pystate)) {
</ins><span class="cx">         return NULL;
</span><ins>+    }
</ins><span class="cx">     
</span><del>-    if (!PyCObject_Check(pystate)) {
</del><ins>+    if (! PyCObject_Check(pystate)) {
</ins><span class="cx">         PyErr_SetString(PyExc_TypeError, &quot;Expected a context object&quot;);
</span><span class="cx">         return NULL;
</span><span class="cx">     }
</span><span class="cx">     
</span><span class="cx">     state = (gss_server_state *)PyCObject_AsVoidPtr(pystate);
</span><del>-    if (state == NULL)
</del><ins>+
+    if (state == NULL) {
</ins><span class="cx">         return NULL;
</span><ins>+    }
</ins><span class="cx">     
</span><span class="cx">     return Py_BuildValue(&quot;s&quot;, state-&gt;targetname);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static PyMethodDef KerberosMethods[] = {
</span><del>-    {&quot;checkPassword&quot;,  checkPassword, METH_VARARGS,
-     &quot;Check the supplied user/password against Kerberos KDC.&quot;},
-    {&quot;changePassword&quot;,  changePassword, METH_VARARGS,
-     &quot;Change the user password.&quot;},
-    {&quot;getServerPrincipalDetails&quot;,  getServerPrincipalDetails, METH_VARARGS,
-     &quot;Return the service principal for a given service and hostname.&quot;},
-    {&quot;authGSSClientInit&quot;,  (PyCFunction)authGSSClientInit, METH_VARARGS | METH_KEYWORDS,
-     &quot;Initialize client-side GSSAPI operations.&quot;},
-    {&quot;authGSSClientClean&quot;,  authGSSClientClean, METH_VARARGS,
-     &quot;Terminate client-side GSSAPI operations.&quot;},
-    {&quot;authGSSClientStep&quot;,  authGSSClientStep, METH_VARARGS,
-     &quot;Do a client-side GSSAPI step.&quot;},
-    {&quot;authGSSClientResponse&quot;,  authGSSClientResponse, METH_VARARGS,
-     &quot;Get the response from the last client-side GSSAPI step.&quot;},
-    {&quot;authGSSClientResponseConf&quot;,  authGSSClientResponseConf, METH_VARARGS,
-     &quot;return 1 if confidentiality was set in the last unwrapped buffer, 0 otherwise.&quot;},
-    {&quot;authGSSClientUserName&quot;,  authGSSClientUserName, METH_VARARGS,
-     &quot;Get the user name from the last client-side GSSAPI step.&quot;},
-    {&quot;authGSSServerInit&quot;,  authGSSServerInit, METH_VARARGS,
-     &quot;Initialize server-side GSSAPI operations.&quot;},
-    {&quot;authGSSClientWrap&quot;,  authGSSClientWrap, METH_VARARGS,
-     &quot;Do a GSSAPI wrap.&quot;},
-    {&quot;authGSSClientUnwrap&quot;,  authGSSClientUnwrap, METH_VARARGS,
-     &quot;Do a GSSAPI unwrap.&quot;},
-    {&quot;authGSSServerClean&quot;,  authGSSServerClean, METH_VARARGS,
-     &quot;Terminate server-side GSSAPI operations.&quot;},
-    {&quot;authGSSServerStep&quot;,  authGSSServerStep, METH_VARARGS,
-     &quot;Do a server-side GSSAPI step.&quot;},
-    {&quot;authGSSServerHasDelegated&quot;,  authGSSServerHasDelegated, METH_VARARGS,
-     &quot;Check whether the client delegated credentials to us.&quot;},
-     {&quot;authGSSServerStoreDelegate&quot;,  authGSSServerStoreDelegate, METH_VARARGS,
-     &quot;Store the delegated Credentials.&quot;},
-    {&quot;authGSSServerResponse&quot;,  authGSSServerResponse, METH_VARARGS,
-     &quot;Get the response from the last server-side GSSAPI step.&quot;},
-    {&quot;authGSSServerUserName&quot;,  authGSSServerUserName, METH_VARARGS,
-        &quot;Get the user name from the last server-side GSSAPI step.&quot;},
-    {&quot;authGSSServerCacheName&quot;,  authGSSServerCacheName, METH_VARARGS,
-        &quot;Get the location of the cache where delegated credentials are stored.&quot;},
-    {&quot;authGSSServerTargetName&quot;,  authGSSServerTargetName, METH_VARARGS,
-        &quot;Get the target name from the last server-side GSSAPI step.&quot;},
</del><ins>+    {
+        &quot;checkPassword&quot;,
+        checkPassword, METH_VARARGS,
+        &quot;Check the supplied user/password against Kerberos KDC.&quot;
+    },
+    {
+        &quot;changePassword&quot;,
+        changePassword, METH_VARARGS,
+        &quot;Change the user password.&quot;
+    },
+    {
+        &quot;getServerPrincipalDetails&quot;,
+        getServerPrincipalDetails, METH_VARARGS,
+        &quot;Return the service principal for a given service and hostname.&quot;
+    },
+    {
+        &quot;authGSSClientInit&quot;,
+        (PyCFunction)authGSSClientInit, METH_VARARGS | METH_KEYWORDS,
+        &quot;Initialize client-side GSSAPI operations.&quot;
+    },
+    {
+        &quot;authGSSClientClean&quot;,
+        authGSSClientClean, METH_VARARGS,
+        &quot;Terminate client-side GSSAPI operations.&quot;
+    },
+    {
+        &quot;authGSSClientStep&quot;,
+        authGSSClientStep, METH_VARARGS,
+        &quot;Do a client-side GSSAPI step.&quot;
+    },
+    {
+        &quot;authGSSClientResponse&quot;,
+        authGSSClientResponse, METH_VARARGS,
+        &quot;Get the response from the last client-side GSSAPI step.&quot;
+    },
+    {
+        &quot;authGSSClientResponseConf&quot;,
+        authGSSClientResponseConf, METH_VARARGS,
+        &quot;return 1 if confidentiality was set in the last unwrapped buffer, 0 otherwise.&quot;
+    },
+    {
+        &quot;authGSSClientUserName&quot;,
+        authGSSClientUserName, METH_VARARGS,
+        &quot;Get the user name from the last client-side GSSAPI step.&quot;
+    },
+    {
+        &quot;authGSSServerInit&quot;,
+        authGSSServerInit, METH_VARARGS,
+        &quot;Initialize server-side GSSAPI operations.&quot;
+    },
+    {
+        &quot;authGSSClientWrap&quot;,
+        authGSSClientWrap, METH_VARARGS,
+        &quot;Do a GSSAPI wrap.&quot;
+    },
+    {
+        &quot;authGSSClientUnwrap&quot;,
+        authGSSClientUnwrap, METH_VARARGS,
+        &quot;Do a GSSAPI unwrap.&quot;
+    },
+    {
+        &quot;authGSSServerClean&quot;,
+        authGSSServerClean, METH_VARARGS,
+        &quot;Terminate server-side GSSAPI operations.&quot;
+    },
+    {
+        &quot;authGSSServerStep&quot;,
+        authGSSServerStep, METH_VARARGS,
+        &quot;Do a server-side GSSAPI step.&quot;
+    },
+    {
+        &quot;authGSSServerHasDelegated&quot;,
+        authGSSServerHasDelegated, METH_VARARGS,
+        &quot;Check whether the client delegated credentials to us.&quot;
+    },
+    {
+        &quot;authGSSServerStoreDelegate&quot;,
+        authGSSServerStoreDelegate, METH_VARARGS,
+        &quot;Store the delegated Credentials.&quot;
+    },
+    {
+        &quot;authGSSServerResponse&quot;,
+        authGSSServerResponse, METH_VARARGS,
+        &quot;Get the response from the last server-side GSSAPI step.&quot;
+    },
+    {
+        &quot;authGSSServerUserName&quot;,
+        authGSSServerUserName, METH_VARARGS,
+        &quot;Get the user name from the last server-side GSSAPI step.&quot;
+    },
+    {
+        &quot;authGSSServerCacheName&quot;,
+        authGSSServerCacheName, METH_VARARGS,
+        &quot;Get the location of the cache where delegated credentials are stored.&quot;
+    },
+    {
+        &quot;authGSSServerTargetName&quot;,
+        authGSSServerTargetName, METH_VARARGS,
+        &quot;Get the target name from the last server-side GSSAPI step.&quot;
+    },
</ins><span class="cx">     {NULL, NULL, 0, NULL}        /* Sentinel */
</span><span class="cx"> };
</span><span class="cx"> 
</span><span class="lines">@@ -562,50 +693,92 @@
</span><span class="cx"> 
</span><span class="cx">     MOD_DEF(m, &quot;kerberos&quot;, NULL, KerberosMethods);
</span><span class="cx"> 
</span><del>-    if (m == NULL)
</del><ins>+    if (m == NULL) {
</ins><span class="cx">         return MOD_ERROR_VAL;
</span><ins>+    }
</ins><span class="cx"> 
</span><span class="cx">     d = PyModule_GetDict(m);
</span><span class="cx"> 
</span><span class="cx">     /* create the base exception class */
</span><del>-    if (!(KrbException_class = PyErr_NewException(&quot;kerberos.KrbError&quot;, NULL, NULL)))
</del><ins>+    if (! (KrbException_class = PyErr_NewException(
+        &quot;kerberos.KrbError&quot;, NULL, NULL
+    ))) {
</ins><span class="cx">         goto error;
</span><ins>+    }
+
</ins><span class="cx">     PyDict_SetItemString(d, &quot;KrbError&quot;, KrbException_class);
</span><span class="cx">     Py_INCREF(KrbException_class);
</span><span class="cx"> 
</span><span class="cx">     /* ...and the derived exceptions */
</span><del>-    if (!(BasicAuthException_class = PyErr_NewException(&quot;kerberos.BasicAuthError&quot;, KrbException_class, NULL)))
</del><ins>+    if (! (BasicAuthException_class = PyErr_NewException(
+        &quot;kerberos.BasicAuthError&quot;, KrbException_class, NULL
+    ))) {
</ins><span class="cx">         goto error;
</span><ins>+    }
+
</ins><span class="cx">     Py_INCREF(BasicAuthException_class);
</span><span class="cx">     PyDict_SetItemString(d, &quot;BasicAuthError&quot;, BasicAuthException_class);
</span><span class="cx"> 
</span><del>-    if (!(PwdChangeException_class = PyErr_NewException(&quot;kerberos.PwdChangeError&quot;, KrbException_class, NULL)))
</del><ins>+    if (! (PwdChangeException_class = PyErr_NewException(
+        &quot;kerberos.PwdChangeError&quot;, KrbException_class, NULL
+    ))) {
</ins><span class="cx">         goto error;
</span><ins>+    }
+
</ins><span class="cx">     Py_INCREF(PwdChangeException_class);
</span><span class="cx">     PyDict_SetItemString(d, &quot;PwdChangeError&quot;, PwdChangeException_class);
</span><span class="cx"> 
</span><del>-    if (!(GssException_class = PyErr_NewException(&quot;kerberos.GSSError&quot;, KrbException_class, NULL)))
</del><ins>+    if (! (GssException_class = PyErr_NewException(
+        &quot;kerberos.GSSError&quot;, KrbException_class, NULL
+    ))) {
</ins><span class="cx">         goto error;
</span><ins>+    }
+
</ins><span class="cx">     Py_INCREF(GssException_class);
</span><del>-    PyDict_SetItemString(d, &quot;GSSError&quot;, GssException_class);
</del><ins>+    PyDict_SetItemString(
+        d, &quot;GSSError&quot;, GssException_class
+    );
</ins><span class="cx"> 
</span><del>-    PyDict_SetItemString(d, &quot;AUTH_GSS_COMPLETE&quot;, PyInt_FromLong(AUTH_GSS_COMPLETE));
-    PyDict_SetItemString(d, &quot;AUTH_GSS_CONTINUE&quot;, PyInt_FromLong(AUTH_GSS_CONTINUE));
</del><ins>+    PyDict_SetItemString(
+        d, &quot;AUTH_GSS_COMPLETE&quot;, PyInt_FromLong(AUTH_GSS_COMPLETE)
+    );
+    PyDict_SetItemString(
+        d, &quot;AUTH_GSS_CONTINUE&quot;, PyInt_FromLong(AUTH_GSS_CONTINUE)
+    );
</ins><span class="cx"> 
</span><del>-    PyDict_SetItemString(d, &quot;GSS_C_DELEG_FLAG&quot;, PyInt_FromLong(GSS_C_DELEG_FLAG));
-    PyDict_SetItemString(d, &quot;GSS_C_MUTUAL_FLAG&quot;, PyInt_FromLong(GSS_C_MUTUAL_FLAG));
-    PyDict_SetItemString(d, &quot;GSS_C_REPLAY_FLAG&quot;, PyInt_FromLong(GSS_C_REPLAY_FLAG));
-    PyDict_SetItemString(d, &quot;GSS_C_SEQUENCE_FLAG&quot;, PyInt_FromLong(GSS_C_SEQUENCE_FLAG));
-    PyDict_SetItemString(d, &quot;GSS_C_CONF_FLAG&quot;, PyInt_FromLong(GSS_C_CONF_FLAG));
-    PyDict_SetItemString(d, &quot;GSS_C_INTEG_FLAG&quot;, PyInt_FromLong(GSS_C_INTEG_FLAG));
-    PyDict_SetItemString(d, &quot;GSS_C_ANON_FLAG&quot;, PyInt_FromLong(GSS_C_ANON_FLAG));
-    PyDict_SetItemString(d, &quot;GSS_C_PROT_READY_FLAG&quot;, PyInt_FromLong(GSS_C_PROT_READY_FLAG));
-    PyDict_SetItemString(d, &quot;GSS_C_TRANS_FLAG&quot;, PyInt_FromLong(GSS_C_TRANS_FLAG));
</del><ins>+    PyDict_SetItemString(
+        d, &quot;GSS_C_DELEG_FLAG&quot;, PyInt_FromLong(GSS_C_DELEG_FLAG)
+    );
+    PyDict_SetItemString(
+        d, &quot;GSS_C_MUTUAL_FLAG&quot;, PyInt_FromLong(GSS_C_MUTUAL_FLAG)
+    );
+    PyDict_SetItemString(
+        d, &quot;GSS_C_REPLAY_FLAG&quot;, PyInt_FromLong(GSS_C_REPLAY_FLAG)
+    );
+    PyDict_SetItemString(
+        d, &quot;GSS_C_SEQUENCE_FLAG&quot;, PyInt_FromLong(GSS_C_SEQUENCE_FLAG)
+    );
+    PyDict_SetItemString(
+        d, &quot;GSS_C_CONF_FLAG&quot;, PyInt_FromLong(GSS_C_CONF_FLAG)
+    );
+    PyDict_SetItemString(
+        d, &quot;GSS_C_INTEG_FLAG&quot;, PyInt_FromLong(GSS_C_INTEG_FLAG)
+    );
+    PyDict_SetItemString(
+        d, &quot;GSS_C_ANON_FLAG&quot;, PyInt_FromLong(GSS_C_ANON_FLAG)
+    );
+    PyDict_SetItemString(
+        d, &quot;GSS_C_PROT_READY_FLAG&quot;, PyInt_FromLong(GSS_C_PROT_READY_FLAG)
+    );
+    PyDict_SetItemString(
+        d, &quot;GSS_C_TRANS_FLAG&quot;, PyInt_FromLong(GSS_C_TRANS_FLAG)
+    );
</ins><span class="cx"> 
</span><span class="cx"> error:
</span><span class="cx">     if (PyErr_Occurred()) {
</span><span class="cx">          PyErr_SetString(PyExc_ImportError, &quot;kerberos: init failed&quot;);
</span><span class="cx">         return MOD_ERROR_VAL;
</span><span class="cx">     }
</span><ins>+
</ins><span class="cx">     return MOD_SUCCESS_VAL(m);
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>