From owner-svn-src-head@freebsd.org Sun Sep 18 18:49:19 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8F09CBDFFAA; Sun, 18 Sep 2016 18:49:19 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 45EE9B77; Sun, 18 Sep 2016 18:49:19 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u8IInIsW051195; Sun, 18 Sep 2016 18:49:18 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u8IInIpD051194; Sun, 18 Sep 2016 18:49:18 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201609181849.u8IInIpD051194@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sun, 18 Sep 2016 18:49:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r305948 - head/usr.bin/soelim X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Sep 2016 18:49:19 -0000 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 __FBSDID("$FreeBSD$"); +#include +#if __FreeBSD_version > 1001510 #include +#endif #include #include @@ -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);