-
-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #803
- Loading branch information
Showing
10 changed files
with
194 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
"""Support for executing Docker containers using the Singularity 2.x engine.""" | ||
|
||
import os | ||
import os.path | ||
from subprocess import ( # nosec | ||
DEVNULL, | ||
PIPE, | ||
Popen, | ||
TimeoutExpired, | ||
check_call, | ||
check_output, | ||
) | ||
from typing import Optional | ||
|
||
|
||
_USERNS = None # type: Optional[bool] | ||
|
||
|
||
def singularity_supports_userns() -> bool: | ||
"""Confirm if the version of Singularity install supports the --userns flag.""" | ||
global _USERNS # pylint: disable=global-statement | ||
if _USERNS is None: | ||
try: | ||
hello_image = os.path.join(os.path.dirname(__file__), "hello.simg") | ||
result = Popen( # nosec | ||
["singularity", "exec", "--userns", hello_image, "true"], | ||
stderr=PIPE, | ||
stdout=DEVNULL, | ||
universal_newlines=True, | ||
).communicate(timeout=60)[1] | ||
_USERNS = ( | ||
"No valid /bin/sh" in result | ||
or "/bin/sh doesn't exist in container" in result | ||
or "executable file not found in" in result | ||
) | ||
except TimeoutExpired: | ||
_USERNS = False | ||
return _USERNS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.