Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/pw/pw_utils.c
| Show First 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | if (pid == 0) { | ||||
| execlp("/usr/bin/make", "make", "-C", "/var/yp/", (char*) NULL); | execlp("/usr/bin/make", "make", "-C", "/var/yp/", (char*) NULL); | ||||
| _exit(1); | _exit(1); | ||||
| } | } | ||||
| waitpid(pid, &i, 0); | waitpid(pid, &i, 0); | ||||
| if ((i = WEXITSTATUS(i)) != 0) | if ((i = WEXITSTATUS(i)) != 0) | ||||
| errx(i, "make exited with status %d", i); | errx(i, "make exited with status %d", i); | ||||
| return (i); | return (i); | ||||
| } | } | ||||
| static void | |||||
| metalog_emit_record(const char *path, const char *target, mode_t mode, | |||||
emaste: This `_` convention seems a bit unusual | |||||
Done Inline ActionsOk, I will rename it to metalog_emit_record(). markj: Ok, I will rename it to metalog_emit_record(). | |||||
| uid_t uid, gid_t gid, int flags) | |||||
| { | |||||
| const char *flagstr, *type; | |||||
| int error; | |||||
| if (conf.metalog == NULL) | |||||
| return; | |||||
| if (target != NULL) | |||||
| type = "link"; | |||||
| else if (S_ISDIR(mode)) | |||||
| type = "dir"; | |||||
| else if (S_ISREG(mode)) | |||||
| type = "file"; | |||||
| else | |||||
| errx(1, "metalog_emit: unhandled file type for %s", path); | |||||
| flagstr = fflagstostr(flags & | |||||
| (UF_IMMUTABLE | UF_APPEND | SF_IMMUTABLE | SF_APPEND)); | |||||
Done Inline ActionsI'm not handling file flags here. I don't think pw sets any, but we should handle that anyway. markj: I'm not handling file flags here. I don't think pw sets any, but we should handle that anyway. | |||||
| if (flagstr == NULL) | |||||
| errx(1, "metalog_emit: fflagstostr failed"); | |||||
| error = fprintf(conf.metalog, | |||||
| "./%s type=%s mode=0%03o uid=%u gid=%u%s%s%s%s\n", | |||||
| path, type, mode & ACCESSPERMS, uid, gid, | |||||
| target != NULL ? " link=" : "", target != NULL ? target : "", | |||||
| *flagstr != '\0' ? " flags=" : "", *flagstr != '\0' ? flagstr : ""); | |||||
Not Done Inline ActionsI wonder if it won't be smart to move the metalog_emit to libutil later so it can be used by other tools bapt: I wonder if it won't be smart to move the metalog_emit to libutil later so it can be used by… | |||||
Done Inline ActionsMaybe, yeah. It's a fairly simple routine though, and different consumers have different requirements (e.g., uname/gname vs. uid/gid, some consumers want to flock the metalog, ...). markj: Maybe, yeah. It's a fairly simple routine though, and different consumers have different… | |||||
| if (error < 0) | |||||
| errx(1, "metalog_emit: write error"); | |||||
| } | |||||
| void | |||||
| metalog_emit(const char *path, mode_t mode, uid_t uid, gid_t gid, int flags) | |||||
| { | |||||
| metalog_emit_record(path, NULL, mode, uid, gid, flags); | |||||
| } | |||||
| void | |||||
| metalog_emit_symlink(const char *path, const char *target, mode_t mode, | |||||
| uid_t uid, gid_t gid) | |||||
| { | |||||
| metalog_emit_record(path, target, mode, uid, gid, 0); | |||||
| } | |||||
This _ convention seems a bit unusual