Use getpwuid() instead of getlogin() in ``allow users''.

This commit is contained in:
Brian Somers 1999-12-20 20:30:40 +00:00
parent ef0a48491b
commit 8b50b30fa7

View File

@ -185,16 +185,17 @@ AllowUsers(struct cmdargs const *arg)
{ {
/* arg->bundle may be NULL (see system_IsValid()) ! */ /* arg->bundle may be NULL (see system_IsValid()) ! */
int f; int f;
char *user; struct passwd *pwd;
userok = 0; userok = 0;
user = getlogin(); pwd = getpwuid(getuid());
if (user && *user) if (pwd != NULL)
for (f = arg->argn; f < arg->argc; f++) for (f = arg->argn; f < arg->argc; f++)
if (!strcmp("*", arg->argv[f]) || !strcmp(user, arg->argv[f])) { if (!strcmp("*", arg->argv[f]) || !strcmp(pwd->pw_name, arg->argv[f])) {
userok = 1; userok = 1;
break; break;
} }
endpwent();
return 0; return 0;
} }