[Pkg-sysvinit-devel] Bug#431224: Bug#431224: deinstallation does not work either with + or * in package name

Petter Reinholdtsen pere at hungry.com
Sat Dec 15 23:02:08 UTC 2007


[Henrique de Moraes Holschuh]
> Exactly.  Banging out with an error in update-rc.d if anything tries
> that is the right thing to do.

Perhaps something like this is a good idea:

--- debian/sysv-rc/sbin/update-rc.d	2007-12-15 23:58:51.000000000 +0100
+++ debian/sysv-rc/sbin/update-rc.d	2007-12-15 23:57:19.000000000 +0100
@@ -44,6 +44,12 @@
 
 &usage() if ($#ARGV < 1);
 my $bn = shift @ARGV;
+
+unless ($bn =~ m/[a-zA-Z0-9+.-]+/) {
+    print STDERR "update-rc.d: illegal character in basename '$bn'\n";
+    exit (1);
+}
+
 if ($ARGV[0] ne 'remove') {
     if (! -f "$initd/$bn") {
 	print STDERR "update-rc.d: $initd/$bn: file does not exist\n";
@@ -103,8 +109,10 @@
 	    die("update-rc.d: chdir $etcd$i.d: $!\n");
 	}
 	opendir(DIR, ".");
+	my $saveBN=$bn;
+	$saveBN =~ s/\+/\\+/g;
 	foreach $_ (readdir(DIR)) {
-	    next unless (/^[SK]\d\d$bn$/);
+	    next unless (/^[SK]\d\d$saveBN$/);
 	    $fn = "$etcd$i.d/$_";
 	    $found = 1;
 	    $islnk = &is_link ($_[0], $fn, $bn);

The patch is completely untested.

Happy hacking,
-- 
Petter Reinholdtsen





More information about the Pkg-sysvinit-devel mailing list