Re: [PATCH] run-parts: permit dot in file name

2021-05-13 Thread Ján Sáreník
If dot is the first character of file name, file is ignored. Thanks tito!

See https://gist.github.com/andyshinn/3ae01fa13cb64c9d36e7#gistcomment-2044506

To test:

mkdir /tmp/testrp
printf "#!/bin/sh\necho test\n" > /tmp/testrp/test.sh
chmod a+x /tmp/testrp/*
busybox run-parts /tmp/testrp
test
mv /tmp/testrp/test.sh /tmp/testrp/.test.sh
busybox run-parts /tmp/testrp
# no output
---
 debianutils/run_parts.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/debianutils/run_parts.c b/debianutils/run_parts.c
index 585a4b58f..7677ab894 100644
--- a/debianutils/run_parts.c
+++ b/debianutils/run_parts.c
@@ -119,7 +119,10 @@ static bool invalid_name(const char *c)
 {
c = bb_basename(c);

-   while (*c && (isalnum(*c) || *c == '_' || *c == '-'))
+   if (*c == '.')
+   return *c;
+
+   while (*c && (isalnum(*c) || *c == '_' || *c == '-' || *c == '.'))
c++;

return *c; /* TRUE (!0) if terminating NUL is not reached */
--
2.25.1

On Thu, May 13, 2021 at 2:04 PM tito  wrote:
>
> On Thu, 13 May 2021 11:01:09 +0200
> Ján Sáreník  wrote:
>
> > See
> > https://gist.github.com/andyshinn/3ae01fa13cb64c9d36e7#gistcomment-2044506
> > --- debianutils/run_parts.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/debianutils/run_parts.c b/debianutils/run_parts.c
> > index 585a4b58f..d2a7f4a08 100644
> > --- a/debianutils/run_parts.c
> > +++ b/debianutils/run_parts.c
> > @@ -119,7 +119,7 @@ static bool invalid_name(const char *c)
> >  {
> > c = bb_basename(c);
> >
> > -   while (*c && (isalnum(*c) || *c == '_' || *c == '-'))
> > + while (*c && (isalnum(*c) || *c == '_' || *c == '-' || *c =='.'))
> >  c++;
> >
> > return *c; /* TRUE (!0) if terminating NUL is not reached */
> > --
> > 2.25.1
>
> Hi,
> at a first glance it seems to me that with this patch also hidden files
> (files starting with a dot) are valid names and I suspect this is not 
> acceptable.
> Maybe something like:
>
> p = c  =  bb_basename(c);
>
> while (*c && (isalnum(*c) || *c == '_' || *c == '-' || (*c =='.' && c != p)))
>   c++;
>
> or
>
>  c  =  bb_basename(c);
>
> if ( *c == '.  ')
> return *c:
>
> Both untested.
>
> Ciao,
> Tito
> ___
> busybox mailing list
> busybox@busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] run-parts: permit dot in file name

2021-05-13 Thread tito
On Thu, 13 May 2021 11:01:09 +0200
Ján Sáreník  wrote:

> See
> https://gist.github.com/andyshinn/3ae01fa13cb64c9d36e7#gistcomment-2044506
> --- debianutils/run_parts.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/debianutils/run_parts.c b/debianutils/run_parts.c
> index 585a4b58f..d2a7f4a08 100644
> --- a/debianutils/run_parts.c
> +++ b/debianutils/run_parts.c
> @@ -119,7 +119,7 @@ static bool invalid_name(const char *c)
>  {
> c = bb_basename(c);
> 
> -   while (*c && (isalnum(*c) || *c == '_' || *c == '-'))
> + while (*c && (isalnum(*c) || *c == '_' || *c == '-' || *c =='.'))
>  c++;
> 
> return *c; /* TRUE (!0) if terminating NUL is not reached */
> --
> 2.25.1

Hi,
at a first glance it seems to me that with this patch also hidden files
(files starting with a dot) are valid names and I suspect this is not 
acceptable.
Maybe something like:

p = c  =  bb_basename(c);

while (*c && (isalnum(*c) || *c == '_' || *c == '-' || (*c =='.' && c != p)))
  c++;

or 

 c  =  bb_basename(c);
 
if ( *c == '.  ')
return *c:

Both untested.

Ciao,
Tito
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox