Skip to content
Browse files

Fixes a couple of issues calling sudo

git-svn-id: svn://cherokee-project.com/installer@6132 5dc97367-97f1-0310-9951-d761b3857238
  • Loading branch information...
1 parent b3a3422 commit 828bc25b175228acb663c6c879b83fe44b032a85 @alobbs alobbs committed Jan 18, 2011
Showing with 20 additions and 13 deletions.
  1. +20 −13 install.py
View
33 install.py
@@ -176,7 +176,11 @@ def exe (cmd, colorer=lambda x: x, cd=None, stdin=None, return_fatal=True):
p = subprocess.Popen (cmd, **kwargs)
if stdin:
- p.stdin.write (stdin)
+ try:
+ p.stdin.write (stdin)
+ p.stdin.close()
+ except IOError:
+ pass
while True:
line = p.stdout.readline()
@@ -196,11 +200,24 @@ def exe (cmd, colorer=lambda x: x, cd=None, stdin=None, return_fatal=True):
return {'stdout': stdout,
'retcode': p.returncode}
+_root_password = None
+def get_root_password():
+ global _root_password
+
+ while not _root_password:
+ _root_password = read_input ("root's password: ")
+ if _root_password:
+ _root_password += '\n'
+
+ return _root_password
+
def exe_sudo (cmd, **kwargs):
- command = "sudo -S " + cmd
+ if os.getuid() != 0:
+ root_password = get_root_password()
+ kwargs['stdin'] = root_password
+ command = "sudo -S " + cmd
return exe (command, **kwargs)
-
def which (program):
def is_exe(fpath):
return os.path.exists(fpath) and os.access(fpath, os.X_OK)
@@ -263,16 +280,6 @@ def read_yes_no (prompt, empty_is=None):
if not ret and empty_is != None:
return empty_is
-_root_password = None
-def get_root_password():
- global _root_password
-
- while not _root_password:
- _root_password = read_input ("root's password: ")
-
- return _root_password
-
-
def figure_initd_app_level (directory, app, not_found=99):
files = [x.lower() for x in os.listdir(directory)]
for filename in files:

0 comments on commit 828bc25

Please sign in to comment.
Something went wrong with that request. Please try again.