Skip to contentSkip to conversation

nfs-utils: Adds support for more encryption types.

PATCH In review [email protected] 2 participants 10 messages Apr 14, 2010 – Apr 16, 2010 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover nfs-utils: Adds support for more encryption types.

From: Steve Dickson <[email protected]>

These three gssd patches added support for more DES and non-DES encryption types. They were authored by Kevin Coffman and tested by me on several recent kernels.

Kevin Coffman (3):
gssd: move function limit_krb5_enctypes into the exported functions area Try to use kernel function to determine supported Kerberos enctypes. Add support for non-DES encryption types.

 utils/gssd/context.h       |    6 ++-
 utils/gssd/context_lucid.c |  128 ++++++++++++++++++++++++++++++++++++-----
 utils/gssd/context_mit.c   |  136 +++++++++++++++++++++++++++++++++-----------
 utils/gssd/gssd_proc.c     |   81 ++++++++++++++++++++++++++-
 utils/gssd/krb5_util.c     |  121 +++++++++++++++++++++------------------
 5 files changed, 368 insertions(+), 104 deletions(-)
#1 lore raw

PATCH 1/3 gssd: move function limit_krb5_enctypes into the exported functions area

From: Kevin Coffman <[email protected]>

cleanup: Move function limit_krb5_enctypes() from the section containing static functions into the section containing externally visible functions.

---
 utils/gssd/krb5_util.c |  109 ++++++++++++++++++++++++------------------------
 1 files changed, 54 insertions(+), 55 deletions(-)
utils/gssd/krb5_util.c +54 -55
index 1295f57..1c10bd4 100644
@@ -292,61 +292,6 @@ gssd_find_existing_krb5_ccache(uid_t uid, char *dirname, struct dirent **d)
 	return err;
 }
 
-
-#ifdef HAVE_SET_ALLOWABLE_ENCTYPES
-/*
- * this routine obtains a credentials handle via gss_acquire_cred()
- * then calls gss_krb5_set_allowable_enctypes() to limit the encryption
- * types negotiated.
- *
- * XXX Should call some function to determine the enctypes supported
- * by the kernel. (Only need to do that once!)
- *
- * Returns:
- *	0 => all went well
- *     -1 => there was an error
- */
-
-int
-limit_krb5_enctypes(struct rpc_gss_sec *sec, uid_t uid)
-{
-	u_int maj_stat, min_stat;
-	gss_cred_id_t credh;
-	gss_OID_set_desc  desired_mechs;
-	krb5_enctype enctypes[] = { ENCTYPE_DES_CBC_CRC,
-				    ENCTYPE_DES_CBC_MD5,
-				    ENCTYPE_DES_CBC_MD4 };
-	int num_enctypes = sizeof(enctypes) / sizeof(enctypes[0]);
-
-	/* We only care about getting a krb5 cred */
-	desired_mechs.count = 1;
-	desired_mechs.elements = &krb5oid;
-
-	maj_stat = gss_acquire_cred(&min_stat, NULL, 0,
-				    &desired_mechs, GSS_C_INITIATE,
-				    &credh, NULL, NULL);
-
-	if (maj_stat != GSS_S_COMPLETE) {
-		if (get_verbosity() > 0)
-			pgsserr("gss_acquire_cred",
-				maj_stat, min_stat, &krb5oid);
-		return -1;
-	}
-
-	maj_stat = gss_set_allowable_enctypes(&min_stat, credh, &krb5oid,
-					     num_enctypes, &enctypes);
-	if (maj_stat != GSS_S_COMPLETE) {
-		pgsserr("gss_set_allowable_enctypes",
-			maj_stat, min_stat, &krb5oid);
-		gss_release_cred(&min_stat, &credh);
-		return -1;
-	}
-	sec->cred = credh;
-
-	return 0;
-}
-#endif	/* HAVE_SET_ALLOWABLE_ENCTYPES */
-
 /*
  * Obtain credentials via a key in the keytab given
  * a keytab handle and a gssd_k5_kt_princ structure.
@@ -1304,3 +1249,57 @@ gssd_k5_get_default_realm(char **def_realm)
 
 	krb5_free_context(context);
 }
+
+#ifdef HAVE_SET_ALLOWABLE_ENCTYPES
+/*
+ * this routine obtains a credentials handle via gss_acquire_cred()
+ * then calls gss_krb5_set_allowable_enctypes() to limit the encryption
+ * types negotiated.
+ *
+ * XXX Should call some function to determine the enctypes supported
+ * by the kernel. (Only need to do that once!)
+ *
+ * Returns:
+ *	0 => all went well
+ *     -1 => there was an error
+ */
+
+int
+limit_krb5_enctypes(struct rpc_gss_sec *sec, uid_t uid)
+{
+	u_int maj_stat, min_stat;
+	gss_cred_id_t credh;
+	gss_OID_set_desc  desired_mechs;
+	krb5_enctype enctypes[] = { ENCTYPE_DES_CBC_CRC,
+				    ENCTYPE_DES_CBC_MD5,
+				    ENCTYPE_DES_CBC_MD4 };
+	int num_enctypes = sizeof(enctypes) / sizeof(enctypes[0]);
+
+	/* We only care about getting a krb5 cred */
+	desired_mechs.count = 1;
+	desired_mechs.elements = &krb5oid;
+
+	maj_stat = gss_acquire_cred(&min_stat, NULL, 0,
+				    &desired_mechs, GSS_C_INITIATE,
+				    &credh, NULL, NULL);
+
+	if (maj_stat != GSS_S_COMPLETE) {
+		if (get_verbosity() > 0)
+			pgsserr("gss_acquire_cred",
+				maj_stat, min_stat, &krb5oid);
+		return -1;
+	}
+
+	maj_stat = gss_set_allowable_enctypes(&min_stat, credh, &krb5oid,
+					     num_enctypes, &enctypes);
+	if (maj_stat != GSS_S_COMPLETE) {
+		pgsserr("gss_set_allowable_enctypes",
+			maj_stat, min_stat, &krb5oid);
+		gss_release_cred(&min_stat, &credh);
+		return -1;
+	}
+	sec->cred = credh;
+
+	return 0;
+}
+#endif	/* HAVE_SET_ALLOWABLE_ENCTYPES */
Signature · 1 line
1.6.6.1
#2 lore raw

PATCH 2/3 Try to use kernel function to determine supported Kerberos enctypes.

In reply to [email protected]

From: Kevin Coffman <[email protected]>

This patch replaces a hard-coded list with a function to obtain the Kerberos encryption types that the kernel's rpcsec_gss code can support. Defaults to old behavior if kernel does not supply information.

---
 utils/gssd/gssd_proc.c |   81 +++++++++++++++++++++++++++++++++++++++++++++++-
 utils/gssd/krb5_util.c |   16 ++++++++-
 2 files changed, 94 insertions(+), 3 deletions(-)
utils/gssd/gssd_proc.c +80 -1
index be4fb11..12e11d5 100644
@@ -600,6 +600,67 @@ update_client_list(void)
 	return retval;
 }
 
+/* Encryption types supported by the kernel rpcsec_gss code */
+int num_krb5_enctypes = 0;
+krb5_enctype *krb5_enctypes = NULL;
+
+/*
+ * Parse the supported encryption type information
+ */
+static int
+parse_enctypes(char *enctypes)
+{
+	int n = 0;
+	char *curr, *comma;
+	int i;
+	static char *cached_types;
+
+	if (cached_types && strcmp(cached_types, enctypes) == 0)
+		return 0;
+	free(cached_types);
+
+	if (krb5_enctypes != NULL) {
+		free(krb5_enctypes);
+		krb5_enctypes = NULL;
+		num_krb5_enctypes = 0;
+	}
+
+	/* count the number of commas */
+	for (curr = enctypes; curr && *curr != '\0'; curr = ++comma) {
+		comma = strchr(curr, ',');
+		if (comma != NULL)
+			n++;
+		else
+			break;
+	}
+	/* If no more commas and we're not at the end, there's one more value */
+	if (*curr != '\0')
+		n++;
+
+	/* Empty string, return an error */
+	if (n == 0)
+		return ENOENT;
+
+	/* Allocate space for enctypes array */
+	if ((krb5_enctypes = (int *) calloc(n, sizeof(int))) == NULL) {
+		return ENOMEM;
+	}
+
+	/* Now parse each value into the array */
+	for (curr = enctypes, i = 0; curr && *curr != '\0'; curr = ++comma) {
+		krb5_enctypes[i++] = atoi(curr);
+		comma = strchr(curr, ',');
+		if (comma == NULL)
+			break;
+	}
+
+	num_krb5_enctypes = n;
+	if (cached_types = malloc(strlen(enctypes)+1))
+		strcpy(cached_types, enctypes);
+
+	return 0;
+}
+
 static int
 do_downcall(int k5_fd, uid_t uid, struct authgss_private_data *pd,
 	    gss_buffer_desc *context_token)
@@ -1128,11 +1189,12 @@ handle_gssd_upcall(struct clnt_info *clp)
 {
 	uid_t			uid;
 	char			*lbuf = NULL;
-	int			lbuflen = 0;
+	int			lbuflen = 0, code;
 	char			*p;
 	char			*mech = NULL;
 	char			*target = NULL;
 	char			*service = NULL;
+	char			*enctypes = NULL;
 
 	printerr(1, "handling gssd upcall (%s)\n", clp->dirname);
 
@@ -1176,6 +1238,23 @@ handle_gssd_upcall(struct clnt_info *clp)
 		goto out;
 	}
 
+	/* read supported encryption types if supplied */
+	if ((p = strstr(lbuf, "enctypes=")) != NULL) {
+		enctypes = malloc(lbuflen);
+		if (!enctypes)
+			goto out;
+		if (sscanf(p, "enctypes=%s", enctypes) != 1) {
+			printerr(0, "WARNING: handle_gssd_upcall: "
+				    "failed to parse target name "
+				    "in upcall string '%s'\n", lbuf);
+			goto out;
+		}
+		if (parse_enctypes(enctypes) != 0) {
+			printerr(0, "WARNING: handle_gssd_upcall: "
+				"parsing encryption types failed: errno %d\n", code);
+		}
+	}
+
 	/* read target name */
 	if ((p = strstr(lbuf, "target=")) != NULL) {
 		target = malloc(lbuflen);
utils/gssd/krb5_util.c +14 -2
index 1c10bd4..0f56b1d 100644
@@ -1274,6 +1274,8 @@ limit_krb5_enctypes(struct rpc_gss_sec *sec, uid_t uid)
 				    ENCTYPE_DES_CBC_MD5,
 				    ENCTYPE_DES_CBC_MD4 };
 	int num_enctypes = sizeof(enctypes) / sizeof(enctypes[0]);
+	extern int num_krb5_enctypes;
+	extern krb5_enctype *krb5_enctypes;
 
 	/* We only care about getting a krb5 cred */
 	desired_mechs.count = 1;
@@ -1290,8 +1292,18 @@ limit_krb5_enctypes(struct rpc_gss_sec *sec, uid_t uid)
 		return -1;
 	}
 
-	maj_stat = gss_set_allowable_enctypes(&min_stat, credh, &krb5oid,
-					     num_enctypes, &enctypes);
+	/*
+	 * If we failed for any reason to produce global
+	 * list of supported enctypes, use local default here.
+	 */
+	if (krb5_enctypes == NULL)
+		maj_stat = gss_set_allowable_enctypes(&min_stat, credh,
+					&krb5oid, num_enctypes, &enctypes);
+	else
+		maj_stat = gss_set_allowable_enctypes(&min_stat, credh,
+					&krb5oid, num_krb5_enctypes,
+					krb5_enctypes);
+
 	if (maj_stat != GSS_S_COMPLETE) {
 		pgsserr("gss_set_allowable_enctypes",
 			maj_stat, min_stat, &krb5oid);
Signature · 1 line
1.6.6.1
#3 lore raw

Re: [PATCH 2/3] Try to use kernel function to determine supported Kerberos enctypes.

Quoted 148 lines · On Wed, Apr 14, 2010 at 3:18 PM, <[email protected]> wrote:

From: Kevin Coffman <[email protected]>

This patch replaces a hard-coded list with a function to obtain the Kerberos encryption types that the kernel's rpcsec_gss code can support.  Defaults to old behavior if kernel does not supply information.

---
 utils/gssd/gssd_proc.c |   81 +++++++++++++++++++++++++++++++++++++++++++++++- utils/gssd/krb5_util.c |   16 ++++++++-

 2 files changed, 94 insertions(+), 3 deletions(-)
utils/gssd/gssd_proc.c +61 -0
index be4fb11..12e11d5 100644
@@ -600,6 +600,67 @@ update_client_list(void)
        return retval;
  }
 
+/* Encryption types supported by the kernel rpcsec_gss code */
+int num_krb5_enctypes = 0;
+krb5_enctype *krb5_enctypes = NULL;
+
+/*
+ * Parse the supported encryption type information
+ */
+static int
+parse_enctypes(char *enctypes)
+{
+       int n = 0;
+       char *curr, *comma;
+       int i;
+       static char *cached_types;
+
+       if (cached_types && strcmp(cached_types, enctypes) == 0)
+               return 0;
+       free(cached_types);
+
+       if (krb5_enctypes != NULL) {
+               free(krb5_enctypes);
+               krb5_enctypes = NULL;
+               num_krb5_enctypes = 0;
+       }
+
+       /* count the number of commas */
+       for (curr = enctypes; curr && *curr != '\0'; curr = ++comma) {
+               comma = strchr(curr, ',');
+               if (comma != NULL)
+                       n++;
+               else
+                       break;
+       }
+       /* If no more commas and we're not at the end, there's one more value */
+       if (*curr != '\0')
+               n++;
+
+       /* Empty string, return an error */
+       if (n == 0)
+               return ENOENT;
+
+       /* Allocate space for enctypes array */
+       if ((krb5_enctypes = (int *) calloc(n, sizeof(int))) == NULL) {
+               return ENOMEM;
+       }
+
+       /* Now parse each value into the array */
+       for (curr = enctypes, i = 0; curr && *curr != '\0'; curr = ++comma) {
+               krb5_enctypes[i++] = atoi(curr);
+               comma = strchr(curr, ',');
+               if (comma == NULL)
+                       break;
+       }
+
+       num_krb5_enctypes = n;
+       if (cached_types = malloc(strlen(enctypes)+1))
+               strcpy(cached_types, enctypes);
+
+       return 0;
+}
+

 static int
 do_downcall(int k5_fd, uid_t uid, struct authgss_private_data *pd, gss_buffer_desc *context_token)

utils/gssd/gssd_proc.c +19 -1
@@ -1128,11 +1189,12 @@ handle_gssd_upcall(struct clnt_info *clp)
  {
        uid_t                   uid;
        char                    *lbuf = NULL;
-       int                     lbuflen = 0;
+       int                     lbuflen = 0, code;
        char                    *p;
        char                    *mech = NULL;
        char                    *target = NULL;
        char                    *service = NULL;
+       char                    *enctypes = NULL;
 
        printerr(1, "handling gssd upcall (%s)\n", clp->dirname);
 
@@ -1176,6 +1238,23 @@ handle_gssd_upcall(struct clnt_info *clp)
                goto out;
        }
 
+       /* read supported encryption types if supplied */
+       if ((p = strstr(lbuf, "enctypes=")) != NULL) {
+               enctypes = malloc(lbuflen);
+               if (!enctypes)
+                       goto out;
+               if (sscanf(p, "enctypes=%s", enctypes) != 1) {
+                       printerr(0, "WARNING: handle_gssd_upcall: "
+                                   "failed to parse target name "
+                                   "in upcall string '%s'\n", lbuf);
+                       goto out;
+               }
+               if (parse_enctypes(enctypes) != 0) {
+                       printerr(0, "WARNING: handle_gssd_upcall: "
+                               "parsing encryption types failed: errno %d\n", code);
+               }
+       }
+
        /* read target name */
        if ((p = strstr(lbuf, "target=")) != NULL) {
                target = malloc(lbuflen);
utils/gssd/krb5_util.c +8 -2
index 1c10bd4..0f56b1d 100644
@@ -1274,6 +1274,8 @@ limit_krb5_enctypes(struct rpc_gss_sec *sec, uid_t uid)
                                    ENCTYPE_DES_CBC_MD5,
                                    ENCTYPE_DES_CBC_MD4 };
        int num_enctypes = sizeof(enctypes) / sizeof(enctypes[0]);
+       extern int num_krb5_enctypes;
+       extern krb5_enctype *krb5_enctypes;
 
        /* We only care about getting a krb5 cred */
        desired_mechs.count = 1;
@@ -1290,8 +1292,18 @@ limit_krb5_enctypes(struct rpc_gss_sec *sec, uid_t uid)
                return -1;
        }
 
-       maj_stat = gss_set_allowable_enctypes(&min_stat, credh, &krb5oid,
-                                            num_enctypes, &enctypes);
+       /*
+        * If we failed for any reason to produce global
+        * list of supported enctypes, use local default here.
+        */
+       if (krb5_enctypes == NULL)
+               maj_stat = gss_set_allowable_enctypes(&min_stat, credh,

utils/gssd/krb5_util.c limit_krb5_enctypes(struct rpc_gss_sec *sec, uid_t uid)

Quoted 10 lines
utils/gssd/krb5_util.c +6 -1
+                                       &krb5oid, num_enctypes, &enctypes);
+       else
+               maj_stat = gss_set_allowable_enctypes(&min_stat, credh,
+                                       &krb5oid, num_krb5_enctypes,
+                                       krb5_enctypes);
+
        if (maj_stat != GSS_S_COMPLETE) {
                pgsserr("gss_set_allowable_enctypes",
                        maj_stat, min_stat, &krb5oid);
--

Hi Steve,

The global krb5_enctypes array was used when the list was being read once from a file. With the list now coming up with each request in the updated upcall, I think the list obtained in the upcall should be added to the clnt_info structure and then passed to the limit_krb5_enctypes function as a parameter.

K.C.

A message that is not in the archive (sent off-list or not yet received): z2j4d569c331004141258y2f16a82ga1aa7826d665b3a9-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#5 lore raw

Re: [PATCH 2/3] Try to use kernel function to determine supported Kerberos enctypes.

Quoted 162 lines · Kevin Coffman
Quoted 148 lines · On Wed, Apr 14, 2010 at 3:18 PM, <[email protected]> wrote:

From: Kevin Coffman <[email protected]>

This patch replaces a hard-coded list with a function to obtain the Kerberos encryption types that the kernel's rpcsec_gss code can support. Defaults to old behavior if kernel does not supply information.

---
 utils/gssd/gssd_proc.c |   81 +++++++++++++++++++++++++++++++++++++++++++++++-
 utils/gssd/krb5_util.c |   16 ++++++++-
 2 files changed, 94 insertions(+), 3 deletions(-)
utils/gssd/gssd_proc.c +80 -1
index be4fb11..12e11d5 100644
@@ -600,6 +600,67 @@ update_client_list(void)
       return retval;
 }
 
+/* Encryption types supported by the kernel rpcsec_gss code */
+int num_krb5_enctypes = 0;
+krb5_enctype *krb5_enctypes = NULL;
+
+/*
+ * Parse the supported encryption type information
+ */
+static int
+parse_enctypes(char *enctypes)
+{
+       int n = 0;
+       char *curr, *comma;
+       int i;
+       static char *cached_types;
+
+       if (cached_types && strcmp(cached_types, enctypes) == 0)
+               return 0;
+       free(cached_types);
+
+       if (krb5_enctypes != NULL) {
+               free(krb5_enctypes);
+               krb5_enctypes = NULL;
+               num_krb5_enctypes = 0;
+       }
+
+       /* count the number of commas */
+       for (curr = enctypes; curr && *curr != '\0'; curr = ++comma) {
+               comma = strchr(curr, ',');
+               if (comma != NULL)
+                       n++;
+               else
+                       break;
+       }
+       /* If no more commas and we're not at the end, there's one more value */
+       if (*curr != '\0')
+               n++;
+
+       /* Empty string, return an error */
+       if (n == 0)
+               return ENOENT;
+
+       /* Allocate space for enctypes array */
+       if ((krb5_enctypes = (int *) calloc(n, sizeof(int))) == NULL) {
+               return ENOMEM;
+       }
+
+       /* Now parse each value into the array */
+       for (curr = enctypes, i = 0; curr && *curr != '\0'; curr = ++comma) {
+               krb5_enctypes[i++] = atoi(curr);
+               comma = strchr(curr, ',');
+               if (comma == NULL)
+                       break;
+       }
+
+       num_krb5_enctypes = n;
+       if (cached_types = malloc(strlen(enctypes)+1))
+               strcpy(cached_types, enctypes);
+
+       return 0;
+}
+
 static int
 do_downcall(int k5_fd, uid_t uid, struct authgss_private_data *pd,
           gss_buffer_desc *context_token)
@@ -1128,11 +1189,12 @@ handle_gssd_upcall(struct clnt_info *clp)
 {
       uid_t                   uid;
       char                    *lbuf = NULL;
-       int                     lbuflen = 0;
+       int                     lbuflen = 0, code;
       char                    *p;
       char                    *mech = NULL;
       char                    *target = NULL;
       char                    *service = NULL;
+       char                    *enctypes = NULL;
 
       printerr(1, "handling gssd upcall (%s)\n", clp->dirname);
 
@@ -1176,6 +1238,23 @@ handle_gssd_upcall(struct clnt_info *clp)
               goto out;
       }
 
+       /* read supported encryption types if supplied */
+       if ((p = strstr(lbuf, "enctypes=")) != NULL) {
+               enctypes = malloc(lbuflen);
+               if (!enctypes)
+                       goto out;
+               if (sscanf(p, "enctypes=%s", enctypes) != 1) {
+                       printerr(0, "WARNING: handle_gssd_upcall: "
+                                   "failed to parse target name "
+                                   "in upcall string '%s'\n", lbuf);
+                       goto out;
+               }
+               if (parse_enctypes(enctypes) != 0) {
+                       printerr(0, "WARNING: handle_gssd_upcall: "
+                               "parsing encryption types failed: errno %d\n", code);
+               }
+       }
+
       /* read target name */
       if ((p = strstr(lbuf, "target=")) != NULL) {
               target = malloc(lbuflen);
utils/gssd/krb5_util.c +8 -2
index 1c10bd4..0f56b1d 100644
@@ -1274,6 +1274,8 @@ limit_krb5_enctypes(struct rpc_gss_sec *sec, uid_t uid)
                                   ENCTYPE_DES_CBC_MD5,
                                   ENCTYPE_DES_CBC_MD4 };
       int num_enctypes = sizeof(enctypes) / sizeof(enctypes[0]);
+       extern int num_krb5_enctypes;
+       extern krb5_enctype *krb5_enctypes;
 
       /* We only care about getting a krb5 cred */
       desired_mechs.count = 1;
@@ -1290,8 +1292,18 @@ limit_krb5_enctypes(struct rpc_gss_sec *sec, uid_t uid)
               return -1;
       }
 
-       maj_stat = gss_set_allowable_enctypes(&min_stat, credh, &krb5oid,
-                                            num_enctypes, &enctypes);
+       /*
+        * If we failed for any reason to produce global
+        * list of supported enctypes, use local default here.
+        */
+       if (krb5_enctypes == NULL)
+               maj_stat = gss_set_allowable_enctypes(&min_stat, credh,

utils/gssd/krb5_util.c limit_krb5_enctypes(struct rpc_gss_sec *sec, uid_t uid)

Quoted 10 lines
utils/gssd/krb5_util.c +6 -1
+                                       &krb5oid, num_enctypes, &enctypes);
+       else
+               maj_stat = gss_set_allowable_enctypes(&min_stat, credh,
+                                       &krb5oid, num_krb5_enctypes,
+                                       krb5_enctypes);
+
       if (maj_stat != GSS_S_COMPLETE) {
               pgsserr("gss_set_allowable_enctypes",
                       maj_stat, min_stat, &krb5oid);
--

Hi Steve,

Quoted 5 lines

The global krb5_enctypes array was used when the list was being read once from a file. With the list now coming up with each request in the updated upcall, I think the list obtained in the upcall should be added to the clnt_info structure and then passed to the limit_krb5_enctypes function as a parameter.

Six of one.... half a dozen of another... ;-)

But I do see there is a memory leak... I don't free the enctypes buffer in handle_gssd_upcall() :-\

I'll repost in a bit...

steved.

#6 lore raw

Re: [PATCH 2/3] Try to use kernel function to determine supported Kerberos enctypes.

In reply to Kevin Coffman

Hey Kevin,

Quoted 6 lines · Kevin Coffman

The global krb5_enctypes array was used when the list was being read once from a file. With the list now coming up with each request in the updated upcall, I think the list obtained in the upcall should be added to the clnt_info structure and then passed to the limit_krb5_enctypes function as a parameter.

I took a look at move the krb5_enctypes array in to the clnt_info structure and I'm thinking it might be better to keep it as global variable. Here is my reasoning...

The "enctypes=" string that comes up in the upcall is basically a static string. Yeah I know it could change but that's highly unlikely any time soon. So if we put the krb5_enctypes array in the clnt_info structure we would have to parse that (static) string on *every* upcall, since the clnt_info structures are dynamically allocated. So parsing a static string on every upcall does not make sense to me.

Keeping the supported enctypes in a global variable allow us to parse the string once and when it changes (which will never happen dynamically). So if the first enctypes values are cached, all that parsing become a simple strcmp()... ala:

+parse_enctypes(char *enctypes)
+{
+ int n = 0;
+ char *curr, *comma;
+ int i;
+ static char *cached_types;
+
+ if (cached_types && strcmp(cached_types, enctypes) == 0)
+ return 0;

Makes sense? Am I missing something??

steved.

#7 lore raw

Re: [PATCH 2/3] Try to use kernel function to determine supported Kerberos enctypes.

Quoted 36 lines · Steve Dickson

Hey Kevin,

Quoted 6 lines · Kevin Coffman

The global krb5_enctypes array was used when the list was being read once from a file.  With the list now coming up with each request in the updated upcall, I think the list obtained in the upcall should be added to the clnt_info structure and then passed to the limit_krb5_enctypes function as a parameter.

I took a look at move the krb5_enctypes array in to the clnt_info structure and I'm thinking it might be better to keep it as global variable. Here is my reasoning...

The "enctypes=" string that comes up in the upcall is basically a static string. Yeah I know it could change but that's highly unlikely any time soon. So if we put the krb5_enctypes array in the clnt_info structure we would have to parse that (static) string on *every* upcall, since the clnt_info structures are dynamically allocated. So parsing a static string on every upcall does not make sense to me.

Keeping the supported enctypes in a global variable allow us to parse the string once and when it changes (which will never happen dynamically). So if the first enctypes values are cached, all that parsing become a simple strcmp()... ala:

utils/gssd/gssd_proc.c +9 -0
+parse_enctypes(char *enctypes)
+{
+       int n = 0;
+       char *curr, *comma;
+       int i;
+       static char *cached_types;
+
+       if (cached_types && strcmp(cached_types, enctypes) == 0)
+               return 0;
Quoted 3 lines

Makes sense? Am I missing something??

steved.

I originally missed the addition of cached_types. I guess this is fine.

K.C.

#8 lore raw

PATCH 2/3 Try to use kernel function to determine supported Kerberos enctypes (Updated)

In reply to [email protected]

I did notice the following problems with this patch.

1) I was not freeing enctypes in handle_gssd_upcall()

utils/gssd/gssd_proc.c +0 -1
index 50a27e4..12e11d5 100644
@@ -1301,7 +1301,6 @@ handle_gssd_upcall(struct clnt_info *clp)
 out:
        free(lbuf);
        free(mech);
-       free(enctypes);
        free(target);
        free(service);
        return; 

2) gss_set_allowable_enctypes last arugment is a void * not a void **

utils/gssd/krb5_util.c +3 -2
index dccbeb6..0f56b1d 100644
@@ -1298,10 +1298,11 @@ limit_krb5_enctypes(struct rpc_gss_sec *sec, uid_t uid)
         */
        if (krb5_enctypes == NULL)
                maj_stat = gss_set_allowable_enctypes(&min_stat, credh,
-                                       &krb5oid, num_enctypes, enctypes);
+                                       &krb5oid, num_enctypes, &enctypes);
        else
                maj_stat = gss_set_allowable_enctypes(&min_stat, credh,
-                                       &krb5oid, num_krb5_enctypes, krb5_enctypes);
+                                       &krb5oid, num_krb5_enctypes,
+                                       krb5_enctypes);
 

Here is the entire updated patch...

Author: Kevin Coffman <[email protected]>
Date:   Thu Apr 15 08:10:07 2010 -0400

gssd: move function limit_krb5_enctypes into the exported functions area

cleanup: Move function limit_krb5_enctypes() from the section containing static functions into the section containing externally visible functions.

utils/gssd/gssd_proc.c +81 -1

110 lines not on this page · raw message

utils/gssd/krb5_util.c +13 -2
index 1c10bd4..dccbeb6 100644
@@ -1274,6 +1274,8 @@ limit_krb5_enctypes(struct rpc_gss_sec *sec, uid_t uid)
 				    ENCTYPE_DES_CBC_MD5,
 				    ENCTYPE_DES_CBC_MD4 };
 	int num_enctypes = sizeof(enctypes) / sizeof(enctypes[0]);
+	extern int num_krb5_enctypes;
+	extern krb5_enctype *krb5_enctypes;
 
 	/* We only care about getting a krb5 cred */
 	desired_mechs.count = 1;
@@ -1290,8 +1292,17 @@ limit_krb5_enctypes(struct rpc_gss_sec *sec, uid_t uid)
 		return -1;
 	}
 
-	maj_stat = gss_set_allowable_enctypes(&min_stat, credh, &krb5oid,
-					     num_enctypes, &enctypes);
+	/*
+	 * If we failed for any reason to produce global
+	 * list of supported enctypes, use local default here.
+	 */
+	if (krb5_enctypes == NULL)
+		maj_stat = gss_set_allowable_enctypes(&min_stat, credh,
+					&krb5oid, num_enctypes, enctypes);
+	else
+		maj_stat = gss_set_allowable_enctypes(&min_stat, credh,
+					&krb5oid, num_krb5_enctypes, krb5_enctypes);
+
 	if (maj_stat != GSS_S_COMPLETE) {
 		pgsserr("gss_set_allowable_enctypes",
 			maj_stat, min_stat, &krb5oid);
#9 lore raw

PATCH 3/3 Add support for non-DES encryption types.

In reply to [email protected]

From: Kevin Coffman <[email protected]>

Sends a new format of context information to the kernel. (Requires kernel support to do anything useful.)

---
 utils/gssd/context.h       |    6 ++-
 utils/gssd/context_lucid.c |  128 ++++++++++++++++++++++++++++++++++++-----
 utils/gssd/context_mit.c   |  136 +++++++++++++++++++++++++++++++++-----------
 3 files changed, 222 insertions(+), 48 deletions(-)
utils/gssd/context.h +5 -1
index be47f9c..c9cb0bd 100644
@@ -1,5 +1,5 @@
 /*
-  Copyright (c) 2004 The Regents of the University of Michigan.
+  Copyright (c) 2004,2008 The Regents of the University of Michigan.
   All rights reserved.
 
   Redistribution and use in source and binary forms, with or without
@@ -36,6 +36,10 @@
 /* Hopefully big enough to hold any serialized context */
 #define MAX_CTX_LEN 4096
 
+/* New context format flag values */
+#define KRB5_CTX_FLAG_INITIATOR         0x00000001
+#define KRB5_CTX_FLAG_CFX               0x00000002
+#define KRB5_CTX_FLAG_ACCEPTOR_SUBKEY   0x00000004
 
 int serialize_context_for_kernel(gss_ctx_id_t ctx, gss_buffer_desc *buf,
 				 gss_OID mech, int32_t *endtime);
utils/gssd/context_lucid.c +114 -14

176 lines not on this page · raw message

utils/gssd/context_mit.c +103 -33

172 lines not on this page · raw message

Signature · 1 line
1.6.6.1
#10 lore raw
In reply to [email protected]
Quoted 10 lines · On 04/14/2010 03:18 PM, [email protected] wrote:

From: Steve Dickson <[email protected]>

These three gssd patches added support for more DES and non-DES encryption types. They were authored by Kevin Coffman and tested by me on several recent kernels.

Kevin Coffman (3):
gssd: move function limit_krb5_enctypes into the exported functions area Try to use kernel function to determine supported Kerberos enctypes. Add support for non-DES encryption types.

Committed and pushed...

steved.