aboutsummaryrefslogtreecommitdiff
path: root/gmid.c
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2022-09-10 09:21:09 +0000
committerOmar Polo <op@omarpolo.com>2022-09-10 09:21:09 +0000
commit7277bb7dc2971fad2a51b7975df85dda1df4c936 (patch)
tree69e11608b6ab40e35e8a1e7f227c54f543068bc9 /gmid.c
parentaae8f6bf2b6be18c8bb4fc46c2df679110fe9d96 (diff)
make config fields `chroot' and `user' fixed-size
Diffstat (limited to 'gmid.c')
-rw-r--r--gmid.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/gmid.c b/gmid.c
index 83e3be7..92ff26b 100644
--- a/gmid.c
+++ b/gmid.c
@@ -205,9 +205,6 @@ init_config(void)
init_mime(&conf.mime);
- conf.chroot = NULL;
- conf.user = NULL;
-
conf.prefork = 3;
}
@@ -224,8 +221,6 @@ free_config(void)
v = conf.verbose;
free_mime(&conf.mime);
- free(conf.chroot);
- free(conf.user);
memset(&conf, 0, sizeof(conf));
conf.verbose = v;
@@ -328,15 +323,15 @@ drop_priv(void)
{
struct passwd *pw = NULL;
- if (conf.chroot != NULL && conf.user == NULL)
+ if (*conf.chroot != '\0' && *conf.user == '\0')
fatal("can't chroot without an user to switch to after.");
- if (conf.user != NULL) {
+ if (*conf.user != '\0') {
if ((pw = getpwnam(conf.user)) == NULL)
fatal("can't find user %s", conf.user);
}
- if (conf.chroot != NULL) {
+ if (*conf.chroot != '\0') {
if (chroot(conf.chroot) != 0 || chdir("/") != 0)
fatal("%s: %s", conf.chroot, strerror(errno));
}