aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Blin <blino@mageia.org>2011-01-10 11:58:26 +0000
committerOlivier Blin <blino@mageia.org>2011-01-10 11:58:26 +0000
commit006ac7133ac41df02a9ca28856c08ea359f7a281 (patch)
treef10f5fc13836dfe39a57cbee9d5a9b8e3606b4b5
parent6b5f7e0aa26985279767d39865e624752ed0037e (diff)
downloadiurt-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
-rwxr-xr-xiurt215
1 files 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 {