Author: bapt
Date: Tue Jun 19 11:39:56 2012
New Revision: 237268
URL: http://svn.freebsd.org/changeset/base/237268

Log:
  Revert user comparison back to user names as some user can share uids 
(root/toor
  for example)
  
  get the username information from old_pw structures to still allow renaming 
of a
  user.
  
  Reported by:  Claude Buisson <clbuis...@orange.fr>
  Approved by:  des (mentor)
  MFC after:    3 weeks

Modified:
  head/lib/libutil/pw_util.c

Modified: head/lib/libutil/pw_util.c
==============================================================================
--- head/lib/libutil/pw_util.c  Tue Jun 19 10:07:50 2012        (r237267)
+++ head/lib/libutil/pw_util.c  Tue Jun 19 11:39:56 2012        (r237268)
@@ -437,14 +437,21 @@ pw_copy(int ffd, int tfd, const struct p
        size_t len;
        int eof, readlen;
 
-       spw = pw;
+       if (old_pw == NULL && pw == NULL)
+                       return (-1);
+
+       spw = old_pw;
+       /* deleting a user */
        if (pw == NULL) {
                line = NULL;
-               if (old_pw == NULL)
+       } else {
+               if ((line = pw_make(pw)) == NULL)
                        return (-1);
-               spw = old_pw;
-       } else if ((line = pw_make(pw)) == NULL)
-               return (-1);
+       }
+
+       /* adding a user */
+       if (spw == NULL)
+               spw = pw;
 
        eof = 0;
        len = 0;
@@ -511,7 +518,7 @@ pw_copy(int ffd, int tfd, const struct p
                 */
 
                *q = t;
-               if (fpw == NULL || fpw->pw_uid != spw->pw_uid) {
+               if (fpw == NULL || strcmp(fpw->pw_name, spw->pw_name) != 0) {
                        /* nope */
                        if (fpw != NULL)
                                free(fpw);
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to