commit - aae8f6bf2b6be18c8bb4fc46c2df679110fe9d96
commit + 7277bb7dc2971fad2a51b7975df85dda1df4c936
blob - 83e3be72dd9acb9971da0d31302935cac85e2f8f
blob + 92ff26b20ef67f8d5ebebd288adc52ad7c0eb4a0
--- gmid.c
+++ gmid.c
init_mime(&conf.mime);
- conf.chroot = NULL;
- conf.user = NULL;
-
conf.prefork = 3;
}
v = conf.verbose;
free_mime(&conf.mime);
- free(conf.chroot);
- free(conf.user);
memset(&conf, 0, sizeof(conf));
conf.verbose = v;
{
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));
}
blob - 38b99ad306905dfa7d5831ed26d91fc0102d364c
blob + 0997699cdcd83851c6c7db9f59fa88aecdc06302
--- gmid.h
+++ gmid.h
int ipv6;
uint32_t protos;
struct mime mime;
- char *chroot;
- char *user;
+ char chroot[PATH_MAX];
+ char user[LOGIN_NAME_MAX];
int prefork;
};
blob - 96ab053d9087b7965cba97623de12cd5f68f3d4d
blob + 9eac0c47a113711a95bce5468556637917a44385
--- parse.y
+++ parse.y
}
;
-option : CHROOT string { conf.chroot = $2; }
+option : CHROOT string {
+ if (strlcpy(conf.chroot, $2, sizeof(conf.chroot)) >=
+ sizeof(conf.chroot))
+ yyerror("chroot path too long");
+ free($2);
+ }
| IPV6 bool { conf.ipv6 = $2; }
| MIME STRING string {
yywarn("`mime MIME EXT' is deprecated and will be "
yyerror("invalid protocols string \"%s\"", $2);
free($2);
}
- | USER string { conf.user = $2; }
+ | USER string {
+ if (strlcpy(conf.user, $2, sizeof(conf.user)) >=
+ sizeof(conf.user))
+ yyerror("user name too long");
+ free($2);
+ }
;
vhost : SERVER string {
/* struct envlist *e; */
/* struct alist *a; */
- if (conf.chroot != NULL)
+ if (*conf.chroot != '\0')
printf("chroot \"%s\"\n", conf.chroot);
printf("ipv6 %s\n", conf.ipv6 ? "on" : "off");
/* XXX: defined mimes? */
printf("port %d\n", conf.port);
printf("prefork %d\n", conf.prefork);
/* XXX: protocols? */
- if (conf.user != NULL)
+ if (*conf.user != '\0')
printf("user \"%s\"\n", conf.user);
TAILQ_FOREACH(h, &hosts, vhosts) {