From 1bcf2ffb594e35befcb277f8a82658efde7deba6 Mon Sep 17 00:00:00 2001 From: nekral-guest Date: Mon, 20 Apr 2009 11:48:59 +0000 Subject: [PATCH] * libmisc/hushed.c, lib/prototypes.h, src/login.c: Change the hushed() prototype to take a username instead of a passwd structure in argument. The passwd entry is retrieved withing hushed(). --- ChangeLog | 7 +++++++ lib/prototypes.h | 2 +- libmisc/hushed.c | 10 ++++++++-- src/login.c | 4 ++-- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6986e898..9eed7f66 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-04-20 Nicolas François + + * libmisc/hushed.c, lib/prototypes.h, src/login.c: Change the + hushed() prototype to take a username instead of a passwd + structure in argument. The passwd entry is retrieved withing + hushed(). + 2009-04-20 Nicolas François * libmisc/setugid.c: Updated comments. diff --git a/lib/prototypes.h b/lib/prototypes.h index 1145ff46..2eb292d8 100644 --- a/lib/prototypes.h +++ b/lib/prototypes.h @@ -175,7 +175,7 @@ extern void __gr_set_changed (void); extern struct group *__gr_dup (const struct group *grent); /* hushed.c */ -extern bool hushed (const struct passwd *pw); +extern bool hushed (const char *username); /* audit_help.c */ #ifdef WITH_AUDIT diff --git a/libmisc/hushed.c b/libmisc/hushed.c index 0af41ab0..753a1441 100644 --- a/libmisc/hushed.c +++ b/libmisc/hushed.c @@ -3,7 +3,7 @@ * Copyright (c) 1991 - 1993, Chip Rosenthal * Copyright (c) 1996 - 2000, Marek Michałkiewicz * Copyright (c) 2003 - 2005, Tomasz Kłoczko - * Copyright (c) 2008 , Nicolas François + * Copyright (c) 2008 - 2009, Nicolas François * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -47,8 +47,9 @@ * Look in the hushed-logins file (or user's home directory) to see * if the user is to receive the login-time messages. */ -bool hushed (const struct passwd *pw) +bool hushed (const char *username) { + const struct passwd *pw; char *hushfile; char buf[BUFSIZ]; bool found; @@ -64,6 +65,11 @@ bool hushed (const struct passwd *pw) return false; } + pw = getspnam (username); + if (NULL == pw) { + return false; + } + /* * If this is not a fully rooted path then see if the * file exists in the user's home directory. diff --git a/src/login.c b/src/login.c index 699549ac..843197d4 100644 --- a/src/login.c +++ b/src/login.c @@ -847,7 +847,7 @@ int main (int argc, char **argv) retcode = pam_setcred (pamh, PAM_ESTABLISH_CRED); PAM_FAIL_CHECK; - retcode = pam_open_session (pamh, hushed (&pwent) ? PAM_SILENT : 0); + retcode = pam_open_session (pamh, hushed (username) ? PAM_SILENT : 0); PAM_FAIL_CHECK; #else /* ! USE_PAM */ @@ -1184,7 +1184,7 @@ int main (int argc, char **argv) (void) bindtextdomain (PACKAGE, LOCALEDIR); (void) textdomain (PACKAGE); - if (!hushed (&pwent)) { + if (!hushed (username)) { addenv ("HUSHLOGIN=FALSE", NULL); /* * pam_unix, pam_mail and pam_lastlog should take care of -- 2.40.0