Debian Codegraph @

src/lib/profiles/profiles.h

raw symbols SCIP
1 /*
2 Authors:
3 Pavel Březina <[email protected]>
4
5 Copyright (C) 2018 Red Hat
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #ifndef _PROFILES_H_
22 #define _PROFILES_H_
23
24 #include <stdbool.h>
25
26 #include "common/errno_t.h"
27 #include "lib/files/files.h"
28
29 /**
30 * Profile information.
31 */
32 struct authselect_profile {
33 /**
34 * Profile identifier.
35 *
36 * This may not be the same as name of the directory where the profile
37 * is stored. Custom profiles have the directory name prefixed with
38 * "custom" which differentiate them from default and vendor profiles.
39 */
40 char *id;
41
42 /**
43 * Filesystem path to the directory where the profile is located.
44 */
45 char *path;
46
47 char *name;
48 char *description;
49 char *requirements;
50
51 /**
52 * System file templates.
53 */
54 struct authselect_files *files;
55 };
56
57 /**
58 * Activate given profile.
59 *
60 * Write all changes to the system.
61 *
62 * @return EOK on success, EACCES if we can not access some directories,
63 * other errno code on error.
64 */
65 errno_t
66 authselect_profile_activate(struct authselect_profile *profile,
67 const char **features);
68
69 /**
70 * List all profile directories in a sorted NULL-terminated string array.
71 *
72 * This will find all profiles within default, vendor and custom profile
73 * directories.
74 *
75 * @param _profiles NULL-terminated sorted string array.
76 *
77 * @return EOK on success, other errno code on failure.
78 */
79 errno_t
80 authselect_profile_list(char ***_profiles);
81
82 /**
83 * Read profile information.
84 *
85 * @param profile_id Profile ID to search for.
86 * @param type Profile type.
87 * @param _profile Profile information.
88 *
89 * @return EOK on success, ENOENT if the profile was not found, other errno
90 * code on error.
91 */
92 errno_t
93 authselect_profile_read(const char *profile_id,
94 enum authselect_profile_type type,
95 struct authselect_profile **_profile);
96
97 /**
98 * Create custom profile id from a directory name.
99 *
100 * @param name Profile directory name.
101 *
102 * @return Custom profile id or NULL if allocation fails.
103 */
104 char *
105 authselect_profile_custom_id(const char *name);
106
107 /**
108 * Return directory name of a custom profile.
109 *
110 * @param profile_id Profile id.
111 *
112 * @return Directory name of the profile, NULL if it is not a custom profile.
113 */
114 const char *
115 authselect_profile_parse_custom(const char *profile_id);
116
117 /**
118 * @return True if @profile_id is a custom profile, false otherwise.
119 */
120 bool
121 authselect_profile_is_custom(const char *profile_id);
122
123 /**
124 * Tell dconf to read updated files.
125 *
126 * @return EOK on success, other errno code on error.
127 */
128 errno_t
129 authselect_profile_dconf_update(void);
130
131 #endif /* _PROFILES_H_ */