]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fixup that patch and uid lookup (only for daemon).
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 6 Jan 2015 14:37:45 +0000 (14:37 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 6 Jan 2015 14:37:45 +0000 (14:37 +0000)
git-svn-id: file:///svn/unbound/trunk@3306 be551aaa-1e26-0410-a405-d3ace91eadb9

daemon/unbound.c
doc/Changelog
util/config_file.c
util/config_file.h

index 1663fa29b80b4f01d89363d8b886ad809bb48d10..a31b0392ffdb24a38f4a32c72ebb18f8b393d1cc 100644 (file)
@@ -651,6 +651,7 @@ run_daemon(const char* cfgfile, int cmdline_verbose, int debug_mode)
                        log_warn("Continuing with default config settings");
                }
                apply_settings(daemon, cfg, cmdline_verbose, debug_mode);
+               config_lookup_uid(cfg);
        
                /* prepare */
                if(!daemon_open_shared_ports(daemon))
index 81c7d4bf82d7618044fe6d7c8d06c921233c1f80..27ac55d1b6adafb555e4f99d7d96f428b17d1a20 100644 (file)
@@ -3,6 +3,7 @@
        - patch for remote control over local sockets, from Dag-Erling
          Smorgrav, Ilya Bakulin.  Use control-interface: /path/sock and
          control-use-cert: no.
+       - Fixup that patch and uid lookup (only for daemon).
 
 5 January 2015: Wouter
        - getauxval test for ppc64 linux compatibility.
index bb39cf9bd7a20229ff167619bcfcb7906c0f6e1b..12b00c9e40dc7720b45b911af8bb9ae2bbfb1c45 100644 (file)
@@ -805,16 +805,6 @@ config_read(struct config_file* cfg, const char* filename, const char* chroot)
                return 0;
        }
 
-#ifdef HAVE_GETPWNAM
-       /* translate username into uid and gid */
-       if(cfg->username && cfg->username[0]) {
-               struct passwd *pwd;
-               if((pwd = getpwnam(cfg->username)) == NULL)
-                       log_err("user '%s' does not exist.", cfg->username);
-               cfg->uid = pwd->pw_uid;
-               cfg->gid = pwd->pw_gid;
-       }
-#endif
        return 1;
 }
 
@@ -1203,6 +1193,20 @@ config_apply(struct config_file* config)
        log_set_time_asc(config->log_time_ascii);
 }
 
+void config_lookup_uid(struct config_file* cfg)
+{
+#ifdef HAVE_GETPWNAM
+       /* translate username into uid and gid */
+       if(cfg->username && cfg->username[0]) {
+               struct passwd *pwd;
+               if((pwd = getpwnam(cfg->username)) == NULL)
+                       log_err("user '%s' does not exist.", cfg->username);
+               cfg->uid = pwd->pw_uid;
+               cfg->gid = pwd->pw_gid;
+       }
+#endif
+}
+
 /** 
  * Calculate string length of full pathname in original filesys
  * @param fname: the path name to convert.
index fd35d7863ae1b9e94520e3fbaf0a9e1bdac41907..327eadc76f7b7c1a36f2932482f6d4f3903b07ba 100644 (file)
@@ -426,6 +426,12 @@ void config_delete(struct config_file* config);
  */
 void config_apply(struct config_file* config);
 
+/**
+ * Find username, sets uid and gid.
+ * @param config: the config structure.
+ */
+void config_lookup_uid(struct config_file* config);
+
 /**
  * Set the given keyword to the given value.
  * @param config: where to store config