Message ID | 20230207142535.1153722-4-marcandre.lureau@redhat.com |
---|---|
State | New |
Headers | show |
Series | Teach 'getfd' QMP command to import win32 sockets | expand |
marcandre.lureau@redhat.com writes: > From: Marc-André Lureau <marcandre.lureau@redhat.com> > > docker.py is run during configure, and produces an error: No module > named 'pwd'. > > Use a more portable and recommended alternative to lookup the user > "login name". > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> > Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Acked-by: Alex Bennée <alex.bennee@linaro.org>
diff --git a/tests/docker/docker.py b/tests/docker/docker.py index 3a1ed7cb18..688ef62989 100755 --- a/tests/docker/docker.py +++ b/tests/docker/docker.py @@ -23,10 +23,10 @@ import tempfile import re import signal +import getpass from tarfile import TarFile, TarInfo from io import StringIO, BytesIO from shutil import copy, rmtree -from pwd import getpwuid from datetime import datetime, timedelta @@ -316,7 +316,7 @@ def build_image(self, tag, docker_dir, dockerfile, if user: uid = os.getuid() - uname = getpwuid(uid).pw_name + uname = getpass.getuser() tmp_df.write("\n") tmp_df.write("RUN id %s 2>/dev/null || useradd -u %d -U %s" % (uname, uid, uname)) @@ -570,7 +570,7 @@ def run(self, args, argv): if args.user: uid = os.getuid() - uname = getpwuid(uid).pw_name + uname = getpass.getuser() df.write("\n") df.write("RUN id %s 2>/dev/null || useradd -u %d -U %s" % (uname, uid, uname))