From 9aa80c5fcd7134b88573b53c075786e2487273c9 Mon Sep 17 00:00:00 2001 From: vsoch Date: Tue, 11 Oct 2022 19:13:47 -0600 Subject: [PATCH] remove -E from sudo default Signed-off-by: vsoch --- CHANGELOG.md | 3 ++- docs/pages/commands.md | 4 ++++ spython/utils/terminal.py | 7 +++++-- spython/version.py | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c43ce0e8..b0f6d168 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,8 @@ The client here will eventually be released as "spython" (and eventually to singularity on pypi), and the versions here will coincide with these releases. ## [master](https://github.com/singularityhub/singularity-cli/tree/master) - - WORKDIR should create container for Singularity converter (0.0.12) + - sudo `-E` flag should not be provided by default (0.2.13) + - WORKDIR should create container for Singularity converter (0.2.12) - support for background process with client run (0.2.11) - parser bugfixes, arg from Docker not properly parsed (0.2.1) - version checks removed to support Singularity 3.x and above (0.2.0) diff --git a/docs/pages/commands.md b/docs/pages/commands.md index 55859a1f..b154c634 100644 --- a/docs/pages/commands.md +++ b/docs/pages/commands.md @@ -7,12 +7,16 @@ toc: false --- # Python API + This commands section primarily focuses on using Singularity Python from within Python and then in an interactive shell (for testing). We will first discuss the Python API, meaning functions that you can use in python to work with Singularity images or instances. Python is strong in the world of scientific programming, and so if you are reading these notes it's likely that you want to integrate Singularity containers into your Python applications. We wrote you a client to do that! Please select the type of command you are interested in below to continue! - [Images](/singularity-cli/commands-images): base API to interact with containers: - [Instances](/singularity-cli/commands-instances): interact with container instances. - [OCI](/singularity-cli/commands-oci): interact with the OCI command group (3.1.0 and up) +Note that for any command that allows specifying `sudo`, you can provide additional options to sudo +(e.g., `-E` to preserve the environment) via `sudo_options`. +
diff --git a/spython/utils/terminal.py b/spython/utils/terminal.py index 5a53a1bf..bb75b103 100644 --- a/spython/utils/terminal.py +++ b/spython/utils/terminal.py @@ -25,12 +25,15 @@ def _process_sudo_cmd(cmd, sudo, sudo_options): + """ + Process the sudo command and honor adding environment (or not) + """ if sudo and sudo_options is not None: if isinstance(sudo_options, str): sudo_options = shlex.split(sudo_options) - cmd = ["sudo", "-E"] + sudo_options + cmd + cmd = ["sudo"] + sudo_options + cmd elif sudo: - cmd = ["sudo", "-E"] + cmd + cmd = ["sudo"] + cmd return [x for x in cmd if x] diff --git a/spython/version.py b/spython/version.py index bc60c477..25b80939 100644 --- a/spython/version.py +++ b/spython/version.py @@ -5,7 +5,7 @@ # with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -__version__ = "0.2.12" +__version__ = "0.2.13" AUTHOR = "Vanessa Sochat" AUTHOR_EMAIL = "vsoch@users.noreply.github.com" NAME = "spython"