Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
6
66
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eric Vidal
66
Commits
ce624788
Commit
ce624788
authored
3 years ago
by
Eric Vidal
Browse files
Options
Downloads
Patches
Plain Diff
provide -h option. Deny regular user execution
parent
9c245611
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/extra-tools/66-nuke.c
+50
-4
50 additions, 4 deletions
src/extra-tools/66-nuke.c
with
50 additions
and
4 deletions
src/extra-tools/66-nuke.c
+
50
−
4
View file @
ce624788
...
...
@@ -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
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment