diff options
author | Norbert Preining <preining@logic.at> | 2012-05-30 20:50:57 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2012-05-30 20:50:57 +0000 |
commit | 73249f7259a59696fe2d6d0a9cc277efab0544a3 (patch) | |
tree | 7128f59991fdddcd274f7c1ee9557725dc2edd66 /Master/texmf | |
parent | 235f3af358ce5e23cf34c18145734eea96f6d1b7 (diff) |
update from source
git-svn-id: svn://tug.org/texlive/trunk@26732 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf')
-rwxr-xr-x | Master/texmf/scripts/tetex/updmap.pl | 51 |
1 files changed, 48 insertions, 3 deletions
diff --git a/Master/texmf/scripts/tetex/updmap.pl b/Master/texmf/scripts/tetex/updmap.pl index 5e1c38e7888..7ecae45ac53 100755 --- a/Master/texmf/scripts/tetex/updmap.pl +++ b/Master/texmf/scripts/tetex/updmap.pl @@ -1,6 +1,6 @@ #!/usr/bin/env perl # mupdmap: utility to maintain map files for outline fonts. -# $Id: updmap.pl 26537 2012-05-21 13:20:24Z preining $ +# $Id: updmap.pl 26731 2012-05-30 20:50:14Z preining $ # # Copyright 2011, 2012 Norbert Preining # This file is licensed under the GNU General Public License version 2 @@ -33,7 +33,7 @@ BEGIN { } -my $version = '$Id: updmap.pl 26537 2012-05-21 13:20:24Z preining $'; +my $version = '$Id: updmap.pl 26731 2012-05-30 20:50:14Z preining $'; use Getopt::Long qw(:config no_autoabbrev ignore_case_always); use strict; @@ -43,6 +43,13 @@ use TeXLive::TLUtils qw(mkdirhier mktexupd win32 basename dirname #use Data::Dumper; #$Data::Dumper::Indent = 1; +my $prg = basename($0); + +# sudo sometimes does not reset the home dir of root, check on that +# see more comments at the definition of the function itself +# this function checks by itself whether it is running on windows or not +reset_root_home(); + chomp(my $TEXMFMAIN = `kpsewhich --var-value=TEXMFMAIN`); chomp(my $TEXMFVAR = `kpsewhich -var-value=TEXMFVAR`); chomp(my $TEXMFCONFIG = `kpsewhich -var-value=TEXMFCONFIG`); @@ -55,7 +62,6 @@ if (win32()) { $TEXMFROOT = lc($TEXMFROOT); } -my $prg = basename($0); my %opts = ( quiet => 0, nohash => 0, nomkmap => 0 ); my $alldata; @@ -1855,6 +1861,45 @@ sub merge_data { } } + +# +# $HOME and sudo and updmap-sys horror +# some instances of sudo do not reset $HOME to the home of root +# as an effect of "sudo updmap" creates root owned files in the home +# of a normal user, and "sudo updmap-sys" uses map files and updmap.cfg +# files from the directory of a normal user, but creating files +# in TEXMFSYSCONFIG. This is *all* wrong. +# we check: if we are running as UID 0 (root) on Unix and the +# ENV{HOME} is NOT the same as the one of root, then give a warning +# and reset it to the real home dir of root. + +sub reset_root_home { + if (!win32() && ($> == 0)) { # $> is effective uid + my $envhome = $ENV{'HOME'}; + # if $HOME isn't an existing directory, that's ok; TLU does this. + if (defined($envhome) && (-d $envhome)) { + # we want to avoid calling getpwuid as far as possible, so if + # $envhome is either / or /root we accept it straight ahead + if ($envhome eq "/" || $envhome eq "/root") { + return; + } + # $HOME is defined, check what is the home of root in reality + my (undef,undef,undef,undef,undef,undef,undef,$roothome) = getpwuid(0); + if (defined($roothome)) { + if ($envhome ne $roothome) { + warning("$prg: resetting \$HOME value (was $envhome) to root's " + . "actual home ($roothome).\n"); + $ENV{'HOME'} = $roothome; + } else { + # envhome and roothome do agree, nothing to do, that is the good case + } + } else { + warning("$prg: home of root not defined, strange!\n"); + } + } + } +} + sub warning { print STDERR @_; } |