diff --git a/src/extra-tools/66-nuke.c b/src/extra-tools/66-nuke.c index 99a0df7f06fc1f403a8b42a16b4343891f0092b6..2f3162f73d688f8b0173e7d151bf05af22a7cfc4 100644 --- a/src/extra-tools/66-nuke.c +++ b/src/extra-tools/66-nuke.c @@ -11,14 +11,60 @@ * This file may not be copied, modified, propagated, or distributed * except according to the terms contained in the LICENSE file./ * - * This file is a strict copy of s6-echo.c file - * coming from skarnet software at https://skarnet.org/software/s6-portable-utils. + * This file is a modified copy of s6-linux-init-nuke.c file + * coming from skarnet software at https://skarnet.org/software/s6-linux-init. * All credits goes to Laurent Bercot <ska-remove-this-if-you-are-not-a-bot@skarnet.org> * */ #include <signal.h> +#include <unistd.h> -int main (void) +#include <oblibs/log.h> + +#include <skalibs/sgetopt.h> + +#define USAGE "66-nuke" + +static inline void info_help (void) +{ + DEFAULT_MSG = 0 ; + + static char const *help = +"\n" +"options :\n" +" -h: print this help\n" +; + + log_info(USAGE,"\n",help) ; +} + +int main (int argc, char const *const *argv) { - return kill(-1, SIGKILL) < 0 ; + + { + subgetopt_t l = SUBGETOPT_ZERO ; + + for (;;) + { + int opt = subgetopt_r(argc,argv, "h", &l) ; + + if (opt == -1) break ; + switch (opt) + { + case 'h' : + + info_help(); + return 0 ; + + default : + + log_usage(USAGE) ; + } + } + } + + if (getuid()) + log_die(LOG_EXIT_SYS,"You must be root to use this program") ; + + return kill(-1, SIGKILL) < 0 ; }