0

I am currently writing a program in Go and trying to implement a switch user functionality. However, I can't find a clean way of sending a password via stdin to su. sudo -S allows for stdin password input, but as this requires sudo rules to be setup it isn't ideal. So:

  • Is there a clean way of programmatically using su? OR
  • Can sudo alone be used to switch users?
clubby789
  • 217
  • 3
  • 10
  • sudo can be used without a password with the correct configuration, and sudo can be used to run a shell, which is often largely equivalent to switching to another user, so the answer is: "probably?" Can you explain what you want to do in more detail? – Slartibartfast Jul 20 '20 at 00:05
  • The idea is to make a general use tool that won’t require any specific configuration. I want a way to run a command as another user, and programmatically supply a password. – clubby789 Jul 20 '20 at 01:09
  • Based on what I'm reading here, this sounds like a security problem waiting to happen. I hope you're being careful with handling credentials (password) and execution of privileged commands / SUID-set executables and the like. Good luck. – Slartibartfast Jul 20 '20 at 01:48

0 Answers0