# # patch "ChangeLog" # from [1eba639ffcceec7eaae610233cc07cb1bc2c58db] # to [3e86aea4870157b3eef3ae4952d15da9f0b93c38] # # patch "unix/process.cc" # from [ac04438936f36fcf7a9eaeaffb60abd9f4dfe5d5] # to [16c179fb6b07c6587fb588a2a83a9d102406798b] # =============================================== --- ChangeLog 1eba639ffcceec7eaae610233cc07cb1bc2c58db +++ ChangeLog 3e86aea4870157b3eef3ae4952d15da9f0b93c38 @@ -1,3 +1,7 @@ +2005-08-03 graydon hoare + + * unix/process.cc (make_executable): Fix race, set user/group/other. + 2005-08-03 Matthew Gregan * botan/data_src.cpp (DataSource_Stream::DataSourceStream): Open =============================================== --- unix/process.cc ac04438936f36fcf7a9eaeaffb60abd9f4dfe5d5 +++ unix/process.cc 16c179fb6b07c6587fb588a2a83a9d102406798b @@ -8,6 +8,7 @@ #include #include #include +#include #include @@ -47,7 +48,7 @@ struct stat s; int rc = stat(path, &s); - N(rc != -1, F("stat() error on file %s)") % path); + N(rc != -1, F("stat() error on file %s") % path); return s.st_mode & S_IXUSR; } @@ -56,11 +57,15 @@ { mode_t mode; struct stat s; - if (stat(path, &s)) - return -1; + int fd = open(path, O_RDWR); + N(fd != -1, F("open() error on file %s") % path); + if (fstat(fd, &s)) + return -1; mode = s.st_mode; - mode |= S_IXUSR; - return chmod(path, mode); + mode |= S_IXUSR|S_IXGRP|S_IXOTH; + int ret = fchmod(fd, mode); + N(close(fd) == 0, F("close() error on file %s") % path); + return ret; } pid_t process_spawn(const char * const argv[])