Hello,

on our linux system I have a script that runs as root that should return a list of subdirectorys a specific user can access.

I have the four directories and aside the users that can access them

dira   ( usera,userb, userc)
dirb   ( userb )
dirc   ( userc )
dird   ( usera, userc )

When I call the function with parameter 'usera'
the function should return

dira
dird

This script returns such a list, but only when called as a specific user

my $erg;
$pfad = '/data01/abteilungen';
@fileliste = <$pfad/*>;
foreach $filename (@fileliste) {
        opendir(DIR,$filename);
        if ($!==0 ) {
                print $filename,"\n";
        }
        closedir(DIR);
        $!=0;
}

Is there a way in perl to impersonate another user in a script ?

If not, is there a function similar to system that also changes user while running the script passed as parameter or
is it necessary to call

@args = ("su", "-", $username,"myscript.pl");

system @ args;

Thanks
Andreas


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to