![]() |
![]()
| ![]() |
![]()
NAMEfileargs_cinit ,
fileargs_cinitnv ,
fileargs_init ,
fileargs_initnv ,
fileargs_free , fileargs_lstat ,
fileargs_open , fileargs_fopen
—
library for handling files in capability mode
LIBRARYlibrary “libcap_fileargs”SYNOPSIS#include <sys/nv.h>
#include <libcasper.h>
#include <casper/cap_fileargs.h>
fileargs_t *
fileargs_t *
fileargs_t *
fileargs_t *
void
int
int
FILE *
char *
DESCRIPTIONThe library is used to simplify Capsicumizing a tools that are using file system. Idea behind the library is that we are passing a remaining argc and argv which contains a list of files that should be open for this program. The library will create a service that will serve those files.The function
The function The functions The fileargs_free close connection to the
The function The functions The function LIMITSThis section describe which values and types should be used to pass arguments to the system.fileargs through thefileargs_initnv () and
fileargs_cinitnv () functions. The
nvlist(9)
for that functions must contain the following values and types:
The nvlist(9) for that functions may contain the following values and types:
EXAMPLESThe following example first parse some options and then create thesystem.fileargs service with remaining arguments.
int ch, fd, i; cap_rights_t rights; fileargs_t *fa; while ((ch = getopt(argc, argv, "h")) != -1) { switch (ch) { case 'h': default: usage(); } } argc -= optind; argv += optind; /* Create capability to the system.fileargs service. */ fa = fileargs_init(argc, argv, O_RDONLY, 0, cap_rights_init(&rights, CAP_READ), FA_OPEN); if (fa == NULL) err(1, "unable to open system.fileargs service"); /* Enter capability mode sandbox. */ if (cap_enter() < 0 && errno != ENOSYS) err(1, "unable to enter capability mode"); /* Open files. */ for (i = 0; i < argc; i++) { fd = fileargs_open(fa, argv[i]); if (fd < 0) err(1, "unable to open file %s", argv[i]); printf("File %s opened in capability mode\n", argv[i]); close(fd); } fileargs_free(fa); SEE ALSOcap_enter(2), lstat(2), open(2), cap_rights_init(3), err(3), fopen(3), getopt(3), realpath(3), capsicum(4), nv(9)HISTORYThecap_fileargs service first appeared in
FreeBSD 10.3.
AUTHORSMariusz Zaborski <oshogbo@FreeBSD.org>BUGSThe library “cap_fileargs” included in FreeBSD is considered experimental, and should not be deployed in production environments without careful consideration of the risks associated with the use of experimental operating system features.
|