[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 03/10] tests/docker: fix a win32 error due to portability
From: |
marcandre . lureau |
Subject: |
[PATCH v3 03/10] tests/docker: fix a win32 error due to portability |
Date: |
Tue, 7 Feb 2023 18:25:28 +0400 |
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>
---
tests/docker/docker.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
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))
--
2.39.1
- [PATCH v3 00/10] Teach 'getfd' QMP command to import win32 sockets, marcandre . lureau, 2023/02/07
- [PATCH v3 01/10] tests: fix path separator, use g_build_filename(), marcandre . lureau, 2023/02/07
- [PATCH v3 02/10] char: do not double-close fd when failing to add client, marcandre . lureau, 2023/02/07
- [PATCH v3 03/10] tests/docker: fix a win32 error due to portability,
marcandre . lureau <=
- [PATCH v3 04/10] osdep: implement qemu_socketpair() for win32, marcandre . lureau, 2023/02/07
- [PATCH v3 05/10] qmp: 'add_client' actually expects sockets, marcandre . lureau, 2023/02/07
- [PATCH v3 06/10] monitor: release the lock before calling close(), marcandre . lureau, 2023/02/07