diff options
author | Olivier Blin <blino@mageia.org> | 2011-01-10 11:58:26 +0000 |
---|---|---|
committer | Olivier Blin <blino@mageia.org> | 2011-01-10 11:58:26 +0000 |
commit | 006ac7133ac41df02a9ca28856c08ea359f7a281 (patch) | |
tree | f10f5fc13836dfe39a57cbee9d5a9b8e3606b4b5 /iurt2 | |
parent | 6b5f7e0aa26985279767d39865e624752ed0037e (diff) | |
download | iurt-006ac7133ac41df02a9ca28856c08ea359f7a281.tar iurt-006ac7133ac41df02a9ca28856c08ea359f7a281.tar.gz iurt-006ac7133ac41df02a9ca28856c08ea359f7a281.tar.bz2 iurt-006ac7133ac41df02a9ca28856c08ea359f7a281.tar.xz iurt-006ac7133ac41df02a9ca28856c08ea359f7a281.zip |
use root wrapper --cp to write sudoers file
Diffstat (limited to 'iurt2')
-rwxr-xr-x | iurt2 | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -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 { |