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 <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
This commit is contained in:
Simon Wilkinson 2010-09-13 08:24:12 +01:00 committed by Derrick Brashear
parent e6a2183f0c
commit eee9fe0945

View File

@ -340,7 +340,7 @@ static int
kerberosSuperUser(struct afsconf_dir *adir, char *tname, char *tinst, kerberosSuperUser(struct afsconf_dir *adir, char *tname, char *tinst,
char *tcell, char *namep) char *tcell, char *namep)
{ {
char tcell_l[MAXKTCREALMLEN]; char tcell_l[MAXKTCREALMLEN] = "";
char *tmp; char *tmp;
/* keep track of which one actually authorized request */ /* keep track of which one actually authorized request */
@ -353,12 +353,14 @@ kerberosSuperUser(struct afsconf_dir *adir, char *tname, char *tinst,
int flag; int flag;
/* generate lowercased version of cell name */ /* generate lowercased version of cell name */
if (tcell) {
strcpy(tcell_l, tcell); strcpy(tcell_l, tcell);
tmp = tcell_l; tmp = tcell_l;
while (*tmp) { while (*tmp) {
*tmp = tolower(*tmp); *tmp = tolower(*tmp);
tmp++; tmp++;
} }
}
/* determine local cell name. It's static, so will only get /* determine local cell name. It's static, so will only get
* calculated the first time through */ * calculated the first time through */
@ -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 /* If yes, then make sure that the name is not present in
* an exclusion list */ * an exclusion list */
if (lrealm_match) { if (lrealm_match) {
if (tinst[0]) if (tinst && tinst[0])
snprintf(uname,sizeof(uname),"%s.%s@%s",tname,tinst,tcell); snprintf(uname,sizeof(uname),"%s.%s@%s",tname,tinst,tcell);
else else
snprintf(uname,sizeof(uname),"%s@%s",tname,tcell); snprintf(uname,sizeof(uname),"%s@%s",tname,tcell);
@ -408,7 +410,8 @@ kerberosSuperUser(struct afsconf_dir *adir, char *tname, char *tinst,
flag = 0; flag = 0;
/* localauth special case */ /* 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)) { && !strcmp(tname, AUTH_SUPERUSER)) {
strcpy(uname, "<LocalAuth>"); strcpy(uname, "<LocalAuth>");
flag = 1; flag = 1;