Forum Moderators: coopster
exec("echo 'password' ¦ /usr/bin/sudo -u user -S du /home/example/mail/"); (replace the ¦ with a real pipe character)
user is a user who has permission to du that directory. password is his password. Untested.
Note: storing passwords in plain text format in scripts is not advisable...
storing passwords in plain text format in scripts is not advisable
I looked into some man pages around sudo and found /etc/sudoers (list of which users may execute what) file and added the following entry for group "nobody" so that I need not to supply password while executing du command.
%nobody ALL=NOPASSWD: /usr/bin/du
Am I creating any security concern?
Milan