sefs_entry Class Reference

#include <entry.hh>

List of all members.


Detailed Description

This class represents an individual entry within a list an fcfile object.

Note that the entry's contents (even upon a copy-constructed version of the entry) are always tied to its fclist, so do not access entries whose fclist has been destroyed.

Definition at line 51 of file entry.hh.


Public Member Functions

 sefs_entry (const sefs_entry *e)
 Perform a deep copy of an entry object.
 ~sefs_entry ()
const apol_context_tcontext () const
 Get the context from a sefs entry.
ino64_t inode () const
 Get the inode number associated with a sefs entry.
const char * dev () const
 Get the device name associated with a sefs entry.
uint32_t objectClass () const
 Get the object class associated with a sefs entry.
const char * path () const
 Get the paths associated with a sefs entry.
const char * origin () const
 Get the file from which a sefs entry originated.
char * toString () const throw (std::bad_alloc)
 Return a string representation of this entry.

Private Member Functions

 sefs_entry (class sefs_fclist *fclist, const struct sefs_context_node *new_context, uint32_t new_objectClass, const char *new_path, const char *new_origin=NULL)
 Create a blank entry.

Private Attributes

sefs_fclist_fclist
const struct sefs_context_node_context
ino64_t _inode
const char * _dev
uint32_t _objectClass
const char * _path
const char * _origin

Friends

class sefs_db
class sefs_fcfile
class sefs_filesystem

Constructor & Destructor Documentation

sefs_entry::sefs_entry const sefs_entry e  ) 
 

Perform a deep copy of an entry object.

Definition at line 38 of file entry.cc.

References _context, _dev, _fclist, _inode, _objectClass, _origin, and _path.

00039 {
00040         _fclist = e->_fclist;
00041         _context = e->_context;
00042         _inode = e->_inode;
00043         _dev = e->_dev;
00044         _objectClass = e->_objectClass;
00045         _path = e->_path;
00046         _origin = e->_origin;
00047 }

sefs_entry::~sefs_entry  ) 
 

Definition at line 49 of file entry.cc.

00050 {
00051         // do nothing
00052 }

sefs_entry::sefs_entry class sefs_fclist fclist,
const struct sefs_context_node new_context,
uint32_t  new_objectClass,
const char *  new_path,
const char *  new_origin = NULL
[private]
 

Create a blank entry.

The entity creating this entry is responsible for setting additional values as needed.

Parameters:
fclist List that will contain this entry. This constructor will not add itself to the fclist.
new_context Context node containing the SELinux context.
new_objectClass Object class for the entry.
new_path Path to this entry. The entry will share this pointer.
new_origin Name of file_contexts file from which this entry originated. The entry will share this pointer.
Exceptions:
std::bad_alloc Out of memory.

Definition at line 131 of file entry.cc.

References _context, _dev, _fclist, _inode, _objectClass, _origin, and _path.

00133 {
00134         _fclist = fclist;
00135         _context = new_context;
00136         _objectClass = new_objectClass;
00137         _inode = 0;
00138         _dev = NULL;
00139         _path = new_path;
00140         _origin = new_origin;
00141 }


Member Function Documentation

const apol_context_t * sefs_entry::context  )  const
 

Get the context from a sefs entry.

If the entry has no context (such as being marked <<none>> in a file_contexts file) then apol_context_get_user() and others will return an empty string.

Returns:
A pointer to the context, or NULL on error. The caller should not modify or destroy the returned context.

Definition at line 54 of file entry.cc.

References _context, apol_context_t, and sefs_context_node::context.

Referenced by fcfile_query(), fcfile_query_map_user_lee(), replace_entry(), and sefs_entry_get_context().

00055 {
00056         return _context->context;
00057 }

ino64_t sefs_entry::inode  )  const
 

Get the inode number associated with a sefs entry.

Returns:
Inode number associated with the entry or 0 on error. Entries originating from a file_contexts object will have no inode and thus return 0.

Definition at line 59 of file entry.cc.

Referenced by db_create_from_filesystem(), and sefs_entry_get_inode().

00060 {
00061         return _inode;
00062 }

const char * sefs_entry::dev  )  const
 

Get the device name associated with a sefs entry.

For example, if /dev/sda5 is mounted as /home, the device name for entry "/home/gburdell" will be "/dev/sda5".

Returns:
Device number associated with the entry or NULL on error. Do not free() this value. Entries originating from a file_contexts object will have no device name and thus return NULL.

Definition at line 64 of file entry.cc.

Referenced by db_create_from_filesystem(), and sefs_entry_get_dev().

00065 {
00066         return _dev;
00067 }

uint32_t sefs_entry::objectClass  )  const
 

Get the object class associated with a sefs entry.

The returned value will be one of one of QPOL_CLASS_ALL, QPOL_CLASS_FILE, etc., as defined in <qpol/genfscon_query.h>. If this returns QPOL_CLASS_ALL then the entry is associated with all object classes.

Returns:
Entry's object class. Upon error return QPOL_CLASS_ALL.
See also:
apol_objclass_to_str() to convert the value to a string.

Definition at line 69 of file entry.cc.

Referenced by db_create_from_filesystem(), fcfile_query(), and sefs_entry_get_object_class().

00070 {
00071         return _objectClass;
00072 }

const char * sefs_entry::path  )  const
 

Get the paths associated with a sefs entry.

Returns:
Path for the entry.If the entry came from a file_contexts object the paths will be a regular expression rather than literal paths. Do not free() this pointer.

Definition at line 74 of file entry.cc.

Referenced by db_create_from_filesystem(), fcfile_query(), replace_entry(), and sefs_entry_get_path().

00075 {
00076         return _path;
00077 }

const char * sefs_entry::origin  )  const
 

Get the file from which a sefs entry originated.

This function is only meaningful when entries are returned from a query on a modular file context file.

Returns:
The path of the file (policy package or source file) providing the entry or NULL if the entry is not from a module. Do not free() this pointer.

Definition at line 79 of file entry.cc.

Referenced by fcfile_query_map_user_lee(), and sefs_entry_get_origin().

00080 {
00081         return _origin;
00082 }

char * sefs_entry::toString  )  const throw (std::bad_alloc)
 

Return a string representation of this entry.

The string is suitable for printing to the screen or to a file_contexts file.

Returns:
An allocated string representation. The caller is responsibily for free()ing the string afterwards.
Exceptions:
std::bad_alloc Out of memory.

Definition at line 84 of file entry.cc.

References _context, _fclist, _path, sefs_context_node::context_str, QPOL_CLASS_ALL, QPOL_CLASS_BLK_FILE, QPOL_CLASS_CHR_FILE, QPOL_CLASS_DIR, QPOL_CLASS_FIFO_FILE, QPOL_CLASS_FILE, QPOL_CLASS_LNK_FILE, QPOL_CLASS_SOCK_FILE, and SEFS_ERR.

Referenced by fcfile_query(), print_entry(), and sefs_entry_to_string().

00085 {
00086         char *class_str;
00087 
00088         switch (_objectClass)
00089         {
00090         case QPOL_CLASS_ALL:
00091                 class_str = "  ";
00092                 break;
00093         case QPOL_CLASS_BLK_FILE:
00094                 class_str = "-b";
00095                 break;
00096         case QPOL_CLASS_CHR_FILE:
00097                 class_str = "-c";
00098                 break;
00099         case QPOL_CLASS_DIR:
00100                 class_str = "-d";
00101                 break;
00102         case QPOL_CLASS_FIFO_FILE:
00103                 class_str = "-p";
00104                 break;
00105         case QPOL_CLASS_FILE:
00106                 class_str = "--";
00107                 break;
00108         case QPOL_CLASS_LNK_FILE:
00109                 class_str = "-l";
00110                 break;
00111         case QPOL_CLASS_SOCK_FILE:
00112                 class_str = "-s";
00113                 break;
00114         default:
00115                 // should never get here
00116                 assert(0);
00117                 class_str = "-?";
00118         }
00119 
00120         char *s = NULL;
00121         if (asprintf(&s, "%s\t%s\t%s", _path, class_str, _context->context_str) < 0)
00122         {
00123                 SEFS_ERR(_fclist, "%s", strerror(errno));
00124                 throw std::bad_alloc();
00125         }
00126         return s;
00127 }


Friends And Related Function Documentation

friend class sefs_db [friend]
 

Definition at line 53 of file entry.hh.

friend class sefs_fcfile [friend]
 

Definition at line 54 of file entry.hh.

friend class sefs_filesystem [friend]
 

Definition at line 55 of file entry.hh.


Member Data Documentation

class sefs_fclist* sefs_entry::_fclist [private]
 

Definition at line 156 of file entry.hh.

Referenced by sefs_entry(), and toString().

const struct sefs_context_node* sefs_entry::_context [private]
 

Definition at line 157 of file entry.hh.

Referenced by context(), sefs_db::getContextNode(), sefs_fcfile::runQueryMap(), sefs_entry(), and toString().

ino64_t sefs_entry::_inode [private]
 

Definition at line 158 of file entry.hh.

Referenced by sefs_filesystem::getEntry(), sefs_db::getEntry(), and sefs_entry().

const char* sefs_entry::_dev [private]
 

Definition at line 159 of file entry.hh.

Referenced by sefs_filesystem::getEntry(), sefs_db::getEntry(), and sefs_entry().

uint32_t sefs_entry::_objectClass [private]
 

Definition at line 160 of file entry.hh.

Referenced by sefs_fcfile::runQueryMap(), and sefs_entry().

const char* sefs_entry::_path [private]
 

Definition at line 161 of file entry.hh.

Referenced by sefs_fcfile::runQueryMap(), sefs_entry(), and toString().

const char * sefs_entry::_origin [private]
 

Definition at line 161 of file entry.hh.

Referenced by sefs_entry().


The documentation for this class was generated from the following files: