From e9e40c9df268b454baa88a28fcdd0dff3ba1ea86 Mon Sep 17 00:00:00 2001 From: Lorenzo Fontana Date: Sun, 6 Aug 2017 17:26:14 +0200 Subject: [PATCH] Using `g_get_tmp_dir` to build the console socket name Signed-off-by: Lorenzo Fontana --- conmon/conmon.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/conmon/conmon.c b/conmon/conmon.c index c9edbd39..2009bf49 100644 --- a/conmon/conmon.c +++ b/conmon/conmon.c @@ -884,7 +884,8 @@ static void write_sync_fd(int sync_pipe_fd, int res, const char *message) static char *setup_console_socket(void) { struct sockaddr_un addr = {0}; - char csname[PATH_MAX] = "/tmp/conmon-term.XXXXXXXX"; + _cleanup_free_ const char *tmpdir = g_get_tmp_dir(); + _cleanup_free_ char *csname = g_build_filename(tmpdir, "conmon-term.XXXXXX", NULL); /* * Generate a temporary name. Is this unsafe? Probably, but we can * replace it with a rename(2) setup if necessary. @@ -908,7 +909,7 @@ static char *setup_console_socket(void) pexit("Failed to change console-socket permissions"); /* XXX: This should be handled with a rename(2). */ if (unlink(csname) < 0) - pexit("Failed to unlink temporary ranom path"); + pexit("Failed to unlink temporary random path"); if (bind(console_socket_fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) pexit("Failed to bind to console-socket"); if (listen(console_socket_fd, 128) < 0) @@ -1116,7 +1117,7 @@ int main(int argc, char *argv[]) the parent is waiting for the stdout to end when the intermediate child dies */ if (dup2(dev_null_r, STDIN_FILENO) < 0) - pexit("Failed to dup over stdout"); + pexit("Failed to dup over stdin"); if (dup2(dev_null_w, STDOUT_FILENO) < 0) pexit("Failed to dup over stdout"); if (dup2(dev_null_w, STDERR_FILENO) < 0)