From 1be9101e4d2cfd1aed5249b0cdf126d747095ce8 Mon Sep 17 00:00:00 2001 Message-Id: <1be9101e4d2cfd1aed5249b0cdf126d747095ce8.1715290146.git.mdw@distorted.org.uk> From: Mark Wooding Date: Sat, 1 Dec 2012 13:28:21 +0000 Subject: [PATCH] client: use privileged socket if possible Organization: Straylight/Edgeware From: Richard Kettlewell This allows the removal of the client dependency on libdb. --- clients/Makefile.am | 4 ++-- disobedience/Makefile.am | 2 +- lib/client-common.c | 12 +++++------- lib/client.c | 15 +++++++-------- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/clients/Makefile.am b/clients/Makefile.am index 197d09c..6ed9f4a 100644 --- a/clients/Makefile.am +++ b/clients/Makefile.am @@ -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 diff --git a/disobedience/Makefile.am b/disobedience/Makefile.am index bf5ea40..3aff555 100644 --- a/disobedience/Makefile.am +++ b/disobedience/Makefile.am @@ -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 diff --git a/lib/client-common.c b/lib/client-common.c index 897260e..f88008f 100644 --- a/lib/client-common.c +++ b/lib/client-common.c @@ -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"); diff --git a/lib/client.c b/lib/client.c index 987ab01..55cfe1c 100644 --- a/lib/client.c +++ b/lib/client.c @@ -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"; -- [mdw]