On Sat, Aug 31, 2013 at 06:23:25AM -0600, Todd C. Miller wrote:
> Assuming we want to make this a non-fatal error the following should
> do.
You meant non-existent skel dir, not empty. Unless you
meant empty argument for -k option, i.e., -k "", but is
there a good use-case for that?
Also, I recall recently reading (on this list I believe)
keeping declaration and initialization separate.
--patrick
> - 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 31 Aug 2013 12:20:40 -0000
> @@ -288,20 +288,20 @@
> {
> struct dirent *dp;
> DIR *dirp;
> - int n;
> + int n = 0;
>
> if ((dirp = opendir(skeldir)) == NULL) {
> warn("can't open source . files dir `%s'", skeldir);
> - return 0;
> - }
> - for (n = 0; (dp = readdir(dirp)) != NULL && n == 0 ; ) {
> - if (strcmp(dp->d_name, ".") == 0 ||
> - strcmp(dp->d_name, "..") == 0) {
> - continue;
> + } else {
> + while ((dp = readdir(dirp)) != NULL) {
> + if (strcmp(dp->d_name, ".") != 0 &&
> + strcmp(dp->d_name, "..") != 0) {
> + n = 1;
> + break;
> + }
> }
> - n = 1;
> + (void) closedir(dirp);
> }
> - (void) closedir(dirp);
> if (n == 0) {
> warnx("No \"dot\" initialisation files found");
> } else {
>