summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2004-12-24 10:08:39 +0000
committerRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2004-12-24 10:08:39 +0000
commit8ffb2ea28196ddeca75ef14eb356ee53ef08bc72 (patch)
tree911e43d68bcce54aa332c525b8f356a9b8f3dc6e
parentb99d49170f0d0d9c39481f1925e66ec3ca17bade (diff)
downloadurpmi-8ffb2ea28196ddeca75ef14eb356ee53ef08bc72.tar
urpmi-8ffb2ea28196ddeca75ef14eb356ee53ef08bc72.tar.gz
urpmi-8ffb2ea28196ddeca75ef14eb356ee53ef08bc72.tar.bz2
urpmi-8ffb2ea28196ddeca75ef14eb356ee53ef08bc72.tar.xz
urpmi-8ffb2ea28196ddeca75ef14eb356ee53ef08bc72.zip
As suggested by Giuseppe Ghibo, fail early if an essential filesystem
is mounted read-only
-rw-r--r--urpm/sys.pm13
-rwxr-xr-xurpmi6
2 files changed, 19 insertions, 0 deletions
diff --git a/urpm/sys.pm b/urpm/sys.pm
index 97f37435..1ccc3b6e 100644
--- a/urpm/sys.pm
+++ b/urpm/sys.pm
@@ -107,4 +107,17 @@ sub find_mntpoints {
@mntpoints;
}
+#- checks if the main filesystems are writeable for urpmi to install files in
+sub check_fs_writable () {
+ open my $mounts, '/proc/mounts' or do { warn "Can't read /proc/mounts: $!\n"; return 1 };
+ local *_;
+ while (<$mounts>) {
+ (undef, our $mountpoint, undef, my $opts) = split ' ';
+ if ($opts =~ /\bro\b/ && $mountpoint =~ m!^(/|/usr|/s?bin)$!) {
+ return 0;
+ }
+ }
+ 1;
+}
+
1;
diff --git a/urpmi b/urpmi
index ede18aff..6e7dcdd0 100755
--- a/urpmi
+++ b/urpmi
@@ -215,6 +215,12 @@ if ($env) {
}
}
+unless ($bug || $install_src || $env || $urpm->{options}{'allow-force'}) {
+ require urpm::sys;
+ urpm::sys::check_fs_writable() or $urpm->{fatal}(1, N("Error: %s appears to be mounted read-only.
+Use --allow-force to force operation.", $urpm::sys::mountpoint));
+}
+
my ($pid_out, $pid_err);
if ($log) {
#- log only at this point in case of query usage.