X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=sbr%2Fmakedir.c;h=1c13bb654e72b016cda6297866d7f411d09b2238;hb=71b43c2803ffed08ec727c29d70a0d2de3ffb3f1;hp=89e90457072b59bbfcd405612411f14b8476855c;hpb=ced6090a330d3d83d0bce709f756aa3d7d65fea4;p=mmh diff --git a/sbr/makedir.c b/sbr/makedir.c index 89e9045..1c13bb6 100644 --- a/sbr/makedir.c +++ b/sbr/makedir.c @@ -16,7 +16,7 @@ #include int -makedir (char *dir) +makedir(char *dir) { char path[PATH_MAX]; char* folder_perms_ASCII; @@ -28,7 +28,7 @@ makedir (char *dir) context_save(); /* save the context file */ fflush(stdout); - if (!(folder_perms_ASCII = context_find ("folder-protect"))) + if (!(folder_perms_ASCII = context_find("folder-protect"))) folder_perms_ASCII = foldprot; /* defaults to "700" */ /* @@ -49,19 +49,19 @@ makedir (char *dir) */ saved_umask = umask(0); - if (getuid () == geteuid ()) { + if (getuid() == geteuid()) { c = strncpy(path, dir, sizeof(path)); while (!had_an_error && (c = strchr((c + 1), '/')) != NULL) { *c = (char)0; if (access(path, X_OK)) { if (errno != ENOENT){ - advise (dir, "unable to create directory"); + advise(dir, "unable to create directory"); had_an_error = 1; } /* Create an outer directory. */ if (mkdir(path, folder_perms)) { - advise (dir, "unable to create directory"); + advise(dir, "unable to create directory"); had_an_error = 1; } } @@ -73,37 +73,40 @@ makedir (char *dir) ** Create the innermost nested subdirectory of the ** path we're being asked to create. */ - if (mkdir (dir, folder_perms) == -1) { - advise (dir, "unable to create directory"); + if (mkdir(dir, folder_perms) == -1) { + advise(dir, "unable to create directory"); had_an_error = 1; } } } else { - /* Ummm, why do we want to avoid creating directories with the effective - user ID? None of the nmh tools are installed such that the effective - should be different from the real, and if some parent process made - the two be different, I don't see why it should be our job to enforce - the real UID. Also, why the heck do we call the mkdir executable - rather than the library function in this case?? If we do want to - call the mkdir executable, we should at least be giving it -p (and - change the single chmod() call below) so it can successfully create - nested directories like the above code can. - - -- Dan Harkless */ + /* + ** Ummm, why do we want to avoid creating directories + ** with the effective user ID? None of the nmh tools are + ** installed such that the effective should be different + ** from the real, and if some parent process made the two + ** be different, I don't see why it should be our job to + ** enforce the real UID. Also, why the heck do we call + ** the mkdir executable rather than the library function in + ** this case?? If we do want to call the mkdir executable, + ** we should at least be giving it -p (and change the single + ** chmod() call below) so it can successfully create nested + ** directories like the above code can. + ** -- Dan Harkless + */ switch (pid = vfork()) { case -1: - advise ("fork", "unable to"); + advise("fork", "unable to"); return 0; case 0: - setgid (getgid ()); - setuid (getuid ()); + setgid(getgid()); + setuid(getuid()); - execl ("/bin/mkdir", "mkdir", dir, NULL); - execl ("/usr/bin/mkdir", "mkdir", dir, NULL); - fprintf (stderr, "unable to exec "); - perror ("mkdir"); - _exit (-1); + execl("/bin/mkdir", "mkdir", dir, NULL); + execl("/usr/bin/mkdir", "mkdir", dir, NULL); + fprintf(stderr, "unable to exec "); + perror("mkdir"); + _exit(-1); default: if (pidXwait(pid, "mkdir")) @@ -111,7 +114,7 @@ makedir (char *dir) break; } - chmod (dir, folder_perms); + chmod(dir, folder_perms); } umask(saved_umask); /* put the user's umask back */