Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'Script has some bugs' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Script has some bugs
Authored by: a1291762 on Mar 12, '02 04:55:20PM

Ditto has to run as root?

Is it a simple Unix executable?

You could do this to make it run as root easily:
sudo chown root.admin ditto
sudo chmod 4755 ditto

This makes it owned by root and group admin. The 4755 makes it setuid and executable. Thus anyone can run it *without* having to use sudo and it will automatically gain root privilages.

I'll go look at the ditto page and suggest this to the author I think...

[ Reply to This | # ]
Authored by: a1291762 on Mar 12, '02 05:27:30PM

D'oh! I just looked at an OS X system...

I didn't realise ditto was an Apple supplied command :)

I just tried the setuid bit and it works except for one small thing... It creates the destination file as root.

So if you do "ditto foo bar" then bar is owned by root and you'll need to sudo chown <yourname>.[admin|staff] and possibly reset the permissions on it.

Oh well... maybe a wrapper program could sort that out...

[ Reply to This | # ]
Script has some bugs
Authored by: sharumpe on Mar 13, '02 01:34:41AM

It is generally a bad idea to run anything as root, and even less of a good idea to set programs to setuid. If the program turns out to have some sort of problem, it may become possible to gain root access.

Not to mention, of course, little things like the fact that the files are created as root. cp has a flag that maintains permissions, I wonder if ditto does?

Mr. Sharumpe

[ Reply to This | # ]