[Pkg-shadow-devel] [PATCH] passwd: abort if we do not have /etc/shadow perms

Mike Frysinger vapier at gentoo.org
Mon Feb 13 04:21:07 UTC 2012


Running `passwd` as non-root and non-setuid results in passwd just
saying "passwords don't match" rather than "unable to read the pw
database".  Add a permission check so now we get:
	$ ./passwd
	passwd: Permission denied.

Signed-off-by: Mike Frysinger <vapier at gentoo.org>
---
 src/passwd.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/passwd.c b/src/passwd.c
index d3a9f19..4393281 100644
--- a/src/passwd.c
+++ b/src/passwd.c
@@ -1057,6 +1057,10 @@ int main (int argc, char **argv)
 	 */
 	sp = getspnam (name); /* !USE_PAM, no need for xgetspnam */
 	if (NULL == sp) {
+		if (errno == EACCES) {
+			(void) fprintf (stderr, _("%s: Permission denied.\n"), Prog);
+			exit (E_NOPERM);
+		}
 		sp = pwd_to_spwd (pw);
 	}
 
-- 
1.7.8.4




More information about the Pkg-shadow-devel mailing list