Lines Matching refs:pwd
53 #include <pwd.h>
105 struct passwd *pwd;
186 if (username == NULL || (pwd = getpwnam(username)) == NULL ||
187 pwd->pw_uid != ruid)
188 pwd = getpwuid(ruid);
189 if (pwd == NULL)
191 username = estrdup(pwd->pw_name);
193 userpass = estrdup(pwd->pw_passwd);
197 if (pwd->pw_shell && *pwd->pw_shell) {
198 (void)estrlcpy(shellbuf, pwd->pw_shell, sizeof(shellbuf));
223 if ((pwd = getpwnam(user)) == NULL)
232 pwd->pw_class = class;
234 if ((lc = login_getclass(pwd->pw_class)) == NULL)
235 errx(EXIT_FAILURE, "Unknown class %s", pwd->pw_class);
244 && (!use_kerberos || kerberos5(username, user, pwd->pw_uid))
247 char *pass = pwd->pw_passwd;
248 int ok = pwd->pw_uid != 0;
274 if (*pass && pwd->pw_uid != ruid) { /* XXX - OK? */
297 pwd->pw_name, ontty());
305 if (chshell(pwd->pw_shell) == 0 && ruid)
307 } else if (pwd->pw_shell && *pwd->pw_shell) {
308 shell = pwd->pw_shell;
328 if (ruid != pwd->pw_uid &&
329 setusercontext(lc, pwd, pwd->pw_uid, LOGIN_SETGROUP) == -1)
332 addgroup(lc, gname, pwd, ruid, GROUP_PASSWORD);
334 if (setusercontext(lc, pwd, pwd->pw_uid,
339 if (setusercontext(lc, pwd, pwd->pw_uid,
345 if (setgid(pwd->pw_gid) == -1)
348 if (ruid != pwd->pw_uid && initgroups(user, pwd->pw_gid) != 0)
351 addgroup(/*EMPTY*/, gname, pwd, ruid, GROUP_PASSWORD);
353 if (setuid(pwd->pw_uid) == -1)
364 if (setusercontext(lc, pwd, pwd->pw_uid,
372 if (gohome && chdir(pwd->pw_dir) == -1)
376 if (asthem || pwd->pw_uid) {
377 (void)setenv("LOGNAME", pwd->pw_name, 1);
378 (void)setenv("USER", pwd->pw_name, 1);
380 (void)setenv("HOME", pwd->pw_dir, 1);
408 if (pwd->pw_change || pwd->pw_expire)
410 if (pwd->pw_change) {
411 if (tp.tv_sec >= pwd->pw_change) {
416 } else if (pwd->pw_change - tp.tv_sec < pw_warntime)
418 user, ctime(&pwd->pw_change));
420 if (pwd->pw_expire) {
421 if (tp.tv_sec >= pwd->pw_expire) {
426 } else if (pwd->pw_expire - tp.tv_sec <
429 user, ctime(&pwd->pw_expire));
434 username, pwd->pw_name, ontty());