forked from ish-app/ish
-
Notifications
You must be signed in to change notification settings - Fork 2
/
misc.c
59 lines (52 loc) · 1.59 KB
/
misc.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <string.h>
#include "kernel/calls.h"
#define PRCTL_SET_KEEPCAPS_ 8
#define PRCTL_SET_NAME_ 15
int_t sys_prctl(dword_t option, uint_t arg2, uint_t UNUSED(arg3), uint_t UNUSED(arg4), uint_t UNUSED(arg5)) {
switch (option) {
case PRCTL_SET_KEEPCAPS_:
// stub
return 0;
case PRCTL_SET_NAME_: {
char name[16];
if (user_read_string(arg2, name, sizeof(name) - 1))
return _EFAULT;
name[sizeof(name) - 1] = '\0';
STRACE("prctl(PRCTL_SET_NAME, \"%s\")", name);
strcpy(current->comm, name);
return 0;
}
default:
STRACE("prctl(%#x)", option);
return _EINVAL;
}
}
int_t sys_arch_prctl(int_t code, addr_t addr) {
STRACE("arch_prctl(%#x, %#x)", code, addr);
return _EINVAL;
}
#define REBOOT_MAGIC1 0xfee1dead
#define REBOOT_MAGIC2 672274793
#define REBOOT_MAGIC2A 85072278
#define REBOOT_MAGIC2B 369367448
#define REBOOT_MAGIC2C 537993216
#define REBOOT_CMD_CAD_OFF 0
#define REBOOT_CMD_CAD_ON 0x89abcdef
int_t sys_reboot(int_t magic, int_t magic2, int_t cmd) {
STRACE("reboot(%#x, %d, %d)", magic, magic2, cmd);
if (!superuser())
return _EPERM;
if (magic != (int) REBOOT_MAGIC1 ||
(magic2 != REBOOT_MAGIC2 &&
magic2 != REBOOT_MAGIC2A &&
magic2 != REBOOT_MAGIC2B &&
magic2 != REBOOT_MAGIC2C))
return _EINVAL;
switch (cmd) {
case REBOOT_CMD_CAD_ON:
case REBOOT_CMD_CAD_OFF:
return 0;
default:
return _EPERM;
}
}