RSBAC Python bindings
  1. rsbac -- An Python interface to the RSBAC system
    1. Main functions and variables
      1. symbolics name and documentation related functions
      2. log related functions
    2. Data types
      1. System roles
      2. Flags
      3. dict- and set- like variables
      4. TTL
    3. RSBAC modules
    4. Transactions
    5. Representing objects
      1. FD objects
      2. Device
      3. User and group
        1. User class
        2. Group class
      4. Process
      5. IPC
      6. SCD
      7. Network device
      8. Network template
      9. Network object
    6. Details about objects properties
      1. RSBAC attributes
      2. rcTypes property
      3. acl property
    7. User management
      1. User
      2. Group
    8. ACL
    9. RC
      1. Type
      2. Role
      3. Pseudo roles and types
    10. Jail
  2. Examples
    1. Module
    2. UM
    3. File flags
  3. Tools
  4. Issues
  5. Authors

1. rsbac -- An Python interface to the RSBAC system

The rsbac package is a full interface to the RSBAC Linux security system, including support to manage the various models it provides. Its goal is to be easy to use, high-level, "object-oriented", complete and with acceptable performance. It allows to easily administrate the RSBAC configuration with the power of Python.

You can download a frequently updated release here.

A git repository is also available at git://git.tuxee.net/py-rsbac and a web interface to explore the repository is here.

Multithreading is not supported at all. Please use some lock to access the package in a multithread environment.

It was developped first for RSBAC 1.2.8 then for RSBAC 1.3.0, tested mainly on a x86 machine and a PowerPC (G4) machine.

The first release of this package will target full coverage of the RSBAC API (except for PM and MAC models which remain to be added.) More high-level tools built on top of it are planned (such as a GUI, new command line tools, a dedicated shell, backup tools or automatic deployment for example.)

1.1 Main functions and variables

The rsbac package provides some generic functions.

moduleVersion

kernelVersion

libraryVersion

headerVersion

dumpStats()

checkConsistency(correct, checkInode)

writeDirtyList()

init(path)

1.1.1 symbolics name and documentation related functions

The librsbac.so provides various functions to retrieve symbolic names for most of the RSBAC constants and conversely to retrieve constant from the symbolic name. These various functions are provided in the rsbac python package.

For each types of constants, there are 3 functions defined as follow:

getFooNumber(name)

getFooName(n)

getFooNames()

There are the following functions:

getRequestName(n), getRequestNames(), getRequestNumber(name)

getResultName(n), getResultNames(), getResultNumber(name)

getAttributeName(n), getAttributeNames(), getAttributeNumber(name)

getScdTypeName(n), getScdTypeNames(), getScdTypeNumber(name)

getTargetName(n), getTargetNames(), getTargetNumbel(name)

getIpcTargetName(n), getIpcTargetNames(), getIpcTargetNumber(name)

getSwitchTargetName(n), getSwitchTargetNames(), getSwitchTargetNumber(name)

getCapName(n), getCapNames(), getCapNumber(name)

getRcTargetName(n), getRcTargetNames(), getRcTargetNumber(name)

getRcAdminName(n), getRcAdminNames(), getRcAdminNumber(name)

getRcScdTypeName(n), getRcScdTypeNames(), getRcScdTypeNumber(name)

getRcSpecialRightName(n), getRcSpecialRightNames(), getRcSpecialRightNumber(name)

getRessourceName(n), getRessourceNames(), getRessourceNumbers(name)

getLogLevelName(n), getLogLevelNames(), getLogLevelNumber(name)

getAttributeModule(attribute)

getErrorName(n)

getAttributeParameters(attribute)

getRcItemParameters(value)

1.1.2 log related functions

openLog()

closeLog()

readLog(size=4096)

readRingBuffer(size=4096)

readAndClearRingBuffer(size=4096)

clearRingBuffer()

1.2 Data types

1.2.1 System roles

Each users have several type of roles for each of the RSBAC modules. For example, root default system role for the FF module is "administrator", while default system role for the security officer for this module is "security_officer" and all others users have the role "user". This way, each users can administrate or obtains rights for a given module.

The module rsbac.roles allows to represent the system roles (not related to RC roles!) The class SystemRole is already instantiated for the predefined RSBAC system role, which are:

Since SystemRole class build singleton instances, it is possible to compare them with the is operator.

1.2.2 Flags

Several data types in RSBAC are in fact integers used as bit vector. For example, the rsbac_request_vector_t is an integer that hold a set of flags related to allowed requests. To manipulate them conveniently under Python, a class was created for each such types. So, for the rsbac_request_vector_t there is the corresponding rsbac.RequestVector data type in the rsbac package, and so on for other types.

Such classes provides an immutable set. To modify them, it is necessary to create a new instance. It is similar to string manipulations under Python, where a new string must be created for each operation.

The flags classes defined in the rsbac module are the following:

Generic description follows: (where Flags name is for illustration purpose)

class Flags(init)

__iter__()

__repr__()

__int__()

__long__()

__cmp__(other)

__or__(other)

__xor__(other)

__and__(other)

__invert__()

FIXME: Give a better set of examples..

Example with the RequestVector type
>>> import rsbac
>>> rsbac.RequestVector()
RequestVector()
>>> rsbac.RequestVector('lock', 'connect', 'alter')
RequestVector('alter', 'connect', 'lock')
>>> int( rsbac.RequestVector('lock') )
562949953421312L  # 2**49
>>> rsbac.RequestVector( 2**49 )
RequestVector('lock')
>>> int( rsbac.RequestVector('alter') )
2
>>> rsbac.RequestVector( [ ( 'lock' , 'ioctl' ) , [ 'mount' ] , 2 ] )
RequestVector('alter', 'mount', 'ioctl', 'lock')
>>> ~rsbac.RequestVector()
RequestVector('add_to_kernel', 'alter', 'append_open', ..., 'ioctl', 'lock', 'authenticate')
>>> rsbac.RequestVector('bind', 'listen') ^ rsbac.RequestVector('bind', 'connect')
RequestVector('listen', 'connect')
>>> rsbac.RequestVector('bind', 'listen') & ~rsbac.RequestVector('bind', 'connect')
RequestVector('listen')
>>> list( rsbac.RequestVector( 127 ) )
['add_to_kernel', 'alter', 'append_open', 'change_group', 'change_owner', 'chdir', 'clone']
>>> a = rsbac.RequestVector( 'bind' )
>>> a |= 'listen' , 'connect'
>>> a
RequestVector('bind', 'listen', 'connect')
>>> a &= ~rsbac.RequestVector( 'bind' , 'listen' )
>>> a
RequestVector('connect')

1.2.3 dict- and set- like variables

At some places, some variables have a dict-like or a set-like interface, meaning that they can be used and updated like the usual Python dictionnaries or Python sets. These variables are usually dynamic, meaning that there contents reflect the state of the RSBAC configuration. Homever, such dictionnaries doesn't support standard method such as .copy or .fromkeys, because it makes no sense.

There is also a type named "TTL dict-like variable" at some place in this document. It's in fact a type sharing both set and dict interface. This type act as a dictionnary, where the values have the meaning described in the "TTL" section. To summarize: a value with False mean that there is no entry for the given key, True and positive integers mean that the entry exists, where an integer specify the TTL and True mean that the TTL is illimited.

1.2.4 TTL

The way to specify TTL in the rsbac package is a bit different from the usage in other RSBAC tools.

In other RSBAC tools (as understood internally in the kernel), a special value (maximum representable TTL value) is used when we want to preserve the TTL, 0 is for unlimited TTL and any other integers are interpreted as a duration in seconds.

But we have chosen another approach. In the rsbac package, None mean that we want to keep the TTL (thus we specify "no" TTL), False mean that the object doesn't exists (the TTL expired, or is undefined or unknown), True means unlimited TTL and any integer means a duration in seconds. Since TTL cannot be lower than 1s, any integers is clamped to this minimal duration. It means that 0 is also interpreted as a number of second, which is clamped to 1s. The whole point is to have a coherent behavior. (A better behavior could have been reached if it was possible to set the TTL to 0s to discard immediatly the corresponding settings in the RSBAC configuration.)

To summarize:

TTLMeaning
FalseExpired TTL (No entry/no such object)
integerremaining TTL in seconds
Trueunlimited TTL
Noneask to keep the current TTL

1.3 RSBAC modules

RSBAC is divided into various models (aka modules, depending of the context.) There are for example the ACL, RC and PM modules. Each of these modules can be turned on and off (depending of kernel options when the kernel was compiled, or depending of the nature of the model), and their softmode may be enabled or disabled. Also, naturally, a model can be available or not, according to choice made when compiling the kernel.

The rsbac.module module provides a list of all the RSBAC modules known to the rsbac package. This module contains an instance of a module.Module class for each of them. There is also a module.all variable which is a list of all these instances.

Each module is represented by the following class:

class Module(..)

__int__()

__long__()

id

name

available

enabled

switchableOn

switchableOff

softmode

softmodeSwitchableOn

softmodeSwitchableOff

1.4 Transactions

RSBAC transactions are fully supported. To make them easy to use, it was chosen to use a global variable used internally by the rsbac package, rather than letting the user specify the current transaction manually when reading/modifying RSBAC system configuration. The module rsbac.transaction contains the class and functions needed to manage transaction.

The standard method to run a block of code with a new transaction and ensuring the transaction is correctly terminated even if exception occurs, is to use the transaction.withTransaction function.

withTransaction(function, uid=.., password=None, ttl=True)

The transaction is represented by a instance of the following class:

class Transaction(..)

refresh(ttl=True)

commit()

forget()

Example of transaction
def doSomething( transaction ) :
  doThing1()
  doThing2()
  if not doThing3() :
    transaction.forget()
  else :
    doThing4()
    transaction.commit()

withTransaction( doSomething , ttl = 300 )

1.5 Representing objects

A central concept to RSBAC is the various Unix objects such as file system objects (file, directory, fifo pipe, ..), processes, network device and so on. To represent them, the rsbac.objects package provides a hierarchy of classes for each RSBAC object type. Through these classes, all RSBAC objects attributes can be read and written.

The module described below also contains 3 functions listAllDevices(), listAllUsers() and listAllGroups() which return the corresponding list of objects known to RSBAC.

Most of the following class contains a rcTypes attribute with a dict-like interface which gives access to all the defined RC type specific to the corresponding class. For more information, see the section discussing this topic.

  1. FD objects
  2. Device
  3. User and group
    1. User class
    2. Group class
  4. Process
  5. IPC
  6. SCD
  7. Network device
  8. Network template
  9. Network object

1.5.1 FD objects

All common filesystem objects are represented with one of the following class:

class FD(id)

class Directory(id)

class File(id)

class Symlink(id)

class Device(id)

class Fifo(id)

class UnixSocket(id)

__str__()

acl, eff_acl

Class attribute:

rcTypes

Additionnaly, there are some predefined instances to match particular RSBAC objects:

These instances are useful for the ACL entries on the default targets.

1.5.2 Device

The following classes derive from the DeviceBase class.

It is different from the Device class which is instantiated with a path, while here we need the major and minor numbers.

class BlockDevice(major[, minor])

class CharacterDevice(major[, minor])

acl, eff_acl

Class attribute:

rcTypes

1.5.3 User and group

See also um.User and um.Group for the UM specific settings related to users and groups.

The rsbac.um class contains the dict-like variable users and groups which gives access to all defined users and groups in RSBAC. Note that you should not perform a call like users.clear() (which remove ALL the users from the UM module) by mistake, especially if the system is configured to rely on RSBAC for all authentication.

addUser(name, uid=None, password=None, ttl=True)

addGroup(name, gid=None, password=None, ttl=True)

1.5.3.1 User class

class User(uid)

removeFromAcl()

acl, eff_acl

Class attribute:

rcTypes

There is also a module objects.pseudoUsers which contains predefined User instance to represent pseudo users named all_users and no_user.

1.5.3.2 Group class

class Group(gid)

acl, eff_acl

Class attribute:

rcTypes

There is also a module objects.pseudoGroups which contains predefined Group instance to represent pseudo groups named all_groups and no_group.

1.5.4 Process

class Process(pid)

acl, eff_acl

Class attribute:

rcTypes

There is also a defaultProcess instance to represent the default process (useful for the ACL entries.)

1.5.5 IPC

The following classes derive from the objects.Ipc class.

class IpcSem(semid)

class IpcMsg(msgid)

class IpcShm(shmid)

class IpcAnonPipe(inode)

class IpcMqueue(mqdes)

class IpcAnonUnix(inode)

Class attribute:

rcTypes

1.5.6 SCD

class SCD(..)

rc_type

acl, eff_acl

Class attribute:

rcTypes

There is also a defaultScd instance to represent the default SCD object.

SCD instances defined in objects.system
>>> dir(rsbac.objects.system)
['__doc__', '__name__',
 'capability', 'clock', 'firewall', 'host_id', 'ioports',
 'kexec', 'kmem', 'ksyms', 'mlock', 'net_id', 'network',
 'nfsd', 'none', 'other', 'priority', 'quota', 'rlimit',
 'rsbac', 'rsbac_log', 'rsbac_remote_log', 'swap', 'sysctl',
 'sysfs', 'syslog', 'time_strucs']

1.5.7 Network device

class NetworkDevice(name)

acl, eff_acl

Class attribute:

rcTypes

There is also a defaultNetworkDevice instance to represent the default network device.

1.5.8 Network template

class NetworkTemplate(id)

acl, eff_acl

selfAcl

This class also contains specific attributes:

name

addresses

socketType

protocol

networkDevice

ports

Methods for this class are:

checkId()

copyTo(target)

delete()

A class method is provided to create new network templates:

create(id, name)

Class attribute:

rcTypes

The module also provides a variable networkTemplates with a dict-like interface to give access to all defined network templates. A network template can be created with networkTemplates[id]=name, since setting the name of an undefined network template automatically creates it.

1.5.9 Network object

class NetworkObject(..)

acl, eff_acl

There is however an instance objects.defaultNetworkObject to represent the default network object.

Class attribute:

rcTypes

1.6 Details about objects properties

The following properties are part of the classes described is the previous section.

1.6.1 RSBAC attributes

All the classes used to represent a RSBAC object give access to the set of RSBAC attributes for the corresponding object via properties. Each of these properties is of a type specific to the RSBAC attribute. The following table gives the name of the attributes, the module concerned (for information purpose, but not needed otherwise), the targets that own the attribute and the type as handled by the rsbac package.

For example, to retrieve the RC type of the process of PID 1 you can use rsbac.objects.Process(1).rc_type.

FIXME: Complete the following table.

ModuleAttributeTypeTarget
GENaudit_uidobjects.UserProcess
GENauid_exemptobjects.UserFD, Process
AUTHauth_last_authobjects.UserProcess
AUTHauth_learnboolFD, Process
AUTHauth_may_set_capboolFD, Process
AUTHauth_may_setuidintFD, Process
AUTHauth_roleSystemRoleUser
CAPcap_ld_envintFD, Process, User
CAPcap_process_hidingintProcess
CAPcap_roleSystemRoleUser
MACcurrent_sec_levelProcess
DAZdaz_roleUser
DAZdaz_scannedFD
DAZdaz_scannerFD, Process
GENfake_root_uidintFD, Process
FFff_flagsFileFlagsFD
FFff_roleSystemRoleUser
MACinitial_security_levelProcess, User
JAILjail_flagsJailFlagsProcess
JAILjail_idintIpc, Process
JAILjail_ipIP²Process
JAILjail_max_capsCapsFlagsProcess
JAILjail_parentintProcess
JAILjail_roleSystemRoleUser
JAILjail_scd_getJailScdVectorProcess
JAILjail_scd_modifyJailScdVectorProcess
GENlinux_dac_disableintFD
GENlocal_log_array-NetworkObject
MAClocal_mac_categories-NetworkObject
PMlocal_pm_ipc_purpose-NetworkObject
PMlocal_pm_object_class-NetworkObject
PMlocal_pm_object_type-NetworkObject
RClocal_rc_type-NetworkObject
MAClocal_sec_level-NetworkObject
GENlog_arraytuple³Device, FD, NetworkDevice, NetworkTemplate
GENlog_program_basedRequestVectorFD, Process
GENlog_user_basedRequestVectorUser
MACmac_autoFD, Process
MACmac_categoriesDevice, FD, Ipc, NetworkTemplate, Process, User
MACmac_checkDevice
MACmac_curr_categoriesProcess
MACmac_file_flagsFD
MACmac_initial_categoriesProcess, User
MACmac_min_categoriesProcess, User
MACmac_process_flagsProcess
MACmac_prop_trustedFD
MACmac_roleUser
MACmac_user_flagsUser
CAPmax_capsCapsFlagsFD, User
CAPmax_caps_programProcess
CAPmax_caps_userProcess
MACmax_read_categoriesProcess
MACmax_read_openProcess
CAPmin_capsCapsFlagsFD, User
MACmin_security_levelProcess, User
MACmin_write_categoriesProcess
MACmin_write_openProcess
PAXpax_flagsPaxFlagsFD, Process
PAXpax_roleSystemRoleUser
PMpm_current_taskProcess
PMpm_ipc_purposeIpc, NetworkTemplate
PMpm_object_classDevice, FD, Ipc, NetworkTemplate
PMpm_object_typeDevice, FD, Ipc, NetworkTemplate
PMpm_process_typeProcess
PMpm_roleUser
PMpm_task_setUser
PMpm_tpFD, Process
GENpseudo-User
RCrc_def_rolerc.RoleUser
RCrc_force_rolerc.RoleFD, Process
RCrc_initial_rolerc.RoleFD
RCrc_rolerc.RoleProcess
RCrc_select_typerc.TypeProcess
RCrc_typerc.TypeDevice, Group, Ipc, NetworkDevice, NetworkTemplate, Process, User
RCrc_type_fdrc.TypeFD
RCrc_type_ntrc.TypeNetworkTemplate
GENremote_ipIP²Process
GENremote_log_array-NetworkObject
MACremote_mac_categories-NetworkObject
PMremote_pm_ipc_purpose-NetworkObject
PMremote_pm_object_class-NetworkObject
PMremote_pm_object_type-NetworkObject
RCremote_rc_type-NetworkObject
MACremote_sec_level-NetworkObject
RESres_maxtuple³FD, User
RESres_mintuple³FD, User
RESres_roleSystemRoleUser
MACsecurity_levelDevice, FD, Ipc, NetworkTemplate, Process, User
GENsymlink_add_mac_levelboolFD
GENsymlink_add_rc_roleboolFD
GENsymlink_add_remote_ipboolFD
GENsymlink_add_uidboolFD

1.6.2 rcTypes property

This class attribute gives access to all the RC type which are specific to the corresponding objects. It's a dict-like object.

For example, to obtain the RC Type 2 of the target FD, you could use rsbac.objects.FD.rcTypes[2]. It also works if you've an instance of the FD class in which case you could use rsbac.objects.FD('/some/path').rcTypes[2], since rcTypes is a class attribute (not specific to an instance.)

1.6.3 acl property

This dict-like attribute gives access to ACL entries for an object against a particular subject.

The entries are represented by a couple (requests,ttl) where requests is of type AclRequestVector and ttl is as described in the data section.

As a convenience, it is possible to the set the entry to just request, in which case an unlimited TTL is implied.

For example, to obtain the ACL entry where:

file = rsbac.objects.FD('/some/path')
user = rsbac.objects.User(0)

you simply use file.acl[user] to read and write the entry on FD object /some/path for the subject User(0) (the root user in this case.)

To access effective values, there is also an eff_acl attribute.

1.7 User management

RSBAC can optionnaly manage the Unix users and groups from inside the kernel (rather than relying on method such as the use of files /etc/passwd and /etc/group.) The rsbac.um package provides the API to manage these users and groups.

Note that the class um.User is not the same as objects.User! The former is to manage settings related to the user as stored in RSBAC, while the latter is to manage behavior of an Unix user to a RSBAC system. FIXME: Not clear.

The module also provides two dict-like variables named users and groups. They contain the list of users and groups currently registered.

1.7.1 User

class User(uid)

__int__()

__long__()

name

fullname

hashedPassword

password

homeDirectory

shell

group

groups

exists

ttl

Additionnaly, there is two methods:

updatePassword(old,new)

delete()

1.7.2 Group

class Group(gid)

__int__()

__long__()

name

hashedPassword

password

ttl

members

extraMembers

exists

Additionnaly, there is two methods:

updatePassword(old,new)

delete()

1.8 ACL

The module rsbac.acl allows to manage the ACL groups. There is a dict-like variable named acl.groups which contains all the existing ACL groups.

ACL groups are represented with the following class:

Group(id)

name

members

owner

private

The rsbac.acl module also provides some additionnal utility functions related to ACL:

grant(subject, object, requests)

revoke(subject, object, requests)

1.9 RC

The module rsbac.rc allows to manage RC Roles and RC Types.

1.9.1 Type

Type(..)

__int__()

__long__()

name

needSecureDelete

copyTo(dest)

clone([name])

delete()

1.9.2 Role

Role(id)

__int__()

__long__()

id

name

compatibility

adminRoles

assignRoles

typeCompatibility

defaultIndividualFdCreateType

bootRole

requireReauthentication

adminType

defaultFdCreateType

defaultUserCreateType

defaultGroupCreateType

defaultProcessCreateType

defaultProcessChownType

defaultProcessExecuteType

defaultIpcCreateType

defaultUnixsockCreateType

copyTo(dest)

clone([name])

delete()

The rsbac.rc module also provides some additionnal utility functions related to RC:

grant(role, type, requests)

revoke(role, type, requests)

findUnnamedRole(start=0)

findUnnamedRoles(n=1, start=0)

findRole(name,[default])

findUnnamedType(target,start=0)

findUnnamedTypes(target,n=1, start=0)

findType(target,name,[default])

newRole(name, start=0)

1.9.3 Pseudo roles and types

There are also predefined RC roles and RC types in the modules rc.pseudoRoles and rc.pseudoTypes:

RC pseudo roles
>>> dir( rsbac.rc.pseudoRoles )
['__doc__', '__name__',
 'inherit_parent', 'inherit_process',
 'inherit_up_mixed', 'inherit_user',
 'use_force_role']
>>> rsbac.rc.pseudoRoles.use_force_role
<RC PseudoRole [-5] use_force_role>
RC pseudo types
>>> dir( rsbac.rc.pseudoTypes )
['__doc__', '__name__',
 'inherit_parent', 'inherit_process',
 'no_chown', 'no_create', 'no_execute',
 'use_fd', 'use_new_role_def_create']
>>> rsbac.rc.pseudoTypes.use_fd
<RC PseudoType [-7] use_fd>
>>> rsbac.rc.findType( rsbac.objects.FD , 'foo' )
<RC Type [14:99] 'foo'>
>>> rsbac.rc.findType( rsbac.objects.FD , 'bar' )
IndexError: Type named 'bar' not found

All theses instances of Role and Type are singleton, meaning that you can compare them safely with the is operator.

1.10 Jail

The module rsbac.jail contains a single function:

jail(path=None, ip=None, flags=None, max_caps=None, scd_get=None, scd_modify=None)

2. Examples

2.1 Module

While testing, turn off softmode, but take care to turn on AUTH softmode before.

>>> rsbac.module.SOFTMODE
<Module SOFTMODE [Enabled]>
>>> rsbac.module.AUTH
<Module AUTH [Enabled]>
>>> rsbac.module.AUTH.softmode = True
>>> rsbac.module.SOFTMODE.enabled = False
>>> rsbac.module.SOFTMODE
<Module SOFTMODE [Disabled]>
>>> rsbac.module.AUTH
<Module AUTH [Enabled,Softmode]>

2.2 UM

Starting the session
>>> from rsbac import um
We start with no users and no groups
>>> um.users
{}
>>> um.groups
{}
Add an user 'secoff' with UID 400 and password 'foobar'
>>> secoff = um.addUser( 'secoff' , 400 , 'foobar' )
>>> secoff.fullname = 'RSBAC security officer'
>>> secoff
<UM User [400] 'secoff'>
>>> um.users
{400: <UM User [400] 'secoff'>}
Add a group 'secoff' with GID 400 and set it to the 'secoff' user
>>> secoffGroup = um.addGroup( 'secoff' , 400 )
>>> secoff.group = secoffGroup  # or secoff.group = 400
Add two test accounts 'foo' and 'bar'
>>> foo = um.addUser( 'foo' )
>>> bar = um.addUser( 'bar' )
>>> um.users
{400: <UM User [400] 'secoff'>, 2000: <UM User [2000] 'foo'>, 2001: <UM User [2001] 'bar'>}
Add two test groups 'g1' and 'g2'
>>> g1 = um.addGroup( 'g1' )
>>> g2 = um.addGroup( 'g2' )
Set group and extra groups
>>> foo.group = g1
>>> bar.group = g2
>>> bar.groups.add( g1 )
>>> g1.members
(<UM User [2000] 'foo'>,)
>>> g1.extraMembers
(<UM User [2001] 'bar'>,)
Change user TTL
>>> print foo.ttl
True               # unlimited TTL
>>> foo.ttl = 10   # set it to 10s
[..wait..]
>>> foo
<UM User [2000] (9s) 'foo'>
[..wait..]
>>> foo
<UM User [2000] (2s) 'foo'>
[..wait..]
>>> foo
<UM User [2000] (?) undefined>
Remove the test accounts and test groups
# foo already deleted because of the end of TTL
>>> bar.delete()
>>> g1.delete()
>>> g2.delete()
>>> foo
<UM User [2000] (?) undefined>
>>> g1
<UM Group [2000] (?) undefined>
Final state
>>> um.users
{400: <UM User [400] 'secoff'>}
>>> um.groups
{400: <UM Group [400] 'secoff'>}

2.3 File flags

>>> from rsbac import FileFlags
>>> from rsbac.objects import Directory
>>> Directory( '/tmp/foo' ).ff_flags
FileFlags('add_inherited')
>>> Directory( '/tmp/foo' ).eff_ff_flags
FileFlags()   # no effective flags
>>> Directory( '/tmp/foo' ).ff_flags = FileFlags( 'no_delete_or_rename' )
>>> Directory( '/tmp/foo' ).ff_flags
FileFlags('no_delete_or_rename')  # add_inherited was removed too
>>> Directory( '/tmp/foo' ).eff_ff_flags
FileFlags('no_delete_or_rename')

3. Tools

To make it easier to figure what I set in RSBAC, I started to build a tool similar to ls and to find.

# sec find /tmp --rc-type 17
/tmp/foo/bash
# sec ls -A --rc --ff /tmp/foo
!17 !17 f -------I-->----------   ????-??-?? ??:?? bash
  0   m f ------N--->------N--- 0 2006-10-25 23:50 baz
  0   m f -------I-->---------- 8 2006-10-26 10:40 bla
  0   m f ------NI-->------N--- 0 2006-10-25 20:52 foo2
  0   m f -------I-->---------- 0 2006-10-26 10:40 ick

The --rc and --ff specify which type of information to display. There is a flag for each RSBAC module that make sense for file objects.

The --rc option display RC attributes, while --ff display FF attributes (file flags.)

In the example above, the first 3 columns are the RC attributes:

Then come a big column to represent the FF flags. The column has 2 parts. The part before the > character is the real file flags, while the part after is the effective flags. Each flags is represented by a letter, as follow:

LetterFlags
rread_only
xexecute_only
ssearch_only
wwrite_only
Ssecure_delete
Xno_execute
Nno_delete_or_rename
Iadd_inherited
aappend_only
Mno_mount

So, in the example, we can see that the bla file have no flags except add_inherited, and there is effective flags.

FIXME: Choose only lower case letters, then represent inherited flag by an upper case (or the opposite?), thus reducing the display of the file flags.

4. Issues

5. Authors

Generated by Crock on Wed Nov 15 15:11:13 2006 UTC