PATCH: fix for broken run-parts
Gabriel L. Somlo
somlo at cmu.edu
Sat Apr 28 10:07:08 PDT 2007
On Sat, Apr 28, 2007 at 02:14:50PM +0000, Nathan Angelacos wrote:
> According to the run-parts manpage:
>
> >run-parts runs a number of scripts or programs found in a single
> >directory directory. Filenames should consist entirely of upper and
> >lower case letters, digits, underscores, and hyphens. Subdirectories of
> >directory and files with other names will be silently ignored.
>
> /foo/bar/blah.ext should not be executed. :-/
Great, I'm perfectly fine with that :) But what about /foo/bar.d/blah ?
The current check will skip over this one as well, and therein lies
the rub :)
>
> Once you accept it, it can be used to advantage... To temporarily
> disable a cron script in the daily or hourly directory, simply rename it
> to: "foo.disabled", and run-parts quits running it.
>
> Please don't take that away.
OK, how about this new patch (still against svn 18518) ?
Bernhard, will this work for you ?
Cheers,
Gabriel
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-28 12:59:25.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) || strchr("_-/", *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)
diff -NarU5 busybox-svn-18518.orig/foo.bar/bar.blah busybox-svn-18518/foo.bar/bar.blah
--- busybox-svn-18518.orig/foo.bar/bar.blah 1969-12-31 19:00:00.000000000 -0500
+++ busybox-svn-18518/foo.bar/bar.blah 2007-04-28 12:58:09.000000000 -0400
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+echo ALABALA
More information about the busybox
mailing list