Quote:
Originally Posted by
saurau
Hi,
I have given access to user mwadmin in shudders file as :
mwadmin ALL:NOPASSWD:/www/* /usr/* /opt/*
However, not able to execute below command:
sudo mkdir -p /usr/test
[sudo] password for mwadmin:
Sorry, user mwadmin is not allowed to execute '/bin/mkdir -p /usr/test' as root.
Quote:
Originally Posted by
saurau
We need a user to have all permissions under /usr Dir which is owned by root.
Even if you set that up correctly, on your system, according to the diagnostic message, mkdir isn't under the /usr hierarchy.
More importantly, as I said, there are multiple errors in your attempt at a sudoers entry.
Did you edit sudoers using visudo? I suspect not, because it would have detected a syntax error (it should be an equals sign after the host specification, not a colon).
Aside from that, there are other non-syntactic, logical errors. Command specifications are comma-delimited. Your command specification will be treated as one long spec, not three. Only files in /www/ will match and the other two patterns are used to restrict the command's arguments.
Even if you delimited the command specifications correctly, the wildcards would not behave as you expect. As with shell pattern matching (aka globbing), the * will not match /. This means that /usr/* only matches files in /usr. It will match /usr/bin/, the directory itself, but not any of the executables of interest in /usr/bin and /usr/sbin.
Wildcards are unnecessary to match all files in a directory. The command specification can list a directory directly and that will be interpreted as matching any executable within it.
You really should spend an evening with the sudo, sudoers, and visudo documentation and inform yourself.
Regards,
Alister