From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web11.5100.1587490963487263370 for ; Tue, 21 Apr 2020 10:42:43 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=UUII8ErD; spf=pass (domain: intel.com, ip: 134.134.136.24, mailfrom: ashley.e.desimone@intel.com) IronPort-SDR: iKagS5kDzd0eRco7/fIuS6djA8n92v3a1HR+yfE9rjLOTyduT1EKY3OGU1QInRZAHh9Q6wGAuo JuqPlonnZTJg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Apr 2020 10:42:42 -0700 IronPort-SDR: vRy5ojwOCuAr7h2S5R9QSlg+yi+hRZQgMqfxvEY2CkxDZBJ0VRqfPnZj7k0B0K5k+NkAq9sEkD mT48Q+DXY9YA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,411,1580803200"; d="scan'208";a="456836732" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga006.fm.intel.com with ESMTP; 21 Apr 2020 10:42:42 -0700 Received: from fmsmsx117.amr.corp.intel.com (10.18.116.17) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 21 Apr 2020 10:42:42 -0700 Received: from FMSEDG001.ED.cps.intel.com (10.1.192.133) by fmsmsx117.amr.corp.intel.com (10.18.116.17) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 21 Apr 2020 10:42:42 -0700 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.41) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 21 Apr 2020 10:42:41 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VR6fiWLNVQNC/R3mnt95NMNUlji7T2eW5tT11dGNrXLDARJbK/3zxEuXjLKW4b8km5+ZxA9VAs+ta//UuY1q4swVNFIkFaHm78vV6DnBvCjr+PpqgdPlxtVC4Z6fxLLqZ8YQpeuKrDDktdITBY+PZ/B5g6B0FsK0SSlhxaPOjm4nuLitsFtuRhp9EyHiKvP7FmskleVKSy7I2MOsx3nBkQTDaxg8/uEZfX3WTTvYNTvBj+eTBRFYb6w0a0OoA9/6ICxKst+XhoUJuiew2z3pe2eV6/1LIBEOUn/PC/Ee8ockwOkkcVTnOilLt65P71pdJGT2vRkaiyRJOc3TLWIlSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OZ2/0ad3GvMa+1EcfixZKQ4D5FRT4dfSYJa1yMSf4Sg=; b=aVKGAWlBrtIt+BSgrcpuc40/jGZOnB4wCJ3q9n2qiO1STxBj2nolOtI/OvlkzF39w8Fp7HrbBzLTDTV+D1CKYtZcl6lh2FY5XRuugGkFpK06yJrPJRpl3wIrEobYshD6mafw6xiCBEKY/TPhKbJmk9y0c6uJOc/URlB+UAG9q2OJhNV6oxRQJ1Sa+eAmXjZ2OedvBe1Ywu+ArpSVQrQTgpIeUYZhwkB2DuWxnc7MCF/0Z8SX2rR2NDEyhtfii1GPaBaNGRQYowBuxikxqSb+W8EtQNbqK2DCtlX7cRFNszWx9MKY9ewI5RAcdbUckV+OmkcnIgzUd7r7ZMAwqOjhEw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OZ2/0ad3GvMa+1EcfixZKQ4D5FRT4dfSYJa1yMSf4Sg=; b=UUII8ErDraCE4wQWoooiTJ+YuqjfhbUnfxRkdl+TwwZr+2D5IOJ+Yxcg7iQn5/+vTEjLO5IWqWiUA25RXalhylAzG2MTYi0r9nbhrW+JyUxftfDcQFcCVWwPkX0Mf/DdrvE9LKfLFbaSAJ86FtKTNhyC/Wy3KNa1lE8Ttb2GyH4= Received: from DM6PR11MB3628.namprd11.prod.outlook.com (2603:10b6:5:144::25) by DM6PR11MB2778.namprd11.prod.outlook.com (2603:10b6:5:c0::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2921.27; Tue, 21 Apr 2020 17:42:40 +0000 Received: from DM6PR11MB3628.namprd11.prod.outlook.com ([fe80::2c41:705f:b0ee:e36c]) by DM6PR11MB3628.namprd11.prod.outlook.com ([fe80::2c41:705f:b0ee:e36c%5]) with mapi id 15.20.2921.030; Tue, 21 Apr 2020 17:42:40 +0000 From: "Ashley E Desimone" To: "Desimone, Nathaniel L" , "devel@edk2.groups.io" CC: "Pandya, Puja" , "Bjorge, Erik C" , Bret Barkelew , "Agyeman, Prince" Subject: Re: [PATCH] EdkRepo: Fix Linux install failures Thread-Topic: [PATCH] EdkRepo: Fix Linux install failures Thread-Index: AQHWF482opsU4SHSYEWoSgyn3mmDSKiD2Viw Date: Tue, 21 Apr 2020 17:42:40 +0000 Message-ID: References: <20200421034406.6541-1-nathaniel.l.desimone@intel.com> In-Reply-To: <20200421034406.6541-1-nathaniel.l.desimone@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.2.0.6 dlp-reaction: no-action dlp-product: dlpe-windows authentication-results: spf=none (sender IP is ) smtp.mailfrom=ashley.e.desimone@intel.com; x-originating-ip: [134.134.136.213] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: a2fd02f2-98ee-4036-0b93-08d7e61b63a0 x-ms-traffictypediagnostic: DM6PR11MB2778: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5236; x-forefront-prvs: 038002787A x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR11MB3628.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(10019020)(346002)(366004)(39860400002)(136003)(396003)(376002)(7696005)(5660300002)(66946007)(316002)(53546011)(6506007)(86362001)(76116006)(9686003)(186003)(71200400001)(478600001)(107886003)(54906003)(110136005)(4326008)(8676002)(2906002)(33656002)(8936002)(81156014)(66556008)(66476007)(55016002)(66446008)(64756008)(26005)(52536014);DIR:OUT;SFP:1102; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: prkp+9zZ+36xR0z5I8iO2eU3m0cVmX/2Ui9AqoxCECKmwBEfPhfArE2hdawR0yiV18SdoADloyCdxThKMzL6FL7v3IGkqkEO/bKu1C/aWR19F3hYI621+0gmz8YuftBqp0N/TTYthaZ9Jw6Ixas6jFUSUbGO8id5g6liURoR6/fCh7wFFy4+clCFmjYVz60mnJ3kEFQovgsUNtY1r87yCcY8DORUqHGIBzznxB5xf7doYYFDxSu6h2KiYwI1jTqhFx1I95F6ZqIjI2ARRQBjxEwgEMrcorrUo7uYcvHojAC8O7vKIfIyri8+34ALJAXJrnXiathRafIzpvGrHFyd8s3ih6dJIgsz9z8hWem9CCHPMLQd0RMmt/5v40aoi/7JCsAyuwVMa5tYfx7u6dvFE1gfxckQu9/RVuVtjmqdIVli8x6BSpuioTlQd0miJbsv x-ms-exchange-antispam-messagedata: pzuCHNGqfFRDyDQfwHXCjqS3CVof48cZnX1+p/cm/qLft1eXlUS7mLU3MhESSoJcs+7wa6WcB/8osH8vfdPSspVjHc7M3eGS6hXiG/stUjLxTtIMDcK+Xz9oHbYSp5zXqr5mFvdCeiWIYVjf4Zaeg3K5aN0sgr753JmSXU1Y1mMb2BDR7zDYQy/5q7wSqbbz7zsHkYiv+oG5WanfGJVikP95QEm1MhyjvPrF0ai5j5qVTY3pU0uzVPc0qvuNdZ/mJoGrlnkOmmLC4+g6D1N7LzblVMfOoQ6ezQjlFpqcDz7OxcvcBzRG0mjCO/kAkhWTxKB9cIT+MpO4u6ZpRh6DcrZlJ70VppDzNIKPtT2V0L9FFVzx7ohqthiuXP846RytktekP7riWqfRG9nNs15dVUa4N+W7BFxhJaBzSxzmkIrR2m+J0Op3OKP3YP7yy3geHGRacJG3YgRRuKh0uKNu27Hil/bJ8s1lv3jHXeNfoqJECAnEy8NJ+pzYQX5K43y2nTVnnsUUmxwKyS1+yHUZaJqXhjWAEY0Tc/2owI84aqOlaT+ZxF0sm3E1sNHlFvc/C6DeWgCA1mA3vK1/fElQ2vsjAizz2b/GXLfnQuFfd+Ynfi2Y+qB/JYcuWFXb63Gj8aMdlEVsbto6BxAsYcoO0dwxYS2Jf0nKHGBbsy1qhmpf/cM11Thx9ZTnyxM4kzoSoan11JB8JEoUs4VO7hQAxzOKFa6XiLdteOJ0PW2ZmJaRPoHEYNwXZGSPLqZUZNJ7PA86LxUYNu+DsX5FPUQJzxD3Mcd+GEofZxWi6O0MO+CSgAXWnXakFQfnKDSF2Lsw MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: a2fd02f2-98ee-4036-0b93-08d7e61b63a0 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Apr 2020 17:42:40.5003 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: mVxUw0J4uFHnmF7eVMGrYpWqRixNLNPQcrGBgFmuFK/h1jb2tkW2/VVsH65LZCLBRojHmqJYzXXDsa0w+kN/ZPb6KxpCk+h+Dbl1x+c5LKk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB2778 Return-Path: ashley.e.desimone@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ashley DeSimone -----Original Message----- From: Desimone, Nathaniel L =20 Sent: Monday, April 20, 2020 8:44 PM To: devel@edk2.groups.io Cc: Desimone, Ashley E ; Pandya, Puja ; Bjorge, Erik C ; Bret Barkelew ; Agyeman, Prince Subject: [PATCH] EdkRepo: Fix Linux install failures Install script currently attempts to run EdkRepo as root, which fails. The = fix ensures that EdkRepo is run under a user account. Signed-off-by: Nate DeSimone Cc: Ashley E Desimone Cc: Puja Pandya Cc: Erik Bjorge Cc: Bret Barkelew Cc: Prince Agyeman --- edkrepo_installer/linux-scripts/install.py | 52 ++++++++++++++++------ 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/edkrepo_installer/linux-scripts/install.py b/edkrepo_installer= /linux-scripts/install.py index feecf49..f3a9248 100755 --- a/edkrepo_installer/linux-scripts/install.py +++ b/edkrepo_installer/linux-scripts/install.py @@ -102,7 +102,7 @@ def is_prompt_customization_installed(user_home_dir): return customization_installed =20 __add_prompt_customization =3D None -def get_add_prompt_customization(args, user_home_dir): +def get_add_prompt_customization(args, username, user_home_dir): global __add_prompt_customization if __add_prompt_customization is not None: return __add_prompt_customization @@ -118,10 +118,16 @@ def get_ad= d_prompt_customization(args, user_home_dir): return False #If the prompt has not been installed and EdkRepo >=3D 2.0.0 is instal= led, then don't install the prompt customization if shutil.which('edkrepo') is not None: - res =3D default_run(['edkrepo', '--version']) - if _check_version(res.stdout.replace('edkrepo ', '').strip(), '2.0= .0') >=3D 0: - __add_prompt_customization =3D False - return False + try: + if is_current_user_root(): + res =3D subprocess.run("echo 'edkrepo --version; exit' | s= u - {}".format(username), shell=3DTrue, universal_newlines=3DTrue, stdout= =3Dsubprocess.PIPE, stderr=3Dsubprocess.STDOUT, check=3DTrue) + else: + res =3D default_run(['edkrepo', '--version']) + if _check_version(res.stdout.replace('edkrepo ', '').strip(), = '2.0.0') >=3D 0: + __add_prompt_customization =3D False + return False + except: + pass #Show the user an advertisement to see if they want the prompt customi= zation from select import select import termios @@ -251,6 +257,12 @@ def get_site_packages_directory(): res =3D default_run([def_python, '-c', 'import site; print(site.getsit= epackages()[0])']) return res.stdout.strip() =20 +def is_current_user_root(): + res =3D default_run(['id', '-u']) + if res.stdout.strip() =3D=3D '0': + return True + return False + def set_execute_permissions(): site_packages =3D get_site_packages_directory() config =3D configparser.ConfigParser(allow_no_value=3DTrue, delimiters= =3D'=3D') @@ -457,7 +469,7 @@ def add_command_completions_to_shell(command_= completion_script, args, username, comment =3D '\n# Add EdkRepo command completions' bash_rc_file =3D os.path.join(user_home_dir, '.bashrc') add_command_comment_to_startup_script(bash_rc_file, regex, new_source_= line, comment, username) - if get_add_prompt_customization(args, user_home_dir): + if get_add_prompt_customization(args, username, user_home_dir): add_command_to_startup_script(bash_rc_file, prompt_regex, bash_pro= mpt_customization, username) zsh_rc_file =3D os.path.join(user_home_dir, '.zshrc') add_command_to_startup_script(zsh_rc_file, zsh_autoload_compinit_regex= , zsh_autoload_compinit, username) @@ -467,7 +479,7 @@ def add_command_comp= letions_to_shell(command_completion_script, args, username, add_command_to_startup_script(zsh_rc_file, zsh_compinit_regex, zsh_com= pinit, username) add_command_to_startup_script(zsh_rc_file, zsh_bashcompinit_regex, zsh= _bashcompinit, username) add_command_comment_to_startup_script(zsh_rc_file, regex, new_source_l= ine, comment, username) - if get_add_prompt_customization(args, user_home_dir): + if get_add_prompt_customization(args, username, user_home_dir): add_command_to_startup_script(zsh_rc_file, prompt_regex, zsh_promp= t_customization, username) =20 def do_install(): @@ -515,11 +527,11 @@ def do_install(): log.info('\nCollecting system information:') if not install_to_local and ostype !=3D MAC: try: - res =3D default_run(['id', '-u']) + user_is_root =3D is_current_user_root() except: log.info('- Failed to determine user ID') return 1 - if res.stdout.strip() !=3D '0': + if not user_is_root: log.info('- Installer must be run as root') return 1 if username is None: @@ -536,17 +548,17 @@ def do_install(): return 1 if ostype =3D=3D MAC: try: - res =3D default_run(['id', '-u']) + user_is_root =3D is_current_user_root() except: log.info('- Failed to determine user ID') return 1 - if res.stdout.strip() =3D=3D '0': + if user_is_root: log.info('- Installer must NOT be run as root') return 1 if os.path.commonprefix([user_home_dir, sys.executable]) !=3D user= _home_dir: install_to_local =3D True default_cfg_dir =3D os.path.join(user_home_dir, cfg_dir) - get_add_prompt_customization(args, user_home_dir) + get_add_prompt_customization(args, username, user_home_dir) log.info('+ System information collected') =20 # Display current system information. @@ -728,7 +740,21 @@ def do_install(): else: command_completion_script =3D os.path.join('/', 'etc', 'profil= e.d', 'edkrepo_completions.sh') try: - res =3D default_run(['edkrepo', 'generate-command-completion-s= cript', command_completion_script]) + user_is_root =3D False + try: + user_is_root =3D is_current_user_root() + except: + pass + current_home =3D None + if 'HOME' in os.environ: + current_home =3D os.environ['HOME'] + try: + if user_is_root and current_home is not None and current_h= ome !=3D user_home_dir: + os.environ['HOME'] =3D user_home_dir + res =3D default_run(['edkrepo', 'generate-command-completi= on-script', command_completion_script]) + finally: + if current_home is not None and os.environ['HOME'] !=3D cu= rrent_home: + os.environ['HOME'] =3D current_home if install_to_local or ostype =3D=3D MAC: shutil.chown(command_completion_script, user=3Dusername) os.chmod(command_completion_script, 0o644) -- 2.17.1