Skip to content

Commit a119caf

Browse files
committed
Fix nopassword sudo on CentOS 7 in docker 20.10.18
## How the problem appears > sudo: timed out reading password ## Known prerequisites to reproduce the problem * Ubuntu host system. * Docker 20.10.18 or newer. * A build against CentOS 7 (`OS=el DIST=7 /path/to/packpack`). I'm not sure, but maybe we also need an `rpm/prebuild.sh` script that invokes `sudo`. ## Summary of investigation In given circumstances the following sudoers line doesn't work as expected: ``` %wheel ALL=(ALL) NOPASSWD: ALL ``` ## Brief explanation of the fix Add current user into sudoers file: ``` <..user..> ALL=(ALL) NOPASSWD: ALL ``` `printf` is used instead of `echo` for portability between `bash` and `dash`. ## Details A more detailed investigation of the problem and an explanation of the fix could be found in the linked issue. Fixes #145
1 parent d420733 commit a119caf

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

packpack

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ else
136136
echo "usermod -a -G sudo $USER 2>/dev/null || :";
137137
echo "usermod -a -G wheel $USER 2>/dev/null || :";
138138
echo "usermod -a -G adm $USER 2>/dev/null || :";
139+
printf 'printf "%s\\tALL=(ALL)\\tNOPASSWD: ALL\\n" >> /etc/sudoers\n' $USER
139140
echo "export HOME=/home/$USER" ;
140141
echo "exec chroot --userspec=$USER / \$@";
141142
) > ${BUILDDIR}/userwrapper.sh

0 commit comments

Comments
 (0)