Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 14 Apr 2019 08:19:22 -0700
From:      Adrian Chadd <adrian.chadd@gmail.com>
To:        Mariusz Zaborski <oshogbo@freebsd.org>
Cc:        src-committers <src-committers@freebsd.org>, svn-src-all@freebsd.org,  svn-src-head@freebsd.org
Subject:   Re: svn commit: r345875 - in head: contrib/elftoolchain/strings usr.bin/strings
Message-ID:  <CAJ-Vmon=bjqSHP0c2LQ6gUAQeLfA=XkQCDsXQvCRiCORTYOUpg@mail.gmail.com>
In-Reply-To: <201904041632.x34GWR4Z006164@repo.freebsd.org>
References:  <201904041632.x34GWR4Z006164@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
This exposed a fun bug - gcc mips 6.4.0 complains about an unused arg (fa)
in fileargs_fopen() in the strings change when you compile without casper
support. I do that on mips.

I have a local change that converts the #define to an inline function so
the unused arg can be (void)'ed away. Mind if I commit it?



-adrian

On Thu, 4 Apr 2019 at 09:32, Mariusz Zaborski <oshogbo@freebsd.org> wrote:

> Author: oshogbo
> Date: Thu Apr  4 16:32:27 2019
> New Revision: 345875
> URL: https://svnweb.freebsd.org/changeset/base/345875
>
> Log:
>   strings: capsicumize it
>
>   Reviewed by:  cem
>   Discussed with: emaste
>   Differential Revision:        https://reviews.freebsd.org/D18038
>
> Modified:
>   head/contrib/elftoolchain/strings/strings.c
>   head/usr.bin/strings/Makefile
>
> Modified: head/contrib/elftoolchain/strings/strings.c
>
> ==============================================================================
> --- head/contrib/elftoolchain/strings/strings.c Thu Apr  4 12:02:48 2019
>       (r345874)
> +++ head/contrib/elftoolchain/strings/strings.c Thu Apr  4 16:32:27 2019
>       (r345875)
> @@ -25,8 +25,10 @@
>   */
>
>  #include <sys/types.h>
> +#include <sys/capsicum.h>
>  #include <sys/stat.h>
>
> +#include <capsicum_helpers.h>
>  #include <ctype.h>
>  #include <err.h>
>  #include <errno.h>
> @@ -44,6 +46,9 @@
>  #include <libelftc.h>
>  #include <gelf.h>
>
> +#include <libcasper.h>
> +#include <casper/cap_fileargs.h>
> +
>  #include "_elftc.h"
>
>  ELFTC_VCSID("$Id: strings.c 3648 2018-11-22 23:26:43Z emaste $");
> @@ -85,7 +90,7 @@ static struct option strings_longopts[] = {
>  };
>
>  int    getcharacter(FILE *, long *);
> -int    handle_file(const char *);
> +int    handle_file(fileargs_t *fa, const char *);
>  int    handle_elf(const char *, FILE *);
>  int    handle_binary(const char *, FILE *, size_t);
>  int    find_strings(const char *, FILE *, off_t, off_t);
> @@ -99,6 +104,8 @@ void usage(void);
>  int
>  main(int argc, char **argv)
>  {
> +       fileargs_t *fa;
> +       cap_rights_t rights;
>         int ch, rc;
>
>         rc = 0;
> @@ -187,27 +194,41 @@ main(int argc, char **argv)
>         argc -= optind;
>         argv += optind;
>
> +       cap_rights_init(&rights, CAP_READ, CAP_SEEK, CAP_FSTAT, CAP_FCNTL);
> +       fa = fileargs_init(argc, argv, O_RDONLY, 0, &rights);
> +       if (fa == NULL)
> +               err(1, "Unable to initialize casper fileargs");
> +
> +       caph_cache_catpages();
> +       if (caph_limit_stdio() < 0 && caph_enter_casper() < 0) {
> +               fileargs_free(fa);
> +               err(1, "Unable to enter capability mode");
> +       }
> +
>         if (min_len == 0)
>                 min_len = 4;
>         if (*argv == NULL)
>                 rc = find_strings("{standard input}", stdin, 0, 0);
>         else while (*argv != NULL) {
> -               if (handle_file(*argv) != 0)
> +               if (handle_file(fa, *argv) != 0)
>                         rc = 1;
>                 argv++;
>         }
> +
> +       fileargs_free(fa);
> +
>         return (rc);
>  }
>
>  int
> -handle_file(const char *name)
> +handle_file(fileargs_t *fa, const char *name)
>  {
>         FILE *pfile;
>         int rt;
>
>         if (name == NULL)
>                 return (1);
> -       pfile = fopen(name, "rb");
> +       pfile = fileargs_fopen(fa, name, "rb");
>         if (pfile == NULL) {
>                 warnx("'%s': %s", name, strerror(errno));
>                 return (1);
>
> Modified: head/usr.bin/strings/Makefile
>
> ==============================================================================
> --- head/usr.bin/strings/Makefile       Thu Apr  4 12:02:48 2019
> (r345874)
> +++ head/usr.bin/strings/Makefile       Thu Apr  4 16:32:27 2019
> (r345875)
> @@ -10,6 +10,12 @@ PROG=        strings
>
>  LIBADD=        elftc elf
>
> +.if ${MK_CASPER} != "no" && !defined(BOOTSTRAPPING)
> +LIBADD+=       casper
> +LIBADD+=       cap_fileargs
> +CFLAGS+=       -DWITH_CASPER
> +.endif
> +
>  CFLAGS+=-I${ELFTCDIR}/libelftc -I${ELFTCDIR}/common
>
>  .include <bsd.prog.mk>
>
>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAJ-Vmon=bjqSHP0c2LQ6gUAQeLfA=XkQCDsXQvCRiCORTYOUpg>