Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

rpmsx.c File Reference

#include "system.h"
#include <rpmlib.h>
#include <rpmmacro.h>
#include "rpmsx.h"
#include "debug.h"

Go to the source code of this file.

Defines

#define _RPMSX_INTERNAL
#define inc_err()   nerr++

Functions

void rpmsxSort (rpmsx sx)
 Stable sort for policy specifications, patterns before paths.
void rpmsxpHasMetaChars (rpmsxp sxp)
size_t rpmsxsPStem (const char *const buf)
 Return the length of the text that can be considered the stem.
size_t rpmsxsFStem (const char *const buf)
 Return the length of the text that is the stem of a file name.
int rpmsxAdd (rpmsx sx, const char **bpp)
 Find (or create) the stem of a file spec.
int rpmsxFind (const rpmsx sx, const char **bpp)
 Find the stem of a file name.
rpmsx XrpmsxUnlink (rpmsx sx, const char *msg, const char *fn, unsigned ln)
rpmsx XrpmsxLink (rpmsx sx, const char *msg, const char *fn, unsigned ln)
rpmsx rpmsxFree (rpmsx sx)
 Destroy a security context patterns.
int rpmsxpCheckNoDupes (const rpmsx sx)
 Check for duplicate specifications.
int rpmsxParse (rpmsx sx, const char *fn)
 Parse selinux file security context patterns.
rpmsx rpmsxNew (const char *fn)
 Create and load security context patterns.
int rpmsxCount (const rpmsx sx)
 Return security context patterns count.
int rpmsxIx (const rpmsx sx)
 Return security context patterns index.
int rpmsxSetIx (rpmsx sx, int ix)
 Set security context patterns index.
const char * rpmsxPattern (const rpmsx sx)
 Return current pattern.
const char * rpmsxType (const rpmsx sx)
 Return current type.
const char * rpmsxContext (const rpmsx sx)
 Return current context.
regex_t * rpmsxRE (const rpmsx sx)
 Return current regex.
mode_t rpmsxFMode (const rpmsx sx)
 Return current file mode.
int rpmsxFStem (const rpmsx sx)
 Return current file stem.
int rpmsxNext (rpmsx sx)
 Return next security context patterns iterator index.
rpmsx rpmsxInit (rpmsx sx, int reverse)
 Initialize security context patterns iterator.
const char * rpmsxFContext (rpmsx sx, const char *fn, mode_t fmode)
 Find file security context from path and type.

Variables

int _rpmsx_debug = 0


Detailed Description

Definition in file rpmsx.c.


Define Documentation

#define _RPMSX_INTERNAL
 

Definition at line 9 of file rpmsx.c.

 
#define inc_err  )     nerr++
 

Referenced by rpmsxParse().


Function Documentation

int rpmsxAdd rpmsx  sx,
const char **  bpp
[static]
 

Find (or create) the stem of a file spec.

Error iff a file in the root directory or a regex that is too complex.

Return values:
*bpp ptr to text after stem.
Returns:
stem index, -1 on error

Definition at line 135 of file rpmsx.c.

References rpmsxs, rpmsxsPStem(), and xrealloc().

Referenced by rpmsxParse().

const char* rpmsxContext const rpmsx  sx  ) 
 

Return current context.

Parameters:
sx security context patterns
Returns:
current context, NULL on invalid

Definition at line 570 of file rpmsx.c.

Referenced by rpmsxFContext().

int rpmsxCount const rpmsx  sx  ) 
 

Return security context patterns count.

Parameters:
sx security context patterns
Returns:
current count

Definition at line 531 of file rpmsx.c.

const char* rpmsxFContext rpmsx  sx,
const char *  fn,
mode_t  fmode
 

Find file security context from path and type.

Parameters:
sx security context patterns
fn file path
fmode file mode
Returns:
file security context

Definition at line 650 of file rpmsx.c.

References rpmsxContext(), rpmsxFind(), rpmsxFMode(), rpmsxFStem(), rpmsxInit(), rpmsxNext(), rpmsxPattern(), and rpmsxRE().

Referenced by fsmMapFContext(), fsmMkdirs(), genCpioListAndHeader(), rpmfiBuildREContexts(), and rpmVerifyFile().

int rpmsxFind const rpmsx  sx,
const char **  bpp
[static]
 

Find the stem of a file name.

Error iff a file in the root directory or a regex that is too complex.

Parameters:
sx security context patterns
Return values:
*bpp ptr to text after stem.
Returns:
stem index, -1 on error

Definition at line 174 of file rpmsx.c.

References rpmsxs, and rpmsxsFStem().

Referenced by rpmsxFContext().

mode_t rpmsxFMode const rpmsx  sx  ) 
 

Return current file mode.

Parameters:
sx security context patterns
Returns:
current file mode, 0 on invalid

Definition at line 588 of file rpmsx.c.

Referenced by rpmsxFContext().

rpmsx rpmsxFree rpmsx  sx  ) 
 

Destroy a security context patterns.

Parameters:
sx security context patterns
Returns:
NULL always

Definition at line 218 of file rpmsx.c.

References _free(), _rpmsx_debug, rpmsx, rpmsxp, rpmsxs, and rpmsxUnlink.

Referenced by fsmMapFContext(), fsmMkdirs(), genCpioListAndHeader(), rpmcliQuery(), rpmcliVerify(), rpmfiBuildREContexts(), rpmInstall(), rpmsxNew(), rpmts_Run(), rpmtsFree(), rpmtsSetREContext(), and rpmVerifyFile().

int rpmsxFStem const rpmsx  sx  ) 
 

Return current file stem.

Parameters:
sx security context patterns
Returns:
current file stem, -1 on invalid

Definition at line 597 of file rpmsx.c.

Referenced by rpmsxFContext().

rpmsx rpmsxInit rpmsx  sx,
int  reverse
 

Initialize security context patterns iterator.

Parameters:
sx security context patterns
reverse iterate in reverse order?
Returns:
security context patterns

Definition at line 638 of file rpmsx.c.

References rpmsx.

Referenced by rpmsxFContext().

int rpmsxIx const rpmsx  sx  ) 
 

Return security context patterns index.

Parameters:
sx security context patterns
Returns:
current index

Definition at line 536 of file rpmsx.c.

rpmsx rpmsxNew const char *  fn  ) 
 

Create and load security context patterns.

Parameters:
fn security context patterns file name
Returns:
new security context patterns

Definition at line 510 of file rpmsx.c.

References rpmsx, rpmsxFree(), rpmsxLink, rpmsxParse(), and xcalloc().

Referenced by genCpioListAndHeader(), rpmcliQuery(), rpmcliVerify(), rpmfiBuildREContexts(), rpmInstall(), and rpmts_Run().

int rpmsxNext rpmsx  sx  ) 
 

Return next security context patterns iterator index.

Parameters:
sx security context patterns
Returns:
security context patterns iterator index, -1 on termination

Definition at line 606 of file rpmsx.c.

References _rpmsx_debug, and rpmsxp.

Referenced by rpmsxFContext().

int rpmsxParse rpmsx  sx,
const char *  fn
 

Parse selinux file security context patterns.

Parameters:
sx security context patterns
fn file name to parse
Returns:
0 on success

Definition at line 311 of file rpmsx.c.

References _, _free(), errno, inc_err, rpmGetPath(), rpmsxAdd(), rpmsxp, rpmsxpCheckNoDupes(), rpmsxpHasMetaChars(), rpmsxSort(), security_check_context, xcalloc(), and xmalloc().

Referenced by rpmsxNew().

const char* rpmsxPattern const rpmsx  sx  ) 
 

Return current pattern.

Parameters:
sx security context patterns
Returns:
current pattern, NULL on invalid

Definition at line 552 of file rpmsx.c.

Referenced by rpmsxFContext().

int rpmsxpCheckNoDupes const rpmsx  sx  )  [static]
 

Check for duplicate specifications.

If a duplicate specification is found and the context is the same, give a warning to the user. If a duplicate specification is found and the context is different, give a warning to the user (This could be changed to error). Return of non-zero is an error.

Parameters:
sx security context patterns
Returns:
0 on success

Definition at line 272 of file rpmsx.c.

References rpmsxp.

Referenced by rpmsxParse().

void rpmsxpHasMetaChars rpmsxp  sxp  )  [static]
 

Definition at line 54 of file rpmsx.c.

Referenced by rpmsxParse().

regex_t* rpmsxRE const rpmsx  sx  ) 
 

Return current regex.

Parameters:
sx security context patterns
Returns:
current context, NULL on invalid

Definition at line 579 of file rpmsx.c.

Referenced by rpmsxFContext().

int rpmsxSetIx rpmsx  sx,
int  ix
 

Set security context patterns index.

Parameters:
sx security context patterns
ix new index
Returns:
current index

Definition at line 541 of file rpmsx.c.

size_t rpmsxsFStem const char *const   buf  )  [static]
 

Return the length of the text that is the stem of a file name.

Returns:
stem length, 0 if no identifiable stem

Definition at line 118 of file rpmsx.c.

Referenced by rpmsxFind().

void rpmsxSort rpmsx  sx  )  [static]
 

Stable sort for policy specifications, patterns before paths.

Parameters:
sx security context patterns

Definition at line 23 of file rpmsx.c.

References _free(), rpmsxp, and xmalloc().

Referenced by rpmsxParse().

size_t rpmsxsPStem const char *const   buf  )  [static]
 

Return the length of the text that can be considered the stem.

Returns:
stem length, 0 if no identifiable stem

Definition at line 96 of file rpmsx.c.

Referenced by rpmsxAdd().

const char* rpmsxType const rpmsx  sx  ) 
 

Return current type.

Parameters:
sx security context patterns
Returns:
current type, NULL on invalid/missing

Definition at line 561 of file rpmsx.c.

rpmsx XrpmsxLink rpmsx  sx,
const char *  msg,
const char *  fn,
unsigned  ln
 

Todo:
Remove debugging entry from the ABI.

Definition at line 205 of file rpmsx.c.

References _rpmsx_debug, and rpmsx.

rpmsx XrpmsxUnlink rpmsx  sx,
const char *  msg,
const char *  fn,
unsigned  ln
 

Todo:
Remove debugging entry from the ABI.

Definition at line 194 of file rpmsx.c.

References _rpmsx_debug, and rpmsx.


Variable Documentation

int _rpmsx_debug = 0
 

Definition at line 17 of file rpmsx.c.


Generated on Sat May 23 04:08:21 2009 for rpm by  doxygen 1.3.9.1