Use k_getpw{name,uid} and strtok_r

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@1051 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Assar Westerlund
1996-11-19 04:16:50 +00:00
parent 2d320a31df
commit 9b4664e29e
7 changed files with 16 additions and 13 deletions

View File

@@ -170,12 +170,11 @@ login(char *host)
int n, aflag = 0;
char *myname = NULL;
struct passwd *pw = getpwuid(getuid());
struct passwd *pw = k_getpwuid(getuid());
if (pw != NULL)
myname = pw->pw_name;
user = pass = acct = 0;
if(do_klogin(host))
printf("\n*** Using plaintext user and password ***\n\n");

View File

@@ -100,7 +100,7 @@ main(int argc, char **argv)
/*
* Set up the home directory in case we're globbing.
*/
pw = getpwuid(getuid());
pw = k_getpwuid(getuid());
if (pw != NULL) {
home = homedir;
strcpy(home, pw->pw_dir);

View File

@@ -254,9 +254,13 @@ parse_auth_level(char *str)
{
char *p;
int ret = 0;
p = strtok(str, ",");
while(p){
if(strcmp(p, "user") == 0) ;
char *foo;
for(p = strtok_r(str, ",", &foo);
p;
p = strtok_r(NULL, ",", &foo)) {
if(strcmp(p, "user") == 0)
;
else if(strcmp(p, "otp") == 0)
ret |= AUTH_PLAIN|AUTH_OTP;
else if(strcmp(p, "ftp") == 0 ||
@@ -268,7 +272,6 @@ parse_auth_level(char *str)
ret |= AUTH_PLAIN|AUTH_FTP;
else
warnx("bad value for -a");
p = strtok(NULL, ",");
}
return ret;
}

View File

@@ -80,7 +80,7 @@ ftp_rooted(const char *path)
static char newpath[MaxPathLen];
struct passwd *pwd;
if(!home[0])
if((pwd = getpwnam("ftp")))
if((pwd = k_getpwnam("ftp")))
strcpy(home, pwd->pw_dir);
sprintf(newpath, "%s/%s", home, path);
if(access(newpath, X_OK))
@@ -96,6 +96,7 @@ ftpd_popen(char *program, char *type, int do_stderr, int no_glob)
FILE *iop;
int argc, gargc, pdes[2], pid;
char **pop, *argv[100], *gargv[1000];
char *foo;
if (strcmp(type, "r") && strcmp(type, "w"))
return (NULL);
@@ -117,7 +118,7 @@ ftpd_popen(char *program, char *type, int do_stderr, int no_glob)
/* break up string into pieces */
for (argc = 0, cp = program;; cp = NULL)
if (!(argv[argc++] = strtok(cp, " \t\n")))
if (!(argv[argc++] = strtok_r(cp, " \t\n", &foo)))
break;
gargv[0] = (char*)ftp_rooted(argv[0]);

View File

@@ -74,7 +74,7 @@ renew (int argc, char **argv, OtpAlgorithm *alg)
if (argc != 2)
usage();
pwd = getpwuid (getuid ());
pwd = k_getpwuid (getuid ());
if (pwd == NULL) {
fprintf(stderr, "%s: You don't exist\n", prog);
return 1;
@@ -127,7 +127,7 @@ set (int argc, char **argv, OtpAlgorithm *alg)
if (argc != 2)
usage();
pwd = getpwuid (getuid ());
pwd = k_getpwuid (getuid ());
if (pwd == NULL) {
fprintf(stderr, "%s: You don't exist\n", prog);
return 1;

View File

@@ -415,7 +415,7 @@ rd_and_store_for_creds(inbuf, ticket, lusername)
return(retval);
}
if (!(pwd = (struct passwd *) k_getpwnam(lusername))) {
if (!(pwd = k_getpwnam(lusername))) {
return -1;
}

View File

@@ -2372,7 +2372,7 @@ int tn(int argc, char **argv)
user = getenv("USER");
if (user == NULL ||
((pw = k_getpwnam(user)) && pw->pw_uid != getuid())) {
if (pw = getpwuid(getuid()))
if (pw = k_getpwuid(getuid()))
user = pw->pw_name;
else
user = NULL;