don't require chrooting; if fails then only chdir into the dir

Signed-off-by: AGentooCat <agentoocat@mail.i2p>
This commit is contained in:
2025-05-01 13:46:17 +00:00
parent 4f48a77cd8
commit 07f977544a

View File

@ -86,9 +86,13 @@ void goto_datadir(char *dir, struct UGid *ugid) {
if ((perms & 0700) != 0700)
log(CRIT, "invalid permissions on datadir \"%s\"", dir);
if (chroot(dir) != 0)
logno(CRIT, "couldn't chroot to %s", dir);
chdir("/");
char *chto = "/";
if (chroot(dir) != 0) {
logno(WARN, "couldn't chroot to %s", dir);
chto = dir;
}
if (chdir(chto) < 0)
logno(CRIT, "couldn't change directory to %s", chto);
}
int open_logfile(char *logfile, struct UGid *ugid) {
@ -174,8 +178,8 @@ iamchild:
if (sigaction(SIGINT, &act, NULL) == -1)
logno(CRIT, "couldn't install SIGINT handler");
char *keydat = readfile("/privkey.dat", "keyfile");
opendb("/mails.db");
char *keydat = readfile("./privkey.dat", "keyfile");
opendb("./mails.db");
opensam(conf->samport, conf->hostname, keydat);
xfree(keydat);
openpop(conf->popport, conf->hostname);