summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 {};