Skip to content

Commit

Permalink
Do not start targetcli if target is not loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
tramjoe committed Oct 21, 2014
1 parent 6608e04 commit e22b58f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions scripts/targetcli
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ under the License.
'''

import sys
from os import getuid
from os import getuid, listdir
from targetcli import UIRoot
from rtslib import RTSLibError
from configshell import ConfigShell
Expand Down Expand Up @@ -51,12 +51,19 @@ def main():
'''
Start the targetcli shell.
'''
shell = TargetCLI('~/.targetcli')

try:
listdir("/sys/kernel/config/target")
except:
shell.con.display("The target service is not running.")
exit()

if getuid() == 0:
is_root = True
else:
is_root = False

shell = TargetCLI('~/.targetcli')
if not is_root:
shell.con.display("You are not root, disabling privileged commands.\n")

Expand Down

0 comments on commit e22b58f

Please sign in to comment.