From: serassio <> Date: Sun, 10 Jul 2005 02:02:49 +0000 (+0000) Subject: Bug #1307: squid -k fails in combination with chroot after patch for bug 1157 X-Git-Tag: SQUID_3_0_PRE4~705 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a572d8be51590c02b60374de995595fcb3e30df5;p=thirdparty%2Fsquid.git Bug #1307: squid -k fails in combination with chroot after patch for bug 1157 Forward port of 2.5 patch. --- diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 55b429bc86..8a11eb0f4b 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -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 * diff --git a/src/globals.h b/src/globals.h index c0210c26b9..afa2963162 100644 --- a/src/globals.h +++ b/src/globals.h @@ -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 */ diff --git a/src/main.cc b/src/main.cc index ec7b75e9fa..a6f25f3399 100644 --- a/src/main.cc +++ b/src/main.cc @@ -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 diff --git a/src/tools.cc b/src/tools.cc index 4a4c3c76ad..7f33a109b1 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -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 */ }