From: Ranga Nathan <[EMAIL PROTECTED]>
   Date: Thu, 19 Jan 2006 19:15:36 -0800

   I have a script that runs as 'root' since it is one script that processes 
   files for all users. It is driven by a configuration file that includes 
   'process as' userids. 

   Frequently I need to execute certain portions of the code (e.g  that 
   creates files / directories)  with the user's permission. I am not sure 
   how to do this in perl. Currently I am doing something like:

   my $rc = `su -c - $user 'mv $source $dest'`

   I am not sure if it is the right way to do it.

   The script works fine and I am happy but is it a good practice?

I've never needed this myself, but if I did, I'd probably try $< and $>
(see perlvar).  This trick may even work with "local", which would be
nice, almost elegant.  And it should be more secure, since it doesn't
require a shell, but that of course depends on what you do with it.  In
any case, it ought to be more efficient.

                                        -- Bob Rogers
                                           http://rgrjr.dyndns.org/
 
_______________________________________________
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to