e822c92d256929cea7fc16805731c24ee8d30a83
chmalee
  Thu Mar 7 14:35:04 2024 -0800
Reset umask when making a per-user directory so apache can delete files later. This is likely only to be a problem during testing where apache doesn't already own the directories/files

diff --git src/hg/hgHubConnect/hooks/post-finish.c src/hg/hgHubConnect/hooks/post-finish.c
index 101abca..f704b47 100644
--- src/hg/hgHubConnect/hooks/post-finish.c
+++ src/hg/hgHubConnect/hooks/post-finish.c
@@ -99,34 +99,39 @@
                 {
                 char *tusInfo = catTwoStrings(tusFile, ".info");
                 char *dataDir = getDataDir(userName);
                 char *newFile = catTwoStrings(dataDir, uploadFname);
                 fprintf(stderr, "moving %s to %s\n", tusFile, newFile);
                 // TODO: check if file exists or not and let user choose to overwrite
                 // and re-call this hook, for now just exit if the file exists
                 if (fileExists(newFile))
                     {
                     rejectUpload(response, "file '%s' exists already, not overwriting");
                     exitStatus = 1;
                     }
                 else
                     {
                     // the directory may not exist yet
+                    int oldUmask = 00;
                     if (!isDirectory(dataDir))
                         {
                         fprintf(stderr, "making directory '%s'\n", dataDir);
+                        // the directory needs to be 777, so ignore umask for now
+                        oldUmask = umask(0);
                         makeDirsOnPath(dataDir);
+                        // restore umask
+                        umask(oldUmask);
                         }
                     copyFile(tusFile, newFile);
                     // the files definitely should not be executable!
                     chmod(newFile, 0666);
                     mustRemove(tusFile);
                     mustRemove(tusInfo);
                     }
                 }
             }
 
         // we've passed all the checks so we can return that we are safe
         if (exitStatus == 0)
             fillOutHttpResponseSuccess(response);
         }
     if (errCatch->gotError)