[sudo-users] using find command in sudo command.

Mohammed Iqbal Mohammed.Iqbal at datacom.com.au
Thu Dec 14 20:56:43 MST 2017


Folks,

I am trying to use find command in sudo  but it's not quit working.

Has anyone had experience using find command in sudoers.

This cmd line is working fine
In sudoers file
Cmnd_Alias LOG_ADM_CMD1     =  /bin/bash -c /bin/find /opt/log/*/core* -mmin -* -print >> /opt/temp/log/core_files.log
peter       CM_LOG_ADM_HOSTS=(john)          NOPASSWD: LOG_ADM_CMD1
[peter at server2]:/tmp> $ sudo -u john bash -c "/bin/find /opt/log/*/core* -mmin -65 -print >> /opt/temp/log/core_files.log"
[peter at server2]:/tmp>

But the following is not working.
Cmnd_Alias LOG_ADM_CMD2     =  /bin/bash -c /bin/find /opt/log/*/core* -mmin +*  -exec /bin/mv {}  /opt/temp/log/  \\;
peter       CM_LOG_ADM_HOSTS=(john)          NOPASSWD: LOG_ADM_CMD2
[peter at server2]:/tmp> sudo -u john bash -c "/bin/find /opt/log/*/core* -mmin +65  -exec /bin/mv {}  /opt/temp/log/ \;"
[sudo] password for john:
Sorry, user john  is not allowed to execute '/bin/bash -c /bin/find /opt/log/*/core* -mmin +65  -exec /bin/mv {}  /opt/temp/log/ \;' as john on server2.local.
[peter at server2]:/tmp>
There are 2 issues, first it asking for password and second does not have permission to execute.

Appreciate positive response.

Regards,

Mohammed Iqbal

Disclaimer

The information contained in this communication from the sender is confidential. It is intended solely for use by the recipient and others authorized to receive it. If you are not the recipient, you are hereby notified that any disclosure, copying, distribution or taking action in relation of the contents of this information is strictly prohibited and may be unlawful.

This email has been scanned for viruses and malware, and may have been automatically archived by Mimecast Ltd, an innovator in Software as a Service (SaaS) for business. Providing a safer and more useful place for your human generated data. Specializing in; Security, archiving and compliance. To find out more visit the Mimecast website.


More information about the sudo-users mailing list