Reputation: 207
I need to find a way to execute sudo dansguardian -r
from a .net core web app. I am not that well familiar with linux so any work around to have the same effect as running the command above from c# is acceptable. I basically need dansguardian to reload configuration files after they have been edited from an asp web app. But I believe sudo will require credentials so how do I pass those in?
Edit for the people that have expresses security concerns. The web app is for admin use. Everything the user is able to do from the web ui he should already be able to do manually using putty and ssh.
Upvotes: 1
Views: 2308
Reputation: 207
Adding www-data ALL=NOPASSWD: /usr/sbin/dansguardian
to the list of sudoers using visudo allowed me to to execute sudo dansguardian -r
using c# .net core.
I understand the consequences to giving to much privileges to Apache server however the Apache server does not have access to the web is all internal to a specific admin group.
Upvotes: 1
Reputation: 46
Passing administrator credentials with a web app would not be a good idea (ie: bad security practice).
A better way would be to create a command (or script) that performs just the required action and then use setuid to give this administrator privileges. A standard user could then run the command without using sudo, which avoids the whole credentials issue.
Note that the command/script would need to be carefully designed and implemented so that it could not be misused.
Refer to https://en.wikipedia.org/wiki/Setuid
Upvotes: 3