how to demote user privileges to run a script

2

I would like to run a script, started by snmptrapd, as a regular user. Looks like the traphandle directive in /etc/snmp/snmptrapd.conf runs the indicated program as a privileged user (root:root). The traphandle program is a bash script. Is there any way to drop privileges from root to a regular user, at beginning of execution/script ? The traphandle program that I intend to run as regular user create files that would better if they were created as regular user. Of course I can issued chmod/chown all over in the script for each file created, but I was wondering if there is a more elegant solution.

best regards,

Miguel Rozsas

Posted 2020-01-16T20:57:40.690

Reputation: 23

Answers

0

You may use the following programs to drop permissions to that of some user account:

  • setuidgid

    setuidgid user /path/unprivileged.sh
    
  • chpst

    chpst -u user /path/unprivileged.sh
    

harrymc

Posted 2020-01-16T20:57:40.690

Reputation: 306 093

Great !! This is what I was looking for. Both are new to me, never heard about. Thank you and best regards ! – Miguel Rozsas – 2020-01-16T23:17:08.673

Sure ! I've tried to use the up arrow but my reputation is too low for now and I assumed the everything was disabled to me. – Miguel Rozsas – 2020-01-18T12:50:39.670

Thank you and good luck. – harrymc – 2020-01-18T13:05:09.883