From 975334992494343706424f285d700d2f6d7f55e0 Mon Sep 17 00:00:00 2001 From: Nuno Goncalves Date: Mon, 13 Jun 2016 19:38:43 +0100 Subject: [PATCH] gpsd: EXIT if device fails to open and there are no control sockets available to make a recover possible Signed-off-by: Nuno Goncalves --- gpsd.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/gpsd.c b/gpsd.c index d98d446..a70b31c 100644 --- a/gpsd.c +++ b/gpsd.c @@ -1839,6 +1839,7 @@ int main(int argc, char *argv[]) struct gps_device_t *device; int i, option; int msocks[2] = {-1, -1}; + bool device_opened = false; bool go_background = true; volatile bool in_restart; @@ -2057,9 +2058,25 @@ int main(int argc, char *argv[]) gpsd_log(&context.errout, LOG_ERROR, "initial GPS device %s open failed\n", argv[i]); + } else { + device_opened = true; } } + if ( +#ifdef CONTROL_SOCKET_ENABLE + control_socket == NULL && +#endif +#ifdef SYSTEMD_ENABLE + sd_socket_count <= 0 && +#endif + !device_opened) { + gpsd_log(&context.errout, LOG_ERROR, + "can't run with neither control socket nor devices open\n"); + exit(EXIT_FAILURE); + } + + /* drop privileges */ if (0 == getuid()) { struct passwd *pw; -- 2.7.4