PATCH: fix for broken run-parts

Bernhard Fischer rep.dot.nop at gmail.com
Mon Apr 30 11:28:35 UTC 2007


On Sun, Apr 29, 2007 at 08:59:07AM -0400, Gabriel L. Somlo wrote:
>On Sun, Apr 29, 2007 at 12:14:30PM +0200, Denis Vlasenko wrote:
>> If the --lsbsysinit option is not given then the names
>> must consist entirely of upper and lower case letters,
>> digits, underscores, and hyphens. 
>
>But that should apply to the 'basename' part of the filename only, not to
>the 'dirname' part of it !
>
>ifupdown.c wants to run-parts in the following directories:
>
>	/etc/network/if-pre-up.d/
>	/etc/network/if-up.d/
>	/etc/network/if-down.d/
>	/etc/network/if-post-down.d/
>
>The current check in run-parts does nothing (and thus ifupdown.c
>fails) because as it is now, the check skips over perfectly well named
>files in those directories, due to the dot in the *directory* name. I'm
>sure that's not what was intended :)

Ok, what about passing basename(file) into act() then?

That would sound much cleaner to me than your suggestion below, no?
>
>What about the second iteration of the patch, which skips over the
>directory name before starting to check ? I botched it when I sent it
>last time (one should never rush these things :) but here it is again:
>
>
>diff -NarU5 busybox-svn-18518.orig/debianutils/run_parts.c busybox-svn-18518/debianutils/run_parts.c
>--- busybox-svn-18518.orig/debianutils/run_parts.c	2007-04-26 17:29:48.000000000 -0400
>+++ busybox-svn-18518/debianutils/run_parts.c	2007-04-29 08:53:24.000000000 -0400
>@@ -58,16 +58,21 @@
> /* True or false? Is this a valid filename (upper/lower alpha, digits,
>  * underscores, and hyphens only?)
>  */
> static bool invalid_name(const char *c)
> {
>-	while (*c) {
>-		if (!isalnum(*c) && (*c != '_') && (*c != '-' && (*c != '/'))) {
>-			return 1;
>-		}
>-		++c;
>-	}
>+	char *base_name = strrchr(c, '/');
>+
>+	if (++base_name)
>+		c = base_name;
>+
>+	while (*c && (isalnum(*c) || *c == '_' || *c == '-'))
>+		c++;
>+
>+	if (*c)
>+		return 1;
>+
> 	return 0;
> }
> #define RUN_PARTS_OPT_a (1<<0)
> #define RUN_PARTS_OPT_u (1<<1)
> #define RUN_PARTS_OPT_t (1<<2)
>
>Gabriel
>_______________________________________________
>busybox mailing list
>busybox at busybox.net
>http://busybox.net/cgi-bin/mailman/listinfo/busybox
>



More information about the busybox mailing list