summaryrefslogtreecommitdiff
path: root/ntpshm.c
diff options
context:
space:
mode:
authorGary E. Miller <gem@rellim.com>2013-10-16 18:22:10 -0700
committerGary E. Miller <gem@rellim.com>2013-10-16 18:22:10 -0700
commitcb05b1122d2dfb9278ff28ebef2a5c65376ee18b (patch)
treefd58462aba71d673d71d5f6ac155572abda5b876 /ntpshm.c
parenta093fe1646a273f3efae523fb9503fa750ee26e4 (diff)
downloadgpsd-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.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/ntpshm.c b/ntpshm.c
index 552ae0f1..8a8f0ba6 100644
--- a/ntpshm.c
+++ b/ntpshm.c
@@ -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 */