-
Notifications
You must be signed in to change notification settings - Fork 1k
Expand file tree
/
Copy pathusermode-helper.c
More file actions
55 lines (51 loc) · 1.71 KB
/
Copy pathusermode-helper.c
File metadata and controls
55 lines (51 loc) · 1.71 KB
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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
int i;
/* TODO: this doesn't go anywhere useful right now. It would be nice to
* switch this to syslog() (or some other mechanism) so that we can
* actually read the contents.
*/
fprintf(stderr, "usermodehelper: ");
for (i = 0; i < argc; i++) {
fprintf(stderr, "%s ", argv[i]);
}
fprintf(stderr, "\n");
if (!strcmp(argv[0], "/sbin/mdev")) {
/* busybox uses /sbin/mdev for early uevent bootstrapping */
execv(argv[0], argv);
} else if (!strcmp(argv[0], "/sbin/modprobe")) {
/* allow modprobe */
execv(argv[0], argv);
} else if (!strcmp(argv[0], "/sbin/poweroff") ||
!strcmp(argv[0], "/sbin/reboot")) {
/* poweroff and reboot are allowed */
execv(argv[0], argv);
} else {
/* This means either we got an unexpected call from the kernel
* or someone is doing something nefarious. Some other possible
* expected callers are:
* - for core dumps. we don't have a "core" binary, and don't
* set this by default to anything. when we do, we need to
* whitelist it here
* - /linuxrc: we're not doing legacy root setup, so we don't
* need this
* - a few drivers and filesystems (drbd, nfs, nfsd, ocfs2)
* - cgroup notify_on_release handlers, which we do not set
* (but e.g. systemd needs, if anyone ever tries to boot
* that on linuxkit)
* - /sbin/request-key, which we don't provide
* - on x86, machine check
*
* Today we only call mdev and modprobe, but as we add more
* features to linuxkit this whitelist may need changing (or a
* policy, like always allow stuff in /sbin).
*/
exit(2);
}
perror("exec failed");
return 1;
}