[PATCH] posix: Fix return value of system if shell can not be executed [BZ #27053]

Florian Weimer fweimer@redhat.com
Fri Dec 11 19:56:37 GMT 2020


* Adhemerval Zanella via Libc-alpha:

> diff --git a/support/Makefile b/support/Makefile
> index f5f59bf8d2..c89b16bbcb 100644
> --- a/support/Makefile
> +++ b/support/Makefile
> @@ -90,6 +90,7 @@ libsupport-routines = \
>    xchroot \
>    xclock_gettime \
>    xclose \
> +  xchmod \
>    xconnect \
>    xcopy_file_range \
>    xdlfcn \
> diff --git a/support/xchmod.c b/support/xchmod.c
> new file mode 100644
> index 0000000000..5e403c7cc2
> --- /dev/null
> +++ b/support/xchmod.c
> @@ -0,0 +1,30 @@
> +/* chmod with error checking.
> +   Copyright (C) 2020 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <support/xunistd.h>
> +#include <support/check.h>
> +
> +#include <sys/stat.h>
> +
> +void
> +xchmod (const char *pathname, mode_t mode)
> +{
> +  int r = chmod (pathname, mode);
> +  if (r < 0)
> +    FAIL_EXIT1 ("chmod (%s, %d): %m", pathname, mode);

Please use 0%o.  Thanks. 8-)

> +}
> diff --git a/support/xunistd.h b/support/xunistd.h
> index b299db77ba..29b9a028b0 100644
> --- a/support/xunistd.h
> +++ b/support/xunistd.h
> @@ -45,6 +45,7 @@ long xsysconf (int name);
>  long long xlseek (int fd, long long offset, int whence);
>  void xftruncate (int fd, long long length);
>  void xsymlink (const char *target, const char *linkpath);
> +void xchmod (const char *pathname, mode_t mode);
>  
>  /* Equivalent of "mkdir -p".  */
>  void xmkdirp (const char *, mode_t);

Okay with the above change in a separate commit.

Florian
-- 
Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn,
Commercial register: Amtsgericht Muenchen, HRB 153243,
Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill



More information about the Libc-alpha mailing list