chiark / gitweb /
client: use privileged socket if possible
authorRichard Kettlewell <rjk@terraraq.org.uk>
Sat, 1 Dec 2012 13:28:21 +0000 (13:28 +0000)
committerRichard Kettlewell <rjk@terraraq.org.uk>
Sat, 1 Dec 2012 13:28:21 +0000 (13:28 +0000)
This allows the removal of the client dependency on libdb.

clients/Makefile.am
disobedience/Makefile.am
lib/client-common.c
lib/client.c

index 197d09c5f0623db79f493b027d243a9d38886e00..6ed9f4ab60e8c9c26a3942285448a42a3aaa9c6c 100644 (file)
@@ -25,7 +25,7 @@ AM_CPPFLAGS=-I${top_srcdir}/lib -I../lib
 disorder_SOURCES=disorder.c authorize.c authorize.h \
        ../lib/memgc.c
 disorder_LDADD=$(LIBOBJS) ../lib/libdisorder.a \
-       $(LIBGC) $(LIBGCRYPT) $(LIBPCRE) $(LIBICONV) $(LIBDB) $(LIBPTHREAD)
+       $(LIBGC) $(LIBGCRYPT) $(LIBPCRE) $(LIBICONV) $(LIBPTHREAD)
 disorder_DEPENDENCIES=$(LIBOBJS) ../lib/libdisorder.a
 
 disorderfm_SOURCES=disorderfm.c \
@@ -36,7 +36,7 @@ disorderfm_DEPENDENCIES=$(LIBOBJS) ../lib/libdisorder.a
 disorder_playrtp_SOURCES=playrtp.c playrtp.h playrtp-mem.c
 disorder_playrtp_LDADD=$(LIBOBJS) ../lib/libdisorder.a \
        $(LIBASOUND) $(LIBPCRE) $(LIBICONV) $(LIBGCRYPT) $(COREAUDIO) \
-       $(LIBDB) $(LIBPTHREAD) -lm
+       $(LIBPTHREAD) -lm
 disorder_playrtp_DEPENDENCIES=$(LIBOBJS) ../lib/libdisorder.a
 
 rtpmon_SOURCES=rtpmon.c
index bf5ea40c4dcf4b40970ae2d455dccce90cb69983..3aff555a46ab6465e6a9cd321c7e9ad80a6305e0 100644 (file)
@@ -30,7 +30,7 @@ disobedience_SOURCES=disobedience.h disobedience.c client.c queue.c   \
        popup.h playlists.c multidrag.c multidrag.h autoscroll.c        \
        autoscroll.h globals.c
 disobedience_LDADD=../lib/libdisorder.a $(LIBPCRE) $(LIBGC) $(LIBGCRYPT) \
-       $(LIBASOUND) $(COREAUDIO) $(LIBDB) $(LIBICONV)
+       $(LIBASOUND) $(COREAUDIO) $(LIBICONV)
 disobedience_LDFLAGS=$(GTK_LIBS)
 
 check: check-help
index 897260e133e34f09d295a1df717e805ac22a2ab4..f88008ffe2e4b8a11e693d281f670d65585f1457 100644 (file)
@@ -54,13 +54,11 @@ socklen_t find_server(struct config *c,
     sa = res->ai_addr;
     len = res->ai_addrlen;
   } else {
-    if(getuid() == 0) {
-      /* root will use the private socket if possible (which it should be) */
-      name = config_get_file2(c, "private/socket");
-      if(access(name, R_OK) != 0) {
-        xfree(name);
-        name = NULL;
-      }
+    /* use the private socket if possible (which it should be) */
+    name = config_get_file2(c, "private/socket");
+    if(access(name, R_OK) != 0) {
+      xfree(name);
+      name = NULL;
     }
     if(!name)
       name = config_get_file2(c, "socket");
index 987ab01edaf07cde9d23e7e3fe9234cf397d20cc..55cfe1c838002147e0382a6eac42c0e5a8a5f0cf 100644 (file)
@@ -50,7 +50,6 @@
 #include "authhash.h"
 #include "client-common.h"
 #include "rights.h"
-#include "trackdb.h"
 #include "kvp.h"
 
 /** @brief Client handle contents */
@@ -521,13 +520,13 @@ int disorder_connect(disorder_client *c) {
     return -1;
   }
   password = config->password;
-  /* Maybe we can read the database */
-  if(!password && trackdb_readable()) {
-    trackdb_init(TRACKDB_NO_RECOVER|TRACKDB_NO_UPGRADE);
-    trackdb_open(TRACKDB_READ_ONLY);
-    password = trackdb_get_password(username);
-    trackdb_close();
-  }
+  /* If we're connecting as 'root' guess that we're the system root
+   * user (or the jukebox user), both of which can use the privileged
+   * socket.  They can also furtle with the db directly: that is why
+   * privileged socket does not represent a privilege escalation. */
+  if(!password
+     && !strcmp(username, "root"))
+    password = "anything will do for root";
   if(!password) {
     /* Oh well */
     c->last = "no password";