Page MenuHomeFreeBSD
Authored By
tig_freebsdfoundation.org
Apr 7 2020, 5:30 PM
Size
626 B
Referenced Files
None
Subscribers
None
#include <libcasper.h>
#include <err.h>
#include <capsicum_helpers.h>
#include <cap_exec.h>
int main() {
cap_channel_t *capcas, *capexec;
int fd;
const char *paths[1] = {"ls"};
capcas = cap_init();
if (capcas == NULL)
err(1, "Unable to contact Casper");
if (cap_enter() < 0 && errno != ENOSYS)
err(1, "Unable to enter capability mode");
capexec = cap_service_open(capcas, "system.exec");
if (capexec == NULL)
err(1, "Unable to open system.exec service");
cap_close(capcas);
cap_exec_init(capexec, 1, paths);
fd = cap_exec(capexec, "touch ~/xd");
if (fd == -1)
err(1, "Not allowed.");
return (0);
}

File Metadata

Mime Type
text/x-c
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2555455
Default Alt Text
test.c (626 B)

Event Timeline