Junio C Hamano <junkio@xxxxxxx> writes: > Johannes Schindelin <Johannes.Schindelin@xxxxxx> writes: > >>> but more importantly, if the directory in question was created by >>> somebody else, I do not think this chmod() would succeed even if you are >>> in the same group as the owner (i.e. previous creator) of the directory. >> >> But if somebody else created it, it should already have the correct >> permissions in the first place (unless the user played around with them, >> which is not a pilot error, but a willfull pointing of the barrel in the >> general direction of your knee). > > True; I think the yesterday's analysis is still incomplete. I > haven't reached the point where I can explain "is a directory". > If the directory was there and mkdir() failed (but we do not > check its return value), it would have set errno to EEXIST not > to EISDIR. There is something else going on. Actually, Florent's said the directory permission was screwed up to begin with, so after following the code a bit more I can see why it said "is a directory". mkdir() may have failed because somebody else had a directory there, perhaps with wrong permission; link_temp_to_file() correctly fails from adjust_shared_perm() (because the directory had incorrect permission that it cannot fix), returns -2 with truncated filename "object/2d", back to move_temp_to_file(), and -2 is not EEXIST so it tries to rename the temporary file to that directory, which would also fail and sets ret to errno (which now is EISDIR). After unlinking the temporary file, we notice that ret is EISDIR and reports the failure. So there is not much more to explain, other than why mkdir() failed in the first place. Previous driver error? I think idempotent chmod() on somebody else's file or directory would fail, so this may be a safer addition to the codepath in question. diff --git a/path.c b/path.c index bb89fb0..b82f194 100644 --- a/path.c +++ b/path.c @@ -279,7 +279,7 @@ int adjust_shared_perm(const char *path) : 0)); if (S_ISDIR(mode)) mode |= S_ISGID; - if (chmod(path, mode) < 0) + if (mode != st.st_mode && chmod(path, mode) < 0) return -2; return 0; } - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html