On Mon, Mar 17, 2025 at 3:40 PM Michael Forney <mfor...@mforney.org> wrote:
>
> Tavian Barnes <taviana...@tavianator.com> wrote:
> > ---
> >  libutil/mode.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/libutil/mode.c b/libutil/mode.c
> > index b3632ad..2754be7 100644
> > --- a/libutil/mode.c
> > +++ b/libutil/mode.c
> > @@ -40,10 +40,10 @@ next:
> >                       who |= S_IRWXG|S_ISGID;
> >                       continue;
> >               case 'o':
> > -                     who |= S_IRWXO;
> > +                     who |= S_IRWXO|S_ISVTX;
> >                       continue;
> >               case 'a':
> > -                     who |= S_IRWXU|S_ISUID|S_IRWXG|S_ISGID|S_IRWXO;
> > +                     who |= 
> > S_IRWXU|S_ISUID|S_IRWXG|S_ISGID|S_IRWXO|S_ISVTX;
> >                       continue;
> >               }
> >               break;
>
> Thanks for catching this.
>
> POSIX says this on the matter:
>
> > The perm symbol t shall specify the S_ISVTX bit. When used with
> > a file of type directory, it can be used with the who symbol a,
> > or with no who symbol. It shall not be an error to specify a who
> > symbol of u, g, or o in conjunction with the perm symbol t, but
> > the meaning of these combinations is unspecified.
>
> So indeed a "who" of 'a' should include S_ISVTX.
>
> But it also says that o with t is unspecified. Can you give some
> context about the motivation for including S_ISVTX? Is it to match
> other existing implementations? Or maybe there is some common
> use-case for o+t?

Mainly for compatibility with coreutils.  It might make sense to apply
only the 'a' hunk of the patch if you want to stick to what's required
by POSIX.  For another data point, FreeBSD chmod ignores o+t.

Reply via email to