[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/2] dmd: Use ~/.dmd.d/ by default when not run as root.
From: |
Alex Sassmannshausen |
Subject: |
[PATCH 1/2] dmd: Use ~/.dmd.d/ by default when not run as root. |
Date: |
Mon, 3 Feb 2014 18:37:44 +0100 |
* modules/dmd/support.scm: Add copyright.
(user-dmddir): New variable.
(default-logfile): Use it instead of user-homedir.
(default-persistency-state-file): Use it instead of user-homedir.
(default-configfile): Use it instead of user-homedir, use init.scm
as default name for configfile, ensure .dmd.d exists.
(default-socket-dir): Add check for root, if #f, use user-dmddir as
base for socket.
---
modules/dmd/support.scm | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/modules/dmd/support.scm b/modules/dmd/support.scm
index 413e65b..f9c9989 100644
--- a/modules/dmd/support.scm
+++ b/modules/dmd/support.scm
@@ -1,4 +1,5 @@
-;; support.scm -- Various general support facilities, shared by deco and dmd.
+;; support.scm -- Various support facilities, used by deco and dmd.
+;; Copyright (C) 2014 A.Sassmannshausen <address@hidden>
;; Copyright (C) 2013 Ludovic Court??s <address@hidden>
;; Copyright (C) 2002, 2003 Wolfgang J??hrling <address@hidden>
;;
@@ -158,21 +159,31 @@ There is NO WARRANTY, to the extent permitted by law.")))
(getenv "HOME")
"/"))
+;; dmd default subdirectory if dmd is run as a normal user.
+(define user-dmddir (string-append user-homedir "/.dmd.d"))
+
;; Logfile.
(define default-logfile
(if (zero? (getuid))
(string-append %localstatedir "/log/dmd.log")
- (string-append user-homedir "/.dmd.log")))
+ (string-append user-dmddir "/dmd.log")))
;; Configuration file.
(define default-config-file
(if (zero? (getuid))
(string-append Prefix-dir "/etc/dmdconf.scm")
- (string-append user-homedir "/.dmdconf.scm")))
+ (begin
+ (let ((config-file (string-append user-dmddir "/init.scm")))
+ (cond ((not (file-exists? user-dmddir))
+ (mkdir user-dmddir)
+ config-file)
+ (else config-file))))))
;; The directory where the socket resides.
(define default-socket-dir
- (string-append %localstatedir "/run/dmd"))
+ (if (zero? (getuid))
+ (string-append %localstatedir "/run/dmd")
+ (string-append user-dmddir "/run")))
;; Unix domain socket for receiving commands in dmd.
(define default-socket-file
@@ -182,7 +193,7 @@ There is NO WARRANTY, to the extent permitted by law.")))
(define default-persistency-state-file
(if (zero? (getuid))
(string-append %localstatedir "/lib/misc/dmd-state")
- (string-append user-homedir "/.dmd-state")))
+ (string-append user-dmddir "/dmd-state")))
;; Global variables set from (dmd).
(define persistency #f)
--
1.7.9.5