tests/docker: fix a win32 error due to portability
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>
This commit is contained in:
parent
8467936e3d
commit
e387ef472f
@ -23,10 +23,10 @@ import enum
|
||||
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 @@ class Docker(object):
|
||||
|
||||
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 @@ class UpdateCommand(SubCommand):
|
||||
|
||||
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))
|
||||
|
Loading…
Reference in New Issue
Block a user