[Pkg-shadow-commits] r666 - in trunk/debian: . patches

Nicolas FRANCOIS nekral-guest at costa.debian.org
Wed Nov 30 22:01:10 UTC 2005


Author: nekral-guest
Date: 2005-11-30 22:01:06 +0000 (Wed, 30 Nov 2005)
New Revision: 666

Added:
   trunk/debian/patches/468_duplicate_passwd_struct_before_usage
Modified:
   trunk/debian/changelog
   trunk/debian/patches/series
Log:
Duplicate the passwd structures retrieved by getpwnam before calling PAM.
Closes: #341230


Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	2005-11-21 19:34:25 UTC (rev 665)
+++ trunk/debian/changelog	2005-11-30 22:01:06 UTC (rev 666)
@@ -1,6 +1,10 @@
 shadow (1:4.0.13-8) UNRELEASED; urgency=low
 
   * The "Crottin de Chavignol" release
+  * Upstream bugs not already fixed in upstream releases or CVS:
+    - 468_duplicate_passwd_struct_before_usage
+      Duplicate the passwd structures retrieved by getpwnam before calling
+      PAM. Closes: #341230
 
  -- Christian Perrier <bubulle at debian.org>  Mon, 21 Nov 2005 20:33:40 +0100
 

Added: trunk/debian/patches/468_duplicate_passwd_struct_before_usage
===================================================================
--- trunk/debian/patches/468_duplicate_passwd_struct_before_usage	2005-11-21 19:34:25 UTC (rev 665)
+++ trunk/debian/patches/468_duplicate_passwd_struct_before_usage	2005-11-30 22:01:06 UTC (rev 666)
@@ -0,0 +1,61 @@
+Goal:
+   The getpwnam man page specifies:
+
+       The getpwnam() and getpwuid() functions return a pointer  to  a  passwd
+       structure,  or  NULL  if  the  matching  entry is not found or an error
+       occurs.  If an error occurs, errno is set appropriately.  If one  wants
+       to  check  errno  after  the  call, it should be set to zero before the
+       call.
+
+       The return value may point to static area, and may  be  overwritten  by
+       subsequent calls to getpwent(), getpwnam(), or getpwuid().
+
+   There is no garranty that a PAM module will not use one of these
+   functions.  (This is the case of pam_unix in PAM 0.76)
+   So the structure must be duplicated before being used (there are call
+   to PAM between the call to getpwnam and the usage of the passwd
+   structure).
+
+   In the GNU libc, only a call to the same function (getpwent(),
+   getpwnam(), or getpwuid()) overrides the static area.
+
+   This patch should fix this kind of issues for the GNU libc. However,
+   getpwuid is often called after the call to getpwnam in shaow. I did not
+   checked if there may be an issue for non-GNU libc.
+
+Fixes: #341230
+
+Status wrt upstream: 
+
+Index: shadow-4.0.13/src/chfn.c
+===================================================================
+--- shadow-4.0.13.orig/src/chfn.c	2005-10-05 13:35:53.000000000 +0200
++++ shadow-4.0.13/src/chfn.c	2005-11-30 21:22:14.000000000 +0100
+@@ -341,6 +341,11 @@
+ 		}
+ 		user = xstrdup (pw->pw_name);
+ 	}
++	pw = __pw_dup(pw);
++	if (!pw) {
++		fprintf (stderr, _("%s: out of memory\n"), Prog);
++		exit (E_NOPERM);
++	}
+ 
+ #ifdef	USE_NIS
+ 	/*
+Index: shadow-4.0.13/src/chsh.c
+===================================================================
+--- shadow-4.0.13.orig/src/chsh.c	2005-11-30 21:57:04.000000000 +0100
++++ shadow-4.0.13/src/chsh.c	2005-11-30 21:56:50.000000000 +0100
+@@ -199,6 +199,11 @@
+ 		}
+ 		user = xstrdup (pw->pw_name);
+ 	}
++	pw = __pw_dup(pw);
++	if (!pw) {
++		fprintf (stderr, _("%s: out of memory\n"), Prog);
++		exit (1);
++	}
+ 
+ #ifdef	USE_NIS
+ 	/*

Modified: trunk/debian/patches/series
===================================================================
--- trunk/debian/patches/series	2005-11-21 19:34:25 UTC (rev 665)
+++ trunk/debian/patches/series	2005-11-30 22:01:06 UTC (rev 666)
@@ -68,6 +68,7 @@
 467_usermod_longopts
 #End of holiday patches
 366_fflush-prompt
+468_duplicate_passwd_struct_before_usage
 # 999-2 is about using cdbs. It does not patch upstream files
 # so shouldn't be here, but we keep it for the future
 # 999-2_build_using_cdbs




More information about the Pkg-shadow-commits mailing list