[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v2 18/25] tests/docker: fix a win32 error due to portability
From: |
marcandre . lureau |
Subject: |
[PULL v2 18/25] tests/docker: fix a win32 error due to portability |
Date: |
Mon, 13 Mar 2023 15:46:41 +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>
Message-Id: <20230306122751.2355515-4-marcandre.lureau@redhat.com>
---
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.2
- [PULL v2 09/25] aio/win32: aio_set_fd_handler() only supports SOCKET, (continued)
- [PULL v2 09/25] aio/win32: aio_set_fd_handler() only supports SOCKET, marcandre . lureau, 2023/03/13
- [PULL v2 10/25] main-loop: remove qemu_fd_register(), win32/slirp/socket specific, marcandre . lureau, 2023/03/13
- [PULL v2 11/25] slirp: unregister the win32 SOCKET, marcandre . lureau, 2023/03/13
- [PULL v2 12/25] slirp: open-code qemu_socket_(un)select(), marcandre . lureau, 2023/03/13
- [PULL v2 13/25] win32: avoid mixing SOCKET and file descriptor space, marcandre . lureau, 2023/03/13
- [PULL v2 16/25] tests: fix path separator, use g_build_filename(), marcandre . lureau, 2023/03/13
- [PULL v2 17/25] char: do not double-close fd when failing to add client, marcandre . lureau, 2023/03/13
- [PULL v2 15/25] win32: replace closesocket() with close() wrapper, marcandre . lureau, 2023/03/13
- [PULL v2 14/25] os-posix: remove useless ioctlsocket() define, marcandre . lureau, 2023/03/13
- [PULL v2 20/25] qmp: 'add_client' actually expects sockets, marcandre . lureau, 2023/03/13
- [PULL v2 18/25] tests/docker: fix a win32 error due to portability,
marcandre . lureau <=
- [PULL v2 19/25] osdep: implement qemu_socketpair() for win32, marcandre . lureau, 2023/03/13
- [PULL v2 21/25] monitor: release the lock before calling close(), marcandre . lureau, 2023/03/13
- [PULL v2 22/25] qmp: add 'get-win32-socket', marcandre . lureau, 2023/03/13
- [PULL v2 23/25] libqtest: make qtest_qmp_add_client work on win32, marcandre . lureau, 2023/03/13
- [PULL v2 24/25] qtest: enable vnc-display test on win32, marcandre . lureau, 2023/03/13
- [PULL v2 25/25] monitor: restrict command getfd to POSIX hosts, marcandre . lureau, 2023/03/13
- Re: [PULL v2 00/25] Win socket patches, Peter Maydell, 2023/03/13