The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
perm.h
Go to the documentation of this file.
1 #pragma once
2 /*
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public
5  * License as published by the Free Software Foundation; either
6  * version 2.1 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
16  */
17 
18 /** Functions to produce and parse the FreeRADIUS presentation format
19  *
20  * @file src/lib/util/perm.h
21  *
22  * @copyright 2021 Arran Cudbard-Bell (a.cudbardb@freeradius.org)
23  */
24 RCSIDH(perm_h, "$Id: 057e7133afe4cb9de5cd38905a50a7a9aa93a9a9 $")
25 
26 #include <pwd.h>
27 #include <sys/stat.h>
28 #include <sys/types.h>
29 #include <grp.h>
30 
31 #include <freeradius-devel/util/talloc.h>
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 char const *fr_perm_mode_to_str(char out[static 10], mode_t mode);
38 
39 char const *fr_perm_mode_to_oct(char out[static 5], mode_t mode);
40 
41 int fr_perm_getpwuid(TALLOC_CTX *ctx, struct passwd **out, uid_t uid) CC_HINT(nonnull(2));
42 
43 int fr_perm_getpwnam(TALLOC_CTX *ctx, struct passwd **out, char const *name) CC_HINT(nonnull(2,3));
44 
45 int fr_perm_getgrgid(TALLOC_CTX *ctx, struct group **out, gid_t gid) CC_HINT(nonnull(2));
46 
47 int fr_perm_getgrnam(TALLOC_CTX *ctx, struct group **out, char const *name) CC_HINT(nonnull(2,3));
48 
49 int fr_perm_uid_from_str(TALLOC_CTX *ctx, uid_t *out, char const *name) CC_HINT(nonnull(2,3));
50 
51 int fr_perm_gid_from_str(TALLOC_CTX *ctx, gid_t *out, char const *name) CC_HINT(nonnull(2,3));
52 
53 char *fr_perm_uid_to_str(TALLOC_CTX *ctx, uid_t uid);
54 
55 char *fr_perm_gid_to_str(TALLOC_CTX *ctx, gid_t gid);
56 
57 void fr_perm_file_error(int num);
58 
59 #ifdef __cplusplus
60 }
61 #endif
#define RCSIDH(h, id)
Definition: build.h:482
unsigned int mode_t
Definition: merged_model.c:21
int fr_perm_getpwuid(TALLOC_CTX *ctx, struct passwd **out, uid_t uid))
Resolve a uid to a passwd entry.
Definition: perm.c:75
char * fr_perm_gid_to_str(TALLOC_CTX *ctx, gid_t gid)
int fr_perm_getgrnam(TALLOC_CTX *ctx, struct group **out, char const *name))
Resolve a group name to a group database entry.
Definition: perm.c:264
char const * fr_perm_mode_to_oct(char out[static 5], mode_t mode)
Definition: perm.c:51
char const * fr_perm_mode_to_str(char out[static 10], mode_t mode)
Convert mode_t into humanly readable permissions flags.
Definition: perm.c:36
int fr_perm_uid_from_str(TALLOC_CTX *ctx, uid_t *out, char const *name))
Resolve a user name to a GID.
Definition: perm.c:323
int fr_perm_getgrgid(TALLOC_CTX *ctx, struct group **out, gid_t gid))
Resolve a gid to a group database entry.
Definition: perm.c:201
int fr_perm_gid_from_str(TALLOC_CTX *ctx, gid_t *out, char const *name))
Resolve a group name to a GID.
Definition: perm.c:345
int fr_perm_getpwnam(TALLOC_CTX *ctx, struct passwd **out, char const *name))
Resolve a username to a passwd entry.
Definition: perm.c:138
void fr_perm_file_error(int num)
Write a file access error to the fr_strerror buffer, including euid/egid.
Definition: perm.c:403
char * fr_perm_uid_to_str(TALLOC_CTX *ctx, uid_t uid)
Print uid to a string.
Definition: perm.c:366
static char const * name
int nonnull(2, 5))
static size_t char ** out
Definition: value.h:997