add capsicum to units(1)
This commit is contained in:
parent
f9374f0724
commit
ac117d5d7e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=263940
@ -22,11 +22,14 @@ static const char rcsid[] =
|
||||
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <sys/capsicum.h>
|
||||
|
||||
#include "pathnames.h"
|
||||
|
||||
#define VERSION "1.0"
|
||||
@ -112,6 +115,7 @@ readunits(const char *userfile)
|
||||
FILE *unitfile;
|
||||
char line[512], *lineptr;
|
||||
int len, linenum, i;
|
||||
cap_rights_t unitfilerights;
|
||||
|
||||
unitcount = 0;
|
||||
linenum = 0;
|
||||
@ -143,6 +147,12 @@ readunits(const char *userfile)
|
||||
errx(1, "can't find units file '%s'", UNITSFILE);
|
||||
}
|
||||
}
|
||||
if (cap_enter() < 0 && errno != ENOSYS)
|
||||
err(1, "unable to enter capability mode");
|
||||
cap_rights_init(&unitfilerights, CAP_READ, CAP_FSTAT);
|
||||
if (cap_rights_limit(fileno(unitfile), &unitfilerights) < 0
|
||||
&& errno != ENOSYS)
|
||||
err(1, "cap_rights_limit() failed");
|
||||
while (!feof(unitfile)) {
|
||||
if (!fgets(line, sizeof(line), unitfile))
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user