From ea91baeb669d27961717b98da3074e39da5badee Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 17 Oct 2013 07:28:31 -0400 Subject: Allow gpsdctl to run as non-root. --- gpsdctl.c | 4 ++++ gpsdctl.xml | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/gpsdctl.c b/gpsdctl.c index 7958c38c..a1ac0844 100644 --- a/gpsdctl.c +++ b/gpsdctl.c @@ -21,6 +21,8 @@ #include "gpsd.h" +#define DEFAULT_GPSD_TEST_SOCKET "/tmp/gpsd.sock" + static char *control_socket = DEFAULT_GPSD_SOCKET; static char *gpsd_options = ""; @@ -97,6 +99,8 @@ int main(int argc, char *argv[]) if (sockenv != NULL) control_socket = sockenv; + else if (geteuid() != 0) + control_socket = DEFAULT_GPSD_TEST_SOCKET; if (optenv != NULL) gpsd_options = optenv; diff --git a/gpsdctl.xml b/gpsdctl.xml index f667c933..b72d2767 100644 --- a/gpsdctl.xml +++ b/gpsdctl.xml @@ -45,7 +45,10 @@ client requests a watch. Two environment variables are interpreted. GPSD_SOCKET sets the location of the -control socket. It defaults to /var/run/gpsd.sock. +control socket. It defaults to +/var/run/gpsd.sock if the effective user ID of +this program is root, /tmp/gpsd.sock +otherwise. GPSD_OPTIONS may be a list of options to be passed to gpsd -- cgit v1.2.1