[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: [gmail] Re: SHADOW problem and patches (1.3.1)
From:       Marc Leeman <marc.leeman () gmail ! com>
Date:       2006-12-28 18:36:09
Message-ID: 20061228183609.GR5750 () scorpius ! homelinux ! org
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/mixed)]


> > Some files need shadow_.h (without having
> > ENABLE_FEATURE_SHADOWPASSWDS).
> 
> Including shadow_.h without having ENABLE_FEATURE_SHADOWPASSWDS
> is wrong. It won't work on systems which don't have shadow.h installed
> (uClibc systems with shadow password disabled).

I assumed as much, but the main purpose of the post was to signal the
problem.

At that time, my main issue was to avoid a battery of error mails from
the continuous build system during my holidays :-)

> The attached patch fixes the problem for pwd_grp.c. (It should be
> fixed the same way for passwd.c and sulogin.c but I don't use them
> so I didn't tried to fix them).

I got some more time this evening (I really should stop updating
firmware builds on holidays :-X ). 

Well, as the name shows, I fixed it properly (tm) this time, so the
attached patch should include your changes and those in passwd.c and
sulogin.c

-- 
  Marc Leeman
  R&D Firmware Engineer
 
  Barco Security and Monitoring Division
  Noordlaan 5, Industriezone, B-8520 Kuurne (BE)
  Tel. +32 56 368 428
  http://www.barco.com/controlrooms/
  mailto:marc.leeman@barco.com

["propershadow.diff" (text/x-diff)]

---
 libpwdgrp/pwd_grp.c          |   26 ++++++++++++++++++++++++++
 libpwdgrp/pwd_grp_internal.c |    2 ++
 loginutils/passwd.c          |   22 +++++++++++-----------
 loginutils/sulogin.c         |   13 ++++++-------
 4 files changed, 45 insertions(+), 18 deletions(-)

Index: busybox-1.3.1/libpwdgrp/pwd_grp.c
===================================================================
--- busybox-1.3.1.orig/libpwdgrp/pwd_grp.c
+++ busybox-1.3.1/libpwdgrp/pwd_grp.c
@@ -103,6 +103,7 @@
 	return rv;
 }
 
+#if ENABLE_FEATURE_SHADOWPASSWDS
 int fgetspent_r(FILE *__restrict stream, struct spwd *__restrict resultbuf,
 				char *__restrict buffer, size_t buflen,
 				struct spwd **__restrict result)
@@ -117,6 +118,7 @@
 
 	return rv;
 }
+#endif
 
 /**********************************************************************/
 /* For the various fget??ent funcs, return NULL on failure and a
@@ -144,6 +146,7 @@
 	return result;
 }
 
+#if ENABLE_FEATURE_SHADOWPASSWDS
 extern int fgetspent_r(FILE *__restrict stream, struct spwd *__restrict resultbuf,
 				char *__restrict buffer, size_t buflen,
 				struct spwd **__restrict result);
@@ -156,7 +159,9 @@
 	fgetspent_r(stream, &resultbuf, buffer, sizeof(buffer), &result);
 	return result;
 }
+#endif
 
+#if ENABLE_FEATURE_SHADOWPASSWDS
 int sgetspent_r(const char *string, struct spwd *result_buf,
 				char *buffer, size_t buflen, struct spwd **result)
 {
@@ -184,6 +189,7 @@
  DONE:
 	return rv;
 }
+#endif
 
 /**********************************************************************/
 
@@ -257,6 +263,7 @@
  * to have been created as a reentrant version of the non-standard
  * functions getspuid.  Why getspuid was added, I do not know. */
 
+#if ENABLE_FEATURE_SHADOWPASSWDS
 int getspuid_r(uid_t uid, struct spwd *__restrict resultbuf,
 		       char *__restrict buffer, size_t buflen,
 		       struct spwd **__restrict result)
@@ -273,10 +280,12 @@
 
 	return rv;
 }
+#endif
 
 /* This function is non-standard and is currently not built.
  * Why it was added, I do not know. */
 
+#if ENABLE_FEATURE_SHADOWPASSWDS
 struct spwd *getspuid(uid_t uid)
 {
 	static char buffer[PWD_BUFFER_SIZE];
@@ -286,6 +295,7 @@
 	getspuid_r(uid, &resultbuf, buffer, sizeof(buffer), &result);
 	return result;
 }
+#endif
 
 struct passwd *getpwnam(const char *name)
 {
@@ -307,6 +317,7 @@
 	return result;
 }
 
+#if ENABLE_FEATURE_SHADOWPASSWDS
 struct spwd *getspnam(const char *name)
 {
 	static char buffer[PWD_BUFFER_SIZE];
@@ -316,6 +327,7 @@
 	getspnam_r(name, &resultbuf, buffer, sizeof(buffer), &result);
 	return result;
 }
+#endif
 
 int getpw(uid_t uid, char *buf)
 {
@@ -464,6 +476,7 @@
 	UNLOCK;
 }
 
+#if ENABLE_FEATURE_SHADOWPASSWDS
 int getspent_r(struct spwd *resultbuf, char *buffer,
 			   size_t buflen, struct spwd **result)
 {
@@ -488,6 +501,7 @@
 	UNLOCK;
 	return rv;
 }
+#endif
 
 struct passwd *getpwent(void)
 {
@@ -509,6 +523,7 @@
 	return result;
 }
 
+#if ENABLE_FEATURE_SHADOWPASSWDS
 struct spwd *getspent(void)
 {
 	static char line_buff[PWD_BUFFER_SIZE];
@@ -518,7 +533,9 @@
 	getspent_r(&spwd, line_buff, sizeof(line_buff), &result);
 	return result;
 }
+#endif
 
+#if ENABLE_FEATURE_SHADOWPASSWDS
 struct spwd *sgetspent(const char *string)
 {
 	static char line_buff[PWD_BUFFER_SIZE];
@@ -528,6 +545,7 @@
 	sgetspent_r(string, &spwd, line_buff, sizeof(line_buff), &result);
 	return result;
 }
+#endif
 
 int initgroups(const char *user, gid_t gid)
 {
@@ -643,6 +661,7 @@
 	return rv;
 }
 
+#if ENABLE_FEATURE_SHADOWPASSWDS
 static const unsigned char _sp_off[] = {
 	offsetof(struct spwd, sp_lstchg),	/* 2 - not a char ptr */
 	offsetof(struct spwd, sp_min),		/* 3 - not a char ptr */
@@ -651,7 +670,9 @@
 	offsetof(struct spwd, sp_inact),	/* 6 - not a char ptr */
 	offsetof(struct spwd, sp_expire),	/* 7 - not a char ptr */
 };
+#endif
 
+#if ENABLE_FEATURE_SHADOWPASSWDS
 int putspent(const struct spwd *p, FILE *stream)
 {
 	static const char ld_format[] = "%ld:";
@@ -688,6 +709,7 @@
 DO_UNLOCK:
 	return rv;
 }
+#endif
 
 /**********************************************************************/
 /* Internal uClibc functions.					 */
@@ -846,6 +868,7 @@
 
 /**********************************************************************/
 
+#if ENABLE_FEATURE_SHADOWPASSWDS
 static const unsigned char sp_off[] = {
 	offsetof(struct spwd, sp_namp),		/* 0 */
 	offsetof(struct spwd, sp_pwdp),		/* 1 */
@@ -857,7 +880,9 @@
 	offsetof(struct spwd, sp_expire),	/* 7 - not a char ptr */
 	offsetof(struct spwd, sp_flag)		/* 8 - not a char ptr */
 };
+#endif
 
+#if ENABLE_FEATURE_SHADOWPASSWDS
 int __parsespent(void *data, char * line)
 {
 	char *endptr;
@@ -900,6 +925,7 @@
 
 	return EINVAL;
 }
+#endif
 
 /**********************************************************************/
 
Index: busybox-1.3.1/libpwdgrp/pwd_grp_internal.c
===================================================================
--- busybox-1.3.1.orig/libpwdgrp/pwd_grp_internal.c
+++ busybox-1.3.1/libpwdgrp/pwd_grp_internal.c
@@ -22,6 +22,7 @@
 #error GETXXKEY_R_FUNC is not defined!
 #endif
 
+#if ENABLE_FEATURE_SHADOWPASSWDS
 int GETXXKEY_R_FUNC(DO_GETXXKEY_R_KEYTYPE key,
 				GETXXKEY_R_ENTTYPE *__restrict resultbuf,
 				char *__restrict buffer, size_t buflen,
@@ -53,6 +54,7 @@
 
 	return rv;
 }
+#endif
 
 #undef GETXXKEY_R_FUNC
 #undef GETXXKEY_R_PARSER
Index: busybox-1.3.1/loginutils/passwd.c
===================================================================
--- busybox-1.3.1.orig/loginutils/passwd.c
+++ busybox-1.3.1/loginutils/passwd.c
@@ -275,18 +275,18 @@
 	}
 
 	filename = bb_path_passwd_file;
-	if (ENABLE_FEATURE_SHADOWPASSWDS) {
-		struct spwd *sp = getspnam(name);
-		if (!sp) {
-			/* LOGMODE_BOTH */
-			bb_error_msg("no record of %s in %s, using %s",
-					name, bb_path_shadow_file,
-					bb_path_passwd_file);
-		} else {
-			filename = bb_path_shadow_file;
-			pw->pw_passwd = sp->sp_pwdp;
-		}
+#if ENABLE_FEATURE_SHADOWPASSWDS
+	struct spwd *sp = getspnam(name);
+	if (!sp) {
+		/* LOGMODE_BOTH */
+		bb_error_msg("no record of %s in %s, using %s",
+				name, bb_path_shadow_file,
+				bb_path_passwd_file);
+	} else {
+		filename = bb_path_shadow_file;
+		pw->pw_passwd = sp->sp_pwdp;
 	}
+#endif
 
 	/* Decide what the new password will be */
 	newp = NULL;
Index: busybox-1.3.1/loginutils/sulogin.c
===================================================================
--- busybox-1.3.1.orig/loginutils/sulogin.c
+++ busybox-1.3.1/loginutils/sulogin.c
@@ -41,7 +41,6 @@
 	char *timeout_arg;
 	const char * const *p;
 	struct passwd *pwd;
-	struct spwd *spwd;
 	const char *shell;
 
 	logmode = LOGMODE_BOTH;
@@ -75,13 +74,13 @@
 		goto auth_error;
 	}
 
-	if (ENABLE_FEATURE_SHADOWPASSWDS) {
-		spwd = getspnam(pwd->pw_name);
-		if (!spwd) {
-			goto auth_error;
-		}
-		pwd->pw_passwd = spwd->sp_pwdp;
+#if ENABLE_FEATURE_SHADOWPASSWDS
+	struct spwd *spwd = getspnam(pwd->pw_name);
+	if (!spwd) {
+		goto auth_error;
 	}
+	pwd->pw_passwd = spwd->sp_pwdp;
+#endif
 
 	while (1) {
 		/* cp points to a static buffer that is zeroed every time */

["signature.asc" (application/pgp-signature)]

_______________________________________________
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic