diff options
author | Omar Polo <op@omarpolo.com> | 2023-07-24 09:05:33 +0000 |
---|---|---|
committer | Omar Polo <op@omarpolo.com> | 2023-07-24 09:05:33 +0000 |
commit | 4acf495f41d2c26136e99072293ca8b9bff91dc0 (patch) | |
tree | ab54ad9b63dbcdb5ca7a2969e8461b102b3df6c0 /gmid.c | |
parent | 3bda540e3428e7e3a18ee1c54a65c449ca10f35e (diff) |
open the log files inside the chroot
Diffstat (limited to 'gmid.c')
-rw-r--r-- | gmid.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -322,16 +322,26 @@ static int main_send_logfd(struct conf *conf) { struct privsep *ps = conf->ps; - int fd = -1; + char path[PATH_MAX]; + int r, fd = -1; if (debug) return 0; if (conf->log_access) { + r = snprintf(path, sizeof(path), "%s%s%s", conf->chroot, + *conf->chroot == '\0' ? "" : "/", conf->log_access); + if (r < 0 || (size_t)r >= sizeof(path)) { + log_warnx("path too long: %s", conf->log_access); + goto done; + } + fd = open(conf->log_access, O_WRONLY|O_CREAT|O_APPEND, 0600); if (fd == -1) log_warn("can't open %s", conf->log_access); } + + done: if (proc_compose_imsg(ps, PROC_LOGGER, -1, IMSG_LOG_TYPE, -1, fd, NULL, 0) == -1) return -1; |