Re: Bug in cron postinst

2003-09-04 Thread Christian Perrier
Quoting Steve Greenland ([EMAIL PROTECTED]):

> > That one is among the oldests "please switch to po-debconf" bugs filed
> > by the french translation team. 
> 
> I'm going to pull the debconf template completely and use the News file,
> which is the appropriate place for that note.

This is common these times and I understand the reasons. However, this
has one drawback : there is currently no way to handle l10n of
README.Debian or other files, so these notes will remain
untranslated

For sarge+1, we definitely need a mechanisme for handling at least
README.Debian translations.





Re: Bug in cron postinst

2003-09-03 Thread John H. Robinson, IV
Matt Zimmerman wrote:
> On Wed, Sep 03, 2003 at 01:40:51PM -0700, John H. Robinson, IV wrote:
> 
> > Matt Zimmerman wrote:
> > > there:[~] /bin/bash
> > > [EMAIL PROTECTED]:~$ foo="a b"
> > > [EMAIL PROTECTED]:~$ for x in $foo; do echo "$x"; done
> > 
> > > a
> > > b
> > 
> > $ foo="a  b"; for x in "$foo"; do echo "$x" : $x; done
> > a  b : a b
> 
> That misses the whole point, which was to iterate over a list of items, some
> of which could contain whitespace.

i understand that. the whole point i was trying to make is that using
bash and sh variables is inadequate to that task.

% a=("apple  tony  the  one  and"\ \ only fred betty "wilma")
% for i in $a ; do echo $i ; done  
apple  tony  the  one  and  only
fred
betty
wilma

as i said, zsh users are excused from this excercise.

for the bash purists:

$ a=("one  two" "a  b" "i  ii")
$ for i in "[EMAIL PROTECTED]"; do echo "$i"; done
one  two
a  b
i  ii

good luck setting that array from the output of find(1), though.
remember, newline is a valid filename character.

quick testing indicates that ``a=(*)'' works, even for files with
embedded newlines. but wasn't the whole point to get away from shell
expansions?

in the following example, file?3 has an embedded newline, and "file 1"
has an embedded space

$ touch file\ 1 file2 file'
> '3
$ a=(*)
$ for i in "[EMAIL PROTECTED]"; do echo :"$i":; done
:file
3:
:file 1:
:file2:


-john




Re: Bug in cron postinst

2003-09-03 Thread Matt Zimmerman
On Wed, Sep 03, 2003 at 01:40:51PM -0700, John H. Robinson, IV wrote:

> Matt Zimmerman wrote:
> > there:[~] /bin/bash
> > [EMAIL PROTECTED]:~$ foo="a b"
> > [EMAIL PROTECTED]:~$ for x in $foo; do echo "$x"; done
> 
> > a
> > b
> 
> $ foo="a  b"; for x in "$foo"; do echo "$x" : $x; done
> a  b : a b

That misses the whole point, which was to iterate over a list of items, some
of which could contain whitespace.

-- 
 - mdz




Re: Bug in cron postinst

2003-09-03 Thread John H. Robinson, IV
Matt Zimmerman wrote:
> On Wed, Sep 03, 2003 at 05:20:54PM +0100, Colin Watson wrote:
> 
> > > [EMAIL PROTECTED]:/tmp/bar% bash
> > > bash-2.05b$ L=`find`  
> > > bash-2.05b$ for i in $L; do echo $i; done
> > > .
> > > ./a
> > > b
> > 
> > No wonder. You aren't quoting correctly! Use 'echo "$i"'.
> 
> there:[~] /bin/bash
> [EMAIL PROTECTED]:~$ foo="a b"
> [EMAIL PROTECTED]:~$ for x in $foo; do echo "$x"; done

> a
> b

$ foo="a  b"; for x in "$foo"; do echo "$x" : $x; done
a  b : a b

note that whenever you use "$variable" you need to enclose it in quotes
to protect it from word separation. zsh users are excused from this
excercise.

looking back at the original script, we see the problem began with
find(1) which has a very hard time with whitespace (newlines,
specifically) in filenames. enclosing the invocation in backticks
guarantees that the $L variable will be broken if a filename has any
whitespace (spaces, tabs, or newlines) in it.

the -print0 command to GNU find gets around this problem nicely, as the
NULL character is not a valid filename character to begin with. it is
left as an excercise for the reader to properly parse the output of
-print0 for their own specific application.

-john




Re: Bug in cron postinst

2003-09-03 Thread Matt Zimmerman
On Wed, Sep 03, 2003 at 05:20:54PM +0100, Colin Watson wrote:

> > [EMAIL PROTECTED]:/tmp/bar% bash
> > bash-2.05b$ L=`find`  
> > bash-2.05b$ for i in $L; do echo $i; done
> > .
> > ./a
> > b
> 
> No wonder. You aren't quoting correctly! Use 'echo "$i"'.

there:[~] /bin/bash
[EMAIL PROTECTED]:~$ foo="a b"
[EMAIL PROTECTED]:~$ for x in $foo; do echo "$x"; done
a
b

-- 
 - mdz




Re: Bug in cron postinst

2003-09-03 Thread John H. Robinson, IV
Jan Schulz wrote:
> [EMAIL PROTECTED]:/tmp/tmp$ IFS="
> "
> [EMAIL PROTECTED]:/tmp/tmp$ for i in $L; do echo $i; done
> .
> ./a b
> 
> Jan, learned the hard way...

except for filenames with embedded newlines. use "$i", and worry no
more.

-john




Re: Bug in cron postinst

2003-09-03 Thread Jan Schulz
Hallo Goswin,

* Goswin von Brederlow wrote:
>(my normal shell is zsh)
>[EMAIL PROTECTED]:/tmp/bar% touch "a b"
>[EMAIL PROTECTED]:/tmp/bar% L=`find` 
>[EMAIL PROTECTED]:/tmp/bar% for i in $L; do echo $i; done
>.
>./a b
>[EMAIL PROTECTED]:/tmp/bar% bash
>bash-2.05b$ L=`find`  
>bash-2.05b$ for i in $L; do echo $i; done
>.
>./a
>b
[EMAIL PROTECTED]:/tmp/tmp$ IFS="
"
[EMAIL PROTECTED]:/tmp/tmp$ for i in $L; do echo $i; done


Re: Bug in cron postinst

2003-09-03 Thread Colin Watson
On Wed, Sep 03, 2003 at 11:12:36AM +0200, Goswin von Brederlow wrote:
> Andreas Metzler <[EMAIL PROTECTED]> writes:
> > Goswin von Brederlow <[EMAIL PROTECTED]> wrote:
> > > And lets add a user with homedir "`rm -rf ..`" just for fun.

Variable expansion happens at the same time as command substitution, not
before it. See EXPANSION in bash(1).

> > [EMAIL PROTECTED]:/tmp/big> bar="\`yes\`"
> > echo $bar
> > `yes`
> 
> I'm allways a bit overcarefull with for loops, globing and splitting.
> Depending on the shell you get different behaviours. In this simple
> case it seems to work out right but take the following as an example:
> 
> (my normal shell is zsh)
> [EMAIL PROTECTED]:/tmp/bar% touch "a b"
> [EMAIL PROTECTED]:/tmp/bar% L=`find` 
> [EMAIL PROTECTED]:/tmp/bar% for i in $L; do echo $i; done
> .
> ./a b
> [EMAIL PROTECTED]:/tmp/bar% bash
> bash-2.05b$ L=`find`  
> bash-2.05b$ for i in $L; do echo $i; done
> .
> ./a
> b

No wonder. You aren't quoting correctly! Use 'echo "$i"'.

-- 
Colin Watson  [EMAIL PROTECTED]




Re: Bug in cron postinst

2003-09-03 Thread Matt Zimmerman
On Wed, Sep 03, 2003 at 10:48:36AM -0500, Steve Greenland wrote:

> On 03-Sep-03, 01:33 (CDT), Goswin von Brederlow <[EMAIL PROTECTED]> wrote: 
> > And lets add a user with homedir "`rm -rf ..`" just for fun.
> 
> I'm missing something here. What does the user's homedir have to do with
> anything? The entry in the spool dir is the username.
> 
> Someone else mentioned usernames with spaces...is that really supported?

I suppose it could be.  I think that:

find /var/spool/cron/crontabs -mindepth 1 -maxdepth 1 -print0 | xargs -0 -r 
chgrp crontab

will handle all cases, including an empty directory, and will also fork
less.

Of course, if usernames can contain slashes, we are all in far worse
trouble. :-)

-- 
 - mdz




Re: Bug in cron postinst

2003-09-03 Thread Matt Zimmerman
On Wed, Sep 03, 2003 at 08:33:26AM +0200, Goswin von Brederlow wrote:

> Steve Greenland <[EMAIL PROTECTED]> writes:
> 
> > for ct in * ; do
> > chown $ct:crontab $ct
> > done
> [...]
> And lets add a user with homedir "`rm -rf ..`" just for fun.

That command line has nothing to do with home directories, and doesn't look
anything up in the passwd file (chown does internally, but I don't think you
can do anything harmful).

-- 
 - mdz




Re: Bug in cron postinst

2003-09-03 Thread Steve Greenland
On 02-Sep-03, 23:50 (CDT), Christian Perrier <[EMAIL PROTECTED]> wrote: 
> Quoting Steve Greenland ([EMAIL PROTECTED]):
> 
> > Yes, obvious in retrospect, and I'll put the brown paper bag on my head
> > after I upload the fix.
> 
> Will the fix include the switch to po-debconf proposed in #195887??

No, it's a fix for a specific problem. 

> That one is among the oldests "please switch to po-debconf" bugs filed
> by the french translation team. 

I'm going to pull the debconf template completely and use the News file,
which is the appropriate place for that note.

Steve

-- 
Steve Greenland
The irony is that Bill Gates claims to be making a stable operating
system and Linus Torvalds claims to be trying to take over the
world.   -- seen on the net




Re: Bug in cron postinst

2003-09-03 Thread Steve Greenland
On 03-Sep-03, 01:33 (CDT), Goswin von Brederlow <[EMAIL PROTECTED]> wrote: 
> And lets add a user with homedir "`rm -rf ..`" just for fun.

I'm missing something here. What does the user's homedir have to do with
anything? The entry in the spool dir is the username.

Someone else mentioned usernames with spaces...is that really supported?

Steve

-- 
Steve Greenland
The irony is that Bill Gates claims to be making a stable operating
system and Linus Torvalds claims to be trying to take over the
world.   -- seen on the net




Re: Bug in cron postinst

2003-09-03 Thread Christian Perrier
Quoting Steve Greenland ([EMAIL PROTECTED]):

> Yes, obvious in retrospect, and I'll put the brown paper bag on my head
> after I upload the fix.

Will the fix include the switch to po-debconf proposed in #195887 ?

That one is among the oldests "please switch to po-debconf" bugs filed
by the french translation team. 





Re: Bug in cron postinst

2003-09-03 Thread Roland Bauerschmidt
Steve Greenland wrote:
> for ct in * ; do
> chown $ct:crontab $ct
> done

This will also fail with usernames that include spaces. I'm sure you
already have a solution, but I'd go with something like this:

find /var/spool/crontab -maxdepth 1 -type f -print | while read ct; do
...
done

Roland




Re: Bug in cron postinst

2003-09-03 Thread Andreas Metzler
Goswin von Brederlow <[EMAIL PROTECTED]> wrote:
> Andreas Metzler <[EMAIL PROTECTED]> writes:
>> Goswin von Brederlow <[EMAIL PROTECTED]> wrote:
>>> Steve Greenland <[EMAIL PROTECTED]> writes:
[...]  
 for ct in * ; do
 chown $ct:crontab $ct
 done
 
>>> This also won't work with too many users.
 
>> No, it will.
 
>> [EMAIL PROTECTED]:/tmp/big> rm *
>> bash: /bin/rm: Argument list too long
>> [EMAIL PROTECTED]:/tmp/big> for ct in *; do rm $ct ; done \
>>   && echo success
>> success

> for doesn't fork so the realy small commandline limit isn't a
> problem. But are you sure the shell does not read in a full list for
> "*" and then work through that?

I've no idea ...

> Ok, with more users than you can hold
> in ram you have other problems.
[...]

... yes. A list of a million users would not take more 20MB of RAM,
but both the number of users and having a directory with a million
entries would probably be unbearably slow.

The RAM-Limit is not of any interest at all, because looping a million
times takes ages. (Just compare "for i in * ; do touch $i ; done"
with "find -maxdepth 1 -print0 | xargs -0r touch" on a directory with
5000 files, the former is a 100 times slower.)
cu andreas
PS: Please respect Mail-Followup-To if set _and_ only send Cc's if
explicitely requested. - TIA.




Re: Bug in cron postinst

2003-09-03 Thread Goswin von Brederlow
Andreas Metzler <[EMAIL PROTECTED]> writes:

> Goswin von Brederlow <[EMAIL PROTECTED]> wrote:
> > Steve Greenland <[EMAIL PROTECTED]> writes:
> >> YES, I know that the postinst doesn't work if you don't have any user
> >> crontabs, feel free to stop reporting the bug -- I have enough.
>  
> >> You can get the installation to complete by editing 
> >> /var/lib/dpkg/info/cron.postinst and removing these three lines near the 
> >> end:
>  
> >> for ct in * ; do
> >> chown $ct:crontab $ct
> >> done
> 
> > This also won't work with too many users.
> 
> No, it will.
> 
> [EMAIL PROTECTED]:/tmp/big> rm *
> bash: /bin/rm: Argument list too long
> [EMAIL PROTECTED]:/tmp/big> for ct in *; do rm $ct ; done \
>   && echo success
> success

for doesn't fork so the realy small commandline limit isn't a
problem. But are you sure the shell does not read in a full list for
"*" and then work through that? Ok, with more users than you can hold
in ram you have other problems.

> > And lets add a user with homedir "`rm -rf ..`" just for fun.
> 
> Would not hurt.

Homedir "a:b"? ==> chown a:b:crontab a:b

> [EMAIL PROTECTED]:/tmp/big> bar="\`yes\`"
> echo $bar
> `yes`

I'm allways a bit overcarefull with for loops, globing and splitting.
Depending on the shell you get different behaviours. In this simple
case it seems to work out right but take the following as an example:

(my normal shell is zsh)
[EMAIL PROTECTED]:/tmp/bar% touch "a b"
[EMAIL PROTECTED]:/tmp/bar% L=`find` 
[EMAIL PROTECTED]:/tmp/bar% for i in $L; do echo $i; done


Re: Bug in cron postinst

2003-09-03 Thread Andreas Metzler
Goswin von Brederlow <[EMAIL PROTECTED]> wrote:
> Steve Greenland <[EMAIL PROTECTED]> writes:
>> YES, I know that the postinst doesn't work if you don't have any user
>> crontabs, feel free to stop reporting the bug -- I have enough.
 
>> You can get the installation to complete by editing 
>> /var/lib/dpkg/info/cron.postinst and removing these three lines near the end:
 
>> for ct in * ; do
>> chown $ct:crontab $ct
>> done

> This also won't work with too many users.

No, it will.

[EMAIL PROTECTED]:/tmp/big> rm *
bash: /bin/rm: Argument list too long
[EMAIL PROTECTED]:/tmp/big> for ct in *; do rm $ct ; done \
  && echo success
success

> And lets add a user with homedir "`rm -rf ..`" just for fun.

Would not hurt.
[EMAIL PROTECTED]:/tmp/big> bar="\`yes\`"
echo $bar
`yes`
(If you want to see the kernels oom killer in action try "eval $bar",
I just did. - "Sep  3 10:13:16 downhill kernel: Out of Memory: Killed
process 788 (bash) ;-)."
cu andreas




Re: Bug in cron postinst

2003-09-03 Thread Goswin von Brederlow
Steve Greenland <[EMAIL PROTECTED]> writes:

> YES, I know that the postinst doesn't work if you don't have any user
> crontabs, feel free to stop reporting the bug -- I have enough.
> 
> You can get the installation to complete by editing 
> /var/lib/dpkg/info/cron.postinst and removing these three lines near the end:
> 
> for ct in * ; do
> chown $ct:crontab $ct
> done

This also won't work with too many users.

And lets add a user with homedir "`rm -rf ..`" just for fun.

MfG
Goswin