diff options
author | Olivier Blin <oblin@mandriva.org> | 2004-01-15 16:57:15 +0000 |
---|---|---|
committer | Olivier Blin <oblin@mandriva.org> | 2004-01-15 16:57:15 +0000 |
commit | 40d1bb84fef9ec229bcb117eece7a93886cada86 (patch) | |
tree | 1265f9d60a96f2d23e59aadd143ea5a70cd7153d | |
parent | cf919b18788df5ed01b43018941c262a51596dfe (diff) | |
download | urpmi-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.pm | 12 | ||||
-rw-r--r-- | urpme | 3 | ||||
-rwxr-xr-x | urpmi | 7 | ||||
-rwxr-xr-x | urpmq | 3 |
4 files changed, 10 insertions, 15 deletions
@@ -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 { @@ -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 = {}; @@ -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"; @@ -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 {}; |