Hi,

After thorough discussion, and a lot of help from people in #debian-women
(mainly Jeroen van Wolffelaar, Steve Langasek, Branden Robinson and Helen
Faulkner) I was able to finish this patch.

The patch adapts parts of the cleanlinks script which I was pointed to by
Steve. cleanlinks is part of the xutils package. The adapted script
replaces the calls to symlinks in /etc/cron.daily/lists-archive. Thus it
removes the dependency on the symlinks package, as requested by Frank
Lichtenstein in the original bug report.

Initially, a simpler script was tested, which turned out to be vulnerable to
maliciously constructed symlinks. This is solved in the new script by the use
of the -f test since, as Steve mentioned, "the only time [ -f "$i" ] returns
false for something that's on the filesystem is a dangling symlink".

The attached patch contains all the changes, including those to the copyright
file as discussed with Branden on IRC as well as the removed dependency on
the symlinks package.

Thanks again to Jeroen, Steve, Branden and Helen; I couldn't have done this
without their help.

--Thierry
diff -Nur lists-archives-200300506.orig/debian/control 
lists-archives-200300506/debian/control
--- lists-archives-200300506.orig/debian/control        2003-05-07 
21:01:53.000000000 +0200
+++ lists-archives-200300506/debian/control     2005-01-10 00:34:13.000000000 
+0100
@@ -7,7 +7,7 @@
 
 Package: lists-archives
 Architecture: all
-Depends: perl5, mhonarc, procmail, symlinks
+Depends: perl5, mhonarc, procmail
 Description: Web archive for mailing lists
  Creates a website of historical posts to mailing lists, in the sorted
  style used by the Debian Project (http://www.debian.org/Lists-Archives).
diff -Nur lists-archives-200300506.orig/debian/copyright 
lists-archives-200300506/debian/copyright
--- lists-archives-200300506.orig/debian/copyright      2001-08-27 
16:03:57.000000000 +0200
+++ lists-archives-200300506/debian/copyright   2005-01-12 01:36:25.000000000 
+0100
@@ -16,3 +16,41 @@
 
 On Debian GNU/Linux systems, the text of the GPL can be found in
 /usr/share/common-licenses/GPL.
+
+
+The script /etc/cron.daily/lists-archives includes code adapted from the
+`cleanlinks' script that is copyright (C) 2000 by The XFree86 Project, Inc.
+and released under the XFree86 1.0 License, the text of which follows:
+
+---
+
+                            XFree86 License
+
+XFree86 code without an explicit copyright is covered by the following copy-
+right/license:
+
+Copyright (C) 1994-2003 The XFree86 Project, Inc.  All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is fur-
+nished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT-
+NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON-
+NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the XFree86 Project shall not
+be used in advertising or otherwise to promote the sale, use or other deal-
+ings in this Software without prior written authorization from the XFree86
+Project.
+
+---
diff -Nur lists-archives-200300506.orig/debian/cron.daily 
lists-archives-200300506/debian/cron.daily
--- lists-archives-200300506.orig/debian/cron.daily     2003-05-06 
18:13:47.000000000 +0200
+++ lists-archives-200300506/debian/cron.daily  2005-01-12 01:48:31.000000000 
+0100
@@ -1,4 +1,25 @@
 #!/bin/sh -e
+
+# Silently remove dangling symlinks.
+#
+# This function is adapted from the `cleanlinks' program which is part of
+# XFree86 (see /usr/share/doc/lists-archives/copyright).
+function clean_symlinks
+{
+    if [ -n "$1" ]; then
+        find "$1" -type l -print |
+        (
+            read i || break
+            while [ -n "$i" ]; do
+                if [ ! -f "$i" ]; then
+                    rm -f "$i"
+                fi
+                read i || break
+            done
+        )
+    fi
+}
+
 [ -d /var/lib/lists-archives/archives ] || exit 0
 umask 002
 
@@ -23,8 +44,7 @@
     [ -f ../lists/$dir ] || touch ../lists/$dir
 done
 
-# Not sure yet why this is needed.  :-)
-symlinks -dr /var/lib/lists-archives > /dev/null 2>&1
+clean_symlinks /var/lib/lists-archives
 
 # Fix stray ownerships and permissions (searchlists.log must be www-data).
 chown -R daemon.list /var/lib/lists-archives/archives
@@ -51,4 +71,4 @@
     ln -sf $dir $base
 done
 
-symlinks -dr /var/lib/lists-archives > /dev/null 2>&1
+clean_symlinks /var/lib/lists-archives

Reply via email to