1

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.

2
  • 4
    That sounds like a bad idea. Commented Jan 8, 2018 at 0:13
  • You could configure sudo to allow this specific command without prompting for a password: askubuntu.com/questions/159007/… Commented Jan 8, 2018 at 0:42

2 Answers 2

3

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

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.