add support for POSIX capabilites http://original.killa.net/infosec/caps/ http://bugs.gentoo.org/5818 --- sysvinit/src/init.c +++ sysvinit/src/init.c @@ -21,6 +21,15 @@ */ #include + +#ifdef __linux__ +#include +#include +#include +#define capget(header, data) syscall(__NR_capget, header, data) +#define capset(header, data) syscall(__NR_capset, header, data) +#endif + #include #include #include @@ -2348,6 +2357,11 @@ int init_main() pid_t rc; int f, st; +#ifdef __linux__ + cap_user_header_t head; + cap_user_data_t data; +#endif + if (!reload) { #if INITDEBUG @@ -2438,6 +2452,31 @@ int init_main() SETSIG(sa, SIGCHLD, chld_handler, SA_RESTART); } +#ifdef __linux__ + /* + * This seems like the right place to do this, just before + * we read /etc/inittab... + */ + + head = malloc(sizeof(head)); + if ((data = malloc(sizeof(data))) == NULL) + free(head); + + if (head && data) { + head->pid = 0; + head->version = _LINUX_CAPABILITY_VERSION; + + if (capget(head, data) == 0) { + /* Max out the inheritable capability set. */ + data->inheritable = data->effective; + capset(head, data); + } + + free(head); + free(data); + } +#endif + /* * Start normal boot procedure. */