something
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@1983 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -10,6 +10,31 @@ krb5_kuserok (krb5_context context,
|
||||
char buf[BUFSIZ];
|
||||
struct passwd *pwd;
|
||||
FILE *f;
|
||||
char *realm;
|
||||
krb5_principal local_principal;
|
||||
krb5_error_code ret;
|
||||
krb5_boolean b;
|
||||
|
||||
ret = krb5_get_default_realm (context, &realm);
|
||||
if (ret) {
|
||||
free (realm);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ret = krb5_build_principal (context,
|
||||
&local_principal,
|
||||
strlen(realm),
|
||||
realm,
|
||||
luser,
|
||||
NULL);
|
||||
free (realm);
|
||||
if (ret)
|
||||
return FALSE;
|
||||
|
||||
b = krb5_principal_compare (context, principal, local_principal);
|
||||
krb5_free_principal (context, local_principal);
|
||||
if (b)
|
||||
return TRUE;
|
||||
|
||||
pwd = getpwnam (luser); /* XXX - Should use k_getpwnam? */
|
||||
if (pwd == NULL)
|
||||
@@ -18,6 +43,24 @@ krb5_kuserok (krb5_context context,
|
||||
f = fopen (buf, "r");
|
||||
if (f == NULL)
|
||||
return FALSE;
|
||||
|
||||
while (fgets (buf, sizeof(buf), f) != NULL) {
|
||||
krb5_principal tmp;
|
||||
|
||||
if(buf[strlen(buf) - 1] == '\n')
|
||||
buf[strlen(buf) - 1] = '\0';
|
||||
|
||||
ret = krb5_parse_name (context, buf, &tmp);
|
||||
if (ret) {
|
||||
fclose (f);
|
||||
return FALSE;
|
||||
}
|
||||
b = krb5_principal_compare (context, principal, tmp);
|
||||
krb5_free_principal (context, tmp);
|
||||
if (b) {
|
||||
fclose (f);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
fclose (f);
|
||||
return FALSE;
|
||||
}
|
||||
|
Reference in New Issue
Block a user