Dr. Werner Fink 2012-04-23 13:24:05 +00:00 committed by Git OBS Bridge
parent 9fe2414e64
commit 730439ad02
4 changed files with 363 additions and 366 deletions

View File

@ -7,7 +7,7 @@
# #
# Please submit bugfixes or comments via http://bugs.opensuse.org/ # Please submit bugfixes or comments via http://bugs.opensuse.org/
# #
# Author: Werner Fink, 1997-2011 # Author: Werner Fink, 1997-2012
# #
typeset -r OLDIFS="$IFS" typeset -r OLDIFS="$IFS"
@ -41,7 +41,7 @@ else
exec 4> /dev/null exec 4> /dev/null
fi fi
type -p texhash &> /dev/null || exit 0 type -p mktexlsr &> /dev/null || exit 0
type -p kpsewhich &> /dev/null || exit 0 type -p kpsewhich &> /dev/null || exit 0
type -p updmap-sys &> /dev/null || exit 0 type -p updmap-sys &> /dev/null || exit 0
type -p find &> /dev/null || { echo "${0##*/}: No find in PATH ... skipping"; exit 0 ; } type -p find &> /dev/null || { echo "${0##*/}: No find in PATH ... skipping"; exit 0 ; }
@ -63,15 +63,8 @@ unset KPSE_DOT || true
: ${TEXMFLSR:=$(kpsewhich --show-path=ls-R 2> /dev/null)} : ${TEXMFLSR:=$(kpsewhich --show-path=ls-R 2> /dev/null)}
: ${WEB2C:=$TEXMFVAR/web2c} : ${WEB2C:=$TEXMFVAR/web2c}
HASHLSR= size=$(find /etc/texmf/ls-R -follow -printf '%s')
for lsr in ${TEXMFLSR//:/ }; do test $size -lt 80 && > /var/run/texlive/run-mktexlsr
find $lsr -prune -type d -and -not -fstype nfs > /dev/null 2>&1 || continue
HASHLSR=${HASHLSR:+$HASHLSR:}${lsr}
size=$(find /etc/texmf/ls-R -follow -printf '%s')
if test $size -lt 80 ; then
> /var/run/texlive/run-texhash
fi
done
tcfmgr () tcfmgr ()
{ {
@ -89,23 +82,31 @@ enablemaps ()
# #
# Straightforward ... here we go # Straightforward ... here we go
# #
if test -e /var/run/texlive/run-texhash; do if test -e /var/run/texlive/run-mktexlsr; then
test $VERBOSE = true && echo -e "\r[ ]Updating TeX hash data base."
mktexlsr < /dev/null 1>&4 2>&4
let rc+=$?
rm -f /var/run/texlive/run-mktexlsr
fi
if test -e /var/run/texlive/run-fmtutil; then
test $VERBOSE = true && echo -e "\r[ ]Updating TeX formats."
fmtutil-sys --missing < /dev/null 1>&4 2>&4
let rc+=$?
rm -f /var/run/texlive/run-fmtutil
fi
if test -e /var/run/texlive/run-updmap; then
test $VERBOSE = true && echo -e "\r[ ]Updating TeX font mappings."
updmap-sys --nohash < /dev/null 1>&4 2>&4
rm -f /var/run/texlive/run-updmap
else
typeset -i n=0 typeset -i n=0
for lsr in ${HASHLSR//:/ }; do
((n++ == 0)) && test $VERBOSE = true && echo -e "\r[ ]Enabling TeX hash data base."
find $lsr -prune -type d -and -not -fstype nfs > /dev/null 2>&1 || continue
if test $f -nt $lsr/ls-R ; then
texhash $lsr 1>&4 2>&4
let rc+=$?
fi
done
cfg=$(tcfmgr --cmd find --file updmap.cfg) cfg=$(tcfmgr --cmd find --file updmap.cfg)
if test -e ${cfg} ; then if test -e ${cfg} ; then
test $VERBOSE = true && echo -e "\r[ ]Enabling TeX font mappings."
updmap-sys --nohash --nomkmap --syncwithtrees < /dev/null 1>&4 2>&4 updmap-sys --nohash --nomkmap --syncwithtrees < /dev/null 1>&4 2>&4
let rc+=$? let rc+=$?
enablemaps | \ enablemaps | \
while read line ; do while read line ; do
((n++ == 0)) && test $VERBOSE = true && echo -e "\r[ ]Updating TeX font mappings."
line='^#![[:space:]]*((Mixed)?Map)[[:space:]]*('$line')' line='^#![[:space:]]*((Mixed)?Map)[[:space:]]*('$line')'
emap=$(sed -n -r "s/$line/\1=\3/p" ${cfg}) emap=$(sed -n -r "s/$line/\1=\3/p" ${cfg})
updmap-sys --nohash --nomkmap --enable $emap < /dev/null 1>&4 2>&4 updmap-sys --nohash --nomkmap --enable $emap < /dev/null 1>&4 2>&4

View File

@ -1,9 +1,9 @@
/* /*
* Nobody For user root run a specific program as user nobody * Nobody For user root run a specific program as user nobody
* *
* Usage: nobody [ls|find|false|true] * Usage: nobody [texhash|ls|find|false|true]
* *
* Copyright (C) 2010 Werner Fink * Copyright (C) 2010,2012 Werner Fink
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -22,6 +22,7 @@
*/ */
#include <errno.h> #include <errno.h>
#include <limits.h>
#include <grp.h> #include <grp.h>
#include <pwd.h> #include <pwd.h>
#include <stdio.h> #include <stdio.h>
@ -42,6 +43,8 @@ static struct {
const char *run; const char *run;
} *lp, list[] = } *lp, list[] =
{ /* prog run */ { /* prog run */
{ "mktexlsr", "/usr/bin/mktexlsr" },
{ "texhash", "/usr/bin/mktexlsr" },
{ "ls", "/bin/ls" }, { "ls", "/bin/ls" },
{ "true", "/bin/true" }, { "true", "/bin/true" },
{ "false", "/bin/false" }, { "false", "/bin/false" },
@ -105,13 +108,13 @@ int main(int argc, char *argv[])
goto err; goto err;
} }
if (ruid == 0 || euid == 0) { if ((pwd = getpwnam("nobody")) == (struct passwd*)0)
goto err;
if (ruid != pwd->pw_uid || euid != pwd->pw_gid) {
int initgrp = 0; int initgrp = 0;
if ((pwd = getpwnam("nobody")) == (struct passwd*)0) if (ruid != pwd->pw_uid) {
goto err;
if (ruid == 0) {
initgrp = 1; initgrp = 1;
ruid = pwd->pw_uid; ruid = pwd->pw_uid;
rgid = pwd->pw_gid; rgid = pwd->pw_gid;
@ -169,6 +172,26 @@ int main(int argc, char *argv[])
} }
} }
} }
if (strcmp(lp->prog, "texhash") == 0 || strcmp(lp->prog, "mktexlsr") == 0) {
int n;
char buf[PATH_MAX+1], *lsr, *base;
for (n = 1; n < argc; n++) {
if (!argv[n] || *argv[n] == '\0')
continue;
if ((lsr = realpath(argv[n], buf)) == NULL)
goto err;
if ((base = strrchr(lsr, '/')) == NULL) {
errno = ENOTSUP;
goto err;
}
if (strcmp(base, "/ls-R") != 0) {
errno = ENOTSUP;
goto err;
}
if (access(lsr, W_OK) != 0)
goto err;
}
}
} }
} }

View File

@ -178,18 +178,30 @@
# The supporting scripts: # The supporting scripts:
: ${MT_MKTEXNAM=`kpsewhich --format='web2c files' mktexnam`} : ${MT_MKTEXNAM=`kpsewhich --format='web2c files' mktexnam`}
--- texk/kpathsea/mktexlsr --- texk/kpathsea/mktexlsr
+++ texk/kpathsea/mktexlsr 2011-09-14 10:37:28.867925384 +0000 +++ texk/kpathsea/mktexlsr 2012-04-23 09:29:20.382064991 +0000
@@ -15,6 +15,9 @@ version='$Id: mktexlsr 23151 2011-06-27 @@ -15,6 +15,21 @@ version='$Id: mktexlsr 23151 2011-06-27
progname=`echo $0 | sed 's%.*/%%'` progname=`echo $0 | sed 's%.*/%%'`
usage="Usage: $progname [OPTION]... [DIR]... usage="Usage: $progname [OPTION]... [DIR]...
+nobody="$(id -un nobody)"
+if test -n "$nobody" -a "$(id -urn 2> /dev/null)" != "$nobody" && type -p nobody > /dev/null 2>&1 ; then
+ grep -qE 'nobody:[^:]*:[0-9]+:0:0::::' /etc/shadow
+ if test $? -eq 0 ; then
+ echo "$progname: Warning the password of the user nobody has expired." >&2
+ echo " Please use program \`chage' to set maxdays to 99999." >&2
+ echo ""
+ exit 1
+ fi
+ exec nobody $0 ${1+"$@"}
+fi
+
+MKTEXLSR=true; export MKTEXLSR +MKTEXLSR=true; export MKTEXLSR
+set -o noclobber +set -o noclobber
+ +
Rebuild ls-R filename databases used by TeX. If one or more arguments Rebuild ls-R filename databases used by TeX. If one or more arguments
DIRS are given, these are used as the directories in which to build DIRS are given, these are used as the directories in which to build
ls-R. Else all directories in the search path for ls-R files ls-R. Else all directories in the search path for ls-R files
@@ -51,6 +54,9 @@ if test "$DOSISH" = "no"; then SEP=':'; @@ -51,6 +66,9 @@ if test "$DOSISH" = "no"; then SEP=':';
# be done before kpsewhich can be called, and thus cannot be put into # be done before kpsewhich can be called, and thus cannot be put into
# mktex.opt. # mktex.opt.
dirname=`echo $0 | sed 's%/*[^/][^/]*$%%'` dirname=`echo $0 | sed 's%/*[^/][^/]*$%%'`
@ -199,58 +211,15 @@
case $dirname in case $dirname in
"") # Do nothing "") # Do nothing
;; ;;
@@ -62,6 +68,28 @@ case $dirname in @@ -134,6 +152,7 @@ old_ls_R_magic='% ls-R -- maintained by
export PATH ;;
esac
+# Sometimes the scripts and binaries are located elsewhere check this
+# by following the links and extend the path with appropiate dirnames.
+ link=`readlink -f $0`
+dirname=`echo $link | sed 's%/*[^/][^/]*$%%'`
+ cpu=`uname -i|tr '[:upper:]' '[:lower:]' | sed 's/ppc64/ppc/;s/i386/i?86/'`
+ os=`uname -s|tr '[:upper:]' '[:lower:]'`
+ binary=`echo $dirname | sed "s%share%lib%;s%noarch%${cpu}-${os}%"`
+ binary=`echo $binary`
+case "$SEP$PATH$SEP" in
+ *$SEP$dirname$SEP*) dirname="" ;;
+esac
+case $dirname in
+ "") # Do nothing
+ ;;
+ /* | [A-z]:/*) # Absolute name
+ PATH="$dirname$SEP$binary$SEP$PATH"
+ export PATH ;;
+ *) # Relative name
+ PATH="`pwd`/$dirname$SEP`pwd`/$binary$SEP$PATH"
+ export PATH ;;
+esac
+
if tty -s; then verbose=true; else verbose=false; fi
dry_run=false
trees=
@@ -134,6 +162,21 @@ old_ls_R_magic='% ls-R -- maintained by
shift shift
} }
+nobody="$(id -un nobody)"
+if test "$(id -ur 2> /dev/null)" = "0" -a -n "$nobody" && type -p nobody > /dev/null 2>&1 ; then
+ grep -qE 'nobody:[^:]*:[0-9]+:0:0::::' /etc/shadow
+ if test $? -eq 0 ; then
+ echo "$progname: Warning the password of the user nobody has expired." >&2
+ echo " Please use program \`chage' to set maxdays to 99999." >&2
+ echo ""
+ exit 1
+ fi
+ runls () { nobody ls -LRa 2>/dev/null; }
+else
+ runls () { ls -LRa 2>/dev/null; }
+fi
+
+cache="`kpsewhich --expand-var='$VARTEXFONTS'`" +cache="`kpsewhich --expand-var='$VARTEXFONTS'`"
for TEXMFLS_R in "$@"; do for TEXMFLS_R in "$@"; do
# Prepend cwd if the directory was relative. # Prepend cwd if the directory was relative.
case "$TEXMFLS_R" in case "$TEXMFLS_R" in
@@ -163,12 +206,23 @@ for TEXMFLS_R in "$@"; do @@ -163,12 +182,23 @@ for TEXMFLS_R in "$@"; do
# want to be silent if the directory doesn't exist, since the ls-R # want to be silent if the directory doesn't exist, since the ls-R
# path ordinarily contains many nonexistent directories. # path ordinarily contains many nonexistent directories.
test -d "$db_dir" || continue test -d "$db_dir" || continue
@ -276,7 +245,7 @@
elif test -s "$db_file" \ elif test -s "$db_file" \
&& test "x`sed '1s/ $//;1q' \"$db_file\"`" != "x$ls_R_magic" \ && test "x`sed '1s/ $//;1q' \"$db_file\"`" != "x$ls_R_magic" \
&& test "x`sed '1s/ $//;1q' \"$db_file\"`" != "x$old_ls_R_magic"; then && test "x`sed '1s/ $//;1q' \"$db_file\"`" != "x$old_ls_R_magic"; then
@@ -179,16 +233,23 @@ for TEXMFLS_R in "$@"; do @@ -179,16 +209,23 @@ for TEXMFLS_R in "$@"; do
# Skip if we cannot write the file: # Skip if we cannot write the file:
kpseaccess -w "$db_file" || { echo "$progname: $db_file: no write permission, skipping..." >&2; continue; } kpseaccess -w "$db_file" || { echo "$progname: $db_file: no write permission, skipping..." >&2; continue; }
@ -304,12 +273,9 @@
# The main task. We put ./: in the output, so top-level files can be # The main task. We put ./: in the output, so top-level files can be
# found via ls-R. Probably irrelevant in practice. The sed command # found via ls-R. Probably irrelevant in practice. The sed command
@@ -200,17 +261,25 @@ for TEXMFLS_R in "$@"; do @@ -202,15 +239,23 @@ for TEXMFLS_R in "$@"; do
#
echo "./:" >>"$db_file_tmp"
vc_dirs='\.\(bzr\|git\|hg\|svn\)\|_darcs' vc_dirs='\.\(bzr\|git\|hg\|svn\)\|_darcs'
- (cd "$TEXMFLS_R" && \ls -LRa 2>/dev/null) \ (cd "$TEXMFLS_R" && \ls -LRa 2>/dev/null) \
+ (cd "$TEXMFLS_R" && \runls) \
| sed -e '/^$/{n;s%^\./%%;s%^%./%;}; /^\.$/d; /^\.\.$/d; /^'$vc_dirs'$/d;' \ | sed -e '/^$/{n;s%^\./%%;s%^%./%;}; /^\.$/d; /^\.\.$/d; /^'$vc_dirs'$/d;' \
- -e '/^[\.\/]*lsR[0-9]*\.tmp:*$/d' \ - -e '/^[\.\/]*lsR[0-9]*\.tmp:*$/d' \
+ -e '/^[\.\/]*lsR[0-9]*\.tmp:*$/d;/^[\.\/]*'${db_dir_tmp##*/}':*$/d' \ + -e '/^[\.\/]*lsR[0-9]*\.tmp:*$/d;/^[\.\/]*'${db_dir_tmp##*/}':*$/d' \

File diff suppressed because it is too large Load Diff