[Mageia-sysadm] [261] use root wrapper --cp to write sudoers file
root at mageia.org
root at mageia.org
Mon Jan 10 12:58:26 CET 2011
Revision: 261
Author: blino
Date: 2011-01-10 12:58:26 +0100 (Mon, 10 Jan 2011)
Log Message:
-----------
use root wrapper --cp to write sudoers file
Modified Paths:
--------------
build_system/iurt/trunk/iurt2
Modified: build_system/iurt/trunk/iurt2
===================================================================
--- build_system/iurt/trunk/iurt2 2011-01-10 11:56:51 UTC (rev 260)
+++ build_system/iurt/trunk/iurt2 2011-01-10 11:58:26 UTC (rev 261)
@@ -1440,9 +1440,10 @@
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 @@
$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 {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/mageia-sysadm/attachments/20110110/a845f1dc/attachment.html>
More information about the Mageia-sysadm
mailing list