#include "../include/helpers.h"
Detailed Description
Implementation of helper functions.
- Author:
- Julian Thome
- Date:
- 2010-08-25
Define Documentation
Function Documentation
Check proces capabilities.
This function check if the CAP_SYS_ADMIN flag is setted for the calling proces.
- Return values:
-
| true | CAP_SYS_ADMIN flag is setted |
| false | CAP_SYS_ADMIN flag is not setted |
int count_delim |
( |
const char * |
string |
) |
|
char* create_arg |
( |
const char * |
fmt, |
|
|
void ** |
arg | |
|
) |
| | |
Create an argument.
This function is usually not called directly. It creates a string using the format and the argument list.
- Parameters:
-
| fmt | The format |
| arg | The argument vector |
- Returns:
- The resulting char array
char** create_argl |
( |
const char * |
fmt, |
|
|
|
... | |
|
) |
| | |
Create an argument verctor.
This function takes multiple formats and associated arguments.
- Parameters:
-
| fmt | The format (Each format should be followed by the associated arguments if fmt isn't a simple string |
- Returns:
- The resulting argument vector
int sec_close |
( |
int * |
fd |
) |
|
Close a filedescritpro securely.
This function close an open filedescritor and sets it to -1.
- Parameters:
-
| fd | Pointer to an open filedescriptor |
- Return values:
-
| 0 | Filedescriptor successfully closed |
| <0 | Something went wrong |
void sec_free |
( |
void ** |
p |
) |
|
Free memory space securely.
This function frees the allocated memory which is accessible over the pointer p and set this pointer to NULL.
- Parameters:
-
| p | Pointer to memory which should be freed |
void sec_free_argl |
( |
void *** |
pp |
) |
|
Free memory space of argument list securely.
This function frees all pointers in the argument vector and the pointer to the argument vector itself and set them to NULL. Be sure that the last element of the argument vector is a NULL pointer !!
- Parameters:
-
| p | Pointer to memory which should be freed |
int set_file_perm |
( |
const char * |
file_path, |
|
|
uid_t |
uid, |
|
|
gid_t |
gid, |
|
|
mode_t |
mode | |
|
) |
| | |
Set file permissions.
This function sets the file permission of the file given by file_path.
- Parameters:
-
| file_path | The path of the file which permissions should be changed |
| uid | User ID to set |
| gid | Group ID to set |
| mode | Mode to set |
- Return values:
-
| 0 | Permissions successfully setted |
| -1 | Something went wrong |
Variable Documentation