[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [users] NO! chmod strikes!



On Sun, Jul 15, 2001 at 12:41:34PM +0200, Joost Kooij wrote:
> Thanks for the compliment.  Don't ruin your system just to try this,
> because it is not perfect.  Consider what happens if you:
> 
>   chmod a-x /bin/chmod

Easy enough to bootstrap yourself out of that one, provided /bin/cp
is still executable:

# umask 000
# cp /bin/cp /tmp/new-chmod
# cat /bin/chmod > /tmp/new-chmod
# /tmp/new-chmod a+x /bin/chmod

The trick is that, although cp won't add execute permissions to the
copied file, it will preserve them by default.  (umask permitting, of
course.)

So, does anyone have a way to recover using only shell builtins, for
just in case there aren't any executable files left?  (I don't think
it can be done, but it would be great to be proven wrong...)



Reply to: