Преглед на файлове

use SUDO_USER if "logname" does not return any result

This can happen in certain situations e.g. when you enter an
OpenVZ container via "vzctl enter CTID" the login name is not
available.
Ashish Kulkarni преди 11 години
родител
ревизия
0f953db61c
променени са 1 файла, в които са добавени 2 реда и са изтрити 2 реда
  1. 2 2
      scripts/build.py

+ 2 - 2
scripts/build.py

@@ -402,7 +402,7 @@ ARCH = ['i386']
 
 
 def check_setup_schroot(config):
 def check_setup_schroot(config):
     check_running_on_debian()
     check_running_on_debian()
-    login = get_output('logname')
+    login = get_output('logname') or os.environ.get('SUDO_USER')
     if not login:
     if not login:
         error('Unable to determine the login for which schroot access is to be given.')
         error('Unable to determine the login for which schroot access is to be given.')
 
 
@@ -412,7 +412,7 @@ def check_setup_schroot(config):
 def build_setup_schroot(config, basedir):
 def build_setup_schroot(config, basedir):
     install_packages('git', 'debootstrap', 'schroot', 'rinse')
     install_packages('git', 'debootstrap', 'schroot', 'rinse')
 
 
-    login  = get_output('logname')
+    login  = get_output('logname') or os.environ.get('SUDO_USER')
     chroot = config[1+config.rindex('-'):]
     chroot = config[1+config.rindex('-'):]
     for arch in ARCH:
     for arch in ARCH:
         print '******************* %s-%s' % (chroot, arch)
         print '******************* %s-%s' % (chroot, arch)