gpsd-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC] get gpsd to work with gnss-share


From: Pavel Machek
Subject: [RFC] get gpsd to work with gnss-share
Date: Sat, 7 Jan 2023 22:01:32 +0100

Hi!

(Second attempt, I should have right list address this time)

On Librem-5 (and I suspect other cellphones), gnss-share is more or
less mandatory to get geoclue working. For legacy applications (xgps,
tangogps), it would be good to be able to start gpsd as an option.

It seems that best solution is to teach gpsd to talk over AF_UNIX
sockets.

Would something like this be acceptable?

Best regards,
                                                                Pavel

Binary files gpsd-3.22.ofic/buildtmp/clients/gpsdecode and 
gpsd-3.22/buildtmp/clients/gpsdecode differ
Binary files gpsd-3.22.ofic/buildtmp/gpsctl and gpsd-3.22/buildtmp/gpsctl differ
Binary files gpsd-3.22.ofic/buildtmp/gpsd/gpsd and gpsd-3.22/buildtmp/gpsd/gpsd 
differ
diff -ur gpsd-3.22.ofic/buildtmp/gpsd/gpsd.c gpsd-3.22/buildtmp/gpsd/gpsd.c
--- gpsd-3.22.ofic/buildtmp/gpsd/gpsd.c 2020-12-09 03:20:50.000000000 +0100
+++ gpsd-3.22/buildtmp/gpsd/gpsd.c      2023-01-07 00:56:22.037487130 +0100
@@ -2244,7 +2244,7 @@
 
 
     /* drop privileges */
-    if (0 == getuid()) {
+    if (0 && 0 == getuid()) {
         struct passwd *pw;
         struct stat stb;
 
Binary files gpsd-3.22.ofic/buildtmp/gpsd/gpsd.o and 
gpsd-3.22/buildtmp/gpsd/gpsd.o differ
diff -ur gpsd-3.22.ofic/buildtmp/gpsd/libgpsd_core.c 
gpsd-3.22/buildtmp/gpsd/libgpsd_core.c
--- gpsd-3.22.ofic/buildtmp/gpsd/libgpsd_core.c 2023-01-06 18:48:42.000000000 
+0100
+++ gpsd-3.22/buildtmp/gpsd/libgpsd_core.c      2023-01-07 01:02:44.844747850 
+0100
@@ -26,6 +26,7 @@
 #include <syslog.h>
 #include <sys/select.h>    // for pselect() per POSIX
 #include <sys/socket.h>
+#include <sys/un.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/wait.h>
@@ -557,7 +558,40 @@
         session->gpsdata.gps_fd = dsock;
         session->sourcetype = source_udp;
         return session->gpsdata.gps_fd;
-    }
+    } else if (str_starts_with(session->gpsdata.dev.path, "unix://")) {
+        char server[GPS_PATH_MAX];
+        socket_t dsock;
+        (void)strlcpy(server, session->gpsdata.dev.path + 7, sizeof(server));
+        INVALIDATE_SOCKET(session->gpsdata.gps_fd);
+        GPSD_LOG(LOG_INF, &session->context->errout,
+                 "opening UNIX feed at %s.\n", server);
+       dsock = socket(AF_UNIX, SOCK_STREAM, 0);
+        if (dsock < 0) {
+            GPSD_LOG(LOG_ERROR, &session->context->errout,
+                     "UNIX socket open error %d.\n", errno);
+            return -1;
+        } else
+            GPSD_LOG(LOG_SPIN, &session->context->errout,
+                     "UNIX socket opened on fd %d\n", dsock);
+       {
+               struct sockaddr_un addr;
+
+               memset(&addr, 0, sizeof(addr));
+               addr.sun_family = AF_UNIX;
+               printf("Connecting at path: %s\n", server);
+               strcpy(addr.sun_path, server);
+               if (connect(dsock, (struct sockaddr *)&addr, sizeof(addr)) < 0) 
{
+                       printf("Connecting at path bad: %s\n", server);
+                       printf("My uid: %d\n", geteuid());
+                       perror("connect");
+                       return -1;
+               }
+               printf("Connecting at path ok: %s\n", server);
+       }
+        session->gpsdata.gps_fd = dsock;
+        session->sourcetype = source_tcp;
+        return session->gpsdata.gps_fd;
+       }
 #endif /* NETFEED_ENABLE */
 #ifdef PASSTHROUGH_ENABLE
     if (str_starts_with(session->gpsdata.dev.path, "gpsd://")) {
Binary files gpsd-3.22.ofic/buildtmp/gpsd/libgpsd_core.o and 
gpsd-3.22/buildtmp/gpsd/libgpsd_core.o differ


-- 
People of Russia, stop Putin before his war on Ukraine escalates.

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]