HWRF  trunk@4391
Classes | Functions | Variables
produtil.acl Namespace Reference

Manipulates Access Control Lists (ACL) More...

Detailed Description

Manipulates Access Control Lists (ACL)

This module is a wrapper around the C libacl library, which provides support for POSIX Access Control Lists, as defined by the abandoned draft standard "IEEE 1003.1e draft 17". Only the widely-supported features are implemented. It is intended to be used with the Linux libacl, but might be portable to other versions if the module-scope acl_library variable is changed to the name of your "dll" or "so" file for libacl and values of ACL_TYPE_ACCESS and ACL_TYPE_DEFAULT are changed. In addition, one must change the means by which errno is accessed if switching from glibc to another C library.

Classes

class  ACL
 ACL class wrapped around the libacl library: More...
 
class  ACLCannotGet
 Raised when the libacl library could not get a file's ACL. More...
 
class  ACLCannotSet
 Raised when the libacl library could not set a file's ACL. More...
 
class  ACLCannotStringify
 Raised when libacl cannot convert an ACL to text. More...
 
class  ACLError
 Superclass of any ACL errors. More...
 
class  ACLLibraryError
 Raised when the libacl library could not be loaded. More...
 
class  ACLMissingError
 Raised when a function that requires an ACL object received None, or an invalid ACL. More...
 

Functions

def load_libc ()
 Library loading routine: More...
 
def load_libacl ()
 Loads the libacl library. More...
 
def acl_to_text (acl)
 Returns a string representation of the given access control list object. More...
 
def acl_get_file
 Returns an object that represents the access control list for the specified file. More...
 
def acl_get_fd (fd)
 Returns an object that represents the access control list for an open file descriptor. More...
 
def acl_set_file
 Sets the named file's access control list. More...
 
def acl_set_fd (fd, acl)
 Given an open file descriptor, sets the corresponding file's access control list. More...
 
def acl_from_text (txt)
 Converts text to an access control list. More...
 
def copy_acl_fd (fromfd, tofd)
 Simplified wrappers that perform common tasks: More...
 

Variables

 libacl = None
 The loaded libacl library from ctypes.cdll.LoadLibrary. More...
 
 libc = None
 The loaded libc library from ctypes.cdll.LoadLibrary. More...
 
int ACL_TYPE_ACCESS = 32768
 The ACL_TYPE for Access Control Lists, defined in the libacl header files. More...
 
int ACL_TYPE_DEFAULT = 16384
 The ACL_TYPE for Default Access Control Lists defined in the libacl header files. More...
 
string acl_library = 'libacl.so.1'
 The ACL library name or path for input to ctypes.cdll.LoadLibrary. More...
 
string c_library = 'libc.so.6'
 The C library name for input to ctypes.cdll.LoadLibrary. More...
 
 get_errno = None
 Function that returns the value of errno. More...
 

Function Documentation

def produtil.acl.acl_from_text (   txt)

Converts text to an access control list.

Parameters
txta text access control list
Returns
a new ACL object

Definition at line 335 of file acl.py.

def produtil.acl.acl_get_fd (   fd)

Returns an object that represents the access control list for an open file descriptor.

Parameters
fdthe integer file descriptor or open file object
Returns
a new ACL object

Definition at line 312 of file acl.py.

def produtil.acl.acl_get_file (   filename,
  access = ACL_TYPE_ACCESS 
)

Returns an object that represents the access control list for the specified file.

Parameters
filenamethe name of the file of interest
accessACL_TYPE_ACCESS or ACL_TYPE_DEFAULT
Returns
a new ACL

Definition at line 304 of file acl.py.

def produtil.acl.acl_set_fd (   fd,
  acl 
)

Given an open file descriptor, sets the corresponding file's access control list.

Parameters
fdthe file descriptor or file object
aclthe ACL object to change
Returns
acl

Definition at line 327 of file acl.py.

def produtil.acl.acl_set_file (   filename,
  acl,
  access = ACL_TYPE_ACCESS 
)

Sets the named file's access control list.

Parameters
filenamethe name of the file of interest
aclthe destination ACL object
accessACL_TYPE_ACCESS or ACL_TYPE_DEFAULT
Returns
acl

Definition at line 319 of file acl.py.

def produtil.acl.acl_to_text (   acl)

Returns a string representation of the given access control list object.

Parameters
aclan ACL object
Returns
the string equivalent

Definition at line 297 of file acl.py.

def produtil.acl.copy_acl_fd (   fromfd,
  tofd 
)

Simplified wrappers that perform common tasks:

Copy an access control list from one object to another

Copies a POSIX Access Control List (ACL) from one open file to another. The arguments should be either UNIX file descriptors, or the return values from open(). This routine is quicker than using the ACL() object due to avoidance of creating unnecessary Python objects. However, the access control list information is discarded in this routine, so it can only be used when the sole need is to copy the information from one file to another.

Parameters
fromfdthe source file descriptor
tofdthe target file descriptor

Definition at line 344 of file acl.py.

def produtil.acl.load_libacl ( )

Loads the libacl library.

Loads the libacl library whose name is specified in the module scope acl_library variable. This function is called automatically when needed; you should never need to call it directly.

Definition at line 97 of file acl.py.

Referenced by produtil.acl.ACL.__init__(), and produtil.acl.copy_acl_fd().

def produtil.acl.load_libc ( )

Library loading routine:

Loads the libc library.

Loads the standard C library, which is needed to test the value of errno in order to report errors. This function is called automatically when needed; you should never need to call it directly.

Definition at line 76 of file acl.py.

Referenced by produtil.acl.load_libacl().

Variable Documentation

produtil.acl.acl_library = 'libacl.so.1'

The ACL library name or path for input to ctypes.cdll.LoadLibrary.

This is intended to be modified externally from this module if needed before using the produtil.acl module.

Definition at line 60 of file acl.py.

produtil.acl.ACL_TYPE_ACCESS = 32768

The ACL_TYPE for Access Control Lists, defined in the libacl header files.

This must match the value in the header.

Definition at line 49 of file acl.py.

produtil.acl.ACL_TYPE_DEFAULT = 16384

The ACL_TYPE for Default Access Control Lists defined in the libacl header files.

This must match the value in the header.

Definition at line 54 of file acl.py.

produtil.acl.c_library = 'libc.so.6'

The C library name for input to ctypes.cdll.LoadLibrary.

This is intended to be modified externally from this module if needed before using the produtil.acl module.

Definition at line 66 of file acl.py.

produtil.acl.get_errno = None

Function that returns the value of errno.

Used for testing for errors in libacl routines.

Definition at line 71 of file acl.py.

Referenced by produtil.acl.copy_acl_fd(), produtil.acl.ACL.from_fd(), produtil.acl.ACL.from_file(), produtil.acl.ACL.from_text(), produtil.acl.ACL.to_fd(), produtil.acl.ACL.to_file(), and produtil.acl.ACL.to_text().

produtil.acl.libacl = None

The loaded libacl library from ctypes.cdll.LoadLibrary.

Definition at line 40 of file acl.py.

produtil.acl.libc = None

The loaded libc library from ctypes.cdll.LoadLibrary.

Definition at line 44 of file acl.py.