From 338e91f33174edebe42d77843c0eea34f53bc53c Mon Sep 17 00:00:00 2001 From: Jonathan McDowell Date: Fri, 21 Aug 2015 12:44:22 +0200 Subject: [PATCH] Add config option to specify keyd socket directory keyd was stashing its Unix domain socket in the DB directory, which is contrary to convention. Add a sock_dir config option and default it to ${prefix}/var/run in the sample config file. --- debian/onak.socket | 2 +- keyd.c | 2 +- keydb_keyd.c | 2 +- keydctl.c | 2 +- onak-conf.c | 1 + onak-conf.h | 2 ++ onak.conf.in | 1 + 7 files changed, 8 insertions(+), 4 deletions(-) diff --git a/debian/onak.socket b/debian/onak.socket index 7e317d5..97a4df8 100644 --- a/debian/onak.socket +++ b/debian/onak.socket @@ -1,5 +1,5 @@ [Socket] -ListenStream=/var/lib/onak/keyd.sock +ListenStream=/var/run/keyd.sock SocketUser=onak SocketMode=0660 diff --git a/keyd.c b/keyd.c index 6a171d4..b73ff28 100644 --- a/keyd.c +++ b/keyd.c @@ -653,7 +653,7 @@ int main(int argc, char *argv[]) } stats->started = time(NULL); - snprintf(sockname, 1023, "%s/%s", config.db_dir, KEYD_SOCKET); + snprintf(sockname, 1023, "%s/%s", config.sock_dir, KEYD_SOCKET); fd = sock_init(sockname); if (fd != -1) { diff --git a/keydb_keyd.c b/keydb_keyd.c index fec6ebb..33d2c21 100644 --- a/keydb_keyd.c +++ b/keydb_keyd.c @@ -527,7 +527,7 @@ struct onak_dbctx *keydb_keyd_init(bool readonly) sock.sun_family = AF_UNIX; snprintf(sock.sun_path, sizeof(sock.sun_path) - 1, "%s/%s", - config.db_dir, + config.sock_dir, KEYD_SOCKET); if (connect(keyd_fd, (struct sockaddr *) &sock, sizeof(sock)) < 0) { logthing(LOGTHING_CRITICAL, diff --git a/keydctl.c b/keydctl.c index ef942db..1aa5d59 100644 --- a/keydctl.c +++ b/keydctl.c @@ -99,7 +99,7 @@ static void keyd_connect(void) sock.sun_family = AF_UNIX; snprintf(sock.sun_path, sizeof(sock.sun_path) - 1, "%s/%s", - config.db_dir, + config.sock_dir, KEYD_SOCKET); if (connect(keyd_fd, (struct sockaddr *) &sock, sizeof(sock)) < 0) { if (verbose >= 0) { diff --git a/onak-conf.c b/onak-conf.c index ccad3c5..02ccf2d 100644 --- a/onak-conf.c +++ b/onak-conf.c @@ -45,6 +45,7 @@ struct onak_config config = { NULL, /* logfile */ false, /* use_keyd */ + ".", /* sock_dir */ /* * Options for directory backends. diff --git a/onak-conf.h b/onak-conf.h index 34dcff2..52439ab 100644 --- a/onak-conf.h +++ b/onak-conf.h @@ -48,6 +48,8 @@ struct onak_config { /** Set if we're using keyd as the backend. */ bool use_keyd; + /** The path to the directory the keyd socket lives in. */ + char *sock_dir; /* * Options for any database backend that needs a directory, be it the diff --git a/onak.conf.in b/onak.conf.in index 1774211..9f586fc 100644 --- a/onak.conf.in +++ b/onak.conf.in @@ -34,6 +34,7 @@ maintainer_email PGP Key Server Administrator mail_intro_file /community/pgp-keyserver/share/mail_intro help_dir /community/pgp-keyserver/share mail_dir @STATEDIR@/spool/onak +sock_dir @STATEDIR@/run ### If you change this, make sure to put a corresponding help file in ### the help_dir named above -- 2.39.5