|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
ntpshm as non-rootHi again, I'd like to run gpsd under a non-root user and use the ntpshm interface to set the system clock. For that, I'd use ntpshm segments 2 and 3 which are opened for everyone by ntpd. However, gpsd.c tests for getuid() == 0, and will not even try to setup with segments 2 and 3 for non-root users. The attached patch changes that, such that only segments 0 and 1 are avoided for non-root users. It also corrects the error handling for the nice(NICEVAL) call. Cheers, Håkan _______________________________________________ Gpsd-dev mailing list Gpsd-dev@... https://lists.berlios.de/mailman/listinfo/gpsd-dev |
|
|
Re: ntpshm as non-rootHåkan Johansson <f96hajo@...>:
> I'd like to run gpsd under a non-root user and use the ntpshm interface > to set the system clock. For that, I'd use ntpshm segments 2 and 3 which > are opened for everyone by ntpd. However, gpsd.c tests for getuid() == > 0, and will not even try to setup with segments 2 and 3 for non-root > users. The attached patch changes that, such that only segments 0 and 1 > are avoided for non-root users. It also corrects the error handling for > the nice(NICEVAL) call. This, unlike some of the other changes in ntpshm.c discussed recenely, seems to me like a relatively safe it-will-work-or-it=won't sort of chanmge. But I didn't see an actual patch attached. -- <a href="http://www.catb.org/~esr/">Eric S. Raymond</a> _______________________________________________ Gpsd-dev mailing list Gpsd-dev@... https://lists.berlios.de/mailman/listinfo/gpsd-dev |
|
|
Re: ntpshm as non-rootSorry, Håkan On Wed, 4 Nov 2009, Eric S. Raymond wrote: > Håkan Johansson <f96hajo@...>: >> I'd like to run gpsd under a non-root user and use the ntpshm interface >> to set the system clock. For that, I'd use ntpshm segments 2 and 3 which >> are opened for everyone by ntpd. However, gpsd.c tests for getuid() == >> 0, and will not even try to setup with segments 2 and 3 for non-root >> users. The attached patch changes that, such that only segments 0 and 1 >> are avoided for non-root users. It also corrects the error handling for >> the nice(NICEVAL) call. > > This, unlike some of the other changes in ntpshm.c discussed recenely, > seems to me like a relatively safe it-will-work-or-it=won't sort of chanmge. > But I didn't see an actual patch attached. > -- > <a href="http://www.catb.org/~esr/">Eric S. Raymond</a> > _______________________________________________ > Gpsd-dev mailing list > Gpsd-dev@... > https://lists.berlios.de/mailman/listinfo/gpsd-dev > Index: gpsd.c =================================================================== --- gpsd.c (revision 6410) +++ gpsd.c (arbetskopia) @@ -1907,14 +1907,10 @@ gpsd_report(LOG_INF, "listening on port %s\n", gpsd_service); #ifdef NTPSHM_ENABLE - if (getuid() == 0) { - errno = 0; - if (nice(NICEVAL) != -1 || errno == 0) - gpsd_report (2, "Priority setting failed.\n"); - (void)ntpshm_init(&context, nowait); - } else { - gpsd_report (LOG_INF, "Unable to start ntpshm. gpsd must run as root.\n"); - } + errno = 0; + if (nice(NICEVAL) == -1 && errno != 0) + gpsd_report (LOG_INF, "Priority setting failed.\n"); + (void)ntpshm_init(&context, nowait); #endif /* NTPSHM_ENABLE */ #ifdef DBUS_ENABLE Index: ntpshm.c =================================================================== --- ntpshm.c (revision 6410) +++ ntpshm.c (arbetskopia) @@ -6,6 +6,9 @@ */ #include <sys/types.h> +#ifndef S_SPLINT_S +#include <unistd.h> +#endif /* S_SPLINT_S */ #include <stdio.h> #include <string.h> #include <stdlib.h> @@ -72,7 +75,7 @@ int i; for (i = 0; i < NTPSHMSEGS; i++) - context->shmTime[i] = getShmTime(i); + context->shmTime[i] = (i >= 2 || getuid() == 0) ? getShmTime(i) : NULL; memset(context->shmTimeInuse,0,sizeof(context->shmTimeInuse)); # ifdef PPS_ENABLE context->shmTimePPS = enablepps; _______________________________________________ Gpsd-dev mailing list Gpsd-dev@... https://lists.berlios.de/mailman/listinfo/gpsd-dev |
|
|
Re: ntpshm as non-root-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1 Yo Håkan If you start ntpd first then it will setup the required segments. gpsd can make them just as a backup, but in the real world that is rarely used. So no need for most of your patch. Check out the gpsd-dev archives for more discussion. RGDS GARY - --------------------------------------------------------------------------- Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97701 gem@... Tel:+1(541)382-8588 On Wed, 4 Nov 2009, Håkan Johansson wrote: > I'd like to run gpsd under a non-root user and use the ntpshm interface to set > the system clock. For that, I'd use ntpshm segments 2 and 3 which are opened > for everyone by ntpd. However, gpsd.c tests for getuid() == 0, and will not > even try to setup with segments 2 and 3 for non-root users. The attached > patch changes that, such that only segments 0 and 1 are avoided for non-root > users. It also corrects the error handling for the nice(NICEVAL) call. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (GNU/Linux) iD8DBQFK8i2dBmnRqz71OvMRAsPbAJ9xeHfEf4/6kvKD4WmjwhzjQzeQWgCeNQBQ gjrEjtABVexNpwsd3Bet5Bs= =pS8u -----END PGP SIGNATURE----- _______________________________________________ Gpsd-dev mailing list Gpsd-dev@... https://lists.berlios.de/mailman/listinfo/gpsd-dev |
|
|
Re: ntpshm as non-rootHi Gary, the problem is gpcd.c, line 1910, which prevents it from even trying as non-root: #ifdef NTPSHM_ENABLE if (getuid() == 0) { errno = 0; if (nice(NICEVAL) != -1 || errno == 0) gpsd_report (2, "Priority setting failed.\n"); (void)ntpshm_init(&context, nowait); } else { gpsd_report (LOG_INF, "Unable to start ntpshm. gpsd must run as root.\n"); } #endif /* NTPSHM_ENABLE */ The only reason for patching in ntpshm.c was to avoid the spurios error messages when gpsd cannot (and should not) create segments 0 and 1 as non-root. Their creation would be wrong in case gpsd happen to be started before ntpd. Is that the not needed part? Regards, Håkan On Thu, 5 Nov 2009, Gary E. Miller wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Yo Håkan > > If you start ntpd first then it will setup the required segments. gpsd > can make them just as a backup, but in the real world that is rarely > used. So no need for most of your patch. > > Check out the gpsd-dev archives for more discussion. > > RGDS > GARY > - --------------------------------------------------------------------------- > Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97701 > gem@... Tel:+1(541)382-8588 > > On Wed, 4 Nov 2009, Håkan Johansson wrote: > >> I'd like to run gpsd under a non-root user and use the ntpshm interface to set >> the system clock. For that, I'd use ntpshm segments 2 and 3 which are opened >> for everyone by ntpd. However, gpsd.c tests for getuid() == 0, and will not >> even try to setup with segments 2 and 3 for non-root users. The attached >> patch changes that, such that only segments 0 and 1 are avoided for non-root >> users. It also corrects the error handling for the nice(NICEVAL) call. > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.3 (GNU/Linux) > > iD8DBQFK8i2dBmnRqz71OvMRAsPbAJ9xeHfEf4/6kvKD4WmjwhzjQzeQWgCeNQBQ > gjrEjtABVexNpwsd3Bet5Bs= > =pS8u > -----END PGP SIGNATURE----- > Gpsd-dev mailing list Gpsd-dev@... https://lists.berlios.de/mailman/listinfo/gpsd-dev |
| Free embeddable forum powered by Nabble | Forum Help |