do the chown first; under VFS chown loses setid bits
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Tue, 5 Sep 1989 08:12:59 +0000 (00:12 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Tue, 5 Sep 1989 08:12:59 +0000 (00:12 -0800)
SCCS-vsn: usr.bin/xinstall/xinstall.c 5.15

usr/src/usr.bin/xinstall/xinstall.c

index f9ff7e5..127005c 100644 (file)
@@ -22,7 +22,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)xinstall.c 5.14 (Berkeley) %G%";
+static char sccsid[] = "@(#)xinstall.c 5.15 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -176,16 +176,16 @@ install(from_name, to_name, isdir)
                if (!docopy)
                        (void)unlink(from_name);
        }
                if (!docopy)
                        (void)unlink(from_name);
        }
-       /* set owner, group, mode for target */
-       if (fchmod(to_fd, mode)) {
-               PERROR("install: fchmod: ", to_name);
-               bad();
-       }
        if ((group || owner) && fchown(to_fd, owner ? pp->pw_uid : -1,
            group ? gp->gr_gid : -1)) {
                PERROR("install: fchown: ", to_name);
                bad();
        }
        if ((group || owner) && fchown(to_fd, owner ? pp->pw_uid : -1,
            group ? gp->gr_gid : -1)) {
                PERROR("install: fchown: ", to_name);
                bad();
        }
+       /* set owner, group, mode for target */
+       if (fchmod(to_fd, mode)) {
+               PERROR("install: fchmod: ", to_name);
+               bad();
+       }
        (void)close(to_fd);
 }
 
        (void)close(to_fd);
 }