Commit Graph

5 Commits

Author SHA1 Message Date
Martin Krajnak
a744bda314 Use python3 for userns-block-fd.py 2020-01-17 14:40:05 +01:00
Simon McVittie
3c488585bd userns-block-fd: Add support for Python 3
According to PEP 394, the python command is meant to be Python 2
until at least 2020, so in practice this script will be run with
Python 2 for now (except on Arch Linux); but it seems good to be
more future-proof.

In Python 3, os.write() takes a bytestring (bytes object), not a
text string (str/unicode object). In Python 2 ≥ 2.6, the b'' syntax
is supported and gives a str object, because that was a bytestring
in Python 2; either way, b'1' is an acceptable argument to os.write().

In Python ≥ 3.4, the result of os.pipe() is close-on-exec
(non-inheritable) by default, so undo that where needed.

Signed-off-by: Simon McVittie <smcv@collabora.com>

Closes: #246
Approved by: giuseppe
2017-11-03 17:55:16 +00:00
Simon McVittie
b8fa270e89 userns-block-fd: Search the PATH for bwrap
This means we can use it with an installed bwrap, which seems a more
common use of a demo script than a just-compiled bwrap, and is
consistent with the shell scripts.

Signed-off-by: Simon McVittie <smcv@collabora.com>

Closes: #246
Approved by: giuseppe
2017-11-03 17:55:16 +00:00
Simon McVittie
30338c3f0d userns-block-fd: Search $PATH for python
On systems without the /usr merge, it's almost certainly in /usr,
so this script would have failed.

Signed-off-by: Simon McVittie <smcv@collabora.com>

Closes: #246
Approved by: giuseppe
2017-11-03 17:55:16 +00:00
Giuseppe Scrivano
0bffcf1679 demos: add demo userns-block-fd.py
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #101
Approved by: alexlarsson
2017-06-29 23:02:32 +00:00