Code runs as root?
I want to write a small program that:
1. Accepts a date string (06/08/2005); 2. Sets system date. However, setting system date/time requries root privilege. So I'd like to know if it possible to do it using C code? I do not want su. |
I don't think so. You may, however, give permission to all users to execute /bin/date, but that would severely put your system in jeopardy. For example, every user capable of changing the date, would be able to delay cron jobs, etc (I think cron uses system date, doesn't it?).
Either way, if you are doing it to learn only, then you can do that. Otherwise is just to call "su" within your program or by changing /bin/date to allow execution by user. I could be mistaken though, as I often am :D |
Quote:
|
Could not get any idea out the man sudo. I tried to edit /etc/sudoers, but don't know how to.
I am running as user 'neo', if I want this user to run date without typing root password, what should I do? |
First, you need to know the full path of the "date" program. It's probably "/bin/date. But to be sure, check with:
Code:
which date Then to enable user "neo" to run "date" witthout being asked for a password, just put one line in /etc/sudoers Code:
neo ALL = NOPASSWD: /bin/date Code:
sudo date 03190100 |
That's great! Thanks!
|
All times are GMT -5. The time now is 02:24 AM. |