]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
added CCACHE_UMASK
authorAndrew Tridgell <tridge@samba.org>
Sat, 27 Sep 2003 11:34:50 +0000 (13:34 +0200)
committerAndrew Tridgell <tridge@samba.org>
Sat, 27 Sep 2003 11:34:50 +0000 (13:34 +0200)
fixed a typo

ccache.1
ccache.c
ccache.yo
execute.c
util.c
web/ccache-man.html

index 962f98e0882bfb54d2a4245a56ae3dc5cc9ad809..8ffb5cc299c78e60e5abd554774eed6da67d16c4 100644 (file)
--- a/ccache.1
+++ b/ccache.1
@@ -133,7 +133,7 @@ compiler as a command line option\&.
 .PP 
 .SH "ENVIRONMENT VARIABLES" 
 .PP 
-ccache used a number of environment variables to control operation\&. In
+ccache uses a number of environment variables to control operation\&. In
 most cases you won\&'t need any of these as the defaults will be fine\&.
 .PP 
 .IP 
@@ -201,6 +201,13 @@ This forces ccache to not use any cached
 results, even if it finds them\&. New results are still cached, but
 existing cache entries are ignored\&.
 .IP 
+.IP "\fBCCACHE_UMASK\fP" 
+This sets the umask for ccache and all child
+processes (such as the compiler)\&. This is mostly useful when you wish
+to share your cache with other users\&. Note that this also affects the
+file permissions set on the object files created from your
+compilations\&.
+.IP 
 .IP "\fBCCACHE_HASHDIR\fP" 
 This tells ccache to hash the current working
 directory when calculating the hash that is used to distinguish two
@@ -300,8 +307,8 @@ Use the same \fBCCACHE_DIR\fP environment variable setting
 Make sure that all users have write permission in the entire
 cache directory (and that you trust all users of the shared cache)\&. 
 .IP o 
-Tell your users to set a umask that allows group writes
-(eg\&. umask 002)
+Make sure everyone sets the CCACHE_UMASK environment variable
+to 002, this ensures that cached files are accessible to everyone\&.
 .IP o 
 Make sure that the setgid bit is set on all directories in the
 cache\&. This tells the filesystem to inherit group ownership for new
index 03e205e817f7ed7fb55c9ca8bb478bce2eac4993..9ead0566f8725ef96527c999ba7408fe0c47d929 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -961,6 +961,8 @@ static void setup_uncached_err(void)
 
 int main(int argc, char *argv[])
 {
+       char *p;
+
        cache_dir = getenv("CCACHE_DIR");
        if (!cache_dir) {
                x_asprintf(&cache_dir, "%s/.ccache", getenv("HOME"));
@@ -969,6 +971,19 @@ int main(int argc, char *argv[])
        cache_logfile = getenv("CCACHE_LOGFILE");
 
        setup_uncached_err();
+       
+
+       /* the user might have set CCACHE_UMASK */
+       p = getenv("CCACHE_UMASK");
+       if (p) {
+               mode_t mask;
+               errno = 0;
+               mask = strtol(p, NULL, 8);
+               if (errno == 0) {
+                       umask(mask);
+               }
+       }
+
 
        /* check if we are being invoked as "ccache" */
        if (strlen(argv[0]) >= strlen(MYNAME) &&
index 72e3e6fe81ce5b8d5039b96065a7ef86796e2f63..f33b3efaa0337622d6741ac161c2e6f6226222d2 100644 (file)
--- a/ccache.yo
+++ b/ccache.yo
@@ -115,7 +115,7 @@ compiler as a command line option.
 
 manpagesection(ENVIRONMENT VARIABLES)
 
-ccache used a number of environment variables to control operation. In
+ccache uses a number of environment variables to control operation. In
 most cases you won't need any of these as the defaults will be fine.
 
 startdit()
@@ -173,6 +173,12 @@ dit(bf(CCACHE_RECACHE)) This forces ccache to not use any cached
 results, even if it finds them. New results are still cached, but
 existing cache entries are ignored.
 
+dit(bf(CCACHE_UMASK)) This sets the umask for ccache and all child
+processes (such as the compiler). This is mostly useful when you wish
+to share your cache with other users. Note that this also affects the
+file permissions set on the object files created from your
+compilations.
+
 dit(bf(CCACHE_HASHDIR)) This tells ccache to hash the current working
 directory when calculating the hash that is used to distinguish two
 compiles. This prevents a problem with the storage of the current
@@ -266,8 +272,8 @@ itemize(
   it() Use the same bf(CCACHE_DIR) environment variable setting
   it() Make sure that all users have write permission in the entire
   cache directory (and that you trust all users of the shared cache). 
-  it() Tell your users to set a umask that allows group writes
-  (eg. umask 002)
+  it() Make sure everyone sets the CCACHE_UMASK environment variable
+  to 002, this ensures that cached files are accessible to everyone.
   it() Make sure that the setgid bit is set on all directories in the
   cache. This tells the filesystem to inherit group ownership for new
   directories. The command "chmod g+s `find $CCACHE_DIR -type d`" might
index f55fbdda54f65923c489dc9c082b3b26a819c1bf..56146a001464f2fcfe8f9234419529d5e3d32157 100644 (file)
--- a/execute.c
+++ b/execute.c
@@ -37,7 +37,7 @@ int execute(char **argv,
                int fd;
 
                unlink(path_stdout);
-               fd = open(path_stdout, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, 0644);
+               fd = open(path_stdout, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, 0666);
                if (fd == -1) {
                        exit(STATUS_NOCACHE);
                }
@@ -45,7 +45,7 @@ int execute(char **argv,
                close(fd);
 
                unlink(path_stderr);
-               fd = open(path_stderr, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, 0644);
+               fd = open(path_stderr, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, 0666);
                if (fd == -1) {
                        exit(STATUS_NOCACHE);
                }
diff --git a/util.c b/util.c
index 6bab50d91007787730e052866fcd0a112603d578..27ddea56a8481ff85e35941ab7a37aa8839f0ed1 100644 (file)
--- a/util.c
+++ b/util.c
@@ -423,7 +423,7 @@ int create_empty_file(const char *fname)
 {
        int fd;
 
-       fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, 0644);
+       fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, 0666);
        if (fd == -1) {
                return -1;
        }
index f739ddbd268484e19c1a0b2957e694166708e7f6..9d0cd09b3163d49c547f7354ce7347a8fb0cb046 100644 (file)
@@ -116,7 +116,7 @@ treated as an input file name and instead be passed along to the
 compiler as a command line option.
 <p><h2>ENVIRONMENT VARIABLES</h2>
     
-<p>ccache used a number of environment variables to control operation. In
+<p>ccache uses a number of environment variables to control operation. In
 most cases you won't need any of these as the defaults will be fine.
 <p><dl>
 <p><p></p><dt><strong><strong>CCACHE_DIR</strong></strong><dd> the CCACHE_DIR environment variable specifies
@@ -161,6 +161,11 @@ file copy. Using hard links is faster, but can confuse programs like
 <p><p></p><dt><strong><strong>CCACHE_RECACHE</strong></strong><dd> This forces ccache to not use any cached
 results, even if it finds them. New results are still cached, but
 existing cache entries are ignored.
+<p><p></p><dt><strong><strong>CCACHE_UMASK</strong></strong><dd> This sets the umask for ccache and all child
+processes (such as the compiler). This is mostly useful when you wish
+to share your cache with other users. Note that this also affects the
+file permissions set on the object files created from your
+compilations.
 <p><p></p><dt><strong><strong>CCACHE_HASHDIR</strong></strong><dd> This tells ccache to hash the current working
 directory when calculating the hash that is used to distinguish two
 compiles. This prevents a problem with the storage of the current
@@ -241,8 +246,8 @@ following conditions need to be met:
   <li > Use the same <strong>CCACHE_DIR</strong> environment variable setting
   <li > Make sure that all users have write permission in the entire
   cache directory (and that you trust all users of the shared cache). 
-  <li > Tell your users to set a umask that allows group writes
-  (eg. umask 002)
+  <li > Make sure everyone sets the CCACHE_UMASK environment variable
+  to 002, this ensures that cached files are accessible to everyone.
   <li > Make sure that the setgid bit is set on all directories in the
   cache. This tells the filesystem to inherit group ownership for new
   directories. The command "chmod g+s `find $CCACHE_DIR -type d`" might