title: Using PolicyKit to allow non-root users to start and stop a service
body: <p>I have a requirement to allow non-root users to start and stop a service. It was recommended to me to use <code>PolicyKit</code> rather than <code>sudoers.d</code>, which I am familiar with. </p>
  
  <p>As I have no experience with <code>PolicyKit</code>, I thought I would experiment and create a rule to allow non-root users to start and stop the Docker service. I have created a file, <code>/etc/polkit-1/rules.d/10-docker.rules</code> containing:</p>
  
  <pre><code>polkit.addRule(function(action, subject) {
      if (action.id == "org.freedesktop.systemd1.manage-units" &amp;&amp;
          action.lookup("unit") == "docker.service")
      {
          return polkit.Result.YES;
      }
  })
  </code></pre>
  
  <p>However, whenever I execute <code>systemctl start|stop|restart docker.service</code>, I keep getting prompted for a password. What am I missing?</p>
  
  <p>Also, I would like to limit non-root users to control this service who are in a specific group e.g. <code>blah</code>. How do I incorporate this into my rule?</p>
  
  <p>My target OS is RHEL 7.7.</p>