summaryrefslogtreecommitdiffstats
path: root/lib/libdisk/create_chunk.c
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1999-12-22 19:06:29 +0000
committerphk <phk@FreeBSD.org>1999-12-22 19:06:29 +0000
commite396740391e7e60805bda6799ac3397d1fc8c539 (patch)
treed4f532132a1c5910be04ec7b8158d9384adc01ef /lib/libdisk/create_chunk.c
parent6a0bba96a22d44c9901e6c1650cbdb06e38b9aeb (diff)
downloadFreeBSD-src-e396740391e7e60805bda6799ac3397d1fc8c539.zip
FreeBSD-src-e396740391e7e60805bda6799ac3397d1fc8c539.tar.gz
Just on the off-chance that somebody might use libdisk in a totally
lobotomized environment, say booted from a floppy with no /etc full of password and group files, give sensible fallbacks for roots uid and operators gid. This might fix sysinstall.
Diffstat (limited to 'lib/libdisk/create_chunk.c')
-rw-r--r--lib/libdisk/create_chunk.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/libdisk/create_chunk.c b/lib/libdisk/create_chunk.c
index 47b1e41..8a851f0 100644
--- a/lib/libdisk/create_chunk.c
+++ b/lib/libdisk/create_chunk.c
@@ -248,6 +248,8 @@ MakeDev(struct chunk *c1, const char *path)
char buf[BUFSIZ], buf2[BUFSIZ];
struct group *grp;
struct passwd *pwd;
+ uid_t owner;
+ gid_t group;
*buf2 = '\0';
if (isDebug())
@@ -334,11 +336,15 @@ MakeDev(struct chunk *c1, const char *path)
return 0;
if ((pwd = getpwnam("root")) == NULL) {
msgDebug("MakeDev: Unable to lookup user \"root\".\n");
- return 0;
+ owner = 0;
+ } else {
+ owner = pwd->pw_uid;
}
if ((grp = getgrnam("operator")) == NULL) {
msgDebug("MakeDev: Unable to lookup group \"operator\".\n");
- return 0;
+ group = 5;
+ } else {
+ group = grp->gr_gid;
}
min = unit * 8 + 65536 * slice + part;
sprintf(buf, "%s/r%s", path, c1->name);
@@ -347,7 +353,7 @@ MakeDev(struct chunk *c1, const char *path)
msgDebug("mknod of %s returned failure status!\n", buf);
return 0;
}
- if (chown(buf, pwd->pw_uid, grp->gr_gid) == -1) {
+ if (chown(buf, owner, group) == -1) {
msgDebug("chown of %s returned failure status!\n", buf);
return 0;
}
@@ -358,7 +364,7 @@ MakeDev(struct chunk *c1, const char *path)
msgDebug("mknod of %s returned failure status!\n", buf);
return 0;
}
- if (chown(buf, pwd->pw_uid, grp->gr_gid) == -1) {
+ if (chown(buf, owner, group) == -1) {
msgDebug("chown of %s returned failure status!\n", buf);
return 0;
}
@@ -369,7 +375,7 @@ MakeDev(struct chunk *c1, const char *path)
msgDebug("mknod of %s returned failure status!\n", buf);
return 0;
}
- if (chown(buf, pwd->pw_uid, grp->gr_gid) == -1) {
+ if (chown(buf, owner, group) == -1) {
msgDebug("chown of %s returned failure status!\n", buf);
return 0;
}
OpenPOWER on IntegriCloud