Date: Sun, 18 Sep 2016 18:49:18 +0000 (UTC) From: Baptiste Daroussin <bapt@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r305948 - head/usr.bin/soelim Message-ID: <201609181849.u8IInIpD051194@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: bapt Date: Sun Sep 18 18:49:18 2016 New Revision: 305948 URL: https://svnweb.freebsd.org/changeset/base/305948 Log: Fix building as bootstrap tools on pre-capsicum.h systems Modified: head/usr.bin/soelim/soelim.c Modified: head/usr.bin/soelim/soelim.c ============================================================================== --- head/usr.bin/soelim/soelim.c Sun Sep 18 18:40:27 2016 (r305947) +++ head/usr.bin/soelim/soelim.c Sun Sep 18 18:49:18 2016 (r305948) @@ -27,7 +27,10 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <sys/param.h> +#if __FreeBSD_version > 1001510 #include <sys/capsicum.h> +#endif #include <sys/types.h> #include <ctype.h> @@ -159,9 +162,11 @@ main(int argc, char **argv) int ch, i, rootfd; int ret = 0; int flags = 0; - unsigned long cmd; char cwd[MAXPATHLEN]; +#if __FreeBSD_version > 1001510 + unsigned long cmd; cap_rights_t rights; +#endif includes = sl_init(); if (getcwd(cwd, sizeof(cwd)) != NULL) @@ -192,6 +197,10 @@ main(int argc, char **argv) argc -= optind; argv += optind; + rootfd = open("/", O_DIRECTORY | O_RDONLY); + if (rootfd == -1) + err(EXIT_FAILURE, "unable to open '/'"); +#if __FreeBSD_version > 1001510 cap_rights_init(&rights, CAP_READ, CAP_FSTAT, CAP_IOCTL); /* * EBADF in case stdin is closed by the caller @@ -204,9 +213,6 @@ main(int argc, char **argv) err(EXIT_FAILURE, "unable to limit rights for stdout"); if (cap_rights_limit(STDERR_FILENO, &rights) < 0 && errno != ENOSYS) err(EXIT_FAILURE, "unable to limit rights for stderr"); - rootfd = open("/", O_DIRECTORY | O_RDONLY); - if (rootfd == -1) - err(EXIT_FAILURE, "unable to open '/'"); cap_rights_init(&rights, CAP_READ, CAP_LOOKUP, CAP_FSTAT, CAP_FCNTL); if (cap_rights_limit(rootfd, &rights) < 0 && errno != ENOSYS) err(EXIT_FAILURE, "unable to limit rights"); @@ -221,6 +227,7 @@ main(int argc, char **argv) if (cap_enter() < 0 && errno != ENOSYS) err(EXIT_FAILURE, "unable to enter capability mode"); +#endif if (argc == 0) ret = soelim_file(rootfd, stdin, flags);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201609181849.u8IInIpD051194>