Commit Diff
Diff:
4ec050febc5abae6c990335c01ecd52bcead034d
9e2ba8ebb451dea6f72e8231797ce5ba755231c0
Commit:
9e2ba8ebb451dea6f72e8231797ce5ba755231c0
Tree:
981ffd15791af4143b45141db6ebff939b4ca828
Author:
pjp <pjp@delphinusdns.org>
Committer:
pjp <pjp@delphinusdns.org>
Date:
Wed Dec 11 16:55:01 2019 UTC
Message:
if a --location=/var/delphinusdns is given to ./configure then a number of things change. It expects /var/delphinusdns/etc then to contain the .conf file. /var/delphinusdns/replicant becomes the rzone dir. Also the _ddd user does not provide the chroot dir for delphinusdns, that is now overridden to be the --location path. This is to make it easier in the future to port delphinusdnsd to a package in a BSD or Linux distribution.
blob - c085645ce0b51fd70e5f7909c8b08c660c44d232
blob + c1762c9e1e994231d45e970c815f529aef1ffd46
--- configure
+++ configure
@@ -1,7 +1,7 @@
#!/bin/sh
-VERSION="1.3"
+VERSION="1.4"
DD_VERSION="delphinusdnsd-$VERSION"
DD_VERSION_LEN=`echo -n $DD_VERSION | wc -c`
NP=0
@@ -14,6 +14,13 @@ do
--user=*)
user=`echo $1 | sed -e 's/--user=//g'`
echo "#define DEFAULT_PRIVILEGE \"$user\"" >> ddd-config.h
+ ;;
+ --location=*)
+ location=`echo $1 | sed -e 's/--location=//g'`
+ echo "#define DEFAULT_LOCATION \"$location\"" >> ddd-config.h
+ echo "#define DEFAULT_CONFFILE \"${location}/etc/delphinusdns.conf\"" >> ddd-config.h
+ echo "#define DEFAULT_RZONE_DIR \"${location}/replicant\"" >> ddd-config.h
+
;;
*)
echo "usage: configure [--needpledge] [--user=USERNAME]"
blob - 5bee29c9cf8b86baee111c27c136acd9203ae893
blob + 59d3c5876c90560aef4730478360cf8024ea04c8
--- ddd-db.h
+++ ddd-db.h
@@ -27,7 +27,7 @@
*/
/*
- * $Id: ddd-db.h,v 1.30 2019/11/25 15:14:42 pjp Exp $
+ * $Id: ddd-db.h,v 1.31 2019/12/11 16:55:01 pjp Exp $
*/
#ifndef _DB_H
@@ -37,8 +37,14 @@
#include <limits.h>
#include <openssl/hmac.h>
+#include "ddd-config.h"
+#ifndef DEFAULT_CONFFILE
#define CONFFILE "/etc/delphinusdns/delphinusdns.conf"
+#else
+#define CONFFILE DEFAULT_CONFFILE
+#endif
+
#define DEFAULT_SOCKET 64
#define PARSEFILE_FLAG_NOSOCKET 0x1
@@ -399,7 +405,11 @@ struct mzone {
SLIST_HEAD(,mzone_dest) dest;
} *mz, *mz0;
+#ifndef DEFAULT_RZONE_DIR
#define DELPHINUS_RZONE_PATH "/etc/delphinusdns/replicant"
+#else
+#define DELPHINUS_RZONE_PATH DEFAULT_RZONE_DIR
+#endif
struct rzone {
SLIST_ENTRY(rzone) rzone_entry;
blob - 09b8cb719d31d7f13b915633b3d4c91385b67442
blob + 473cec6e718c2acddbc149cf943e5d7cb940aa8d
--- delphinusdnsd.c
+++ delphinusdnsd.c
@@ -27,7 +27,7 @@
*/
/*
- * $Id: delphinusdnsd.c,v 1.91 2019/12/07 08:08:44 pjp Exp $
+ * $Id: delphinusdnsd.c,v 1.92 2019/12/11 16:55:01 pjp Exp $
*/
@@ -894,7 +894,11 @@ main(int argc, char *argv[], char *environ[])
exit(1);
case 0:
/* chroot to the drop priv user home directory */
+#ifdef DEFAULT_LOCATION
+ if (drop_privs(DEFAULT_LOCATION, pw) < 0) {
+#else
if (drop_privs(pw->pw_dir, pw) < 0) {
+#endif
dolog(LOG_INFO, "axfr dropping privileges\n", strerror(errno));
slave_shutdown();
exit(1);
@@ -1008,7 +1012,11 @@ main(int argc, char *argv[], char *environ[])
} /* raxfrflag */
/* the rest of the daemon goes on in TCP and UDP loops */
+#ifdef DEFAULT_LOCATION
+ if (drop_privs(DEFAULT_LOCATION, pw) < 0) {
+#else
if (drop_privs(pw->pw_dir, pw) < 0) {
+#endif
dolog(LOG_INFO, "dropping privileges failed\n");
slave_shutdown();
exit(1);
@@ -3415,7 +3423,11 @@ setup_unixsocket(char *socketpath, struct imsgbuf *ibu
exit(1);
}
+#ifdef DEFAULT_LOCATION
+ if (drop_privs(DEFAULT_LOCATION, pw) < 0) {
+#else
if (drop_privs(pw->pw_dir, pw) < 0) {
+#endif
dolog(LOG_INFO, "dropping privileges failed in unix socket\n");
slave_shutdown();
exit(1);
repomaster@centroid.eu