diff options
author | Gary E. Miller <gem@rellim.com> | 2013-10-16 18:22:10 -0700 |
---|---|---|
committer | Gary E. Miller <gem@rellim.com> | 2013-10-16 18:22:10 -0700 |
commit | cb05b1122d2dfb9278ff28ebef2a5c65376ee18b (patch) | |
tree | fd58462aba71d673d71d5f6ac155572abda5b876 /ntpshm.c | |
parent | a093fe1646a273f3efae523fb9503fa750ee26e4 (diff) | |
download | gpsd-cb05b1122d2dfb9278ff28ebef2a5c65376ee18b.tar.gz |
There is a race between opening /dev/pps0 and dropping root. Make it
an explicit error when that race is lost.
Also note a logic error where 'ok' is reset after being set if KPPS
is compiled in.
Diffstat (limited to 'ntpshm.c')
-rw-r--r-- | ntpshm.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -510,6 +510,11 @@ static int init_kernel_pps(struct gps_device_t *session) { (void)snprintf(path, sizeof(path), "/dev/pps%c", pps_num); /* root privs are required for this device open */ + if ( 0 != getuid() ) { + gpsd_report(session->context->debug, LOG_INF, + "KPPS only works as root \n"); + return -1; + } int ret = open(path, O_RDWR); if ( 0 > ret ) { gpsd_report(session->context->debug, LOG_INF, @@ -743,7 +748,7 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg) #endif /* HAVE_SYS_TIMEPPS_H */ #if defined(TIOCMIWAIT) - ok = false; + ok = false; /* FIXME, this steps on ok = TRUE just above */ log = NULL; /*@ +ignoresigns */ |