The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
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 */
24RCSIDH(perm_h, "$Id: 474db39bb2153596ba064de75122f3c5155ee3cd $")
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
34extern "C" {
35#endif
36
37char const *fr_perm_mode_to_str(char out[static 10], mode_t mode);
38
39char const *fr_perm_mode_to_oct(char out[static 5], mode_t mode);
40
41int fr_perm_mode_from_str(mode_t *out, char const *str) CC_HINT(nonnull);
42
43int fr_perm_getpwuid(TALLOC_CTX *ctx, struct passwd **out, uid_t uid) CC_HINT(nonnull(2));
44
45int fr_perm_getpwnam(TALLOC_CTX *ctx, struct passwd **out, char const *name) CC_HINT(nonnull(2,3));
46
47int fr_perm_getgrgid(TALLOC_CTX *ctx, struct group **out, gid_t gid) CC_HINT(nonnull(2));
48
49int fr_perm_getgrnam(TALLOC_CTX *ctx, struct group **out, char const *name) CC_HINT(nonnull(2,3));
50
51int fr_perm_uid_from_str(TALLOC_CTX *ctx, uid_t *out, char const *name) CC_HINT(nonnull(2,3));
52
53int fr_perm_gid_from_str(TALLOC_CTX *ctx, gid_t *out, char const *name) CC_HINT(nonnull(2,3));
54
55char *fr_perm_uid_to_str(TALLOC_CTX *ctx, uid_t uid);
56
57char *fr_perm_gid_to_str(TALLOC_CTX *ctx, gid_t gid);
58
59void fr_perm_file_error(int num);
60
61#ifdef __cplusplus
62}
63#endif
#define RCSIDH(h, id)
Definition build.h:484
unsigned int mode_t
int fr_perm_getpwuid(TALLOC_CTX *ctx, struct passwd **out, uid_t uid))
Resolve a uid to a passwd entry.
Definition perm.c:203
char * fr_perm_uid_to_str(TALLOC_CTX *ctx, uid_t uid)
Print uid to a string.
Definition perm.c:494
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
char const * fr_perm_mode_to_oct(char out[static 5], mode_t mode)
Definition perm.c:51
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:392
char * fr_perm_gid_to_str(TALLOC_CTX *ctx, gid_t gid)
int fr_perm_mode_from_str(mode_t *out, char const *str)
Definition perm.c:62
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:451
int fr_perm_getgrgid(TALLOC_CTX *ctx, struct group **out, gid_t gid))
Resolve a gid to a group database entry.
Definition perm.c:329
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:473
int fr_perm_getpwnam(TALLOC_CTX *ctx, struct passwd **out, char const *name))
Resolve a username to a passwd entry.
Definition perm.c:266
void fr_perm_file_error(int num)
Write a file access error to the fr_strerror buffer, including euid/egid.
Definition perm.c:531
static char const * name
int nonnull(2, 5))
static size_t char ** out
Definition value.h:997