diff options
Diffstat (limited to 'contrib/cvs/src/filesubr.c')
-rw-r--r-- | contrib/cvs/src/filesubr.c | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/contrib/cvs/src/filesubr.c b/contrib/cvs/src/filesubr.c index 71df566..b5121a7 100644 --- a/contrib/cvs/src/filesubr.c +++ b/contrib/cvs/src/filesubr.c @@ -287,7 +287,8 @@ mkdir_if_needed (name) { if (mkdir (name, 0777) < 0) { - if (errno != EEXIST) + if (!(errno == EEXIST + || (errno == EACCES && isdir (name)))) error (1, errno, "cannot make directory %s", name); return 1; } @@ -416,13 +417,16 @@ int unlink_file_dir (f) const char *f; { - if (trace) + if (trace #ifdef SERVER_SUPPORT - (void) fprintf (stderr, "%c-> unlink_file_dir(%s)\n", - (server_active) ? 'S' : ' ', f); -#else - (void) fprintf (stderr, "-> unlink_file_dir(%s)\n", f); + /* This is called by the server parent process in contexts where + it is not OK to send output (e.g. after we sent "ok" to the + client). */ + && !server_active #endif + ) + (void) fprintf (stderr, "-> unlink_file_dir(%s)\n", f); + if (noexec) return (0); @@ -690,7 +694,26 @@ last_component (path) /* Return the home directory. Returns a pointer to storage managed by this function or its callees (currently getenv). This function will return the same thing every time it is - called. */ + called. Returns NULL if there is no home directory. + + Note that for a pserver server, this may return root's home + directory. What typically happens is that upon being started from + inetd, before switching users, the code in cvsrc.c calls + get_homedir which remembers root's home directory in the static + variable. Then the switch happens and get_homedir might return a + directory that we don't even have read or execute permissions for + (which is bad, when various parts of CVS try to read there). One + fix would be to make the value returned by get_homedir only good + until the next call (which would free the old value). Another fix + would be to just always malloc our answer, and let the caller free + it (that is best, because some day we may need to be reentrant). + + The workaround is to put -f in inetd.conf which means that + get_homedir won't get called until after the switch in user ID. + + The whole concept of a "home directory" on the server is pretty + iffy, although I suppose some people probably are relying on it for + .cvsrc and such, in the cases where it works. */ char * get_homedir () { |