]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug #1307: squid -k fails in combination with chroot after patch for bug 1157
authorserassio <>
Sun, 10 Jul 2005 02:02:49 +0000 (02:02 +0000)
committerserassio <>
Sun, 10 Jul 2005 02:02:49 +0000 (02:02 +0000)
Forward port of 2.5 patch.

src/cache_cf.cc
src/globals.h
src/main.cc
src/tools.cc

index 55b429bc86fafbc7acb70c20ee5abe1405132d94..8a11eb0f4bee97fb52acf1b15eb8e2de143650a0 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: cache_cf.cc,v 1.476 2005/06/26 18:51:20 serassio Exp $
+ * $Id: cache_cf.cc,v 1.477 2005/07/09 20:02:49 serassio Exp $
  *
  * DEBUG: section 3     Configuration File Parsing
  * AUTHOR: Harvest Derived
@@ -375,8 +375,9 @@ parseConfigFile(const char *file_name)
         enter_suid();
     }
 
+    configDoConfigure();
+
     if (opt_send_signal == -1) {
-        configDoConfigure();
         cachemgrRegister("config",
                          "Current Squid Configuration",
                          dump_config,
@@ -3037,8 +3038,12 @@ requirePathnameExists(const char *name, const char *path)
         path = pathbuf;
     }
 
-    if (stat(path, &sb) < 0)
-        fatalf("%s %s: %s", name, path, xstrerror());
+    if (stat(path, &sb) < 0) {
+        if (opt_send_signal == -1 || opt_send_signal == SIGHUP)
+            fatalf("%s %s: %s", name, path, xstrerror());
+        else
+            fprintf(stderr, "WARNING: %s %s: %s\n", name, path, xstrerror());
+    }
 }
 
 char *
index c0210c26b92412277e29b7cde9433e4352fe9c21..afa2963162e8b4c83b8c85862b6322fc814af08f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: globals.h,v 1.132 2005/05/01 08:11:48 serassio Exp $
+ * $Id: globals.h,v 1.133 2005/07/09 20:02:49 serassio Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -176,8 +176,8 @@ extern void *sbrk_start;    /* 0 */
 
 extern int ssl_ex_index_server;        /* -1 */
 extern int ssl_ctx_ex_index_dont_verify_domain; /* -1 */
-extern int opt_no_daemon; /* 0 */
 
 extern const char *external_acl_message;      /* NULL */
 extern int opt_send_signal;    /* -1 */
+extern int opt_no_daemon; /* 0 */
 #endif /* SQUID_GLOBALS_H */
index ec7b75e9fac1670e5be215aaf4bfe4098fe27feb..a6f25f3399f2d5ea3642776cbb112ce9ce4fe0c3 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: main.cc,v 1.410 2005/04/30 19:32:01 serassio Exp $
+ * $Id: main.cc,v 1.411 2005/07/09 20:02:49 serassio Exp $
  *
  * DEBUG: section 1     Startup and Main Loop
  * AUTHOR: Harvest Derived
@@ -1046,8 +1046,13 @@ main(int argc, char **argv)
     if (opt_send_signal != -1) {
         /* chroot if configured to run inside chroot */
 
-        if (Config.chroot_dir && chroot(Config.chroot_dir)) {
-            fatal("failed to chroot");
+        if (Config.chroot_dir) {
+            if (chroot(Config.chroot_dir))
+                fatal("failed to chroot");
+
+            no_suid();
+        } else {
+            leave_suid();
         }
 
         sendSignal();
@@ -1195,6 +1200,7 @@ main(int argc, char **argv)
     return 0;
 
 #endif
+
 }
 
 static void
@@ -1456,6 +1462,7 @@ watch_child(char *argv[])
 
     /* NOTREACHED */
 #endif /* _SQUID_MSWIN_ */
+
 }
 
 static void
index 4a4c3c76adec513c61f9b81da4d163799a30d3ba..7f33a109b133be9457e10d6958cb75e346e6bc8b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: tools.cc,v 1.256 2005/05/06 01:57:55 hno Exp $
+ * $Id: tools.cc,v 1.257 2005/07/09 20:02:49 serassio Exp $
  *
  * DEBUG: section 21    Misc Functions
  * AUTHOR: Harvest Derived
@@ -624,7 +624,11 @@ getMyHostname(void)
             return host;
     }
 
-    fatal("Could not determine fully qualified hostname.  Please set 'visible_hostname'\n");
+    if (opt_send_signal == -1)
+        fatal("Could not determine fully qualified hostname.  Please set 'visible_hostname'\n");
+    else
+        return ("localhost");
+
     return NULL;               /* keep compiler happy */
 }