title: Authentication error upon running a shell script as sudo inside a flask application being run by uWSGI
body: <p>I'm using a shell script to restart my flask app upon receiving a webhook request from github, but I'm running into an issue with no-password sudo authentication, but only when <code>uWSGI</code> is runs the restart function.</p>
  <p>I have the application deployed as a <code>systemd</code> service and in order to restart the service, I have to run <code>systemctl restart myapp.service</code> as <code>sudo</code>. So I stuck that line into a script, and marked it as runnable as sudo without password authentication in <code>/etc/sudoers</code> by the user that runs the webapp.</p>
  <p>The restart function is very simple:</p>
  <pre class="lang-py prettyprint-override"><code>import os
  
  
  def on_push():
      os.setuid(os.geteuid())
      os.system('sudo /path/to/script.sh')
  </code></pre>
  <p>And the script itself is a one-liner:</p>
  <pre class="lang-sh prettyprint-override"><code>systemctl restart myapp.service
  </code></pre>
  <p>Running the command via <code>os.system('sudo /path/to/script.sh')</code> in a normal python shell restarts the app as expected, without asking for the password. However, when the command is run by a <code>uWSGI</code> worker process, it fails to restart with the message that <code>Interactive authentication required</code>.</p>
  <p>Is this an issue that can be solved by changing uWSGI launch parameters?</p>