[comp.unix.wizards] Broken chmod

roy@phri.UUCP (Roy Smith) (12/15/87)

In article <10841@brl-adm.ARPA> rbj@icst-cmr.arpa (Root Boy Jim) writes:
> Awhile back, somebody lamented the fact that their chmod had somehow
> acquired mode 644. Since there was no way to chmod chmod because it wasn't
> executable, they loaded it from a backup tape.

Why not just compile:

main ()
{
	chmod ("/bin/chmod", 0755);
}

and run it (probably suid to root)?
-- 
Roy Smith, {allegra,cmcl2,philabs}!phri!roy
System Administrator, Public Health Research Institute
455 First Avenue, New York, NY 10016

rbj@ICST-CMR.arpa (Root Boy Jim) (12/15/87)

Awhile back, somebody lamented the fact that their chmod had somehow
acquired mode 644. Since there was no way to chmod chmod because it wasn't
executable, they loaded it from a backup tape.

Why couldn't they just have done the following:

cd /bin
cp cat foo		# create foo with mode 755
cp chmod foo		# doesn't change mode of foo, or
cat < chmod > foo	# doesn't change mode either
./foo 755 chmod
rm foo

	(Root Boy) Jim Cottrell	<rbj@icst-cmr.arpa>
	National Bureau of Standards
	Flamer's Hotline: (301) 975-5688
I guess it was all a DREAM..  or an episode of HAWAII FIVE-O...

rcw@qetzal.UUCP (Robert C. White) (12/15/87)

In article <10841@brl-adm.ARPA>, rbj@icst-cmr.arpa (Root Boy Jim) writes:
-----------------------------------------
% Why couldn't they just have done the following: [chmod with 0644 perms]
% 
% cd /bin
% cp cat foo		# create foo with mode 755
% cp chmod foo		# doesn't change mode of foo, or
% cat < chmod > foo	# doesn't change mode either
% ./foo 755 chmod
% rm foo
-----------------------------------------
main()
{
	chmod("/bin/chmod",0755);
}

Robert White

-- 
//////////////////286 Moderator -- comp.unix.microport\\\\\\\\\\\\\\\\\
Email to microport@uwspan for info on the newsgroup comp.unix.microport.
otherwise mail to microport@uwspan with a Subject containing one of:
386 286 Bug Source Merge or "Send Buglist" (rutgers!uwvax!uwspan!microport)

alex@umbc3.UMD.EDU (Alex S. Crain) (12/15/87)

In article <3067@phri.UUCP> roy@phri.UUCP (Roy Smith) writes:
>In article <10841@brl-adm.ARPA> rbj@icst-cmr.arpa (Root Boy Jim) writes:
>> Awhile back, somebody lamented the fact that their chmod had somehow
>> acquired mode 644. Since there was no way to chmod chmod because it wasn't
>> executable, they loaded it from a backup tape.
>
>Why not just compile:
>
>main ()
>{
>	chmod ("/bin/chmod", 0755);
>}
>
>and run it (probably suid to root)?
>-- 
	     ^^^^^^^^^^^^^^^^^^^^^

hmmm... would you do this

# chmod 4755 a.out  

or perhaps

main()
{
	chmod( "a.out", 4755 );
}

which would require root protections, which if you had, you wouldn't need ;-)

						:alex.

alex@umbc3.imd.edu

shz@pierce.UUCP (S. Zirin) (12/15/87)

In article <10841@brl-adm.ARPA> rbj@icst-cmr.arpa writes:
>Awhile back, somebody lamented the fact that their chmod had somehow
>acquired mode 644. Since there was no way to chmod chmod because it wasn't
>executable, they loaded it from a backup tape.
>
>Why couldn't they just have done the following:
>
>cd /bin
>cp cat foo		# create foo with mode 755
>cp chmod foo		# doesn't change mode of foo, or
>cat < chmod > foo	# doesn't change mode either
>./foo 755 chmod
>rm foo

Because most people throw up their hands and give up far too soon.  They
haven't learned how rewarding it can be to come up with an inventive
solution to a problem.

Seth Zirin
ihnp4!pierce!shz

ftw@datacube.UUCP (12/16/87)

alex@umbc3.UUCP writes:
> In article <3067@phri.UUCP> roy@phri.UUCP (Roy Smith) writes:
> >In article <10841@brl-adm.ARPA> rbj@icst-cmr.arpa (Root Boy Jim) writes:
> >> Awhile back, somebody lamented the fact that their chmod had somehow
> >> acquired mode 644. Since there was no way to chmod chmod because it wasn't
> >> executable, they loaded it from a backup tape.

> >Why not just compile:
>
> >main ()
> >{
> >	chmod ("/bin/chmod", 0755);
> >}
>
> >and run it (probably suid to root)?
> >-- 
> 	     ^^^^^^^^^^^^^^^^^^^^^

> hmmm... would you do this

Probably by logging in as root and then running the program...

<edited>
				Farrell T. Woods 

Datacube Inc. Systems / Software Group	4 Dearborn Rd. Peabody, Ma 01960
VOICE:	617-535-6644;	FAX: (617) 535-5643;  TWX: (710) 347-0125
INTERNET: ftw@datacube.COM
UUCP: {rutgers, ihnp4, mirror}!datacube!ftw

"OS/2 -- Half an operating system"

decot@hpisod2.HP.COM (Dave Decot) (12/17/87)

If you have the install command available, it can also be used to
change the mode of files.

Dave Decot
hpda!decot