Skip to content

Commit

Permalink
Convert cap_enter() < 0 && errno != ENOSYS to caph_enter() < 0.
Browse files Browse the repository at this point in the history
No functional change intended.
  • Loading branch information
oshogbo committed Jun 19, 2018
1 parent 54c94ee commit 8acf9b1
Show file tree
Hide file tree
Showing 41 changed files with 55 additions and 50 deletions.
2 changes: 1 addition & 1 deletion bin/dd/dd.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ main(int argc __unused, char *argv[])
setup();

caph_cache_catpages();
if (cap_enter() == -1 && errno != ENOSYS)
if (caph_enter() < 0)
err(1, "unable to enter capability mode");

(void)signal(SIGINFO, siginfo_handler);
Expand Down
2 changes: 1 addition & 1 deletion bin/echo/echo.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ main(int argc, char *argv[])
char newline[] = "\n";
char *progname = argv[0];

if (caph_limit_stdio() < 0 || (cap_enter() < 0 && errno != ENOSYS))
if (caph_limit_stdio() < 0 || caph_enter() < 0)
err(1, "capsicum");

/* This utility may NOT do getopt(3) option parsing. */
Expand Down
2 changes: 1 addition & 1 deletion bin/sleep/sleep.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ main(int argc, char *argv[])
time_t original;
char buf[2];

if (caph_limit_stdio() < 0 || (cap_enter() < 0 && errno != ENOSYS))
if (caph_limit_stdio() < 0 || caph_enter() < 0)
err(1, "capsicum");

if (argc != 2)
Expand Down
2 changes: 1 addition & 1 deletion bin/uuidgen/uuidgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ main(int argc, char *argv[])
caph_cache_catpages();
if (caph_limit_stdio() < 0)
err(1, "Unable to limit stdio");
if (cap_enter() < 0 && errno != ENOSYS)
if (caph_enter() < 0)
err(1, "Unable to enter capability mode");

if (count == -1)
Expand Down
2 changes: 1 addition & 1 deletion contrib/dma/dma-mbox-create.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ main(int argc, char **argv)
err(EX_OSERR, "can't limit maildirfd rights");

/* Enter Capsicum capability sandbox */
if (cap_enter() < 0 && errno != ENOSYS)
if (caph_enter() < 0)
err(EX_OSERR, "cap_enter");
#endif

Expand Down
3 changes: 2 additions & 1 deletion sbin/decryptcore/decryptcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$");
#include <sys/wait.h>

#include <ctype.h>
#include <capsicum_helpers.h>
#include <fcntl.h>
#include <stdbool.h>
#include <stdlib.h>
Expand Down Expand Up @@ -167,7 +168,7 @@ decrypt(int ofd, const char *privkeyfile, const char *keyfile,
goto failed;
}

if (cap_enter() < 0 && errno != ENOSYS) {
if (caph_enter() < 0) {
pjdlog_errno(LOG_ERR, "Unable to enter capability mode");
goto failed;
}
Expand Down
4 changes: 3 additions & 1 deletion sbin/dhclient/dhclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ __FBSDID("$FreeBSD$");
#include <sys/capsicum.h>
#include <sys/endian.h>

#include <capsicum_helpers.h>

#include <net80211/ieee80211_freebsd.h>

#ifndef _PATH_VAREMPTY
Expand Down Expand Up @@ -539,7 +541,7 @@ main(int argc, char *argv[])

setproctitle("%s", ifi->name);

if (CASPER_SUPPORT && cap_enter() < 0 && errno != ENOSYS)
if (caph_enter_casper() < 0)
error("can't enter capability mode: %m");

if (immediate_daemon)
Expand Down
3 changes: 2 additions & 1 deletion sbin/dumpon/dumpon.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$");
#include <sys/sysctl.h>

#include <assert.h>
#include <capsicum_helpers.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
Expand Down Expand Up @@ -227,7 +228,7 @@ genkey(const char *pubkeyfile, struct diocskerneldump_arg *kdap)
if (fp == NULL)
err(1, "Unable to open %s", pubkeyfile);

if (cap_enter() < 0 && errno != ENOSYS)
if (caph_enter() < 0)
err(1, "Unable to enter capability mode");

pubkey = RSA_new();
Expand Down
6 changes: 2 additions & 4 deletions sbin/md5/md5.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,7 @@ main(int argc, char *argv[])
if (*(argv + 1) == NULL) {
cap_rights_init(&rights, CAP_READ);
if ((cap_rights_limit(fd, &rights) < 0 &&
errno != ENOSYS) ||
(cap_enter() < 0 && errno != ENOSYS))
errno != ENOSYS) || caph_enter() < 0)
err(1, "capsicum");
}
if ((p = Algorithm[digest].Fd(fd, buf)) == NULL) {
Expand All @@ -253,8 +252,7 @@ main(int argc, char *argv[])
}
} while (*++argv);
} else if (!sflag && (optind == 1 || qflag || rflag)) {
if (caph_limit_stdin() < 0 ||
(cap_enter() < 0 && errno != ENOSYS))
if (caph_limit_stdin() < 0 || caph_enter() < 0)
err(1, "capsicum");
MDFilter(&Algorithm[digest], 0);
}
Expand Down
2 changes: 1 addition & 1 deletion usr.bin/basename/basename.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ main(int argc, char **argv)

setlocale(LC_ALL, "");

if (caph_limit_stdio() < 0 || (cap_enter() < 0 && errno != ENOSYS))
if (caph_limit_stdio() < 0 || caph_enter() < 0)
err(1, "capsicum");

aflag = 0;
Expand Down
2 changes: 1 addition & 1 deletion usr.bin/cmp/cmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ main(int argc, char *argv[])

caph_cache_catpages();

if (cap_enter() < 0 && errno != ENOSYS)
if (caph_enter() < 0)
err(ERR_EXIT, "unable to enter capability mode");

if (!special) {
Expand Down
2 changes: 1 addition & 1 deletion usr.bin/col/col.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ main(int argc, char **argv)
if (caph_limit_stdio() == -1)
err(1, "unable to limit stdio");

if (cap_enter() < 0 && errno != ENOSYS)
if (caph_enter() < 0)
err(1, "unable to enter capability mode");

max_bufd_lines = 256;
Expand Down
2 changes: 1 addition & 1 deletion usr.bin/diff/diffreg.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ diffreg(char *file1, char *file2, int flags, int capsicum)

caph_cache_catpages();
caph_cache_tzdata();
if (cap_enter() < 0 && errno != ENOSYS)
if (caph_enter() < 0)
err(2, "unable to enter capability mode");
}

Expand Down
2 changes: 1 addition & 1 deletion usr.bin/diff3/diff3.c
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ main(int argc, char **argv)
nleft++;

caph_cache_catpages();
if (cap_enter() < 0 && errno != ENOSYS)
if (caph_enter() < 0)
err(2, "unable to enter capability mode");

/* parse diffs */
Expand Down
2 changes: 1 addition & 1 deletion usr.bin/dirname/dirname.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ main(int argc, char **argv)
char *p;
int ch;

if (caph_limit_stdio() < 0 || (cap_enter() < 0 && errno != ENOSYS))
if (caph_limit_stdio() < 0 || caph_enter() < 0)
err(1, "capsicum");

while ((ch = getopt(argc, argv, "")) != -1)
Expand Down
2 changes: 1 addition & 1 deletion usr.bin/elfdump/elfdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ main(int ac, char **av)
caph_limit_stdout() < 0 || caph_limit_stderr() < 0) {
err(1, "unable to limit rights for stdio");
}
if (cap_enter() < 0 && errno != ENOSYS)
if (caph_enter() < 0)
err(1, "unable to enter capability mode");
e = mmap(NULL, sb.st_size, PROT_READ, MAP_SHARED, fd, 0);
if (e == MAP_FAILED)
Expand Down
2 changes: 1 addition & 1 deletion usr.bin/getopt/getopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ main(int argc, char *argv[])
int c;
int status = 0;

if (caph_limit_stdio() < 0 || (cap_enter() < 0 && errno != ENOSYS))
if (caph_limit_stdio() < 0 || caph_enter() < 0)
err(1, "capsicum");

optind = 2; /* Past the program name and the option letters. */
Expand Down
2 changes: 1 addition & 1 deletion usr.bin/hexdump/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ next(char **argv)
* We've opened our last input file; enter capsicum sandbox.
*/
if (statok == 0 || *(_argv + 1) == NULL) {
if (cap_enter() < 0 && errno != ENOSYS)
if (caph_enter() < 0)
err(1, "unable to enter capability mode");
}

Expand Down
4 changes: 2 additions & 2 deletions usr.bin/iconv/iconv.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ main(int argc, char **argv)
err(EXIT_FAILURE, "iconv_open(%s, %s)", opt_t, opt_f);

if (argc == 0) {
if (cap_enter() < 0 && errno != ENOSYS)
if (caph_enter() < 0)
err(EXIT_FAILURE, "unable to enter capability mode");
res = do_conv(stdin, cd, opt_s, opt_c);
} else {
Expand All @@ -228,7 +228,7 @@ main(int argc, char **argv)
err(EXIT_FAILURE, "Cannot open `%s'",
argv[i]);
/* Enter Capsicum sandbox for final input file. */
if (i + 1 == argc && cap_enter() < 0 && errno != ENOSYS)
if (i + 1 == argc && caph_enter() < 0)
err(EXIT_FAILURE,
"unable to enter capability mode");
res |= do_conv(fp, cd, opt_s, opt_c);
Expand Down
2 changes: 1 addition & 1 deletion usr.bin/ident/ident.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ main(int argc, char **argv)
}

/* Enter Capsicum sandbox. */
if (cap_enter() < 0 && errno != ENOSYS)
if (caph_enter() < 0)
err(EXIT_FAILURE, "unable to enter capability mode");

for (i = 0; i < (int)nfds; i++) {
Expand Down
3 changes: 2 additions & 1 deletion usr.bin/indent/indent.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$");

#include <sys/param.h>
#include <sys/capsicum.h>
#include <capsicum_helpers.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
Expand Down Expand Up @@ -248,7 +249,7 @@ main(int argc, char **argv)
cap_rights_init(&rights, CAP_FSTAT, CAP_READ);
if (cap_rights_limit(fileno(input), &rights) < 0 && errno != ENOSYS)
err(EXIT_FAILURE, "unable to limit rights for %s", in_name);
if (cap_enter() < 0 && errno != ENOSYS)
if (caph_enter() < 0)
err(EXIT_FAILURE, "unable to enter capability mode");

if (opt.com_ind <= 1)
Expand Down
2 changes: 1 addition & 1 deletion usr.bin/jot/jot.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ main(int argc, char **argv)
*/
caph_cache_catpages();

if (cap_enter() < 0 && errno != ENOSYS)
if (caph_enter() < 0)
err(1, "unable to enter capability mode");

while ((ch = getopt(argc, argv, "b:cnp:rs:w:")) != -1)
Expand Down
4 changes: 2 additions & 2 deletions usr.bin/kdump/kdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,12 +434,12 @@ main(int argc, char *argv[])
}
}
if (resolv == 0 || (cappwd != NULL && capgrp != NULL)) {
if (cap_enter() < 0 && errno != ENOSYS)
if (caph_enter() < 0)
err(1, "unable to enter capability mode");
}
#else
if (resolv == 0) {
if (cap_enter() < 0 && errno != ENOSYS)
if (caph_enter() < 0)
err(1, "unable to enter capability mode");
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion usr.bin/ktrdump/ktrdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ main(int ac, char **av)
* kvm_nlist() above uses kldsym(2) for native kernels, and that isn't
* allowed in the sandbox.
*/
if (cap_enter() < 0 && errno != ENOSYS)
if (caph_enter() < 0)
err(1, "unable to enter capability mode");

if (iflag) {
Expand Down
2 changes: 1 addition & 1 deletion usr.bin/lam/lam.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ main(int argc, char *argv[])
* mode.
*/
caph_cache_catpages();
if (cap_enter() < 0 && errno != ENOSYS)
if (caph_enter() < 0)
err(1, "unable to enter capability mode");

for (;;) {
Expand Down
2 changes: 1 addition & 1 deletion usr.bin/last/last.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ main(int argc, char *argv[])
if (setutxdb(UTXDB_LOG, file) != 0)
err(1, "%s", file != NULL ? file : "(default utx db)");

if (cap_enter() < 0 && errno != ENOSYS)
if (caph_enter() < 0)
err(1, "cap_enter");

if (sflag && width == 8) usage();
Expand Down
3 changes: 1 addition & 2 deletions usr.bin/locate/bigram/locate.bigram.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ static char sccsid[] = "@(#)locate.bigram.c 8.1 (Berkeley) 6/6/93";

#include <capsicum_helpers.h>
#include <err.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/param.h> /* for MAXPATHLEN */
Expand All @@ -78,7 +77,7 @@ main(void)
u_char *oldpath = buf1, *path = buf2;
u_int i, j;

if (caph_limit_stdio() < 0 || (cap_enter() < 0 && errno != ENOSYS))
if (caph_limit_stdio() < 0 || caph_enter() < 0)
err(1, "capsicum");

while (fgets(path, sizeof(buf2), stdin) != NULL) {
Expand Down
2 changes: 1 addition & 1 deletion usr.bin/logname/logname.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ main(int argc, char *argv[] __unused)
{
char *p;

if (caph_limit_stdio() < 0 || (cap_enter() < 0 && errno != ENOSYS))
if (caph_limit_stdio() < 0 || caph_enter() < 0)
err(1, "capsicum");

if (argc != 1)
Expand Down
2 changes: 1 addition & 1 deletion usr.bin/ministat/ministat.c
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ main(int argc, char **argv)
setfilenames[i]);

/* Enter Capsicum sandbox. */
if (cap_enter() < 0 && errno != ENOSYS)
if (caph_enter() < 0)
err(2, "unable to enter capability mode");

for (i = 0; i < nds; i++) {
Expand Down
2 changes: 1 addition & 1 deletion usr.bin/pom/pom.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ main(int argc, char **argv)
err(1, "unable to limit capabitilities for stdio");

caph_cache_catpages();
if (cap_enter() < 0 && errno != ENOSYS)
if (caph_enter() < 0)
err(1, "unable to enter capability mode");

while ((ch = getopt(argc, argv, "d:pt:")) != -1)
Expand Down
4 changes: 2 additions & 2 deletions usr.bin/primes/primes.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static const char rcsid[] =
* validation check: there are 664579 primes between 0 and 10^7
*/

#include <sys/capsicum.h>
#include <capsicum_helpers.h>
#include <ctype.h>
#include <err.h>
#include <errno.h>
Expand Down Expand Up @@ -104,7 +104,7 @@ main(int argc, char *argv[])
/* Cache NLS data, for strerror, for err(3), before cap_enter. */
(void)catopen("libc", NL_CAT_LOCALE);

if (cap_enter() < 0 && errno != ENOSYS)
if (caph_enter() < 0)
err(1, "cap_enter");

while ((ch = getopt(argc, argv, "h")) != -1)
Expand Down
2 changes: 1 addition & 1 deletion usr.bin/printenv/printenv.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ main(int argc, char *argv[])
size_t len;
int ch;

if (caph_limit_stdio() < 0 || (cap_enter() < 0 && errno != ENOSYS))
if (caph_limit_stdio() < 0 || caph_enter() < 0)
err(1, "capsicum");

while ((ch = getopt(argc, argv, "")) != -1)
Expand Down
3 changes: 2 additions & 1 deletion usr.bin/rwho/rwho.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$");

#include <protocols/rwhod.h>

#include <capsicum_helpers.h>
#include <dirent.h>
#include <err.h>
#include <errno.h>
Expand Down Expand Up @@ -136,7 +137,7 @@ main(int argc, char *argv[])
*/
(void) time(&ct);
(void) localtime(&ct);
if (cap_enter() < 0 && errno != ENOSYS)
if (caph_enter() < 0)
err(1, "cap_enter");
(void) time(&now);
cap_rights_init(&rights, CAP_READ);
Expand Down
2 changes: 1 addition & 1 deletion usr.bin/tee/tee.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ main(int argc, char *argv[])
} else
add(fd, *argv);

if (cap_enter() < 0 && errno != ENOSYS)
if (caph_enter() < 0)
err(EXIT_FAILURE, "unable to enter capability mode");
while ((rval = read(STDIN_FILENO, buf, BSIZE)) > 0)
for (p = head; p; p = p->next) {
Expand Down
2 changes: 1 addition & 1 deletion usr.bin/tr/tr.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ main(int argc, char **argv)
if (caph_limit_stdio() == -1)
err(1, "unable to limit stdio");

if (cap_enter() < 0 && errno != ENOSYS)
if (caph_enter() < 0)
err(1, "unable to enter capability mode");

Cflag = cflag = dflag = sflag = 0;
Expand Down
Loading

0 comments on commit 8acf9b1

Please sign in to comment.