LDFL
LD_PRELOAD library rerule files & directories.
Loading...
Searching...
No Matches
ldfl.c File Reference

Structures of interest in ldfl.c. More...

Data Structures

struct  ldfl_rule_t
 Represents matching + operation rule. More...
 
struct  ldfl_setting_t
 Represents the general settings. More...
 

Macros

#define ldfl_op_index(op)   __builtin_ctzll(op)
 

Typedefs

typedef void(* ldfl_logger_t) (uint64_t mask, int priority, const char *fmt,...)
 Variadic logger function type.
 

Enumerations

enum  ldfl_path_type_t { LDFL_PATH_ORIG = 0 , LDFL_PATH_ABS = 1 }
 flag More...
 
enum  ldfl_log_category_t {
  LDFL_LOG_FN_CALL = 1ULL << 0 , LDFL_LOG_FN_CALL_ERR = 1ULL << 1 , LDFL_LOG_RULE_SEARCH = 1ULL << 2 , LDFL_LOG_RULE_FOUND = 1ULL << 3 ,
  LDFL_LOG_RULE_APPLY = 1ULL << 4 , LDFL_LOG_INIT = 1ULL << 5 , LDFL_LOG_ALL = ~0ULL
}
 Bitmask flags for specifying logging categories. More...
 
enum  ldfl_operation_t {
  LDFL_OP_NOOP = 1ULL << 0 , LDFL_OP_PATH_REDIR = 1ULL << 1 , LDFL_OP_EXEC_REDIR = 1ULL << 2 , LDFL_OP_MEM_OPEN = 1ULL << 3 ,
  LDFL_OP_MEM_DATA = 1ULL << 4 , LDFL_OP_PERM , LDFL_OP_DENY = 1ULL << 6 , LDFL_OP_RO = 1ULL << 7 ,
  LDFL_OP_END = 0ULL , LDFL_OP_ALL = ~0ULL
}
 enum for the type of operations More...
 

Variables

const uint64_t LDFL_OP_COMPAT_TABLE []
 Compatibility mask table for LDFL operations.
 

Detailed Description

Structures of interest in ldfl.c.

Defines the structure for a single rule entry.

Macro Definition Documentation

◆ ldfl_op_index

#define ldfl_op_index (   op)    __builtin_ctzll(op)

Typedef Documentation

◆ ldfl_logger_t

typedef void(* ldfl_logger_t) (uint64_t mask, int priority, const char *fmt,...)

Variadic logger function type.

This function type is used for logging messages in ldfl. Implement this signature if you want your own logger

Parameters
maskLogging category bitmask (see ldfl_log_category_t).
priorityPriority level of the log message.
fmtFormat string for the log message (like sprintf).
...Variadic arguments for the format string.
Note
Default loggers implementing this interface:
  • ldfl_dummy_logger: A no-op logger that discards all messages.
  • ldfl_stderr_logger: Logs messages to standard error (stderr).
  • ldfl_syslog_logger: Logs messages to the system log (syslog).

Enumeration Type Documentation

◆ ldfl_log_category_t

Bitmask flags for specifying logging categories.

This enumeration defines flags used to control the logging behavior of the ldfl. Each flag represents a specific category of operations to be logged, and they can be combined using bitwise OR operations.

Enumerator
LDFL_LOG_FN_CALL 

Log LibC function calls.

LDFL_LOG_FN_CALL_ERR 

Log LibC function calls errors

LDFL_LOG_RULE_SEARCH 

Log rule search operations.

LDFL_LOG_RULE_FOUND 

Log rule found operations.

LDFL_LOG_RULE_APPLY 

Log rule application operations.

LDFL_LOG_INIT 

Log initialization and deinitialization operations.

LDFL_LOG_ALL 

Log all categories.

◆ ldfl_operation_t

enum for the type of operations

Enumerator
LDFL_OP_NOOP 

No operation.

LDFL_OP_PATH_REDIR 

Path redirection.

LDFL_OP_EXEC_REDIR 

Path redirection for executable.

LDFL_OP_MEM_OPEN 

Memory open (empty).

LDFL_OP_MEM_DATA 

Memory open (with Content).

LDFL_OP_PERM 

Change permissions/ownership, uses extra_option "<USER>|<GROUP>|<FILE_PERM>|<DIR_PERM>".

LDFL_OP_DENY 

Deny access.

LDFL_OP_RO 

Restrict to Read Only access.

LDFL_OP_END 

End marker.

LDFL_OP_ALL 

All ops mask

◆ ldfl_path_type_t

flag

This enumeration defines if we should use the absolute path or the unaltered path in the transformation.

Enumerator
LDFL_PATH_ORIG 
LDFL_PATH_ABS 

Variable Documentation

◆ LDFL_OP_COMPAT_TABLE

const uint64_t LDFL_OP_COMPAT_TABLE[]
Initial value:
= {
}
@ LDFL_OP_DENY
Definition ldfl.c:82
@ LDFL_OP_PATH_REDIR
Definition ldfl.c:76
@ LDFL_OP_PERM
Definition ldfl.c:80
@ LDFL_OP_ALL
Definition ldfl.c:85
@ LDFL_OP_MEM_OPEN
Definition ldfl.c:78
@ LDFL_OP_END
Definition ldfl.c:84
@ LDFL_OP_NOOP
Definition ldfl.c:75
@ LDFL_OP_MEM_DATA
Definition ldfl.c:79
@ LDFL_OP_EXEC_REDIR
Definition ldfl.c:77
@ LDFL_OP_RO
Definition ldfl.c:83
#define ldfl_op_index(op)
Definition ldfl.c:88

Compatibility mask table for LDFL operations.

Indexed by ldfl_op_index(op), this table defines which operations are valid to combine with each LDFL operation.