"Todd C. Miller" <todd.mil...@courtesan.com> wrote: >I changed my mind and decided it is better to just move the chown >and chmod out of copydotfiles() and add an explicit check for skeldir >set to the empty string. Much as I would like to prettify the >user.c code it is a losing battle so here is a minimal diff. > > - todd > >Index: usr.sbin/user/user.c >=================================================================== >RCS file: /home/cvs/openbsd/src/usr.sbin/user/user.c,v >retrieving revision 1.95 >diff -u -r1.95 user.c >--- usr.sbin/user/user.c 2 Apr 2013 05:04:47 -0000 1.95 >+++ usr.sbin/user/user.c 5 Sep 2013 20:47:23 -0000 >@@ -290,6 +290,8 @@ > DIR *dirp; > int n; > >+ if (*skeldir != '\0') >+ return 0;
Woot? /A > if ((dirp = opendir(skeldir)) == NULL) { > warn("can't open source . files dir `%s'", skeldir); > return 0; >@@ -308,8 +310,6 @@ > (void) asystem("cd %s && %s -rw -pe %s . %s", > skeldir, PAX, (verbose) ? "-v" : "", dir); > } >- (void) asystem("%s -R -P %u:%u %s", CHOWN, uid, gid, dir); >- (void) asystem("%s -R u+w %s", CHMOD, dir); > return n; > } > >@@ -1177,6 +1177,9 @@ > err(EXIT_FAILURE, "can't mkdir `%s'", home); > } > (void) copydotfiles(up->u_skeldir, up->u_uid, gid, > home); >+ (void) asystem("%s -R -P %u:%u %s", CHOWN, up->u_uid, >+ gid, home); >+ (void) asystem("%s -R u+w %s", CHMOD, home); > } > } > if (strcmp(up->u_primgrp, "=uid") == 0 &&