Lines 144-159
main(int argc, char **argv)
Link Here
|
144 |
login_class = strchr(login_name, '/'); |
144 |
login_class = strchr(login_name, '/'); |
145 |
if (login_class) |
145 |
if (login_class) |
146 |
*login_class++ = '\0'; |
146 |
*login_class++ = '\0'; |
147 |
pw = getpwnam(login_name); |
147 |
if (*login_name != '\0' && strcmp(login_name,"-") != 0) { |
148 |
if (pw == NULL) { |
148 |
pw = getpwnam(login_name); |
149 |
char *endp = NULL; |
149 |
if (pw == NULL) { |
150 |
errno = 0; |
150 |
char *endp = NULL; |
151 |
uid = strtoul(login_name, &endp, 10); |
151 |
errno = 0; |
152 |
if (errno == 0 && *endp == '\0') |
152 |
uid = strtoul(login_name, &endp, 10); |
153 |
pw = getpwuid(uid); |
153 |
if (errno == 0 && *endp == '\0') |
|
|
154 |
pw = getpwuid(uid); |
155 |
} |
156 |
if (pw == NULL) |
157 |
errx(EXIT_FAILURE, "no such user: %s", login_name); |
154 |
} |
158 |
} |
155 |
if (pw == NULL) |
159 |
/* |
156 |
errx(EXIT_FAILURE, "no such user: %s", login_name); |
160 |
* Note that it is safe for pw to be null here; the libutil |
|
|
161 |
* code handles that, bypassing substitution of $ and using |
162 |
* the class "default" if no class name is given either. |
163 |
*/ |
157 |
if (login_class != NULL) { |
164 |
if (login_class != NULL) { |
158 |
lc = login_getclass(login_class); |
165 |
lc = login_getclass(login_class); |
159 |
if (lc == NULL) |
166 |
if (lc == NULL) |