From: Simon Wilkinson Date: Mon, 13 Sep 2010 07:24:12 +0000 (+0100) Subject: userok: Allow NULL components in kerberosSuperUser X-Git-Tag: openafs-devel-1_7_1~1226 X-Git-Url: http://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=eee9fe09452a1c05153042dffb5a6c4fbed0fb5b userok: Allow NULL components in kerberosSuperUser Modify kerberosSuperUser so that it can support callers passing NULL, rather than just empty, instance and cell strings Change-Id: Ifc21eb0c4f562d65519e31db32723c3a2d19b363 Reviewed-on: http://gerrit.openafs.org/3351 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- diff --git a/src/auth/userok.c b/src/auth/userok.c index 36260e5..a8cb274 100644 --- a/src/auth/userok.c +++ b/src/auth/userok.c @@ -340,7 +340,7 @@ static int kerberosSuperUser(struct afsconf_dir *adir, char *tname, char *tinst, char *tcell, char *namep) { - char tcell_l[MAXKTCREALMLEN]; + char tcell_l[MAXKTCREALMLEN] = ""; char *tmp; /* keep track of which one actually authorized request */ @@ -353,11 +353,13 @@ kerberosSuperUser(struct afsconf_dir *adir, char *tname, char *tinst, int flag; /* generate lowercased version of cell name */ - strcpy(tcell_l, tcell); - tmp = tcell_l; - while (*tmp) { - *tmp = tolower(*tmp); - tmp++; + if (tcell) { + strcpy(tcell_l, tcell); + tmp = tcell_l; + while (*tmp) { + *tmp = tolower(*tmp); + tmp++; + } } /* determine local cell name. It's static, so will only get @@ -394,7 +396,7 @@ kerberosSuperUser(struct afsconf_dir *adir, char *tname, char *tinst, /* If yes, then make sure that the name is not present in * an exclusion list */ if (lrealm_match) { - if (tinst[0]) + if (tinst && tinst[0]) snprintf(uname,sizeof(uname),"%s.%s@%s",tname,tinst,tcell); else snprintf(uname,sizeof(uname),"%s@%s",tname,tcell); @@ -408,7 +410,8 @@ kerberosSuperUser(struct afsconf_dir *adir, char *tname, char *tinst, flag = 0; /* localauth special case */ - if (strlen(tinst) == 0 && strlen(tcell) == 0 + if ((tinst == NULL || strlen(tinst) == 0) && + (tcell == NULL || strlen(tcell) == 0) && !strcmp(tname, AUTH_SUPERUSER)) { strcpy(uname, ""); flag = 1;