Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Writeability of a file for a different user

by InfiniteMonkey (Novice)
on Aug 02, 2011 at 23:37 UTC ( [id://918154]=perlquestion: print w/replies, xml ) Need Help??

InfiniteMonkey has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks! I need to be able to find out if a particular file is writeable, but for a different user to the current one. If it was for the current user, I can of course use -w, but I don't know how to get the same info for some other user?

Replies are listed 'Best First'.
Re: Writeability of a file for a different user
by strredwolf (Chaplain) on Aug 03, 2011 at 03:15 UTC
    What I would do is stat() the file, which will get you the mask and I think the ID# of the user and group. From that, you can parse through /etc/group and /etc/passwd on any Unix.
    Information doesn't want to be free. It wants to be feline.
      That works fine if access control is done solely by the standard permission bits. It fails is access control is done via ACLs, which allows making a file writeable for more than the owner of a file, without having to resort to groups. (One can only be a member of a limited number of groups, a number that quickly exceeds the number of permutations of a small group of people wanting to share files)

      AFAIK, there's no way to ACL querying with just standard Perl. But I'd be surprised if there aren't CPAN modules available that will do ACL management for the more common systems out there (but I haven't checked).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://918154]
Approved by strredwolf
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2024-03-28 11:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found