On Fri, Sep 30, 2011 at 2:53 PM, Jeff Johnson <n3npq....@gmail.com> wrote:

> Umm … whatever.
>
> I don't mind living with this patch: but the precedent (if continued) will
> force
> umask(2) wrapping of every system call that sets a file mode, and also
> for library functions like mkstemp(3), if consistently applied everywhere.
>
> No. It is only for function as mkstemp for now
https://buildsecurityin.us-cert.gov/bsi/articles/knowledge/coding/781-BSI.html
Thanks
Best Regards


> That end-point -- controlling for umask(2) side-effects everywhere --
> isn't the best approach to setting file modes deterministically in
> order to meet expectations.
>
> There are surely library calls that exist that need both +umask and -umask
> because more than one file mode needs to be set.
>
> hth
>
> 73 de Jeff
>
> On Sep 30, 2011, at 8:43 AM, Pinto Elia wrote:
>
> >  RPM Package Manager, CVS Repository
> >  http://rpm5.org/cvs/
> >
>  ____________________________________________________________________________
> >
> >  Server: rpm5.org                         Name:   Pinto Elia
> >  Root:   /v/rpm/cvs                       Email:  devzero2...@rpm5.org
> >  Module: rpm                              Date:   30-Sep-2011 14:43:35
> >  Branch: rpm-5_4                          Handle: 2011093012433202
> >
> >  Modified files:           (Branch: rpm-5_4)
> >    rpm                     CHANGES
> >    rpm/lib                 rpmchecksig.c
> >    rpm/rpmio               macro.c
> >
> >  Log:
> >    call umask before mkstemp.
> >
> >    The mkstemp() function generates a unique temporary file name from the
> supplied template,
> >    opens a file of that name using the O_EXCL flag (guaranteeing the
> current process to be the only user)
> >    and returns a file descriptor.
> >
> >    The POSIX specification does not say anything about file modes, so the
> application should make sure its umask
> >    is set appropriately before calling mkstemp
> >    ( ref.
> https://buildsecurityin.us-cert.gov/bsi/articles/knowledge/coding/781-BSI.html
> )
> >
> >  Summary:
> >    Revision    Changes     Path
> >    1.3501.2.174+8  -0      rpm/CHANGES
> >    1.240.2.3   +3  -0      rpm/lib/rpmchecksig.c
> >    2.249.2.5   +3  -0      rpm/rpmio/macro.c
> >
>  ____________________________________________________________________________
> >
> >  patch -p0 <<'@@ .'
> >  Index: rpm/CHANGES
> >
>  ============================================================================
> >  $ cvs diff -u -r1.3501.2.173 -r1.3501.2.174 CHANGES
> >  --- rpm/CHANGES      24 Sep 2011 19:36:10 -0000      1.3501.2.173
> >  +++ rpm/CHANGES      30 Sep 2011 12:43:32 -0000      1.3501.2.174
> >  @@ -1,4 +1,12 @@
> >   5.4.2 -> 5.4.3:
> >  +    - devzero2000: call umask before mkstemp.
> >  +      The mkstemp() function generates a unique temporary file name
> from the supplied template,
> >  +      opens a file of that name using the O_EXCL flag (guaranteeing the
> current process to be the only user)
> >  +      and returns a file descriptor.
> >  +
> >  +      The POSIX specification does not say anything about file modes,
> so the application should make sure its umask
> >  +      is set appropriately before calling mkstemp
> >  +      ( ref.
> https://buildsecurityin.us-cert.gov/bsi/articles/knowledge/coding/781-BSI.html
> )
> >       - jbj: js: port and compile against mosjs185 API. more todo++.
> >       - jbj: arm: add arm-peculier cpuinfo fields.
> >       - jbj: ruby: disable "make check" until -lpcreposix gets linked
> correctly.
> >  @@ .
> >  patch -p0 <<'@@ .'
> >  Index: rpm/lib/rpmchecksig.c
> >
>  ============================================================================
> >  $ cvs diff -u -r1.240.2.2 -r1.240.2.3 rpmchecksig.c
> >  --- rpm/lib/rpmchecksig.c    5 Sep 2011 23:00:28 -0000       1.240.2.2
> >  +++ rpm/lib/rpmchecksig.c    30 Sep 2011 12:43:33 -0000      1.240.2.3
> >  @@ -206,6 +206,7 @@
> >       rpmRC rpmrc = 0;
> >       int xx;
> >       int i;
> >  +    mode_t mode;
> >
> >       tmprpm[0] = '\0';
> >
> >  @@ -417,7 +418,9 @@
> >       (void) stpcpy( stpcpy(tmprpm, fn), ".XXXXXX");
> >
> >   #if defined(HAVE_MKSTEMP)
> >  +         mode = umask(0077);
> >       (void) close(mkstemp(tmprpm));
> >  +        (void) umask(mode);
> >   #else
> >       (void) mktemp(tmprpm);
> >   #endif
> >  @@ .
> >  patch -p0 <<'@@ .'
> >  Index: rpm/rpmio/macro.c
> >
>  ============================================================================
> >  $ cvs diff -u -r2.249.2.4 -r2.249.2.5 macro.c
> >  --- rpm/rpmio/macro.c        6 Sep 2011 15:03:54 -0000       2.249.2.4
> >  +++ rpm/rpmio/macro.c        30 Sep 2011 12:43:34 -0000      2.249.2.5
> >  @@ -1237,6 +1237,7 @@
> >       char * buf = alloca(bufn);
> >       char *b = NULL, *be;
> >       int c;
> >  +    mode_t mode;
> >
> >       buf[0] = '\0';
> >       if (g != NULL) {
> >  @@ -1370,7 +1371,9 @@
> >           be++;
> >   /*@=globs@*/
> >   #if defined(HAVE_MKSTEMP)
> >  +        mode = umask(0077);
> >       (void) close(mkstemp(b));
> >  +        (void) umask(mode);
> >   #else
> >       (void) mktemp(b);
> >   #endif
> >  @@ .
> > ______________________________________________________________________
> > RPM Package Manager                                    http://rpm5.org
> > CVS Sources Repository                                rpm-...@rpm5.org
>
> ______________________________________________________________________
> RPM Package Manager                                    http://rpm5.org
> Developer Communication List                        rpm-devel@rpm5.org
>

Reply via email to