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


Click here to return to the 'Update code files in /usr/share/misc' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Update code files in /usr/share/misc
Authored by: bluehz on Aug 08, '03 07:21:15PM
1. Copy the code above and paste into a text document. Save it as text only if using TextEdit. For our example, lets say you save the text file to your desktop as "update_codes". 2. Open the terminal and enter (hit return or enter after each command):
cd ~/desktop
chmod 755 update_codes
sudo ./update_codes
Thats it! The first command (cd) changes to your desktop directory. The 2nd command (chmod) makes the file executable, and the 3rd command (sudo) actually executes the command. You will be asked for your password.

[ Reply to This | # ]
Update code files in /usr/share/misc
Authored by: tstewart777 on Aug 08, '03 07:26:10PM

You can also copy the text from the hint and create it in the terminal in emacs:

emacs update_codes

(paste in text from the hint)

ctrl-x ctrl-s to save
ctrl-x ctrl-c to exit

That's it, then do the chmod to make it executable. Emacs is easy to deal with for stuff like this, IMHO, the learning curve is slight compared to vi.

Tim



[ Reply to This | # ]
Update code files in /usr/share/misc
Authored by: GaelicWizard on Aug 09, '03 05:25:06AM

emacs, vi, ... they're all hugely massive and incredibly incomprehensable to a newbie, i'd recommend pico if you're just beginning. once you've got the terminal basics down, then you can tackel emacs or vi or whatever.

---
Pell



[ Reply to This | # ]
The SUID Bit
Authored by: jyncroft on Aug 09, '03 03:23:07AM

Alternatively, you could set the owner of the shell script to root and set the uid (SUID) bit. Then you could run the script w/o having to type sudo (the SUID bit causes the script to run with the rights of the owner).

A note of caution here: setting the uid bit on a script could compromise your system. Be sure you know what the script does (everything it does) before doing so. Think twice before setting the SUID bit for scripts (owned by root) that take arguments at the command line. Since you never know what parameters a malicious user may pass to your script. Since the script would run as root it could do great damage if misused.

So, here's what you'd do:

% sudo chown root update_codes.sh
% sudo chmod 4755 update_codes.sh

or
% sudo chmod u+s update_codes.sh

Now when you want to run the script, just type the name of the script (if it's in your path) or ./update_codes.sh when you're in the same directory.

Jennifer



[ Reply to This | # ]
The SUID Bit
Authored by: GaelicWizard on Aug 09, '03 05:26:19AM

I'm not sure, but I don't believe the SUID bit works on shell scripts...

---
Pell



[ Reply to This | # ]
The SUID Bit
Authored by: jyncroft on Aug 09, '03 11:29:18AM

It does... try it. I have a few scripts set up this way, works great

Jennifer



[ Reply to This | # ]
The SUID Bit
Authored by: Crawdad on Dec 11, '03 03:48:49PM
Think twice before setting the SUID bit for scripts (owned by root) that take arguments at the command line. Since you never know what parameters a malicious user may pass to your script. Since the script would run as root it could do great damage if misused.
Not enough. The invoker could set an environment variable which causes the script to be parsed differently by the shell. Take $IFS for example, normally containing SP TAB NEWLINE. Add a well-chosen letter to that and the script does something the author never dreamed of. Setuid shell scripts are Bad Juju. If you think you must have one, write a setuid C wrapper that cleans the environment, then does setreuid() and runs the script.

[ Reply to This | # ]