]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Author: Alex Rousskov <rousskov@measurement-factory.com>
authorAmos Jeffries <squid3@treenet.co.nz>
Fri, 2 May 2008 11:12:10 +0000 (23:12 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 2 May 2008 11:12:10 +0000 (23:12 +1200)
Bug 2254: umask support needs porting from 2.6

src/cache_cf.cc
src/cf.data.pre
src/main.cc
src/protos.h
src/structs.h
src/tools.cc

index 89deda6176a6fb3d3ba5fa7273eca641f0b2c0e6..4056090aceb0c62b50f8352ec7dc28bd35c58069 100644 (file)
@@ -389,6 +389,7 @@ parseConfigFile(const char *file_name, CacheManager & manager)
 
     if (!Config.chroot_dir) {
         leave_suid();
+        setUmask(Config.umask);
         _db_init(Config.Log.log, Config.debugOptions);
         enter_suid();
     }
index e9c070949254dc346413ef1acf49df9943b33f45..1d0c116244ed00bd7ffeabe93effdc9eeda39b33 100644 (file)
@@ -3319,6 +3319,18 @@ DOC_START
        A list of other DNS names your cache has.
 DOC_END
 
+NAME: umask
+TYPE: int
+LOC: Config.umask
+DEFAULT: 027
+DOC_START
+       Minimum umask which should be enforced while the proxy
+       is running, in addition to the umask set at startup.
+
+       For a traditional octal representation of umasks, start
+        your value with 0.
+DOC_END
+
 COMMENT_START
  OPTIONS FOR THE CACHE REGISTRATION SERVICE
  -----------------------------------------------------------------------------
index 2434181ff08bfc556d12d0d1393ce24cdcd53929..28bd54fc5cd41449d4f7d42db4e25984aef3364e 100644 (file)
@@ -632,6 +632,7 @@ mainReconfigure(void)
     errorClean();
     enter_suid();              /* root to read config file */
     parseConfigFile(ConfigFile, manager);
+    setUmask(Config.umask);
     Mem::Report();
     setEffectiveUser();
     _db_init(Config.Log.log, Config.debugOptions);
@@ -1068,7 +1069,6 @@ int
 main(int argc, char **argv)
 #endif
 {
-    mode_t oldmask;
 #ifdef _SQUID_WIN32_
 
     int WIN32_init_err;
@@ -1211,6 +1211,7 @@ main(int argc, char **argv)
 
             return parse_err;
     }
+    setUmask(Config.umask);
     if (-1 == opt_send_signal)
         if (checkRunningPid())
             exit(1);
index 72e19d5f0a7157f6632690105ab842bc0aea3850..a47aeb98cdee49fd5f2903b4e60eaf504043c2ab 100644 (file)
@@ -663,6 +663,7 @@ SQUIDCEXTERN int xrename(const char *from, const char *to);
 SQUIDCEXTERN int isPowTen(int);
 SQUIDCEXTERN void parseEtcHosts(void);
 SQUIDCEXTERN int getMyPort(void);
+SQUIDCEXTERN void setUmask(mode_t mask);
 
 SQUIDCEXTERN char *strwordtok(char *buf, char **t);
 SQUIDCEXTERN void strwordquote(MemBuf * mb, const char *str);
index 67749d902caa92f6afe3244526aaecf4b824ef0b..3cdaa4a5073667898fc2e38cbcb7ecfe782ab51d 100644 (file)
@@ -740,6 +740,7 @@ struct _SquidConfig
 #endif
 
     char *accept_filter;
+    int umask;
 };
 
 struct _SquidConfig2
index 9f890a52c91e694e79f1d729d9fc1e0cac2f06e5..3c6e191d1f341c4f36d6b649c1c29fd0efd4bf6c 100644 (file)
@@ -1272,6 +1272,17 @@ getMyPort(void)
     return 0;                  /* NOT REACHED */
 }
 
+/*
+ * Set the umask to at least the given mask. This is in addition
+ * to the umask set at startup
+ */
+void
+setUmask(mode_t mask)
+{
+    // No way to get the current umask value without setting it.
+    static const mode_t orig_umask = umask(mask); // once, to get
+    umask(mask | orig_umask); // always, to set
+}
 
 /*
  * Inverse of strwordtok. Quotes a word if needed