Changeset View
Changeset View
Standalone View
Standalone View
head/usr.bin/login/login.c
Show First 20 Lines • Show All 787 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
static const char *noexport[] = { | static const char *noexport[] = { | ||||
"SHELL", "HOME", "LOGNAME", "MAIL", "CDPATH", | "SHELL", "HOME", "LOGNAME", "MAIL", "CDPATH", | ||||
"IFS", "PATH", NULL | "IFS", "PATH", NULL | ||||
}; | }; | ||||
char *p; | char *p; | ||||
const char **pp; | const char **pp; | ||||
size_t n; | size_t n; | ||||
int rv; | |||||
if (strlen(s) > 1024 || (p = strchr(s, '=')) == NULL) | if (strlen(s) > 1024 || (p = strchr(s, '=')) == NULL) | ||||
return (0); | return (0); | ||||
if (strncmp(s, "LD_", 3) == 0) | if (strncmp(s, "LD_", 3) == 0) | ||||
return (0); | return (0); | ||||
for (pp = noexport; *pp != NULL; pp++) { | for (pp = noexport; *pp != NULL; pp++) { | ||||
n = strlen(*pp); | n = strlen(*pp); | ||||
if (s[n] == '=' && strncmp(s, *pp, n) == 0) | if (s[n] == '=' && strncmp(s, *pp, n) == 0) | ||||
return (0); | return (0); | ||||
} | } | ||||
*p = '\0'; | *p = '\0'; | ||||
(void)setenv(s, p + 1, 1); | rv = setenv(s, p + 1, 1); | ||||
*p = '='; | *p = '='; | ||||
if (rv == 1) | |||||
pfg: This is actually -1 : 1 is vener returned by setenv(3). | |||||
return (0); | |||||
return (1); | return (1); | ||||
} | } | ||||
static void | static void | ||||
usage(void) | usage(void) | ||||
{ | { | ||||
(void)fprintf(stderr, "usage: login [-fp] [-h hostname] [username]\n"); | (void)fprintf(stderr, "usage: login [-fp] [-h hostname] [username]\n"); | ||||
▲ Show 20 Lines • Show All 219 Lines • Show Last 20 Lines |
This is actually -1 : 1 is vener returned by setenv(3).