Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F6346417
test.c
tig_freebsdfoundation.org (Tiger Gao)
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
tig_freebsdfoundation.org
Apr 7 2020, 5:30 PM
2020-04-07 17:30:55 (UTC+0)
Size
626 B
Referenced Files
None
Subscribers
None
test.c
View Options
#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
Details
Attached
Mime Type
text/x-c
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2555455
Default Alt Text
test.c (626 B)
Attached To
Mode
D24327: Add new casper execution service
Attached
Detach File
Event Timeline
Log In to Comment