summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.org>2004-01-15 16:57:15 +0000
committerOlivier Blin <oblin@mandriva.org>2004-01-15 16:57:15 +0000
commit40d1bb84fef9ec229bcb117eece7a93886cada86 (patch)
tree1265f9d60a96f2d23e59aadd143ea5a70cd7153d
parentcf919b18788df5ed01b43018941c262a51596dfe (diff)
downloadurpmi-40d1bb84fef9ec229bcb117eece7a93886cada86.tar
urpmi-40d1bb84fef9ec229bcb117eece7a93886cada86.tar.gz
urpmi-40d1bb84fef9ec229bcb117eece7a93886cada86.tar.bz2
urpmi-40d1bb84fef9ec229bcb117eece7a93886cada86.tar.xz
urpmi-40d1bb84fef9ec229bcb117eece7a93886cada86.zip
- urpmi, urpme, urpmq: / can be used as root, it's not a particular case
- urpm.pm: lock rpm db in chroot, and urpmi db in / - urpmi: ask to be root to install binary rpms in chroot
-rw-r--r--urpm.pm12
-rw-r--r--urpme3
-rwxr-xr-xurpmi7
-rwxr-xr-xurpmq3
4 files changed, 10 insertions, 15 deletions
diff --git a/urpm.pm b/urpm.pm
index decfd7d4..6cbea321 100644
--- a/urpm.pm
+++ b/urpm.pm
@@ -2690,6 +2690,10 @@ sub download_source_packages {
%sources, %error_sources;
}
+#- lock policy concerning chroot :
+# - lock rpm db in chroot
+# - lock urpmi db in /
+
#- safety rpm db locking mechanism
sub exlock_rpm_db {
my ($urpm) = @_;
@@ -2698,7 +2702,7 @@ sub exlock_rpm_db {
my ($LOCK_EX, $LOCK_NB) = (2, 4);
#- lock urpmi database, but keep lock to wait for an urpmi.update to finish.
- open RPMLOCK_FILE, ">$urpm->{statedir}/.RPMLOCK";
+ open RPMLOCK_FILE, ">$urpm->{root}/$urpm->{statedir}/.RPMLOCK";
flock RPMLOCK_FILE, $LOCK_EX|$LOCK_NB or $urpm->{fatal}(7, N("urpmi database locked"));
}
sub shlock_rpm_db {
@@ -2708,12 +2712,12 @@ sub shlock_rpm_db {
my ($LOCK_SH, $LOCK_NB) = (1, 4);
#- create the .LOCK file if needed (and if possible)
- unless (-e "$urpm->{statedir}/.RPMLOCK") {
- open RPMLOCK_FILE, ">$urpm->{statedir}/.RPMLOCK";
+ unless (-e "$urpm->{root}/$urpm->{statedir}/.RPMLOCK") {
+ open RPMLOCK_FILE, ">$urpm->{root}/$urpm->{statedir}/.RPMLOCK";
close RPMLOCK_FILE;
}
#- lock urpmi database, if the LOCK file doesn't exists no share lock.
- open RPMLOCK_FILE, "$urpm->{statedir}/.RPMLOCK" or return;
+ open RPMLOCK_FILE, "$urpm->{root}/$urpm->{statedir}/.RPMLOCK" or return;
flock RPMLOCK_FILE, $LOCK_SH|$LOCK_NB or $urpm->{fatal}(7, N("urpmi database locked"));
}
sub unlock_rpm_db {
diff --git a/urpme b/urpme
index 59f1a610..1d6efb9c 100644
--- a/urpme
+++ b/urpme
@@ -68,9 +68,6 @@ while (defined($_ = shift @ARGV)) {
push @l, $_;
}
-# We assume --root / is stupid (P. Terjan idea)
-$root =~ s!^/*$!!;
-
my $urpm = new urpm;
my $state = {};
diff --git a/urpmi b/urpmi
index 4fd44977..3432f034 100755
--- a/urpmi
+++ b/urpmi
@@ -239,9 +239,6 @@ while (defined($_ = shift @argv)) {
$src = 0; #- reset switch for next package.
}
-# We assume --root / is stupid (P. Terjan idea)
-$root =~ s!^/*$!!;
-
#- use install_src to promote all names as src package.
if ($install_src) {
@files and $urpm->{fatal}(1, N("What can be done with binary rpm files when using --install-src"));
@@ -269,8 +266,8 @@ if ($env) {
$urpm->{statedir} = $env;
} else {
if ($uid > 0) {
- #- only src files are installable using urpmi.
- !($install_src || $root) and @names || @files and $urpm->{fatal}(1, N("Only superuser is allowed to install packages"));
+ #- need to be root if binary rpms are to be installed
+ @names || @files and $urpm->{fatal}(1, N("Only superuser is allowed to install packages"));
} else {
#- allow log if not defined.
$log ||= "/var/log/urpmi.log";
diff --git a/urpmq b/urpmq
index 4abf1323..394c66a9 100755
--- a/urpmq
+++ b/urpmq
@@ -166,9 +166,6 @@ while (defined($_ = shift @ARGV)) {
$query->{src} = 0; #- reset switch for next package.
}
-# We assume --root / is stupid (P. Terjan idea)
-$root =~ s!^/*$!!;
-
#- remove verbose if not asked.
$query->{verbose} or $urpm->{log} = sub {};