diff options
author | Chris Kuethe <chris.kuethe@gmail.com> | 2006-11-29 05:58:07 +0000 |
---|---|---|
committer | Chris Kuethe <chris.kuethe@gmail.com> | 2006-11-29 05:58:07 +0000 |
commit | 5999e86621b60948fd0a006705834cb7e4a04a94 (patch) | |
tree | c056cbd50d9ba3cb0ec258e7c20ea58b305ddb78 /drivers.c | |
parent | cb3bb51b406a3f070191b44a58f547d502965dcb (diff) | |
download | gpsd-5999e86621b60948fd0a006705834cb7e4a04a94.tar.gz |
We temporarily need root privs to set up the nmea line discipline on OpenBSD.
This diff makes that happen, and tries to be forthcoming about
when it is making gpsd run as root.
Diffstat (limited to 'drivers.c')
-rw-r--r-- | drivers.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -78,7 +78,8 @@ gps_mask_t nmea_parse_input(struct gps_device_t *session) gpsd_report(LOG_WARN, "unknown sentence: \"%s\"\n", session->outbuffer); } #ifdef NMEADISC - if (st & TIME_SET && session->gpsdata.ldisc == 0) { + if (session->gpsdata.ldisc == 0) { + uid_t old; int ldisc = NMEADISC; #ifdef TIOCSTSTAMP @@ -90,6 +91,11 @@ gps_mask_t nmea_parse_input(struct gps_device_t *session) #endif /* PPS_ON_CTS */ tstamps.ts_clr = 0; + old = geteuid(); + if (seteuid(0) == -1) + gpsd_report(LOG_WARN, "can't seteuid(0) - %s", strerror(errno)); + else + gpsd_report(LOG_WARN, "seteuid(0) to enable timestamping"); if (ioctl(session->gpsdata.gps_fd, TIOCSTSTAMP, &tstamps) < 0) gpsd_report(LOG_WARN, "can't set kernel timestamping: %s\n", strerror(errno)); @@ -103,6 +109,12 @@ gps_mask_t nmea_parse_input(struct gps_device_t *session) gpsd_report(LOG_WARN, "activated nmea discipline\n"); /* this is a flag that shows if we've tried the setup */ session->gpsdata.ldisc = NMEADISC; + + if (old){ + gpsd_report(LOG_WARN, "giving up euid 0"); + (void)seteuid(old); + } + gpsd_report(LOG_WARN, "running with effective user ID %d\n", geteuid()); } #endif /*NMEADISC */ #ifdef NTPSHM_ENABLE |