0

I need to restart a systemd service (running as root) every time a new user is created. I saw that some systems have a way to make an adduser hook but this isn't an option in RHEL8. What is the best (least invasive; most secure) way to do this?

Currently only thing I can think of is adding a script to /etc/profile.d but I'm not sure if there's a way to make it run scripts as root (without doing something insecure)

4
  • What's the purpose of that? Why would you need to restart a service every time a new user is created? Commented Oct 9, 2023 at 16:21
  • Yeah honestly after looking into it more I now realize that user home directories are created at first login and not user creation... But still the adduser hook exists for a reason. Commented Oct 9, 2023 at 17:00
  • 1
    I'd thought adding it to /etc/profile.d would restart the service when a user logs in, not when the user is created. Commented Oct 9, 2023 at 17:31
  • Correct, but that's close enough in my case. Only problem is that I don't think those scripts get run as root Commented Oct 9, 2023 at 19:50

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.