Skip to content
Snippets Groups Projects
Commit ce624788 authored by Eric Vidal's avatar Eric Vidal :speech_balloon:
Browse files

provide -h option. Deny regular user execution

parent 9c245611
No related branches found
No related tags found
No related merge requests found
......@@ -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 ;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment