testparm: do not fail if /run/samba does not exist
authorMichael Tokarev <mjt@tls.msk.ru>
Tue, 26 Apr 2022 13:14:38 +0000 (16:14 +0300)
committerMichael Tokarev <mjt@tls.msk.ru>
Mon, 16 Oct 2023 15:26:31 +0000 (16:26 +0100)
testparm explicitly fails if $piddir or $lockdir does not exist.
However, the daemons which actually use these directories, will
create it on demand, there is no need to fail even simple testparm
operations if the dirs are not there.

This change lets to (pre)configure samba without bothering to
pre-create the directories which are overwise needed only to fulfil
testparm criteria.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Gbp-Pq: Name testparm-do-not-fail-if-pid-dir-does-not-exist.patch

python/samba/netcmd/testparm.py
source3/utils/testparm.c

index 41dbb4bd62362dc93a9fc2220ecb5830ce6db157..02e52ffcbefae50a79af030c8e3083d75e935bd8 100644 (file)
@@ -145,14 +145,12 @@ class cmd_testparm(Command):
         lockdir = lp.get("lockdir")
 
         if not os.path.isdir(lockdir):
-            logger.error("lock directory %s does not exist", lockdir)
-            valid = False
+            logger.warning("lock directory %s does not exist", lockdir)
 
         piddir = lp.get("pid directory")
 
         if not os.path.isdir(piddir):
-            logger.error("pid directory %s does not exist", piddir)
-            valid = False
+            logger.warning("pid directory %s does not exist", piddir)
 
         winbind_separator = lp.get("winbind separator")
 
index 96e05a57f47a06e3974ab26d63ec07601e14b0c1..8db66c7d6532b3615888dfd2381cf1fa31cfb9d9 100644 (file)
@@ -337,9 +337,8 @@ static int do_global_checks(void)
        }
 
        if (!directory_exist_stat(lp_lock_directory(), &st)) {
-               fprintf(stderr, "ERROR: lock directory %s does not exist\n\n",
+               fprintf(stderr, "WARNING: lock directory %s does not exist\n\n",
                       lp_lock_directory());
-               ret = 1;
        } else if ((st.st_ex_mode & 0777) != 0755) {
                fprintf(stderr, "WARNING: lock directory %s should have "
                                "permissions 0755 for browsing to work\n\n",
@@ -367,9 +366,8 @@ static int do_global_checks(void)
        }
 
        if (!directory_exist_stat(lp_pid_directory(), &st)) {
-               fprintf(stderr, "ERROR: pid directory %s does not exist\n\n",
+               fprintf(stderr, "WARNING: pid directory %s does not exist\n\n",
                       lp_pid_directory());
-               ret = 1;
        }
 
        if (lp_passdb_expand_explicit()) {