Blame SOURCES/PyKerberos-delegation.patch

d21295
diff -uPr python-kerberos-1.1/pysrc/kerberos.py python-kerberos-1.1-gssflags/pysrc/kerberos.py
d21295
--- python-kerberos-1.1/pysrc/kerberos.py	2008-09-17 07:17:15.000000000 -0400
d21295
+++ python-kerberos-1.1-gssflags/pysrc/kerberos.py	2008-12-15 09:21:42.000000000 -0500
d21295
@@ -90,7 +90,18 @@
d21295
 AUTH_GSS_CONTINUE=0 
d21295
 AUTH_GSS_COMPLETE=1 
d21295
      
d21295
-def authGSSClientInit(service):
d21295
+#Some useful gss flags
d21295
+GSS_C_DELEG_FLAG=1
d21295
+GSS_C_MUTUAL_FLAG=2
d21295
+GSS_C_REPLAY_FLAG=4
d21295
+GSS_C_SEQUENCE_FLAG=8
d21295
+GSS_C_CONF_FLAG=16
d21295
+GSS_C_INTEG_FLAG=32
d21295
+GSS_C_ANON_FLAG=64
d21295
+GSS_C_PROT_READY_FLAG=128
d21295
+GSS_C_TRANS_FLAG=256
d21295
+
d21295
+def authGSSClientInit(service, gssflags=GSS_C_MUTUAL_FLAG|GSS_C_SEQUENCE_FLAG):
d21295
     """
d21295
     Initializes a context for GSSAPI client-side authentication with the given service principal.
d21295
     authGSSClientClean must be called after this function returns an OK result to dispose of
d21295
@@ -98,6 +109,9 @@
d21295
 
d21295
     @param service: a string containing the service principal in the form 'type@fqdn'
d21295
         (e.g. 'imap@mail.apple.com').
d21295
+    @param gssflags: optional integer used to set GSS flags.
d21295
+        (e.g.  GSS_C_DELEG_FLAG|GSS_C_MUTUAL_FLAG|GSS_C_SEQUENCE_FLAG will allow
d21295
+         to forward credentials to the remote host)
d21295
     @return:        a tuple of (result, context) where result is the result code (see above) and
d21295
         context is an opaque value that will need to be passed to subsequent functions.
d21295
     """
d21295
diff -uPr python-kerberos-1.1/src/kerberos.c python-kerberos-1.1-gssflags/src/kerberos.c
d21295
--- python-kerberos-1.1/src/kerberos.c	2008-09-17 05:38:55.000000000 -0400
d21295
+++ python-kerberos-1.1-gssflags/src/kerberos.c	2008-12-15 09:26:39.000000000 -0500
d21295
@@ -84,20 +84,22 @@
d21295
         return NULL;
d21295
 }
d21295
 
d21295
-static PyObject* authGSSClientInit(PyObject* self, PyObject* args)
d21295
+static PyObject* authGSSClientInit(PyObject* self, PyObject* args, PyObject* keywds)
d21295
 {
d21295
     const char *service;
d21295
     gss_client_state *state;
d21295
     PyObject *pystate;
d21295
+    static char *kwlist[] = {"service", "gssflags", NULL};
d21295
+    long int gss_flags = GSS_C_MUTUAL_FLAG|GSS_C_SEQUENCE_FLAG;
d21295
     int result = 0;
d21295
     
d21295
-    if (!PyArg_ParseTuple(args, "s", &service))
d21295
+    if (!PyArg_ParseTupleAndKeywords(args, keywds, "s|l", kwlist, &service, &gss_flags))
d21295
         return NULL;
d21295
     
d21295
     state = (gss_client_state *) malloc(sizeof(gss_client_state));
d21295
     pystate = PyCObject_FromVoidPtr(state, NULL);
d21295
     
d21295
-    result = authenticate_gss_client_init(service, state);
d21295
+    result = authenticate_gss_client_init(service, gss_flags, state);
d21295
     if (result == AUTH_GSS_ERROR)
d21295
         return NULL;
d21295
     
d21295
@@ -367,7 +369,7 @@
d21295
      "Change the user password."},
d21295
     {"getServerPrincipalDetails",  getServerPrincipalDetails, METH_VARARGS,
d21295
      "Return the service principal for a given service and hostname."},
d21295
-    {"authGSSClientInit",  authGSSClientInit, METH_VARARGS,
d21295
+    {"authGSSClientInit",  (PyCFunction)authGSSClientInit, METH_VARARGS|METH_KEYWORDS,
d21295
      "Initialize client-side GSSAPI operations."},
d21295
     {"authGSSClientClean",  authGSSClientClean, METH_VARARGS,
d21295
      "Terminate client-side GSSAPI operations."},
d21295
@@ -427,6 +429,15 @@
d21295
     PyDict_SetItemString(d, "AUTH_GSS_COMPLETE", PyInt_FromLong(AUTH_GSS_COMPLETE)); 
d21295
     PyDict_SetItemString(d, "AUTH_GSS_CONTINUE", PyInt_FromLong(AUTH_GSS_CONTINUE)); 
d21295
 
d21295
+    PyDict_SetItemString(d, "GSS_C_DELEG_FLAG", PyInt_FromLong(GSS_C_DELEG_FLAG)); 
d21295
+    PyDict_SetItemString(d, "GSS_C_MUTUAL_FLAG", PyInt_FromLong(GSS_C_MUTUAL_FLAG)); 
d21295
+    PyDict_SetItemString(d, "GSS_C_REPLAY_FLAG", PyInt_FromLong(GSS_C_REPLAY_FLAG)); 
d21295
+    PyDict_SetItemString(d, "GSS_C_SEQUENCE_FLAG", PyInt_FromLong(GSS_C_SEQUENCE_FLAG)); 
d21295
+    PyDict_SetItemString(d, "GSS_C_CONF_FLAG", PyInt_FromLong(GSS_C_CONF_FLAG)); 
d21295
+    PyDict_SetItemString(d, "GSS_C_INTEG_FLAG", PyInt_FromLong(GSS_C_INTEG_FLAG)); 
d21295
+    PyDict_SetItemString(d, "GSS_C_ANON_FLAG", PyInt_FromLong(GSS_C_ANON_FLAG)); 
d21295
+    PyDict_SetItemString(d, "GSS_C_PROT_READY_FLAG", PyInt_FromLong(GSS_C_PROT_READY_FLAG)); 
d21295
+    PyDict_SetItemString(d, "GSS_C_TRANS_FLAG", PyInt_FromLong(GSS_C_TRANS_FLAG)); 
d21295
 error:
d21295
     if (PyErr_Occurred())
d21295
         PyErr_SetString(PyExc_ImportError, "kerberos: init failed");
d21295
diff -uPr python-kerberos-1.1/src/kerberosgss.c python-kerberos-1.1-gssflags/src/kerberosgss.c
d21295
--- python-kerberos-1.1/src/kerberosgss.c	2008-09-17 06:35:15.000000000 -0400
d21295
+++ python-kerberos-1.1-gssflags/src/kerberosgss.c	2008-12-15 09:21:42.000000000 -0500
d21295
@@ -108,7 +108,7 @@
d21295
     return result;
d21295
 }
d21295
 
d21295
-int authenticate_gss_client_init(const char* service, gss_client_state* state)
d21295
+int authenticate_gss_client_init(const char* service, long int gss_flags, gss_client_state* state)
d21295
 {
d21295
     OM_uint32 maj_stat;
d21295
     OM_uint32 min_stat;
d21295
@@ -119,6 +119,7 @@
d21295
     state->context = GSS_C_NO_CONTEXT;
d21295
     state->username = NULL;
d21295
     state->response = NULL;
d21295
+    state->gss_flags = gss_flags;
d21295
     
d21295
     // Import server name first
d21295
     name_token.length = strlen(service);
d21295
@@ -190,7 +191,7 @@
d21295
 				    &state->context,
d21295
 				    state->server_name,
d21295
 				    GSS_C_NO_OID,
d21295
-				    GSS_C_MUTUAL_FLAG | GSS_C_SEQUENCE_FLAG,
d21295
+				    (OM_uint32)state->gss_flags,
d21295
 				    0,
d21295
 				    GSS_C_NO_CHANNEL_BINDINGS,
d21295
 				    &input_token,
d21295
diff -uPr python-kerberos-1.1/src/kerberosgss.h python-kerberos-1.1-gssflags/src/kerberosgss.h
d21295
--- python-kerberos-1.1/src/kerberosgss.h	2008-05-23 12:40:38.000000000 -0400
d21295
+++ python-kerberos-1.1-gssflags/src/kerberosgss.h	2008-12-15 09:21:42.000000000 -0500
d21295
@@ -33,6 +33,7 @@
d21295
 typedef struct {
d21295
     gss_ctx_id_t     context;
d21295
     gss_name_t       server_name;
d21295
+    long int         gss_flags;
d21295
     char*            username;
d21295
     char*            response;
d21295
 } gss_client_state;
d21295
@@ -49,7 +50,7 @@
d21295
 
d21295
 char* server_principal_details(const char* service, const char* hostname);
d21295
 
d21295
-int authenticate_gss_client_init(const char* service, gss_client_state* state);
d21295
+int authenticate_gss_client_init(const char* service, long int gss_flags, gss_client_state* state);
d21295
 int authenticate_gss_client_clean(gss_client_state *state);
d21295
 int authenticate_gss_client_step(gss_client_state *state, const char *challenge);
d21295
 int authenticate_gss_client_unwrap(gss_client_state* state, const char* challenge);