| 1 |
/* COVERAGE: vhangup */ |
| 2 |
|
| 3 |
#include <unistd.h> |
| 4 |
#include <sys/types.h> |
| 5 |
#include <linux/capability.h> |
| 6 |
#include <sys/syscall.h> |
| 7 |
|
| 8 |
#define capget(x,y) syscall(__NR_capget,x,y) |
| 9 |
#define capset(x,y) syscall(__NR_capset,x,y) |
| 10 |
|
| 11 |
static struct __user_cap_header_struct header; |
| 12 |
static struct __user_cap_data_struct data; |
| 13 |
|
| 14 |
int main() |
| 15 |
{ |
| 16 |
// Ensure vhangup() won't be able to succed. |
| 17 |
header.version = _LINUX_CAPABILITY_VERSION; |
| 18 |
header.pid = getpid(); |
| 19 |
capget(&header, &data); |
| 20 |
data.effective &= ~(1 << CAP_SYS_TTY_CONFIG); |
| 21 |
capset(&header, &data); |
| 22 |
|
| 23 |
// Test vhangup() |
| 24 |
vhangup(); |
| 25 |
//staptest// vhangup () = -NNNN (EPERM) |
| 26 |
|
| 27 |
return 0; |
| 28 |
} |