# # # add_file "tests/t_executable_umask.at" # content [7e16c020f9016f1adde56de73e7937d82923f22e] # # patch "ChangeLog" # from [ca91f12d7b8e996444ad8a930c93e4d6f1cb79db] # to [e22726da02a2fd8ba0df733f1e4ab4da183eee5c] # # patch "testsuite.at" # from [050da6d98d9f856078d7d0853e0cd9f6d5bc0600] # to [80b375d09f688706f03a3152abe47f7ad953fc6f] # # patch "unix/process.cc" # from [3a10d73ce7457e22b104777f87d29f8d5fdd2ea8] # to [7b082099d353d8d3d6418754c36964123cb6f4fd] # ============================================================ --- tests/t_executable_umask.at 7e16c020f9016f1adde56de73e7937d82923f22e +++ tests/t_executable_umask.at 7e16c020f9016f1adde56de73e7937d82923f22e @@ -0,0 +1,39 @@ +AT_SETUP([mtn:execute attr respects umask]) +MTN_SETUP + +NOT_ON_WIN32 + +# I don't know why this fails! When I set umask 077 and check out +# this tree by hand, it works fine; when I run this test, though, then +# for some reason the foo file is checked out with permission 600! +AT_XFAIL_IF(true) + +ADD_FILE(foo, [blah blah +]) +ADD_FILE(bar, [blah blah +]) +AT_CHECK(MTN attr set foo mtn:execute true) +COMMIT(testbranch) +R=`BASE_REVISION` + +umask 077 + +# log +AT_CHECK(umask, [], [ignore], [ignore]) +AT_CHECK(MTN co -r$R 077-co, [], [ignore], [ignore]) +AT_CHECK(stat -c '%a' 077-co/foo, [], [700 +]) +AT_CHECK(stat -c '%a' 077-co/bar, [], [600 +]) + +umask 577 + +# log +AT_CHECK(umask, [], [ignore], [ignore]) +AT_CHECK(MTN co -r$R 577-co, [], [ignore], [ignore]) +AT_CHECK(stat -c '%a' 577-co/foo, [], [200 +]) +AT_CHECK(stat -c '%a' 577-co/bar, [], [200 +]) + +AT_CLEANUP ============================================================ --- ChangeLog ca91f12d7b8e996444ad8a930c93e4d6f1cb79db +++ ChangeLog e22726da02a2fd8ba0df733f1e4ab4da183eee5c @@ -1,3 +1,10 @@ +2006-04-12 Nathaniel Smith + + * unix/process.cc (read_umask): New function. + (make_executable): Use it. + * tests/t_executable_umask.at, testsuite.at: New test. + XFAILed, because of totally mysterious failure! + 2006-04-11 Nathaniel Smith * UPGRADE: Add a note that all certs will be re-issued, and all ============================================================ --- testsuite.at 050da6d98d9f856078d7d0853e0cd9f6d5bc0600 +++ testsuite.at 80b375d09f688706f03a3152abe47f7ad953fc6f @@ -872,3 +872,4 @@ m4_include(tests/t_pidfile.at) m4_include(tests/t_rosterify_empty_manifest.at) m4_include(tests/t_netsync_no_include.at) +m4_include(tests/t_executable_umask.at) ============================================================ --- unix/process.cc 3a10d73ce7457e22b104777f87d29f8d5fdd2ea8 +++ unix/process.cc 7b082099d353d8d3d6418754c36964123cb6f4fd @@ -55,6 +55,15 @@ return (s.st_mode & S_IXUSR) && !(s.st_mode & S_IFDIR); } +// copied from libc info page +static mode_t +read_umask() +{ + mode_t mask = umask(0); + umask(mask); + return mask; +} + int make_executable(const char *path) { mode_t mode; @@ -64,7 +73,7 @@ if (fstat(fd, &s)) return -1; mode = s.st_mode; - mode |= S_IXUSR|S_IXGRP|S_IXOTH; + mode |= ((S_IXUSR|S_IXGRP|S_IXOTH) & ~read_umask()); int ret = fchmod(fd, mode); N(close(fd) == 0, F("error closing file %s: %s") % path % strerror(errno)); return ret;