summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven Eden <yamakuzure@gmx.net>2013-09-09 15:44:19 +0200
committerSven Eden <yamakuzure@gmx.net>2013-09-09 15:44:19 +0200
commit3746f56e9fda85c5e3329e138e314c8fbffb9046 (patch)
tree36c3d21f0b398fcdf73e12dce1cfa16c4c92283b /Portage.pm
parentChanged the search for files if make.conf is a directory to be done by a recu... (diff)
downloadufed-3746f56e9fda85c5e3329e138e314c8fbffb9046.tar.gz
ufed-3746f56e9fda85c5e3329e138e314c8fbffb9046.tar.bz2
ufed-3746f56e9fda85c5e3329e138e314c8fbffb9046.zip
If the determined make.conf is not writable by the effective uid/gid, a warning is issued and the new shared variable $ro_mode is set to 1.
Diffstat (limited to 'Portage.pm')
-rw-r--r--Portage.pm23
1 files changed, 19 insertions, 4 deletions
diff --git a/Portage.pm b/Portage.pm
index e8c3c15..5d21edf 100644
--- a/Portage.pm
+++ b/Portage.pm
@@ -51,6 +51,10 @@ our $use_flags;
# points to the file the last USE settings are found in.
our $used_make_conf = "";
+# If the found make.conf can not be changed by the effective
+# uid/gid of the caller, this value is set to 1
+our $ro_mode = 0;
+
# --- private members ---
my %_environment = ();
my $_EPREFIX = "";
@@ -274,11 +278,13 @@ sub _determine_make_conf
or $used_make_conf = "${_EPREFIX}/etc/make.conf";
# If $used_make_conf points to a directory now,
- # it is emptied so _read_make_conf will determine
- # the later used value
+ # or if it is simply not present, it is emptied so
+ # _read_make_conf will determine the later used
+ # value
- ( -d $used_make_conf)
- and $used_make_conf = "";
+ if ( (! -e $used_make_conf) || (-d $used_make_conf) ) {
+ $used_make_conf = "";
+ }
return;
}
@@ -729,6 +735,15 @@ sub _read_make_conf {
}
debugMsg("$used_make_conf will be used to store changes");
+ # If the make.conf is not writable, enable read-only-mode
+ if (! -w $used_make_conf ) {
+ my $egid = $);
+ $egid =~ s/\s+.*$//;
+ $ro_mode = 1;
+ print "$used_make_conf not writable by uid/gid $>/$egid\n";
+ print "ufed will run in read-only-mode!\n";
+ }
+
# Note the conf state of the read flags:
for my $flag ( keys %{$oldEnv{USE}}) {
_add_temp($flag, "global");