The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Implementation of named semaphores that release on exit. More...
#include <sys/ipc.h>
#include <sys/sem.h>
#include <sys/stat.h>
#include <stdbool.h>
#include <signal.h>
#include <freeradius-devel/util/perm.h>
#include <freeradius-devel/util/sem.h>
#include <freeradius-devel/util/strerror.h>
#include <freeradius-devel/util/syserror.h>
Go to the source code of this file.
Macros | |
#define | DEFAULT_PROJ_ID ((int)'f') /* Only 8 bits are used */ |
Functions | |
int | fr_sem_cgid (uid_t *gid, int sem_id) |
Return the GID that created the semaphore. | |
int | fr_sem_close (int sem_id, char const *file) |
Remove the semaphore, this helps with permissions issues. | |
int | fr_sem_cuid (uid_t *uid, int sem_id) |
Return the UID that created the semaphore. | |
int | fr_sem_get (char const *file, int proj_id, uid_t uid, gid_t gid, bool check_perm, bool must_exist) |
Returns a semid for the semaphore associated with the file. | |
int | fr_sem_gid (uid_t *gid, int sem_id) |
Return the GID that last operated on the semaphore. | |
int | fr_sem_pid (pid_t *pid, int sem_id) |
Return the PID of the process that last operated on the semaphore. | |
int | fr_sem_post (int sem_id, char const *file, bool undo_on_exit) |
Decrement the semaphore by 1. | |
int | fr_sem_take (int sem_id, char const *file, bool undo_on_exit) |
Increment the semaphore by 1. | |
int | fr_sem_uid (uid_t *uid, int sem_id) |
Return the UID that last operated on the semaphore. | |
int | fr_sem_wait (int sem_id, char const *file, bool undo_on_exit, bool nonblock) |
Wait for a semaphore to reach 0, then increment it by 1. | |
static bool | sem_check_gid (char const *file, int proj_id, char const *thing, gid_t expected, gid_t got) |
static bool | sem_check_uid (char const *file, int proj_id, char const *thing, uid_t expected, uid_t got) |
Implementation of named semaphores that release on exit.
Definition in file sem.c.
int fr_sem_cgid | ( | uid_t * | gid, |
int | sem_id | ||
) |
int fr_sem_close | ( | int | sem_id, |
char const * | file | ||
) |
int fr_sem_cuid | ( | uid_t * | uid, |
int | sem_id | ||
) |
int fr_sem_get | ( | char const * | file, |
int | proj_id, | ||
uid_t | uid, | ||
gid_t | gid, | ||
bool | check_perm, | ||
bool | must_exist | ||
) |
Returns a semid for the semaphore associated with the file.
[in] | file | to get or create semaphore from. |
[in] | proj_id | if 0 will default to '0xf4ee4a31'. |
[in] | uid | that should own the semaphore. |
[in] | gid | that should own the semaphore. |
[in] | check_perm | Verify the semaphore is owned by the specified uid/gid, and that it was created by the specified uid/gid or root. Also verify that it is not world writable. |
[in] | must_exist | semaphore must already exist. |
Definition at line 421 of file sem.c.
int fr_sem_gid | ( | uid_t * | gid, |
int | sem_id | ||
) |
int fr_sem_pid | ( | pid_t * | pid, |
int | sem_id | ||
) |
Return the PID of the process that last operated on the semaphore.
[out] | pid | that last modified the semaphore. |
[in] | sem_id | semaphore ID. |
Definition at line 53 of file sem.c.
int fr_sem_post | ( | int | sem_id, |
char const * | file, | ||
bool | undo_on_exit | ||
) |
Decrement the semaphore by 1.
[in] | sem_id | to take. |
[in] | file | to use in error messages. |
[in] | undo_on_exit | decrement the semaphore on exit. |
Definition at line 182 of file sem.c.
int fr_sem_take | ( | int | sem_id, |
char const * | file, | ||
bool | undo_on_exit | ||
) |
Increment the semaphore by 1.
[in] | sem_id | to take. |
[in] | file | to use in error messages. |
[in] | undo_on_exit | decrement the semaphore on exit. |
Definition at line 221 of file sem.c.
int fr_sem_uid | ( | uid_t * | uid, |
int | sem_id | ||
) |
Wait for a semaphore to reach 0, then increment it by 1.
[in] | sem_id | to operate on. |
[in] | file | to use in error messages. |
[in] | undo_on_exit | If true, semaphore will be decremented if this process exits. |
[in] | nonblock | If true, don't wait and return 1 if the semaphore is not at 0. |
Definition at line 252 of file sem.c.
|
static |