seatd-launch: Specify exact environment to seatd

The parent environment might contain nasty things. Create a new
environment for the seatd process containing only the environment
variables we care about. For now, that's only SEATD_LOGLEVEL.
This commit is contained in:
Kenny Levinsen 2021-09-16 00:10:56 +02:00
parent 907b75de1a
commit ebf512c2bf

View file

@ -71,8 +71,16 @@ int main(int argc, char *argv[]) {
char pipebuf[16] = {0};
snprintf(pipebuf, sizeof pipebuf, "%d", fds[1]);
char *env[2] = {NULL, NULL};
char loglevelbuf[32] = {0};
char *cur_loglevel = getenv("SEATD_LOGLEVEL");
if (cur_loglevel != NULL) {
snprintf(loglevelbuf, sizeof loglevelbuf, "SEATD_LOGLEVEL=%s", cur_loglevel);
env[0] = loglevelbuf;
}
char *command[] = {"seatd", "-n", pipebuf, "-s", sockpath, NULL};
execv(SEATD_INSTALLPATH, command);
execve(SEATD_INSTALLPATH, command, env);
perror("Could not start seatd");
_exit(1);
}