]> granicus.if.org Git - shadow/commitdiff
* libmisc/copydir.c, src/usermod.c, lib/prototypes.h: The uid and
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Tue, 1 Jan 2008 14:31:00 +0000 (14:31 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Tue, 1 Jan 2008 14:31:00 +0000 (14:31 +0000)
  gid parameters can be set to -1 to indicate that the original
  owners must be kept. Change the types from uid_t/gid_t to a
  long int (signed).
* libmisc/copydir.c: Change the copy_entry(), copy_dir(),
  copy_symlink(), copy_special(), and copy_file() prototypes
  accordingly.
* lib/prototypes.h: Add the parameters' name for the
  libmisc/copydir.c functions.

ChangeLog
lib/prototypes.h
libmisc/copydir.c
src/usermod.c

index 7bc847c01974500ed77f60b17ef8157a81da1603..2cd0a1fe89c2731189b16dfee07a7154f256296f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2008-01-01  Nicolas François  <nicolas.francois@centraliens.net>
+
+       * libmisc/copydir.c, src/usermod.c, lib/prototypes.h: The uid and
+       gid parameters can be set to -1 to indicate that the original
+       owners must be kept. Change the types from uid_t/gid_t to a
+       long int (signed).
+       * libmisc/copydir.c: Change the copy_entry(), copy_dir(),
+       copy_symlink(), copy_special(), and copy_file() prototypes
+       accordingly.
+       * lib/prototypes.h: Add the parameters' name for the
+       libmisc/copydir.c functions.
+
 2008-01-01  Nicolas François  <nicolas.francois@centraliens.net>
 
        * libmisc/limits.c, libmisc/obscure.c, src/login_nopam.c,
index 64b205cda920b7af87471dd3bc369bca643ba37a..166827683254c90de47572fbe18ef031df4e84e2 100644 (file)
@@ -51,8 +51,9 @@ extern int console (const char *);
 extern int is_listed (const char *, const char *, int);
 
 /* copydir.c */
-extern int copy_tree (const char *, const char *, uid_t, gid_t);
-extern int remove_tree (const char *);
+extern int copy_tree (const char *src_root, const char *dst_root,
+                      long int uid, long int gid);
+extern int remove_tree (const char *root);
 
 /* encrypt.c */
 extern char *pw_encrypt (const char *, const char *);
index 0423238268cd5b023c500aa4954d908ff17a875a..16c6fd47f1ac43d744ea41f597395a205a0fa1d1 100644 (file)
@@ -55,23 +55,23 @@ struct link_name {
 static struct link_name *links;
 
 static int copy_entry (const char *src, const char *dst,
-                       uid_t uid, gid_t gid);
+                       long int uid, long int gid);
 static int copy_dir (const char *src, const char *dst,
                      const struct stat *statp, const struct timeval mt[2],
-                     uid_t uid, gid_t gid);
+                     long int uid, long int gid);
 #ifdef S_IFLNK
 static int copy_symlink (const char *src, const char *dst,
                          const struct stat *statp, const struct timeval mt[2],
-                         uid_t uid, gid_t gid);
+                         long int uid, long int gid);
 #endif
 static int copy_hardlink (const char *src, const char *dst,
                           struct link_name *lp);
 static int copy_special (const char *src, const char *dst,
                          const struct stat *statp, const struct timeval mt[2],
-                         uid_t uid, gid_t gid);
+                         long int uid, long int gid);
 static int copy_file (const char *src, const char *dst,
                       const struct stat *statp, const struct timeval mt[2],
-                      uid_t uid, gid_t gid);
+                      long int uid, long int gid);
 
 #ifdef WITH_SELINUX
 /*
@@ -180,7 +180,8 @@ static struct link_name *check_link (const char *name, const struct stat *sb)
  *     copy_tree() walks a directory tree and copies ordinary files
  *     as it goes.
  */
-int copy_tree (const char *src_root, const char *dst_root, uid_t uid, gid_t gid)
+int copy_tree (const char *src_root, const char *dst_root,
+               long int uid, long int gid)
 {
        char src_name[1024];
        char dst_name[1024];
@@ -271,7 +272,7 @@ int copy_tree (const char *src_root, const char *dst_root, uid_t uid, gid_t gid)
  *     not be modified.
  */
 static int copy_entry (const char *src, const char *dst,
-                       uid_t uid, gid_t gid)
+                       long int uid, long int gid)
 {
        int err = 0;
        struct stat sb;
@@ -350,7 +351,7 @@ static int copy_entry (const char *src, const char *dst,
  */
 static int copy_dir (const char *src, const char *dst,
                      const struct stat *statp, const struct timeval mt[2],
-                     uid_t uid, gid_t gid)
+                     long int uid, long int gid)
 {
        int err = 0;
 
@@ -364,8 +365,8 @@ static int copy_dir (const char *src, const char *dst,
 #endif
        if (   (mkdir (dst, statp->st_mode) != 0)
            || (chown (dst,
-                      (uid == (uid_t) - 1) ? statp->st_uid : uid,
-                      (gid == (gid_t) - 1) ? statp->st_gid : gid) != 0)
+                      (uid == - 1) ? statp->st_uid : (uid_t) uid,
+                      (gid == - 1) ? statp->st_gid : (gid_t) gid) != 0)
            || (chmod (dst, statp->st_mode) != 0)
            || (copy_tree (src, dst, uid, gid) != 0)
            || (utimes (dst, mt) != 0)) {
@@ -388,7 +389,7 @@ static int copy_dir (const char *src, const char *dst,
  */
 static int copy_symlink (const char *src, const char *dst,
                          const struct stat *statp, const struct timeval mt[2],
-                         uid_t uid, gid_t gid)
+                         long int uid, long int gid)
 {
        char oldlink[1024];
        char dummy[1024];
@@ -419,8 +420,8 @@ static int copy_symlink (const char *src, const char *dst,
 #endif
        if (   (symlink (oldlink, dst) != 0)
            || (lchown (dst,
-                       (uid == (uid_t) - 1) ? statp->st_uid : uid,
-                       (gid == (gid_t) - 1) ? statp->st_gid : gid) != 0)) {
+                       (uid == -1) ? statp->st_uid : (uid_t) uid,
+                       (gid == -1) ? statp->st_gid : (gid_t) gid) != 0)) {
                return -1;
        }
 
@@ -476,7 +477,7 @@ static int copy_hardlink (const char *src, const char *dst,
  */
 static int copy_special (const char *src, const char *dst,
                          const struct stat *statp, const struct timeval mt[2],
-                         uid_t uid, gid_t gid)
+                         long int uid, long int gid)
 {
        int err = 0;
 
@@ -486,8 +487,8 @@ static int copy_special (const char *src, const char *dst,
 
        if (   (mknod (dst, statp->st_mode & ~07777, statp->st_rdev) != 0)
            || (chown (dst,
-                      (uid == (uid_t) - 1) ? statp->st_uid : uid,
-                      (gid == (gid_t) - 1) ? statp->st_gid : gid) != 0)
+                      (uid == -1) ? statp->st_uid : (uid_t) uid,
+                      (gid == -1) ? statp->st_gid : (gid_t) gid) != 0)
            || (chmod (dst, statp->st_mode & 07777) != 0)
            || (utimes (dst, mt) != 0)) {
                err = -1;
@@ -508,7 +509,7 @@ static int copy_special (const char *src, const char *dst,
  */
 static int copy_file (const char *src, const char *dst,
                       const struct stat *statp, const struct timeval mt[2],
-                      uid_t uid, gid_t gid)
+                      long int uid, long int gid)
 {
        int err = 0;
        int ifd;
@@ -526,8 +527,8 @@ static int copy_file (const char *src, const char *dst,
        ofd = open (dst, O_WRONLY | O_CREAT | O_TRUNC, 0);
        if (   (ofd < 0)
            || (chown (dst,
-                      (uid == (uid_t) - 1) ? statp->st_uid : uid,
-                      (gid == (gid_t) - 1) ? statp->st_gid : gid) != 0)
+                      (uid == -1) ? statp->st_uid : (uid_t) uid,
+                      (gid == -1) ? statp->st_gid : (gid_t) gid) != 0)
            || (chmod (dst, statp->st_mode & 07777) != 0)) {
                close (ifd);
                return -1;
index b99d6264d1537239341f0dcc31fe154ed2e07505..8e1daf6e8d5c5b9307ff57793e2e3b5304aef896 100644 (file)
@@ -1328,8 +1328,8 @@ static void move_home (void)
                                        fail_exit (E_HOMEDIR);
                                }
                                if (copy_tree (user_home, user_newhome,
-                                              uflg ? user_newid : -1,
-                                              gflg ? user_newgid : -1) == 0) {
+                                              uflg ? (long int)user_newid : -1,
+                                              gflg ? (long int)user_newgid : -1) == 0) {
                                        if (remove_tree (user_home) != 0 ||
                                            rmdir (user_home) != 0)
                                                fprintf (stderr,