Skip to content

Commit

Permalink
For daemon mode, set the read permission on the
Browse files Browse the repository at this point in the history
psuedo-terminal
  • Loading branch information
markwal committed Nov 17, 2020
1 parent a5a67bc commit 3e3e6e7
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/gpx/gpxresp.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <strings.h>
#include <string.h>
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 3e3e6e7

Please sign in to comment.