Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I drop privileges in Perl?

I created a server program that will be started as root. After it is started I want to drop privileges to another user. How can I do this securely?

like image 902
Peter Stuifzand Avatar asked May 26 '09 11:05

Peter Stuifzand


2 Answers

See Privileges::Drop.

like image 134
Benji York Avatar answered Sep 21 '22 21:09

Benji York


You don't really need a module, although the one linked by Benji York looks pretty nice.

It's a simple matter of setting the UID via $< and $>. See perlvar for further information on these. You can also set the GID this way using $( and $); note that you need to set $) = "$target_gid $target_gid" if you want to drop supplemental groups. Don't forget to test for success afterwards.

like image 38
jettero Avatar answered Sep 22 '22 21:09

jettero