* [PATCH] Fix git init --shared=all on FreeBSD 4.11 @ 2008-03-03 23:44 Alex Riesen 2008-03-04 0:31 ` Junio C Hamano 0 siblings, 1 reply; 10+ messages in thread From: Alex Riesen @ 2008-03-03 23:44 UTC (permalink / raw) To: git; +Cc: Junio C Hamano At least FreeBSD 4.11p2 does not allow changing SUID/GUID bits to a non-root user. Signed-off-by: Alex Riesen <raa.lkml@gmail.com> --- I seem to get really weird systems lately... path.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/path.c b/path.c index af27161..4865e98 100644 --- a/path.c +++ b/path.c @@ -265,6 +265,7 @@ int adjust_shared_perm(const char *path) return 0; if (lstat(path, &st) < 0) return -1; + st.st_mode &= 07777 & ~(S_ISUID|S_ISGID); mode = st.st_mode; if (mode & S_IRUSR) mode |= (shared_repository == PERM_GROUP -- 1.5.4.3.469.gf84e2 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] Fix git init --shared=all on FreeBSD 4.11 2008-03-03 23:44 [PATCH] Fix git init --shared=all on FreeBSD 4.11 Alex Riesen @ 2008-03-04 0:31 ` Junio C Hamano 2008-03-04 7:25 ` Alex Riesen 0 siblings, 1 reply; 10+ messages in thread From: Junio C Hamano @ 2008-03-04 0:31 UTC (permalink / raw) To: Alex Riesen; +Cc: git Alex Riesen <raa.lkml@gmail.com> writes: > At least FreeBSD 4.11p2 does not allow changing SUID/GUID bits to > a non-root user. Sorry, but I do not understand this change. > diff --git a/path.c b/path.c > index af27161..4865e98 100644 > --- a/path.c > +++ b/path.c > @@ -265,6 +265,7 @@ int adjust_shared_perm(const char *path) > return 0; > if (lstat(path, &st) < 0) > return -1; > + st.st_mode &= 07777 & ~(S_ISUID|S_ISGID); > mode = st.st_mode; If the thing is a directory, we say later in the code that we want to see S_ISGID set, like this: ... if (S_ISDIR(mode)) mode |= S_ISGID; if ((mode & st.st_mode) != mode && chmod(path, mode) < 0) return -2; return 0; and then we compare with st.st_mode so that we do not chmod() what's already good Your change means we will always try to chmod all the directories, and your explanation suggests that such a chmod to do g+s on directories would also fail (and your patch does not fix it -- we actively try to make sure directories have g+s set). Side note. the wording in your message, "does not allow changing", is very unclear. Do you mean "non-root cannot do u+s,g+s"? Or do you mean "non-root cannot do u+s,g+s, non-root cannot do u-s,g-s either"? For regular files, I do not think we have any reason to set u+s or g+s ourselves, and we do not try to do so either. As long as the original st.st_mode does not have such bits set, the mode we will pass to chmod for regular would not try to set them. If you already had u+s,g+s when you read st.st_mode that's a different story, but then I do not know why you had such a file to begin with. I do not mind a change to make sure we do u-s,g-s on regular files, but I do not think it is necessary, and I am curious why you had files with such perm bits to begin with. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Fix git init --shared=all on FreeBSD 4.11 2008-03-04 0:31 ` Junio C Hamano @ 2008-03-04 7:25 ` Alex Riesen 2008-03-04 8:08 ` Junio C Hamano 0 siblings, 1 reply; 10+ messages in thread From: Alex Riesen @ 2008-03-04 7:25 UTC (permalink / raw) To: Junio C Hamano; +Cc: git Junio C Hamano, Tue, Mar 04, 2008 01:31:12 +0100: > Alex Riesen <raa.lkml@gmail.com> writes: > > > At least FreeBSD 4.11p2 does not allow changing SUID/GUID bits to > > a non-root user. > > Sorry, but I do not understand this change. > Now that I look at it again, I admint I don't understand what I was thinking either. I see the problem in t1301-shared-repo.sh: it fails to chmod(042775, ".git/refs") with EPERM. Will re-investigate. > > diff --git a/path.c b/path.c > > index af27161..4865e98 100644 > > --- a/path.c > > +++ b/path.c > > @@ -265,6 +265,7 @@ int adjust_shared_perm(const char *path) > > return 0; > > if (lstat(path, &st) < 0) > > return -1; > > + st.st_mode &= 07777 & ~(S_ISUID|S_ISGID); > > mode = st.st_mode; > > If the thing is a directory, we say later in the code that we want to see > S_ISGID set, like this: > > ... > if (S_ISDIR(mode)) > mode |= S_ISGID; > if ((mode & st.st_mode) != mode && chmod(path, mode) < 0) > return -2; > return 0; > > and then we compare with st.st_mode so that we do not chmod() what's > already good Your change means we will always try to chmod all the > directories, and your explanation suggests that such a chmod to do g+s on > directories would also fail (and your patch does not fix it -- we actively > try to make sure directories have g+s set). The change is very bogus. Dunno how it happened... > Side note. the wording in your message, "does not allow changing", > is very unclear. Do you mean "non-root cannot do u+s,g+s"? Or do > you mean "non-root cannot do u+s,g+s, non-root cannot do u-s,g-s > either"? chmod(2), as it was, just fails. It seemed like the ordinary users could not do g+s (which is what the function is actually supposed to do). > I do not mind a change to make sure we do u-s,g-s on regular files, but I > do not think it is necessary, and I am curious why you had files with such > perm bits to begin with. It is a directory. The bit 02000 is S_ISGID on FreeBSD too. It just does not work (now I am just observing, no coding). ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Fix git init --shared=all on FreeBSD 4.11 2008-03-04 7:25 ` Alex Riesen @ 2008-03-04 8:08 ` Junio C Hamano 2008-03-04 20:20 ` [PATCH] Do not use GUID on dir in git init --shared=all on FreeBSD 4.11p2 Alex Riesen 0 siblings, 1 reply; 10+ messages in thread From: Junio C Hamano @ 2008-03-04 8:08 UTC (permalink / raw) To: Alex Riesen; +Cc: git Alex Riesen <raa.lkml@gmail.com> writes: > It is a directory. The bit 02000 is S_ISGID on FreeBSD too. It just > does not work (now I am just observing, no coding). IIRC, g+s on directory to make group ownership inherited was a SysVism; BSD did not need that as it did the sane thing by default without g+s. Perhaps we should make it conditional. ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH] Do not use GUID on dir in git init --shared=all on FreeBSD 4.11p2 2008-03-04 8:08 ` Junio C Hamano @ 2008-03-04 20:20 ` Alex Riesen 2008-03-04 20:44 ` Junio C Hamano 2008-03-04 20:50 ` [PATCH] Do not use GUID on dir in git init --shared=all on FreeBSD 4.11p2 Johannes Schindelin 0 siblings, 2 replies; 10+ messages in thread From: Alex Riesen @ 2008-03-04 20:20 UTC (permalink / raw) To: Junio C Hamano; +Cc: git It does not allow changing the bit to a non-root user. This fixes t1301-shared-repo.sh on the platform. Signed-off-by: Alex Riesen <raa.lkml@gmail.com> --- Junio C Hamano, Tue, Mar 04, 2008 09:08:24 +0100: > Alex Riesen <raa.lkml@gmail.com> writes: > > > It is a directory. The bit 02000 is S_ISGID on FreeBSD too. It just > > does not work (now I am just observing, no coding). > > IIRC, g+s on directory to make group ownership inherited was a SysVism; > BSD did not need that as it did the sane thing by default without g+s. > > Perhaps we should make it conditional. > Perhaps like this (FreeBSD 4 and older). Can someone try the change on the later versions? path.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/path.c b/path.c index af27161..6f09ba2 100644 --- a/path.c +++ b/path.c @@ -282,8 +282,10 @@ int adjust_shared_perm(const char *path) : (shared_repository == PERM_EVERYBODY ? (S_IXGRP|S_IXOTH) : 0)); +#if !defined(__FreeBSD__) || (__FreeBSD__ > 4) if (S_ISDIR(mode)) mode |= S_ISGID; +#endif if ((mode & st.st_mode) != mode && chmod(path, mode) < 0) return -2; return 0; -- 1.5.4.3.469.gf84e2 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] Do not use GUID on dir in git init --shared=all on FreeBSD 4.11p2 2008-03-04 20:20 ` [PATCH] Do not use GUID on dir in git init --shared=all on FreeBSD 4.11p2 Alex Riesen @ 2008-03-04 20:44 ` Junio C Hamano 2008-03-04 21:46 ` Alex Riesen 2008-03-04 23:15 ` [PATCH] Do not use GUID on dir in git init --shared=all on FreeBSD Alex Riesen 2008-03-04 20:50 ` [PATCH] Do not use GUID on dir in git init --shared=all on FreeBSD 4.11p2 Johannes Schindelin 1 sibling, 2 replies; 10+ messages in thread From: Junio C Hamano @ 2008-03-04 20:44 UTC (permalink / raw) To: Alex Riesen; +Cc: git Alex Riesen <raa.lkml@gmail.com> writes: > It does not allow changing the bit to a non-root user. > This fixes t1301-shared-repo.sh on the platform. ... > diff --git a/path.c b/path.c > index af27161..6f09ba2 100644 > --- a/path.c > +++ b/path.c > @@ -282,8 +282,10 @@ int adjust_shared_perm(const char *path) > : (shared_repository == PERM_EVERYBODY > ? (S_IXGRP|S_IXOTH) > : 0)); > +#if !defined(__FreeBSD__) || (__FreeBSD__ > 4) > if (S_ISDIR(mode)) > mode |= S_ISGID; > +#endif As usual, please do something like (1) In git-compat-util.h #ifndef MKDIR_HAS_BSD_GROUP_SEMANTICS #define FORCE_BSD_GROUP_SEMANTICS S_ISGID #else #define FORCE_BSD_GROUP_SEMANTICS 0 #endif (2) In Makefile (and configure.in perhaps) ifeq ($(uname_S),FreeBSD) MKDIR_HAS_BSD_GROUP_SEMANTICS = YesPlease endif ... ifdef MKDIR_HAS_BSD_GROUP_SEMANTICS COMPAT_CFLAGS += -DMKDIR_HAS_BSD_GROUP_SEMANTICS endif (3) In the above codepath: if (S_ISDIR(mode)) mode |= FORCE_BSD_GROUP_SEMANTICS; or something. Avoid #if directly based on platform names in *.c files. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Do not use GUID on dir in git init --shared=all on FreeBSD 4.11p2 2008-03-04 20:44 ` Junio C Hamano @ 2008-03-04 21:46 ` Alex Riesen 2008-03-04 23:15 ` [PATCH] Do not use GUID on dir in git init --shared=all on FreeBSD Alex Riesen 1 sibling, 0 replies; 10+ messages in thread From: Alex Riesen @ 2008-03-04 21:46 UTC (permalink / raw) To: Junio C Hamano; +Cc: git Junio C Hamano, Tue, Mar 04, 2008 21:44:29 +0100: > Alex Riesen <raa.lkml@gmail.com> writes: > > > It does not allow changing the bit to a non-root user. > > This fixes t1301-shared-repo.sh on the platform. > > ... > > > diff --git a/path.c b/path.c > > index af27161..6f09ba2 100644 > > --- a/path.c > > +++ b/path.c > > @@ -282,8 +282,10 @@ int adjust_shared_perm(const char *path) > > : (shared_repository == PERM_EVERYBODY > > ? (S_IXGRP|S_IXOTH) > > : 0)); > > +#if !defined(__FreeBSD__) || (__FreeBSD__ > 4) > > if (S_ISDIR(mode)) > > mode |= S_ISGID; > > +#endif > > As usual, please do something like > Right. Will do. ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH] Do not use GUID on dir in git init --shared=all on FreeBSD 2008-03-04 20:44 ` Junio C Hamano 2008-03-04 21:46 ` Alex Riesen @ 2008-03-04 23:15 ` Alex Riesen 1 sibling, 0 replies; 10+ messages in thread From: Alex Riesen @ 2008-03-04 23:15 UTC (permalink / raw) To: Junio C Hamano; +Cc: git It does not allow changing the bit to a non-root user. This fixes t1301-shared-repo.sh on the platform. Signed-off-by: Alex Riesen <raa.lkml@gmail.com> --- Junio C Hamano, Tue, Mar 04, 2008 21:44:29 +0100: > (2) In Makefile (and configure.in perhaps) Just the configure.ac is a bit too much for today. > ifeq ($(uname_S),FreeBSD) > MKDIR_HAS_BSD_GROUP_SEMANTICS = YesPlease > endif > ... > ifdef MKDIR_HAS_BSD_GROUP_SEMANTICS > COMPAT_CFLAGS += -DMKDIR_HAS_BSD_GROUP_SEMANTICS > endif I tweaked the names a bit. Makefile | 4 ++++ git-compat-util.h | 6 ++++++ path.c | 2 +- 3 files changed, 11 insertions(+), 1 deletions(-) diff --git a/Makefile b/Makefile index ca5aad9..6e857e6 100644 --- a/Makefile +++ b/Makefile @@ -478,6 +478,7 @@ ifeq ($(uname_S),FreeBSD) NO_MEMMEM = YesPlease BASIC_CFLAGS += -I/usr/local/include BASIC_LDFLAGS += -L/usr/local/lib + DIR_HAS_BSD_GROUP_SEMANTICS = YesPlease endif ifeq ($(uname_S),OpenBSD) NO_STRCASESTR = YesPlease @@ -747,6 +748,9 @@ ifdef THREADED_DELTA_SEARCH EXTLIBS += -lpthread LIB_OBJS += thread-utils.o endif +ifdef DIR_HAS_BSD_GROUP_SEMANTICS + COMPAT_CFLAGS += -DDIR_HAS_BSD_GROUP_SEMANTICS +endif ifeq ($(TCLTK_PATH),) NO_TCLTK=NoThanks diff --git a/git-compat-util.h b/git-compat-util.h index 2a40703..5912443 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -437,4 +437,10 @@ void git_qsort(void *base, size_t nmemb, size_t size, #define qsort git_qsort #endif +#ifndef DIR_HAS_BSD_GROUP_SEMANTICS +# define FORCE_DIR_SET_GID S_ISGID +#else +# define FORCE_DIR_SET_GID 0 +#endif + #endif diff --git a/path.c b/path.c index af27161..f4ed979 100644 --- a/path.c +++ b/path.c @@ -283,7 +283,7 @@ int adjust_shared_perm(const char *path) ? (S_IXGRP|S_IXOTH) : 0)); if (S_ISDIR(mode)) - mode |= S_ISGID; + mode |= FORCE_DIR_SET_GID; if ((mode & st.st_mode) != mode && chmod(path, mode) < 0) return -2; return 0; -- 1.5.4.3.272.gf0c3 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] Do not use GUID on dir in git init --shared=all on FreeBSD 4.11p2 2008-03-04 20:20 ` [PATCH] Do not use GUID on dir in git init --shared=all on FreeBSD 4.11p2 Alex Riesen 2008-03-04 20:44 ` Junio C Hamano @ 2008-03-04 20:50 ` Johannes Schindelin 2008-03-04 21:46 ` Alex Riesen 1 sibling, 1 reply; 10+ messages in thread From: Johannes Schindelin @ 2008-03-04 20:50 UTC (permalink / raw) To: Alex Riesen; +Cc: Junio C Hamano, git Hi, On Tue, 4 Mar 2008, Alex Riesen wrote: > +#if !defined(__FreeBSD__) || (__FreeBSD__ > 4) We are not avoiding to clutter the source code with ugly __MINGW32__ conditionals with a huge effort, so that you can clutter it with __FreeBSD__ conditionals. > if (S_ISDIR(mode)) > mode |= S_ISGID; What problem does FreeBSD < 4 have with that? Ciao, Dscho ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Do not use GUID on dir in git init --shared=all on FreeBSD 4.11p2 2008-03-04 20:50 ` [PATCH] Do not use GUID on dir in git init --shared=all on FreeBSD 4.11p2 Johannes Schindelin @ 2008-03-04 21:46 ` Alex Riesen 0 siblings, 0 replies; 10+ messages in thread From: Alex Riesen @ 2008-03-04 21:46 UTC (permalink / raw) To: Johannes Schindelin; +Cc: Junio C Hamano, git Johannes Schindelin, Tue, Mar 04, 2008 21:50:34 +0100: > Hi, > > On Tue, 4 Mar 2008, Alex Riesen wrote: > > > +#if !defined(__FreeBSD__) || (__FreeBSD__ > 4) > > We are not avoiding to clutter the source code with ugly __MINGW32__ > conditionals with a huge effort, so that you can clutter it with > __FreeBSD__ conditionals. > Will fix. > > if (S_ISDIR(mode)) > > mode |= S_ISGID; > > What problem does FreeBSD < 4 have with that? > No idea. ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2008-03-04 23:48 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-03-03 23:44 [PATCH] Fix git init --shared=all on FreeBSD 4.11 Alex Riesen 2008-03-04 0:31 ` Junio C Hamano 2008-03-04 7:25 ` Alex Riesen 2008-03-04 8:08 ` Junio C Hamano 2008-03-04 20:20 ` [PATCH] Do not use GUID on dir in git init --shared=all on FreeBSD 4.11p2 Alex Riesen 2008-03-04 20:44 ` Junio C Hamano 2008-03-04 21:46 ` Alex Riesen 2008-03-04 23:15 ` [PATCH] Do not use GUID on dir in git init --shared=all on FreeBSD Alex Riesen 2008-03-04 20:50 ` [PATCH] Do not use GUID on dir in git init --shared=all on FreeBSD 4.11p2 Johannes Schindelin 2008-03-04 21:46 ` Alex Riesen
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).