mirror of https://github.com/omar-polo/gmid.git
fix configtest with chroot
The configtest checks try to open the root directories too, operation that can fail when they're expected to be inside a chroot.
This commit is contained in:
parent
ef5057cdec
commit
e371817b34
19
gmid.c
19
gmid.c
|
@ -320,15 +320,6 @@ main(int argc, char **argv)
|
||||||
strlcpy(conf->chroot, chroot, sizeof(conf->chroot));
|
strlcpy(conf->chroot, chroot, sizeof(conf->chroot));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conftest) {
|
|
||||||
if (config_test(conf) == -1)
|
|
||||||
fatalx("failed to load the configuration");
|
|
||||||
fprintf(stderr, "config OK\n");
|
|
||||||
if (conftest > 1)
|
|
||||||
main_print_conf(conf);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((ps = calloc(1, sizeof(*ps))) == NULL)
|
if ((ps = calloc(1, sizeof(*ps))) == NULL)
|
||||||
fatal("calloc");
|
fatal("calloc");
|
||||||
ps->ps_env = conf;
|
ps->ps_env = conf;
|
||||||
|
@ -343,6 +334,16 @@ main(int argc, char **argv)
|
||||||
sizeof(conf->chroot));
|
sizeof(conf->chroot));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (conftest) {
|
||||||
|
conf->conftest = 1;
|
||||||
|
if (config_test(conf) == -1)
|
||||||
|
fatalx("failed to load the configuration");
|
||||||
|
fprintf(stderr, "config OK\n");
|
||||||
|
if (conftest > 1)
|
||||||
|
main_print_conf(conf);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
ps->ps_instances[PROC_SERVER] = conf->prefork;
|
ps->ps_instances[PROC_SERVER] = conf->prefork;
|
||||||
ps->ps_instance = proc_instance;
|
ps->ps_instance = proc_instance;
|
||||||
if (title != NULL)
|
if (title != NULL)
|
||||||
|
|
1
gmid.h
1
gmid.h
|
@ -254,6 +254,7 @@ struct conf {
|
||||||
char *log_access;
|
char *log_access;
|
||||||
enum log_format log_format;
|
enum log_format log_format;
|
||||||
int use_privsep_crypto;
|
int use_privsep_crypto;
|
||||||
|
int conftest;
|
||||||
|
|
||||||
struct fcgihead fcgi;
|
struct fcgihead fcgi;
|
||||||
struct vhosthead hosts;
|
struct vhosthead hosts;
|
||||||
|
|
15
server.c
15
server.c
|
@ -1412,12 +1412,25 @@ load_vhosts(struct conf *conf)
|
||||||
{
|
{
|
||||||
struct vhost *h;
|
struct vhost *h;
|
||||||
struct location *l;
|
struct location *l;
|
||||||
|
char path[PATH_MAX], *p;
|
||||||
|
int r;
|
||||||
|
|
||||||
TAILQ_FOREACH(h, &conf->hosts, vhosts) {
|
TAILQ_FOREACH(h, &conf->hosts, vhosts) {
|
||||||
TAILQ_FOREACH(l, &h->locations, locations) {
|
TAILQ_FOREACH(l, &h->locations, locations) {
|
||||||
if (*l->dir == '\0')
|
if (*l->dir == '\0')
|
||||||
continue;
|
continue;
|
||||||
l->dirfd = open(l->dir, O_RDONLY | O_DIRECTORY);
|
|
||||||
|
p = l->dir;
|
||||||
|
|
||||||
|
if (conf->conftest && *conf->chroot != '\0') {
|
||||||
|
r = snprintf(path, sizeof(path), "%s/%s",
|
||||||
|
conf->chroot, l->dir);
|
||||||
|
if (r < 0 || (size_t)r >= sizeof(path))
|
||||||
|
fatalx("path too long: %s", l->dir);
|
||||||
|
p = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
l->dirfd = open(p, O_RDONLY | O_DIRECTORY);
|
||||||
if (l->dirfd == -1)
|
if (l->dirfd == -1)
|
||||||
fatal("open %s for domain %s", l->dir,
|
fatal("open %s for domain %s", l->dir,
|
||||||
h->domain);
|
h->domain);
|
||||||
|
|
Loading…
Reference in New Issue