Quote:
Originally Posted by
brjohnsmith
Hi Corona688,
Thank you for providing me this code, but the problem is that I never know who is the user, because it could be anyone
Read it more carefully please. sudo will allow anyone in the
group user1 to touch user1's files.
If anyone not in the user1 group tries to use the script, sudo will refuse it.
If the file in question does not actually belong to the user user1, touch will refuse it.
Quote:
Besides this, the folder where the file is, it could be anyone as well.
Do you mean anyone or any
where?
If you're content with anyone in the user1 group being able to set dates on any one of user1's files, you can rip out my error checking in a quarter-second.
Quote:
as this script is executed by the application, I thought that this script could run under root and the touch command would be executed as well.
Never never never.
Any bugs in the script, etc can only do as much damage as the user it runs under.
If you have no reason to run it as root, never run it as root.
Quote:
I am not sure if it is possible a script be executed as root via sudoers.
It is possible. I just showed you how to do it.
Quote:
Would it be possible? How the script could be and the changes on sudores?
I showed you an example script and the necessary changes to sudoers.