From 3e3e6e71d3388958cec5016371f7f31d14442498 Mon Sep 17 00:00:00 2001 From: Mark Walker Date: Tue, 17 Nov 2020 21:06:14 +0000 Subject: [PATCH] For daemon mode, set the read permission on the psuedo-terminal --- src/gpx/gpxresp.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/gpx/gpxresp.c b/src/gpx/gpxresp.c index a693339..29cf2c8 100644 --- a/src/gpx/gpxresp.c +++ b/src/gpx/gpxresp.c @@ -27,6 +27,8 @@ #include #include #include +#include +#include #include #include #include @@ -1090,6 +1092,16 @@ static int gpx_create_daemon_port(Gpx *gpx, const char *daemon_port) } fprintf(gpx->log, "Created virtual port: %s.\n", pn); + // get the perms on the slave end + struct stat st; + if (stat(pn, &st) == -1) { + fprintf(gpx->log, "Warn: Unable to retrieve permissions on psuedo-terminal %s. errno = %d\n", pn, errno); + } + // set the perms on the slave end + else if (chmod(pn, st.st_mode | S_IRGRP)) { + fprintf(gpx->log, "Warn: Unable to set permissions on psuedo-terminal %s. errno = %d\n", pn, errno); + } + // create the requested "daemon_port" as a symlink to the slave end if (unlink(daemon_port) < 0 && errno != ENOENT) { fprintf(gpx->log, "Error: %s already exists and can't be removed. errno = %d\n", daemon_port, errno);