diff options
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/du/du.c | 6 | ||||
-rw-r--r-- | usr.bin/env/env.c | 7 | ||||
-rw-r--r-- | usr.bin/limits/limits.c | 10 | ||||
-rw-r--r-- | usr.bin/login/login.c | 7 | ||||
-rw-r--r-- | usr.bin/su/su.c | 8 |
5 files changed, 28 insertions, 10 deletions
diff --git a/usr.bin/du/du.c b/usr.bin/du/du.c index 00c1f5e..73583e3 100644 --- a/usr.bin/du/du.c +++ b/usr.bin/du/du.c @@ -140,16 +140,16 @@ main(int argc, char *argv[]) cflag = 1; break; case 'h': - putenv("BLOCKSIZE=512"); + setenv("BLOCKSIZE", "512", 1); hflag = 1; break; case 'k': hflag = 0; - putenv("BLOCKSIZE=1024"); + setenv("BLOCKSIZE", "1024", 1); break; case 'm': hflag = 0; - putenv("BLOCKSIZE=1048576"); + setenv("BLOCKSIZE", "1048576", 1); break; case 'n': nodumpflag = 1; diff --git a/usr.bin/env/env.c b/usr.bin/env/env.c index 815976f..b11a0b7 100644 --- a/usr.bin/env/env.c +++ b/usr.bin/env/env.c @@ -67,6 +67,7 @@ main(int argc, char **argv) char *altpath, **ep, *p, **parg; char *cleanenv[1]; int ch, want_clear; + int rtrn; altpath = NULL; want_clear = 0; @@ -105,7 +106,11 @@ main(int argc, char **argv) for (argv += optind; *argv && (p = strchr(*argv, '=')); ++argv) { if (env_verbosity) fprintf(stderr, "#env setenv:\t%s\n", *argv); - (void)setenv(*argv, ++p, 1); + *p = '\0'; + rtrn = setenv(*argv, p + 1, 1); + *p = '='; + if (rtrn == -1) + err(EXIT_FAILURE, "setenv %s", *argv); } if (*argv) { if (altpath) diff --git a/usr.bin/limits/limits.c b/usr.bin/limits/limits.c index e976f36..0383ac2 100644 --- a/usr.bin/limits/limits.c +++ b/usr.bin/limits/limits.c @@ -244,6 +244,7 @@ main(int argc, char *argv[]) int rcswhich, shelltype; int i, num_limits = 0; int ch, doeval = 0, doall = 0; + int rtrn; login_cap_t * lc = NULL; enum { ANY=0, SOFT=1, HARD=2, BOTH=3, DISPLAYONLY=4 } type = ANY; enum { RCSUNKNOWN=0, RCSSET=1, RCSSEL=2 } todo = RCSUNKNOWN; @@ -399,8 +400,13 @@ main(int argc, char *argv[]) login_close(lc); /* set leading environment variables, like eval(1) */ - while (*argv && (p = strchr(*argv, '='))) - (void)setenv(*argv++, ++p, 1); + while (*argv && (p = strchr(*argv, '='))) { + *p = '\0'; + rtrn = setenv(*argv++, p + 1, 1); + *p = '='; + if (rtrn == -1) + err(EXIT_FAILURE, "setenv %s", *argv); + } /* Set limits */ for (rcswhich = 0; rcswhich < RLIM_NLIMITS; rcswhich++) { diff --git a/usr.bin/login/login.c b/usr.bin/login/login.c index 7827ea1..549e015 100644 --- a/usr.bin/login/login.c +++ b/usr.bin/login/login.c @@ -766,10 +766,11 @@ export(const char *s) "SHELL", "HOME", "LOGNAME", "MAIL", "CDPATH", "IFS", "PATH", NULL }; + char *p; const char **pp; size_t n; - if (strlen(s) > 1024 || strchr(s, '=') == NULL) + if (strlen(s) > 1024 || (p = strchr(s, '=')) == NULL) return (0); if (strncmp(s, "LD_", 3) == 0) return (0); @@ -778,7 +779,9 @@ export(const char *s) if (s[n] == '=' && strncmp(s, *pp, n) == 0) return (0); } - (void)putenv(s); + *p = '\0'; + (void)setenv(s, p + 1, 1); + *p = '='; return (1); } diff --git a/usr.bin/su/su.c b/usr.bin/su/su.c index 76f76b6..8bc5472 100644 --- a/usr.bin/su/su.c +++ b/usr.bin/su/su.c @@ -564,10 +564,14 @@ static void export_pam_environment(void) { char **pp; + char *p; for (pp = environ_pam; *pp != NULL; pp++) { - if (ok_to_export(*pp)) - putenv(*pp); + if (ok_to_export(*pp)) { + p = strchr(*pp, '='); + *p = '\0'; + setenv(*pp, p + 1, 1); + } free(*pp); } } |