[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#203532: tetex-extra: permissions of ls-R wrong



On Thu, Jul 31, 2003 at 02:44:45PM +0200, Frank K?ster wrote:
> Unfortunately it isn't that simple. We would first have to load
> dh_confmodule, get the answer the user gave at install time ("Which
> group should own the ls-R files?") and chgrp to this. Maybe the others
> can comment on this (I'm not the official maintainer, anyway), but I
> think we should find a clean solution, not only a workaround.

The simplest way is probably to modify mktexlsr to do the following:

  - (safely) create the temporary file in $TMPDIR instead of in the
    same directory as the existing ls-R
  - when all is successful, cat $db_file_tmp > $db_file, so that the
    permissions are preserved.

Here is a patch which does this; what do people think?

--- /usr/bin/mktexlsr	2003-03-03 01:22:09.000000000 +0000
+++ /tmp/mktexlsr	2003-07-31 17:08:25.000000000 +0100
@@ -95,11 +95,8 @@
   # Skip if we cannot write the file:
   access -w "$db_file" || { echo "$progname: $db_file: no write permission. Skipping..." >&2; continue; }
 
-  db_dir_tmp="$db_dir/lsR$$.tmp"
-  (umask 077 && mkdir "$db_dir_tmp" ) \
-    || { echo "$progname: could not create directory '$db_dir_tmp'. Skipping..." >&2; continue; }
-  db_file_tmp="$db_dir_tmp/lsR$$.tmp"
-  rm -f "$db_file_tmp"
+  db_file_tmp=`tempfile -p ls-R` \
+    || { echo "$progname: could not create temporary file for '$db_file'. Skipping..." >&2; continue; }
 
   tty -s && echo "$progname: Updating $db_file... "
   echo "$ls_R_magic" >"$db_file_tmp"
@@ -113,12 +110,8 @@
   (cd "$TEXMFLS_R" && \ls -LRa 2>/dev/null) |
     sed 's%^[^.].*:$%./&%; /^\.$/d; /^\.\.$/d; /^lsR[0-9]*\.tmp$/d' >>"$db_file_tmp"
 
-  # To be really safe, a loop.
-  until PERMS=`kpsestat = "$db_file"`; do sleep 1; done
-  chmod $PERMS "$db_file_tmp"
-  rm -f "$db_file"
-  mv "$db_file_tmp" "$db_file"
-  rm -rf "$db_dir_tmp"
+  cat "$db_file_tmp" > "$db_file"
+  rm -f "$db_file_tmp"
 done
 tty -s && echo "$progname: Done."
 exit 0


   Julian

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

        Julian Gilbey, website: http://www.polya.uklinux.net/
   Debian GNU/Linux Developer, see: http://people.debian.org/~jdg/
     Visit http://www.thehungersite.com/ to help feed the hungry



Reply to: