News for hackers. Stuff that matters.
Re:Chmod -x chmod by aes on Saturday October 09, 2010 @06:45PM (#1776089)
The simplest way I could figure out was:

cp sh chmod.new

cp chmod chmod.new

Re:Chmod -x chmod by mrb on Saturday October 09, 2010 @08:33PM (#1776285)
IMO the simplest way is:

$ /lib/ld-linux-x86-64.so.2 /bin/chmod +x /bin/chmod

ELF files run by manually launching the dynamic loader don't require the executable bit.

Re:Chmod -x chmod by CUViper on Saturday October 09, 2010 @09:55PM (#1776381)
I agree that this is easiest, and I'm surprised that the article calls it "hardcore" (slides 38-39). But it does bring to mind a more devious challenge: Someone ran "chmod -x ld.so"...
Re:Chmod -x chmod by xtacy on Sunday October 10, 2010 @12:39AM (#1776563)
What about:

  find / -type f -perm +x | xargs chmod -x
EDIT: chmod has to be the last program to be chmodded, in the above list.. :-)
Re:Chmod -x chmod by tange on Sunday October 10, 2010 @10:33AM (#1777122)
Your use of xargs can lead to nasty surprises because of the separator problem http://en.wikipedia.org/wiki/Xargs#The_separator_problem

GNU Parallel http://www.gnu.org/software/parallel/ does not have that problem.

Watch the intro video for GNU Parallel: http://www.youtube.com/watch?v=OpaiGYxkSuQ

Re:Chmod -x chmod by ralph on Monday October 11, 2010 @08:36AM (#1779504)
GNU Parallel isn't needed to avoid this, using find's -print0 and xargs's -0 would suffice. The advert is unwarranted.
Re:Chmod -x chmod by pvg on Sunday October 10, 2010 @12:37AM (#1776561)
The parent seems simpler. More importantly, it works on just about any Unix.
Re:Chmod -x chmod by RexRollman on Sunday October 10, 2010 @08:51AM (#1777025)
Couldn't you just set an appropriate umask and then make a copy of chmod?
Re:Chmod -x chmod by pvg on Sunday October 10, 2010 @09:20AM (#1777057)
I don't think umask setting affects the executable bits of files, just directories. You can try by entering something like

  umask 0; touch foo; ls -l foo
Re:Chmod -x chmod by CUViper on Sunday October 10, 2010 @04:11PM (#1777825)
It does affect files, but umask only subtracts permission bits. So if the program creating the file doesn't try to set it executable, then umask will never change that.
Re:Chmod -x chmod by iclelland on Sunday October 10, 2010 @11:52AM (#1777230)
My first thought was pretty similar:

cp /bin/sh chmod.new

cat /bin/chmod > chmod.new

mv chmod.new /bin/chmod

Re:Chmod -x chmod by gaius on Sunday October 10, 2010 @08:13AM (#1776989)
My first thought was, just re-implement it in C, then I remembered than we do have a bunch of boxes without a compiler on.