static char *_get_pw_info(pool *p, const char *u, time_t *lstchg, time_t *min, time_t *max, time_t *warn, time_t *inact, time_t *expire) { struct spwd *sp; char *cpw = NULL; PRIVS_ROOT #ifdef HAVE_SETSPENT setspent(); #endif /* HAVE_SETSPENT */ sp = getspnam(u); if (sp != NULL) { cpw = pstrdup(p, sp->sp_pwdp); if (lstchg != NULL) { *lstchg = SP_CVT_DAYS(sp->sp_lstchg); } if (min != NULL) { *min = SP_CVT_DAYS(sp->sp_min); } if (max != NULL) { *max = SP_CVT_DAYS(sp->sp_max); } #ifdef HAVE_SPWD_SP_WARN if (warn != NULL) { *warn = SP_CVT_DAYS(sp->sp_warn); } #endif /* HAVE_SPWD_SP_WARN */ #ifdef HAVE_SPWD_SP_INACT if (inact != NULL) { *inact = SP_CVT_DAYS(sp->sp_inact); } #endif /* HAVE_SPWD_SP_INACT */ #ifdef HAVE_SPWD_SP_EXPIRE if (expire != NULL) { *expire = SP_CVT_DAYS(sp->sp_expire); } #endif /* HAVE_SPWD_SP_EXPIRE */ } #ifdef PR_USE_AUTO_SHADOW if (sp == NULL) { struct passwd *pw; endspent(); PRIVS_RELINQUISH pw = getpwnam(u); if (pw != NULL) { cpw = pstrdup(p, pw->pw_passwd); if (lstchg != NULL) { *lstchg = (time_t) -1; } if (min != NULL) { *min = (time_t) -1; } if (max != NULL) { *max = (time_t) -1; } if (warn != NULL) { *warn = (time_t) -1; } if (inact != NULL) { *inact = (time_t) -1; } if (expire != NULL) { *expire = (time_t) -1; } } } else { PRIVS_RELINQUISH } #else endspent(); PRIVS_RELINQUISH #endif /* PR_USE_AUTO_SHADOW */ return cpw; }
static char *_get_pw_info(pool *p, const char *u, time_t *lstchg, time_t *min, time_t *max, time_t *warn, time_t *inact, time_t *expire) { struct spwd *sp; char *cpw = NULL; pr_trace_msg(trace_channel, 7, "looking up user '%s' via Unix shadow mechanism", u); PRIVS_ROOT #ifdef HAVE_SETSPENT setspent(); #endif /* HAVE_SETSPENT */ sp = getspnam(u); if (sp != NULL) { cpw = pstrdup(p, sp->sp_pwdp); if (lstchg != NULL) { *lstchg = SP_CVT_DAYS(sp->sp_lstchg); } if (min != NULL) { *min = SP_CVT_DAYS(sp->sp_min); } if (max != NULL) { *max = SP_CVT_DAYS(sp->sp_max); } #ifdef HAVE_SPWD_SP_WARN if (warn != NULL) { *warn = SP_CVT_DAYS(sp->sp_warn); } #endif /* HAVE_SPWD_SP_WARN */ #ifdef HAVE_SPWD_SP_INACT if (inact != NULL) { *inact = SP_CVT_DAYS(sp->sp_inact); } #endif /* HAVE_SPWD_SP_INACT */ #ifdef HAVE_SPWD_SP_EXPIRE if (expire != NULL) { *expire = SP_CVT_DAYS(sp->sp_expire); } #endif /* HAVE_SPWD_SP_EXPIRE */ } else { pr_log_debug(DEBUG5, "mod_auth_unix: getspnam(3) for user '%s' error: %s", u, strerror(errno)); } #ifdef PR_USE_AUTO_SHADOW if (sp == NULL) { struct passwd *pw; pr_trace_msg(trace_channel, 7, "looking up user '%s' via Unix autoshadow mechanism", u); endspent(); PRIVS_RELINQUISH pw = getpwnam(u); if (pw != NULL) { cpw = pstrdup(p, pw->pw_passwd); if (lstchg != NULL) { *lstchg = (time_t) -1; } if (min != NULL) { *min = (time_t) -1; } if (max != NULL) { *max = (time_t) -1; } if (warn != NULL) { *warn = (time_t) -1; } if (inact != NULL) { *inact = (time_t) -1; } if (expire != NULL) { *expire = (time_t) -1; } } else { pr_log_debug(DEBUG5, "mod_auth_unix: getpwnam(3) for user '%s' error: %s", u, strerror(errno)); } } else { PRIVS_RELINQUISH } #else endspent(); PRIVS_RELINQUISH #endif /* PR_USE_AUTO_SHADOW */ return cpw; }