Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nicolas Wavrant
slapos.core
Commits
6795119f
Commit
6795119f
authored
May 17, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check that 'slapos node' commands are run as root.
parent
fa924818
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
25 additions
and
1 deletion
+25
-1
slapos/cli/bang.py
slapos/cli/bang.py
+2
-0
slapos/cli/command.py
slapos/cli/command.py
+13
-0
slapos/cli/format.py
slapos/cli/format.py
+2
-0
slapos/cli/register.py
slapos/cli/register.py
+2
-1
slapos/cli/slapgrid.py
slapos/cli/slapgrid.py
+2
-0
slapos/cli/supervisorctl.py
slapos/cli/supervisorctl.py
+2
-0
slapos/cli/supervisord.py
slapos/cli/supervisord.py
+2
-0
No files found.
slapos/cli/bang.py
View file @
6795119f
...
...
@@ -2,6 +2,7 @@
import
logging
from
slapos.cli.command
import
must_be_root
from
slapos.cli.config
import
ConfigCommand
from
slapos.bang
import
do_bang
...
...
@@ -19,6 +20,7 @@ class BangCommand(ConfigCommand):
help
=
'Message for bang'
)
return
ap
@
must_be_root
def
take_action
(
self
,
args
):
configp
=
self
.
fetch_config
(
args
)
do_bang
(
configp
,
args
.
message
)
slapos/cli/command.py
View file @
6795119f
# -*- coding: utf-8 -*-
import
argparse
import
functools
import
os
import
sys
import
cliff
class
Command
(
cliff
.
command
.
Command
):
def
get_parser
(
self
,
prog_name
):
parser
=
argparse
.
ArgumentParser
(
description
=
self
.
get_description
(),
...
...
@@ -14,3 +18,12 @@ class Command(cliff.command.Command):
)
return
parser
def
must_be_root
(
func
):
@
functools
.
wraps
(
func
)
def
func
(
self
,
*
args
,
**
kw
):
if
os
.
getuid
()
!=
0
:
self
.
app
.
log
.
error
(
'This slapos command must be run as root.'
)
sys
.
exit
(
5
)
return
func
slapos/cli/format.py
View file @
6795119f
...
...
@@ -3,6 +3,7 @@
import
logging
import
sys
from
slapos.cli.command
import
must_be_root
from
slapos.cli.config
import
ConfigCommand
from
slapos.format
import
do_format
,
FormatConfig
,
tracing_monkeypatch
,
UsageError
...
...
@@ -55,6 +56,7 @@ class FormatCommand(ConfigCommand):
return
ap
@
must_be_root
def
take_action
(
self
,
args
):
configp
=
self
.
fetch_config
(
args
)
...
...
slapos/cli/register.py
View file @
6795119f
...
...
@@ -3,7 +3,7 @@
import
logging
import
sys
from
slapos.cli.command
import
Command
from
slapos.cli.command
import
Command
,
must_be_root
from
slapos.register.register
import
do_register
,
RegisterConfig
...
...
@@ -66,6 +66,7 @@ class RegisterCommand(Command):
return
ap
@
must_be_root
def
take_action
(
self
,
args
):
try
:
conf
=
RegisterConfig
(
logger
=
self
.
log
)
...
...
slapos/cli/slapgrid.py
View file @
6795119f
...
...
@@ -2,6 +2,7 @@
import
logging
from
slapos.cli.command
import
must_be_root
from
slapos.cli.config
import
ConfigCommand
from
slapos.grid.utils
import
setRunning
,
setFinished
...
...
@@ -57,6 +58,7 @@ class SlapgridCommand(ConfigCommand):
help
=
'Launch slapgrid without delay. Default behavior.'
)
return
ap
@
must_be_root
def
take_action
(
self
,
args
):
configp
=
self
.
fetch_config
(
args
)
options
=
merged_options
(
args
,
configp
)
...
...
slapos/cli/supervisorctl.py
View file @
6795119f
...
...
@@ -4,6 +4,7 @@ import argparse
import
logging
import
os
from
slapos.cli.command
import
must_be_root
from
slapos.cli.config
import
ConfigCommand
from
slapos.grid.svcbackend
import
launchSupervisord
...
...
@@ -22,6 +23,7 @@ class SupervisorctlCommand(ConfigCommand):
help
=
'parameters passed to supervisorctl'
)
return
ap
@
must_be_root
def
take_action
(
self
,
args
):
configp
=
self
.
fetch_config
(
args
)
instance_root
=
configp
.
get
(
'slapos'
,
'instance_root'
)
...
...
slapos/cli/supervisord.py
View file @
6795119f
...
...
@@ -3,6 +3,7 @@
import
logging
import
os
from
slapos.cli.command
import
must_be_root
from
slapos.cli.config
import
ConfigCommand
from
slapos.grid.svcbackend
import
launchSupervisord
...
...
@@ -12,6 +13,7 @@ class SupervisordCommand(ConfigCommand):
log
=
logging
.
getLogger
(
'supervisord'
)
@
must_be_root
def
take_action
(
self
,
args
):
configp
=
self
.
fetch_config
(
args
)
instance_root
=
configp
.
get
(
'slapos'
,
'instance_root'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment