The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
sem.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or (at
7  * your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18 
19 /** Functions for establishing and managing low level sockets
20  *
21  * @file src/lib/util/sem.h
22  *
23  * @copyright 2021 Arran Cudbard-Bell (a.cudbardb@freeradius.org)
24  */
25 RCSIDH(sem_h, "$Id: a89712d8ca126423874ad3b0b2b6e1d4bbfd35ae $")
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 #ifndef __EMSCRIPTEN__
32 #define HAVE_SEMAPHORES
33 
34 int fr_sem_pid(pid_t *pid, int sem_id);
35 
36 int fr_sem_uid(uid_t *uid, int sem_id);
37 
38 int fr_sem_gid(uid_t *gid, int sem_id);
39 
40 int fr_sem_cuid(uid_t *uid, int sem_id);
41 
42 int fr_sem_cgid(gid_t *gid, int sem_id);
43 
44 int fr_sem_post(int sem_id, char const *file, bool undo_on_exit);
45 
46 int fr_sem_take(int sem_id, char const *file, bool undo_on_exit);
47 
48 int fr_sem_wait(int sem_id, char const *file, bool undo_on_exit, bool nonblock);
49 
50 int fr_sem_close(int sem_id, char const *file);
51 
52 int fr_sem_get(char const *file, int proj_id, uid_t uid, gid_t gid, bool check_perm, bool must_exist);
53 #endif
54 
55 #ifdef __cplusplus
56 }
57 #endif
58 
int const char * file
Definition: acutest.h:702
#define RCSIDH(h, id)
Definition: build.h:445
int fr_sem_gid(uid_t *gid, int sem_id)
Return the GID that last operated on the semaphore.
Definition: sem.c:102
int fr_sem_cgid(gid_t *gid, int sem_id)
int fr_sem_post(int sem_id, char const *file, bool undo_on_exit)
Decrement the semaphore by 1.
Definition: sem.c:182
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.
Definition: sem.c:252
int fr_sem_close(int sem_id, char const *file)
Remove the semaphore, this helps with permissions issues.
Definition: sem.c:329
int fr_sem_cuid(uid_t *uid, int sem_id)
Return the UID that created the semaphore.
Definition: sem.c:128
int fr_sem_uid(uid_t *uid, int sem_id)
Return the UID that last operated on the semaphore.
Definition: sem.c:76
int fr_sem_pid(pid_t *pid, int sem_id)
Return the PID of the process that last operated on the semaphore.
Definition: sem.c:53
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.
Definition: sem.c:421
int fr_sem_take(int sem_id, char const *file, bool undo_on_exit)
Increment the semaphore by 1.
Definition: sem.c:221