Why not fork of a child process as the target user and directly test if the specific set of files are accessible?
Something like this: (Untested)
#!/usr/bin/perl -w use strict; use English; my $child_pid = open(FROM_KID, "|-") or die "can't fork: $!"; if ($child_pid) { # am the parent read FROM_KID my $child_message = <FROM_KID>; if( $child_message =~ m/ERROR accessing files/ ) { # Alert the sysadmin } # Else OK. wait $child_pid; # Wait for the child to quit before continuing +. } else { # Change userID $EGID=22; # aka: $> $UID=22; # aka: $< # am the child; use STDIN/STDOUT normally if( test_access_files() ) { print "OK accessing files as userID 22\n"; } else { print "ERROR accessing files as userID 22\n"; } exit; }
In reply to Re: How do I check if another user can access a file?
by chrestomanci
in thread How do I check if another user can access a file?
by mtnboy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |