From 006ac7133ac41df02a9ca28856c08ea359f7a281 Mon Sep 17 00:00:00 2001 From: Olivier Blin Date: Mon, 10 Jan 2011 11:58:26 +0000 Subject: use root wrapper --cp to write sudoers file --- iurt2 | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/iurt2 b/iurt2 index 1f504f7..a3efc83 100755 --- a/iurt2 +++ b/iurt2 @@ -1440,9 +1440,10 @@ sub search_packages { sub add_sudoers { my ($_run, $chroot, $user) = @_; + my $tmpfile = "/tmp/sudoers"; my $file = "$chroot/etc/sudoers"; my $f; - if (!open $f, qq(| $sudo sh -c "cat > $file")) { + if (!open $f, ">$tmpfile") { plog("ERROR: could not open $file ($!)"); return 0; } @@ -1451,9 +1452,17 @@ root ALL=(ALL) ALL $user ALL=(ALL) NOPASSWD:RPM ); close $f; + plog("adding sudo for /bin/rpm, /usr/sbin/urpmi and /usr/sbin/urpme"); - -f $file or return 0; - 1; + my $ret = sudo($run, $config, '--cp', $tmpfile, $file); + unlink $tmpfile; + + if (!$ret) { + plog("ERROR: could not write $file ($!)"); + return 0; + } + + return -f $file; } sub dump_status { -- cgit v1.2.1