Debian Codegraph @

src/cli/main.c

raw symbols SCIP
1 /*
2 Authors:
3 Pavel Březina <[email protected]>
4
5 Copyright (C) 2017 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 #include "config.h"cxx . . $ `<file>/config.h`/
22
23 #include <time.h>
24 #include <errno.h>
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <locale.h>
29 #include <sys/stat.h>
30
31 #include "authselect.h"cxx . . $ `<file>/include/authselect.h`/
32 #include "common/common.h"cxx . . $ `<file>/src/common/common.h`/
33 #include "lib/util/string_array.h"cxx . . $ `<file>/src/lib/util/string_array.h`/
34 #include "cli/cli_tool.h"cxx . . $ `<file>/src/cli/cli_tool.h`/
35 #include "cli/presets.h"cxx . . $ `<file>/src/cli/presets.h`/
36
37 #define CLI_ERRORcxx . . $ `src/cli/main.c:37:9`!(msg, ...) fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, gettextcxx . . $ `<external>/9900141763895812947/libintl.h:109:10`!(msg), ## __VA_ARGS__)
38
39 #define CLI_PRINTcxx . . $ `src/cli/main.c:39:9`!(msg, ...) printf(gettextcxx . . $ `<external>/9900141763895812947/libintl.h:109:10`!(msg), ## __VA_ARGS__)
40 #define CLI_MSGcxx . . $ `src/cli/main.c:40:9`!(quiet, msg, ...) do { \
41 if (!quiet) { \
42 CLI_PRINTcxx . . $ `src/cli/main.c:39:9`!((msg), ## __VA_ARGS__); \
43 } \
44 } while (0)
45
46 static size_tcxx . . $ size_t#
47 list_max_lengthcxx . . $ list_max_length(44350d944485fca).(char **list)
48 {
49 size_tcxx . . $ size_t# max = 0;
50 size_tcxx . . $ size_t# len;
51 int i;
52
53 for (i = 0; list[i] != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; i++) {
54 len = strlencxx . . $ strlen(751346f8406fd082).(list[i]);
55 if (max < len) {
56 max = len;
57 }
58 }
59
60 return max;
61 }
62
63 static errno_tcxx . . $ errno_t#
64 parse_profile_optionscxx . . $ parse_profile_options(fe2371ca2d64bbde).(struct cli_cmdlinecxx . . $ cli_cmdline# *cmdline,
65 struct poptOptioncxx . . $ poptOption# *options,
66 char **_profile_id,
67 char ***_features)
68 {
69 char *profile_id;
70 char *preset_profile_id;
71 char **features;
72 char **merged_features;
73 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! profile_skipped;
74 errno_tcxx . . $ errno_t# ret;
75 int i;
76
77 *_profile_id = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
78
79 ret = cli_tool_popt_excxx . . $ cli_tool_popt_ex(6e0400684c960c82).(cmdline, options, CLI_TOOL_OPT_OPTIONALcxx . . $ CLI_TOOL_OPT_OPTIONAL.,
80 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, "PROFILE-ID", _cxx . . $ `src/common/common.h:33:9`!("Profile identifier."),
81 &profile_id, truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
82 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
83 ERRORcxx . . $ `src/common/common.h:71:9`!("Unable to parse command arguments");
84 return ret;
85 }
86
87 features = string_array_createcxx . . $ string_array_create(4d3fbc76ec7ad0ba).(0);
88 if (features == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) {
89 ERRORcxx . . $ `src/common/common.h:71:9`!("Unable to create string array");
90 return ENOMEMcxx . . $ `<external>/8987895939074593727/errno-base.h:16:9`!;
91 }
92
93 profile_skipped = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
94 for (i = 0; i < cmdline->argccxx . . $ cli_cmdline#argc.; i++) {
95 /* Skip options. */
96 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(cmdline->argvcxx . . $ cli_cmdline#argv.[i], "--backup") == 0) {
97 /* Skip also the next parameter which is the backup name. */
98 i++;
99 continue;
100 }
101
102 if (cmdline->argvcxx . . $ cli_cmdline#argv.[i][0] == '-') {
103 continue;
104 }
105
106 /* First free option is profile name. We must skip it. For example:
107 * authselect select sssd with-feature --force
108 * authselect select --force sssd with-feature
109 */
110 if (!profile_skipped) {
111 profile_skipped = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
112 continue;
113 }
114
115 features = string_array_add_valuecxx . . $ string_array_add_value(db56f6d53b8c0a98).(features, cmdline->argvcxx . . $ cli_cmdline#argv.[i], truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!);
116 if (features == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) {
117 ret = ENOMEMcxx . . $ `<external>/8987895939074593727/errno-base.h:16:9`!;
118 goto done;
119 }
120 }
121
122 /* Resolve preset if needed */
123 if (cli_preset_is_presetcxx . . $ cli_preset_is_preset(c5f7da30cbc0f4e9).(profile_id)) {
124 ret = cli_preset_resolvecxx . . $ cli_preset_resolve(c8377c9f8d72bd4b).(profile_id, (const char **)features,
125 &preset_profile_id, &merged_features);
126 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
127 goto done;
128 }
129
130 freecxx . . $ free(5d22bdacc48458e8).(profile_id);
131 string_array_freecxx . . $ string_array_free(3ed91490e421178f).(features);
132
133 profile_id = preset_profile_id;
134 features = merged_features;
135 }
136
137 *_profile_id = profile_id;
138 *_features = features;
139
140 ret = EOKcxx . . $ `src/common/errno_t.h:34:9`!;
141
142 done:
143 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
144 freecxx . . $ free(5d22bdacc48458e8).(profile_id);
145 string_array_freecxx . . $ string_array_free(3ed91490e421178f).(features);
146 }
147
148 return ret;
149 }
150
151 static errno_tcxx . . $ errno_t#
152 perform_backupcxx . . $ perform_backup(704025c2f01734e3).(int quiet,
153 int backup,
154 const char *backup_name)
155 {
156 char *backup_path;
157 errno_tcxx . . $ errno_t# ret;
158
159 if (!backup && backup_name == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) {
160 return EOKcxx . . $ `src/common/errno_t.h:34:9`!;
161 }
162
163 ret = authselect_backupcxx . . $ authselect_backup(c4dada3283861623).(backup_name, &backup_path);
164 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
165 CLI_ERRORcxx . . $ `src/cli/main.c:37:9`!("Unable to backup current configuration!\n");
166 return ret;
167 }
168
169 CLI_MSGcxx . . $ `src/cli/main.c:40:9`!(quiet, "Backup stored at %s\n", backup_path);
170 freecxx . . $ free(5d22bdacc48458e8).(backup_path);
171
172 return EOKcxx . . $ `src/common/errno_t.h:34:9`!;
173 }
174
175 static errno_tcxx . . $ errno_t# activatecxx . . $ activate(b6d55c42bf71c8b5).(struct cli_cmdlinecxx . . $ cli_cmdline# *cmdline)
176 {
177 struct authselect_profilecxx . . $ authselect_profile# *profile = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
178 char **features = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
179 char *profile_id = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
180 char *requirements = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
181 char *backup_name = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
182 char **maps = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
183 int backup = 0;
184 int nobackup = 0;
185 int enforce = 0;
186 int quiet = 0;
187 errno_tcxx . . $ errno_t# ret;
188 int i;
189
190 struct poptOptioncxx . . $ poptOption# options[] = {
191 {"force", 'f', POPT_ARG_VALcxx . . $ `<external>/16232926639102580118/popt.h:31:9`!, &enforce, 1, _cxx . . $ `src/common/common.h:33:9`!("Enforce changes"), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! },
192 {NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, 'b', POPT_ARG_VALcxx . . $ `<external>/16232926639102580118/popt.h:31:9`!, &backup, 1, _cxx . . $ `src/common/common.h:33:9`!("Backup system files before activating profile (generate unique name)"), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! },
193 {"backup", '\0', POPT_ARG_STRINGcxx . . $ `<external>/16232926639102580118/popt.h:19:9`! | POPT_ARG_NONEcxx . . $ `<external>/16232926639102580118/popt.h:18:9`!, &backup_name, 0, _cxx . . $ `src/common/common.h:33:9`!("Backup system files before activating profile"), _cxx . . $ `src/common/common.h:33:9`!("NAME") },
194 {"nobackup", '\0', POPT_ARG_VALcxx . . $ `<external>/16232926639102580118/popt.h:31:9`!, &nobackup, 1, _cxx . . $ `src/common/common.h:33:9`!("Do not backup system files when --force is set"), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! },
195 {"quiet", 'q', POPT_ARG_VALcxx . . $ `<external>/16232926639102580118/popt.h:31:9`!, &quiet, 1, _cxx . . $ `src/common/common.h:33:9`!("Do not print profile requirements"), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! },
196 POPT_TABLEENDcxx . . $ `<external>/16232926639102580118/popt.h:161:9`!
197 };
198
199 ret = parse_profile_optionscxx . . $ parse_profile_options(fe2371ca2d64bbde).(cmdline, options, &profile_id, &features);
200 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
201 goto done;
202 }
203
204 ret = authselect_profilecxx . . $ authselect_profile(9cd096d22a496993).(profile_id, &profile);
205 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
206 ERRORcxx . . $ `src/common/common.h:71:9`!("Unable to get profile information [%d]: %s",
207 ret, strerror(ret));
208 ret = ENOMEMcxx . . $ `<external>/8987895939074593727/errno-base.h:16:9`!;
209 goto done;
210 }
211
212 requirements = authselect_profile_requirementscxx . . $ authselect_profile_requirements(e64a63f0b99072ff).(profile, (const char **)features);
213 if (requirements == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) {
214 ERRORcxx . . $ `src/common/common.h:71:9`!("Unable to read profile requirements!");
215 ret = EFAULTcxx . . $ `<external>/8987895939074593727/errno-base.h:18:9`!;
216 goto done;
217 }
218
219 if (backup || backup_name != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! || (enforce && !nobackup)) {
220 ret = perform_backupcxx . . $ perform_backup(704025c2f01734e3).(quiet, 1, backup_name);
221 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
222 goto done;
223 }
224 }
225
226 ret = authselect_activatecxx . . $ authselect_activate(ee6f66a11326c070).(profile_id, (const char **)features, enforce);
227 if (ret == EEXISTcxx . . $ `<external>/8987895939074593727/errno-base.h:21:9`!) {
228 CLI_ERRORcxx . . $ `src/cli/main.c:37:9`!("\nSome unexpected changes to the configuration were "
229 "detected.\nUse --force parameter if you want to overwrite "
230 "these changes.\n");
231 goto done;
232 } else if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
233 CLI_ERRORcxx . . $ `src/cli/main.c:37:9`!("Unable to activate profile [%d]: %s\n",
234 ret, strerror(ret));
235 goto done;
236 }
237
238 CLI_MSGcxx . . $ `src/cli/main.c:40:9`!(quiet, "Profile \"%s\" was selected.\n", profile_id);
239
240 if (maps != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! && maps[0] != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) {
241 CLI_MSGcxx . . $ `src/cli/main.c:40:9`!(quiet, "The following nsswitch maps are overwritten "
242 "by the profile:\n");
243 for (i = 0; maps[i] != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; i++) {
244 CLI_MSGcxx . . $ `src/cli/main.c:40:9`!(quiet, "- %s\n", maps[i]);
245 }
246 }
247
248 if (requirements[0] != '\0') {
249 CLI_MSGcxx . . $ `src/cli/main.c:40:9`!(quiet, "\n%s\n", requirements);
250 }
251
252 ret = EOKcxx . . $ `src/common/errno_t.h:34:9`!;
253
254 done:
255 freecxx . . $ free(5d22bdacc48458e8).(requirements);
256 authselect_array_freecxx . . $ authselect_array_free(3ed91490e421178f).(maps);
257 authselect_profile_freecxx . . $ authselect_profile_free(56572ca77072da15).(profile);
258 authselect_array_freecxx . . $ authselect_array_free(3ed91490e421178f).((char **)features);
259 freecxx . . $ free(5d22bdacc48458e8).(profile_id);
260
261 return ret;
262 }
263
264 static errno_tcxx . . $ errno_t# apply_changescxx . . $ apply_changes(b6d55c42bf71c8b5).(struct cli_cmdlinecxx . . $ cli_cmdline# *cmdline)
265 {
266 char *backup_name = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
267 int backup = 0;
268 int upgrade = 0;
269 errno_tcxx . . $ errno_t# ret;
270
271 struct poptOptioncxx . . $ poptOption# options[] = {
272 {"upgrade", '\0', POPT_ARG_VALcxx . . $ `<external>/16232926639102580118/popt.h:31:9`!, &upgrade, 1, _cxx . . $ `src/common/common.h:33:9`!("Only apply changes if installed profiles have changed"), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! },
273 {NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, 'b', POPT_ARG_VALcxx . . $ `<external>/16232926639102580118/popt.h:31:9`!, &backup, 1, _cxx . . $ `src/common/common.h:33:9`!("Backup system files before activating profile (generate unique name)"), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! },
274 {"backup", '\0', POPT_ARG_STRINGcxx . . $ `<external>/16232926639102580118/popt.h:19:9`! | POPT_ARG_NONEcxx . . $ `<external>/16232926639102580118/popt.h:18:9`!, &backup_name, 0, _cxx . . $ `src/common/common.h:33:9`!("Backup system files before activating profile"), _cxx . . $ `src/common/common.h:33:9`!("NAME") },
275 POPT_TABLEENDcxx . . $ `<external>/16232926639102580118/popt.h:161:9`!
276 };
277
278 ret = cli_tool_poptcxx . . $ cli_tool_popt(56747616750755be).(cmdline, options, CLI_TOOL_OPT_OPTIONALcxx . . $ CLI_TOOL_OPT_OPTIONAL., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
279 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
280 ERRORcxx . . $ `src/common/common.h:71:9`!("Unable to parse command arguments");
281 return ret;
282 }
283
284 ret = perform_backupcxx . . $ perform_backup(704025c2f01734e3).(falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!, backup, backup_name);
285 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
286 return ret;
287 }
288
289 ret = authselect_apply_changescxx . . $ authselect_apply_changes(73da94e76e6bd037).(upgrade);
290 switch (ret) {
291 case EOKcxx . . $ `src/common/errno_t.h:34:9`!:
292 CLI_PRINTcxx . . $ `src/cli/main.c:39:9`!("Changes were successfully applied.\n");
293 break;
294 case EAGAINcxx . . $ `<external>/8987895939074593727/errno-base.h:15:9`!:
295 CLI_PRINTcxx . . $ `src/cli/main.c:39:9`!("Installed profiles did not change. No action is needed.\n");
296 ret = EOKcxx . . $ `src/common/errno_t.h:34:9`!;
297 break;
298 case ENOENTcxx . . $ `<external>/8987895939074593727/errno-base.h:6:9`!:
299 CLI_ERRORcxx . . $ `src/cli/main.c:37:9`!("No existing configuration detected.\n");
300 break;
301 case EEXISTcxx . . $ `<external>/8987895939074593727/errno-base.h:21:9`!:
302 CLI_ERRORcxx . . $ `src/cli/main.c:37:9`!("Some unexpected changes to the configuration were "
303 "detected. Use 'select' command instead.\n");
304 break;
305 default:
306 CLI_ERRORcxx . . $ `src/cli/main.c:37:9`!("Unable to apply changes [%d]: %s\n", ret, strerror(ret));
307 break;
308 }
309
310 return ret;
311 }
312
313 static errno_tcxx . . $ errno_t# currentcxx . . $ current(b6d55c42bf71c8b5).(struct cli_cmdlinecxx . . $ cli_cmdline# *cmdline)
314 {
315 int raw_output = 0;
316 char *profile_id;
317 char **features;
318 errno_tcxx . . $ errno_t# ret;
319 int i;
320
321 struct poptOptioncxx . . $ poptOption# options[] = {
322 {"raw", 'r', POPT_ARG_VALcxx . . $ `<external>/16232926639102580118/popt.h:31:9`!, &raw_output, 1,
323 _cxx . . $ `src/common/common.h:33:9`!("Print command parameters instead of formatted output"), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! },
324 POPT_TABLEENDcxx . . $ `<external>/16232926639102580118/popt.h:161:9`!
325 };
326
327 ret = cli_tool_poptcxx . . $ cli_tool_popt(56747616750755be).(cmdline, options, CLI_TOOL_OPT_OPTIONALcxx . . $ CLI_TOOL_OPT_OPTIONAL., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
328 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
329 ERRORcxx . . $ `src/common/common.h:71:9`!("Unable to parse command arguments");
330 return ret;
331 }
332
333 ret = authselect_current_configurationcxx . . $ authselect_current_configuration(2bdaab245118da41).(&profile_id, &features);
334 if (ret == ENOENTcxx . . $ `<external>/8987895939074593727/errno-base.h:6:9`!) {
335 CLI_PRINTcxx . . $ `src/cli/main.c:39:9`!("No existing configuration detected.\n");
336 return ret;
337 } else if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
338 ERRORcxx . . $ `src/common/common.h:71:9`!("Unable to get current configuration [%d]: %s",
339 ret, strerror(ret));
340 return ret;
341 }
342
343 if (raw_output) {
344 printfcxx . . $ printf(581fddd72a8db8fc).("%s", profile_id);
345 if (features != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) {
346 for (i = 0; features[i] != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; i++) {
347 printfcxx . . $ printf(581fddd72a8db8fc).(" %s", features[i]);
348 }
349 }
350 printfcxx . . $ printf(581fddd72a8db8fc).("\n");
351 } else {
352 CLI_PRINTcxx . . $ `src/cli/main.c:39:9`!("Profile ID: %s\n", profile_id);
353 CLI_PRINTcxx . . $ `src/cli/main.c:39:9`!("Enabled features:");
354
355 if (features == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! || features[0] == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) {
356 CLI_PRINTcxx . . $ `src/cli/main.c:39:9`!(" None\n");
357 } else {
358 printfcxx . . $ printf(581fddd72a8db8fc).("\n");
359 for (i = 0; features[i] != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; i++) {
360 printfcxx . . $ printf(581fddd72a8db8fc).("- %s\n", features[i]);
361 }
362 }
363 }
364
365 freecxx . . $ free(5d22bdacc48458e8).(profile_id);
366 authselect_array_freecxx . . $ authselect_array_free(3ed91490e421178f).(features);
367
368 return EOKcxx . . $ `src/common/errno_t.h:34:9`!;
369 }
370
371 static errno_tcxx . . $ errno_t# checkcxx . . $ check(b6d55c42bf71c8b5).(struct cli_cmdlinecxx . . $ cli_cmdline# *cmdline)
372 {
373 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! is_valid;
374 errno_tcxx . . $ errno_t# ret;
375
376 ret = cli_tool_poptcxx . . $ cli_tool_popt(56747616750755be).(cmdline, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, CLI_TOOL_OPT_OPTIONALcxx . . $ CLI_TOOL_OPT_OPTIONAL., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
377 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
378 ERRORcxx . . $ `src/common/common.h:71:9`!("Unable to parse command arguments");
379 return ret;
380 }
381
382 ret = authselect_validate_configurationcxx . . $ authselect_validate_configuration(4de84dfa0cae09e5).(&is_valid);
383 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`! && ret != ENOENTcxx . . $ `<external>/8987895939074593727/errno-base.h:6:9`! && ret != EEXISTcxx . . $ `<external>/8987895939074593727/errno-base.h:21:9`!) {
384 ERRORcxx . . $ `src/common/common.h:71:9`!("Unable to test current configuration [%d]: %s",
385 ret, strerror(ret));
386
387 return ret;
388 }
389
390 if (!is_valid) {
391 putscxx . . $ puts(5c4306d8553b3696).(_cxx . . $ `src/common/common.h:33:9`!("Current configuration is not valid. "
392 "It was probably modified outside authselect."));
393 return EBADFcxx . . $ `<external>/8987895939074593727/errno-base.h:13:9`!;
394 }
395
396 switch (ret) {
397 case EOKcxx . . $ `src/common/errno_t.h:34:9`!:
398 putscxx . . $ puts(5c4306d8553b3696).(_cxx . . $ `src/common/common.h:33:9`!("Current authselect configuration is valid."));
399 break;
400 case ENOENTcxx . . $ `<external>/8987895939074593727/errno-base.h:6:9`!:
401 putscxx . . $ puts(5c4306d8553b3696).(_cxx . . $ `src/common/common.h:33:9`!("No configuration detected."));
402 ret = ENODEVcxx . . $ `<external>/8987895939074593727/errno-base.h:23:9`!;
403 break;
404 case EEXISTcxx . . $ `<external>/8987895939074593727/errno-base.h:21:9`!:
405 putscxx . . $ puts(5c4306d8553b3696).(_cxx . . $ `src/common/common.h:33:9`!("System was not configured with authselect."));
406 ret = ENOENTcxx . . $ `<external>/8987895939074593727/errno-base.h:6:9`!; /* for backwards compatibility */
407 break;
408 }
409
410 /* EOK = existing configuration is valid,
411 * ENODEV = no configuration detected,
412 * ENOENT = non-authselet configuration is valid */
413 return ret;
414 }
415
416 static errno_tcxx . . $ errno_t# listcxx . . $ list(b6d55c42bf71c8b5).(struct cli_cmdlinecxx . . $ cli_cmdline# *cmdline)
417 {
418 struct authselect_profilecxx . . $ authselect_profile# *profile;
419 char **profiles;
420 errno_tcxx . . $ errno_t# ret;
421 int preset_maxlen;
422 int maxlen;
423 int i;
424
425 ret = cli_tool_poptcxx . . $ cli_tool_popt(56747616750755be).(cmdline, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, CLI_TOOL_OPT_OPTIONALcxx . . $ CLI_TOOL_OPT_OPTIONAL., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
426 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
427 ERRORcxx . . $ `src/common/common.h:71:9`!("Unable to parse command arguments");
428 return ret;
429 }
430
431 profiles = authselect_listcxx . . $ authselect_list(6aacb5881005f5e4).();
432 if (profiles == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) {
433 ERRORcxx . . $ `src/common/common.h:71:9`!("Unable to get profile list!");
434 return ENOMEMcxx . . $ `<external>/8987895939074593727/errno-base.h:16:9`!;
435 }
436
437 maxlen = list_max_lengthcxx . . $ list_max_length(44350d944485fca).(profiles);
438
439 /* Use larger of profile names or preset names for alignment */
440 preset_maxlen = cli_preset_max_name_lengthcxx . . $ cli_preset_max_name_length(b126dc7c1de90089).();
441 if (preset_maxlen > maxlen) {
442 maxlen = preset_maxlen;
443 }
444
445 for (i = 0; profiles[i] != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; i++) {
446 ret = authselect_profilecxx . . $ authselect_profile(9cd096d22a496993).(profiles[i], &profile);
447 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
448 ERRORcxx . . $ `src/common/common.h:71:9`!("Unable to get profile information [%d]: %s",
449 ret, strerror(ret));
450 goto done;
451 }
452
453 printfcxx . . $ printf(581fddd72a8db8fc).("- %-*s\t %s\n", maxlen, profiles[i],
454 authselect_profile_namecxx . . $ authselect_profile_name(96f23b929ece55c2).(profile));
455
456 authselect_profile_freecxx . . $ authselect_profile_free(56572ca77072da15).(profile);
457 }
458
459 /* Show presets section */
460 struct cli_presetcxx . . $ cli_preset# *preset_list = cli_preset_listcxx . . $ cli_preset_list(923eb9540c629223).();
461
462 if (preset_list != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! && preset_list[0].namecxx . . $ cli_preset#name. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) {
463 printfcxx . . $ printf(581fddd72a8db8fc).("\nPresets:\n");
464
465 for (i = 0; preset_list[i].namecxx . . $ cli_preset#name. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; i++) {
466 printfcxx . . $ printf(581fddd72a8db8fc).("- %-*s\t %s\n", maxlen, preset_list[i].namecxx . . $ cli_preset#name.,
467 preset_list[i].descriptioncxx . . $ cli_preset#description.);
468 }
469 }
470
471 cli_preset_list_freecxx . . $ cli_preset_list_free(8ed6e3eef1294f83).(preset_list);
472
473 ret = EOKcxx . . $ `src/common/errno_t.h:34:9`!;
474
475 done:
476 authselect_array_freecxx . . $ authselect_array_free(3ed91490e421178f).(profiles);
477 return ret;
478 }
479
480 static errno_tcxx . . $ errno_t# list_featurescxx . . $ list_features(b6d55c42bf71c8b5).(struct cli_cmdlinecxx . . $ cli_cmdline# *cmdline)
481 {
482 struct authselect_profilecxx . . $ authselect_profile# *profile;
483 char *profile_id;
484 char **features;
485 errno_tcxx . . $ errno_t# ret;
486 int i;
487
488 ret = cli_tool_popt_excxx . . $ cli_tool_popt_ex(6e0400684c960c82).(cmdline, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, CLI_TOOL_OPT_OPTIONALcxx . . $ CLI_TOOL_OPT_OPTIONAL.,
489 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, "PROFILE-ID", _cxx . . $ `src/common/common.h:33:9`!("Profile identifier."),
490 &profile_id, truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
491 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
492 ERRORcxx . . $ `src/common/common.h:71:9`!("Unable to parse command arguments");
493 goto done;
494 }
495
496 /* Resolve preset */
497 if (cli_preset_is_presetcxx . . $ cli_preset_is_preset(c5f7da30cbc0f4e9).(profile_id)) {
498 char *resolved_id;
499 ret = cli_preset_resolvecxx . . $ cli_preset_resolve(c8377c9f8d72bd4b).(profile_id, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, &resolved_id, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
500 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
501 goto done;
502 }
503 freecxx . . $ free(5d22bdacc48458e8).(profile_id);
504 profile_id = resolved_id;
505 }
506
507 ret = authselect_profilecxx . . $ authselect_profile(9cd096d22a496993).(profile_id, &profile);
508 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
509 ERRORcxx . . $ `src/common/common.h:71:9`!("Unable to get profile information [%d]: %s",
510 ret, strerror(ret));
511 goto done;
512 }
513
514 features = authselect_profile_featurescxx . . $ authselect_profile_features(99e33f263369bfd1).(profile);
515 authselect_profile_freecxx . . $ authselect_profile_free(56572ca77072da15).(profile);
516 if (features == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) {
517 ERRORcxx . . $ `src/common/common.h:71:9`!("Unable to get profile features [%d]: %s",
518 ret, strerror(ret));
519 ret = ENOMEMcxx . . $ `<external>/8987895939074593727/errno-base.h:16:9`!;
520 goto done;
521 }
522
523 for (i = 0; features[i] != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; i++) {
524 putscxx . . $ puts(5c4306d8553b3696).(features[i]);
525 }
526
527 authselect_array_freecxx . . $ authselect_array_free(3ed91490e421178f).(features);
528
529 ret = EOKcxx . . $ `src/common/errno_t.h:34:9`!;
530
531 done:
532 freecxx . . $ free(5d22bdacc48458e8).(profile_id);
533 return ret;
534 }
535
536 static errno_tcxx . . $ errno_t# showcxx . . $ show(b6d55c42bf71c8b5).(struct cli_cmdlinecxx . . $ cli_cmdline# *cmdline)
537 {
538 struct authselect_profilecxx . . $ authselect_profile# *profile;
539 char *profile_id;
540 errno_tcxx . . $ errno_t# ret;
541 int i;
542
543 ret = cli_tool_popt_excxx . . $ cli_tool_popt_ex(6e0400684c960c82).(cmdline, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, CLI_TOOL_OPT_OPTIONALcxx . . $ CLI_TOOL_OPT_OPTIONAL.,
544 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, "PROFILE-ID", _cxx . . $ `src/common/common.h:33:9`!("Profile identifier."),
545 &profile_id, falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
546 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
547 ERRORcxx . . $ `src/common/common.h:71:9`!("Unable to parse command arguments");
548 goto done;
549 }
550
551 /* Handle presets */
552 if (cli_preset_is_presetcxx . . $ cli_preset_is_preset(c5f7da30cbc0f4e9).(profile_id)) {
553 const struct cli_presetcxx . . $ cli_preset# *preset = cli_preset_findcxx . . $ cli_preset_find(2fcd4ad798ac1b8c).(profile_id);
554 char *resolved_profile_id;
555 char **resolved_features;
556
557 ret = cli_preset_resolvecxx . . $ cli_preset_resolve(c8377c9f8d72bd4b).(profile_id, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, &resolved_profile_id,
558 &resolved_features);
559 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
560 goto done;
561 }
562
563 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `src/common/common.h:33:9`!("Preset: %s\n"), preset->namecxx . . $ cli_preset#name.);
564 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `src/common/common.h:33:9`!("Description: %s\n"), preset->descriptioncxx . . $ cli_preset#description.);
565 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `src/common/common.h:33:9`!("Source: %s\n\n"), preset->config_pathcxx . . $ cli_preset#config_path.);
566 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `src/common/common.h:33:9`!("Resolves to:\n"));
567 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `src/common/common.h:33:9`!(" Profile: %s\n"), resolved_profile_id);
568
569 if (resolved_features != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! && resolved_features[0] != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) {
570 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `src/common/common.h:33:9`!(" Features:\n"));
571 for (i = 0; resolved_features[i] != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; i++) {
572 printfcxx . . $ printf(581fddd72a8db8fc).(" - %s\n", resolved_features[i]);
573 }
574 } else {
575 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `src/common/common.h:33:9`!(" Features: None\n"));
576 }
577
578 freecxx . . $ free(5d22bdacc48458e8).(resolved_profile_id);
579 authselect_array_freecxx . . $ authselect_array_free(3ed91490e421178f).(resolved_features);
580 freecxx . . $ free(5d22bdacc48458e8).(profile_id);
581 return EOKcxx . . $ `src/common/errno_t.h:34:9`!;
582 }
583
584 ret = authselect_profilecxx . . $ authselect_profile(9cd096d22a496993).(profile_id, &profile);
585 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
586 ERRORcxx . . $ `src/common/common.h:71:9`!("Unable to get profile information [%d]: %s",
587 ret, strerror(ret));
588 ret = ENOMEMcxx . . $ `<external>/8987895939074593727/errno-base.h:16:9`!;
589 goto done;
590 }
591
592 putscxx . . $ puts(5c4306d8553b3696).(authselect_profile_descriptioncxx . . $ authselect_profile_description(96f23b929ece55c2).(profile));
593
594 authselect_profile_freecxx . . $ authselect_profile_free(56572ca77072da15).(profile);
595
596 ret = EOKcxx . . $ `src/common/errno_t.h:34:9`!;
597
598 done:
599 freecxx . . $ free(5d22bdacc48458e8).(profile_id);
600 return ret;
601 }
602
603 static errno_tcxx . . $ errno_t# requirementscxx . . $ requirements(b6d55c42bf71c8b5).(struct cli_cmdlinecxx . . $ cli_cmdline# *cmdline)
604 {
605 struct authselect_profilecxx . . $ authselect_profile# *profile = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
606 char *profile_id = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
607 char **features;
608 char *requirements = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
609 errno_tcxx . . $ errno_t# ret;
610
611 ret = parse_profile_optionscxx . . $ parse_profile_options(fe2371ca2d64bbde).(cmdline, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, &profile_id, &features);
612 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
613 goto done;
614 }
615
616 ret = authselect_profilecxx . . $ authselect_profile(9cd096d22a496993).(profile_id, &profile);
617 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
618 ERRORcxx . . $ `src/common/common.h:71:9`!("Unable to get profile information [%d]: %s",
619 ret, strerror(ret));
620 ret = ENOMEMcxx . . $ `<external>/8987895939074593727/errno-base.h:16:9`!;
621 goto done;
622 }
623
624 requirements = authselect_profile_requirementscxx . . $ authselect_profile_requirements(e64a63f0b99072ff).(profile, (const char **)features);
625 if (requirements == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) {
626 ERRORcxx . . $ `src/common/common.h:71:9`!("Unable to read profile requirements!");
627 ret = EFAULTcxx . . $ `<external>/8987895939074593727/errno-base.h:18:9`!;
628 goto done;
629 } else if (requirements[0] == '\0') {
630 putscxx . . $ puts(5c4306d8553b3696).("No requirements are specified.");
631 } else {
632 putscxx . . $ puts(5c4306d8553b3696).(requirements);
633 }
634
635 ret = EOKcxx . . $ `src/common/errno_t.h:34:9`!;
636
637 done:
638 freecxx . . $ free(5d22bdacc48458e8).(requirements);
639 authselect_array_freecxx . . $ authselect_array_free(3ed91490e421178f).((char **)features);
640 freecxx . . $ free(5d22bdacc48458e8).(profile_id);
641 authselect_profile_freecxx . . $ authselect_profile_free(56572ca77072da15).(profile);
642
643 return ret;
644 }
645
646 static errno_tcxx . . $ errno_t# testcxx . . $ test(b6d55c42bf71c8b5).(struct cli_cmdlinecxx . . $ cli_cmdline# *cmdline)
647 {
648 struct authselect_filescxx . . $ authselect_files# *files;
649 char *profile_id = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
650 char **features;
651 const char *content;
652 const char *path;
653 int print_all = 1;
654 int print_nsswitch = 0;
655 int print_systemauth = 0;
656 int print_passwordauth = 0;
657 int print_smartcardauth = 0;
658 int print_fingerprintauth = 0;
659 int print_switchableauth = 0;
660 int print_postlogin = 0;
661 int print_dconfdb = 0;
662 int print_dconflock = 0;
663 errno_tcxx . . $ errno_t# ret;
664 int i;
665
666 struct poptOptioncxx . . $ poptOption# options[] = {
667 {"all", 'a', POPT_ARG_VALcxx . . $ `<external>/16232926639102580118/popt.h:31:9`!, &print_all, 1, _cxx . . $ `src/common/common.h:33:9`!("Print content of all files"), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! },
668 {"nsswitch", 'n', POPT_ARG_VALcxx . . $ `<external>/16232926639102580118/popt.h:31:9`!, &print_nsswitch, 1, _cxx . . $ `src/common/common.h:33:9`!("Print nsswitch.conf content"), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! },
669 {"system-auth", 's', POPT_ARG_VALcxx . . $ `<external>/16232926639102580118/popt.h:31:9`!, &print_systemauth, 1, _cxx . . $ `src/common/common.h:33:9`!("Print system-auth content"), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! },
670 {"password-auth", 'p', POPT_ARG_VALcxx . . $ `<external>/16232926639102580118/popt.h:31:9`!, &print_passwordauth, 1, _cxx . . $ `src/common/common.h:33:9`!("Print password-auth content"), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! },
671 {"smartcard-auth", 'c', POPT_ARG_VALcxx . . $ `<external>/16232926639102580118/popt.h:31:9`!, &print_smartcardauth, 1, _cxx . . $ `src/common/common.h:33:9`!("Print smartcard-auth content"), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! },
672 {"fingerprint-auth", 'f', POPT_ARG_VALcxx . . $ `<external>/16232926639102580118/popt.h:31:9`!, &print_fingerprintauth, 1, _cxx . . $ `src/common/common.h:33:9`!("Print fingerprint-auth content"), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! },
673 {"switchable-auth", 'w', POPT_ARG_VALcxx . . $ `<external>/16232926639102580118/popt.h:31:9`!, &print_switchableauth, 1, _cxx . . $ `src/common/common.h:33:9`!("Print switchable-auth content"), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! },
674 {"postlogin", 'o', POPT_ARG_VALcxx . . $ `<external>/16232926639102580118/popt.h:31:9`!, &print_postlogin, 1, _cxx . . $ `src/common/common.h:33:9`!("Print postlogin content"), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! },
675 {"dconf-db", 'd', POPT_ARG_VALcxx . . $ `<external>/16232926639102580118/popt.h:31:9`!, &print_dconfdb, 1, _cxx . . $ `src/common/common.h:33:9`!("Print dconf database content"), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! },
676 {"dconf-lock", 'l', POPT_ARG_VALcxx . . $ `<external>/16232926639102580118/popt.h:31:9`!, &print_dconflock, 1, _cxx . . $ `src/common/common.h:33:9`!("Print dconf lock content"), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! },
677 POPT_TABLEENDcxx . . $ `<external>/16232926639102580118/popt.h:161:9`!
678 };
679
680 structcxx . . $ test(b6d55c42bf71c8b5).$anonymous_type_0# {
681 const char * (*content_fncxx . . $ test(b6d55c42bf71c8b5).$anonymous_type_0#content_fn.)(const struct authselect_filescxx . . $ authselect_files# *);
682 const char * (*path_fncxx . . $ test(b6d55c42bf71c8b5).$anonymous_type_0#path_fn.)(void);
683 int *enabledcxx . . $ test(b6d55c42bf71c8b5).$anonymous_type_0#enabled.;
684 } generated[] = {
685 {authselect_files_nsswitchcxx . . $ authselect_files_nsswitch(5d1c3e03439491a3)., authselect_path_nsswitchcxx . . $ authselect_path_nsswitch(87c6ae427bbae0f6)., &print_nsswitch},
686 {authselect_files_systemauthcxx . . $ authselect_files_systemauth(5d1c3e03439491a3)., authselect_path_systemauthcxx . . $ authselect_path_systemauth(87c6ae427bbae0f6)., &print_systemauth},
687 {authselect_files_passwordauthcxx . . $ authselect_files_passwordauth(5d1c3e03439491a3)., authselect_path_passwordauthcxx . . $ authselect_path_passwordauth(87c6ae427bbae0f6)., &print_passwordauth},
688 {authselect_files_smartcardauthcxx . . $ authselect_files_smartcardauth(5d1c3e03439491a3)., authselect_path_smartcardauthcxx . . $ authselect_path_smartcardauth(87c6ae427bbae0f6)., &print_smartcardauth},
689 {authselect_files_fingerprintauthcxx . . $ authselect_files_fingerprintauth(5d1c3e03439491a3)., authselect_path_fingerprintauthcxx . . $ authselect_path_fingerprintauth(87c6ae427bbae0f6)., &print_fingerprintauth},
690 {authselect_files_switchableauthcxx . . $ authselect_files_switchableauth(5d1c3e03439491a3)., authselect_path_switchableauthcxx . . $ authselect_path_switchableauth(87c6ae427bbae0f6)., &print_switchableauth},
691 {authselect_files_postlogincxx . . $ authselect_files_postlogin(5d1c3e03439491a3)., authselect_path_postlogincxx . . $ authselect_path_postlogin(87c6ae427bbae0f6)., &print_postlogin},
692 {authselect_files_dconf_dbcxx . . $ authselect_files_dconf_db(5d1c3e03439491a3)., authselect_path_dconf_dbcxx . . $ authselect_path_dconf_db(87c6ae427bbae0f6)., &print_dconfdb},
693 {authselect_files_dconf_lockcxx . . $ authselect_files_dconf_lock(5d1c3e03439491a3)., authselect_path_dconf_lockcxx . . $ authselect_path_dconf_lock(87c6ae427bbae0f6)., &print_dconflock},
694 {NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!}
695 };
696
697 ret = parse_profile_optionscxx . . $ parse_profile_options(fe2371ca2d64bbde).(cmdline, options, &profile_id, &features);
698 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
699 goto done;
700 }
701
702 ret = authselect_filescxx . . $ authselect_files(879a8b3bb2b9eac1).(profile_id, (const char **)features, &files);
703 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
704 ERRORcxx . . $ `src/common/common.h:71:9`!("Unable to get generated content [%d]: %s", ret, strerror(ret));
705 goto done;
706 }
707
708 for (i = 0; generated[i].content_fncxx . . $ test(b6d55c42bf71c8b5).$anonymous_type_0#content_fn. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; i++) {
709 if (*generated[i].enabledcxx . . $ test(b6d55c42bf71c8b5).$anonymous_type_0#enabled. == 1) {
710 print_all = 0;
711 }
712 }
713
714 for (i = 0; generated[i].content_fncxx . . $ test(b6d55c42bf71c8b5).$anonymous_type_0#content_fn. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; i++) {
715 if (!print_all && *generated[i].enabledcxx . . $ test(b6d55c42bf71c8b5).$anonymous_type_0#enabled. == 0) {
716 continue;
717 }
718
719 path = generated[i].path_fncxx . . $ test(b6d55c42bf71c8b5).$anonymous_type_0#path_fn.();
720 content = generated[i].content_fncxx . . $ test(b6d55c42bf71c8b5).$anonymous_type_0#content_fn.(files);
721
722 if (content == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) {
723 CLI_PRINTcxx . . $ `src/cli/main.c:39:9`!("File %s: Empty\n\n", path);
724 } else {
725 CLI_PRINTcxx . . $ `src/cli/main.c:39:9`!("File %s:\n%s\n\n", path, content);
726 }
727 }
728
729 done:
730 authselect_array_freecxx . . $ authselect_array_free(3ed91490e421178f).((char **)features);
731 freecxx . . $ free(5d22bdacc48458e8).(profile_id);
732 return ret;
733 }
734
735 static errno_tcxx . . $ errno_t# enablecxx . . $ enable(b6d55c42bf71c8b5).(struct cli_cmdlinecxx . . $ cli_cmdline# *cmdline)
736 {
737 struct authselect_profilecxx . . $ authselect_profile# *profile = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
738 char *backup_name = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
739 char *requirements = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
740 char *profile_id = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
741 char *feature;
742 const char *features[2];
743 int backup = 0;
744 int quiet = 0;
745 errno_tcxx . . $ errno_t# ret;
746
747 struct poptOptioncxx . . $ poptOption# options[] = {
748 {NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, 'b', POPT_ARG_VALcxx . . $ `<external>/16232926639102580118/popt.h:31:9`!, &backup, 1, _cxx . . $ `src/common/common.h:33:9`!("Backup system files before activating profile (generate unique name)"), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! },
749 {"backup", '\0', POPT_ARG_STRINGcxx . . $ `<external>/16232926639102580118/popt.h:19:9`! | POPT_ARG_NONEcxx . . $ `<external>/16232926639102580118/popt.h:18:9`!, &backup_name, 0, _cxx . . $ `src/common/common.h:33:9`!("Backup system files before activating profile"), _cxx . . $ `src/common/common.h:33:9`!("NAME") },
750 {"quiet", 'q', POPT_ARG_VALcxx . . $ `<external>/16232926639102580118/popt.h:31:9`!, &quiet, 1, _cxx . . $ `src/common/common.h:33:9`!("Do not print profile requirements"), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! },
751 POPT_TABLEENDcxx . . $ `<external>/16232926639102580118/popt.h:161:9`!
752 };
753
754 ret = cli_tool_popt_excxx . . $ cli_tool_popt_ex(6e0400684c960c82).(cmdline, options, CLI_TOOL_OPT_OPTIONALcxx . . $ CLI_TOOL_OPT_OPTIONAL.,
755 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, "FEATURE", _cxx . . $ `src/common/common.h:33:9`!("Feature to enable."),
756 &feature, falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
757 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
758 ERRORcxx . . $ `src/common/common.h:71:9`!("Unable to parse command arguments");
759 return ret;
760 }
761
762 features[0] = feature;
763 features[1] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
764
765 ret = authselect_current_configurationcxx . . $ authselect_current_configuration(2bdaab245118da41).(&profile_id, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
766 if (ret == ENOENTcxx . . $ `<external>/8987895939074593727/errno-base.h:6:9`!) {
767 CLI_PRINTcxx . . $ `src/cli/main.c:39:9`!("No existing configuration detected.\n");
768 goto done;
769 } else if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
770 ERRORcxx . . $ `src/common/common.h:71:9`!("Unable to get current configuration [%d]: %s",
771 ret, strerror(ret));
772 goto done;
773 }
774
775 ret = authselect_profilecxx . . $ authselect_profile(9cd096d22a496993).(profile_id, &profile);
776 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
777 ERRORcxx . . $ `src/common/common.h:71:9`!("Unable to get profile information [%d]: %s",
778 ret, strerror(ret));
779 ret = ENOMEMcxx . . $ `<external>/8987895939074593727/errno-base.h:16:9`!;
780 goto done;
781 }
782
783 requirements = authselect_profile_requirementscxx . . $ authselect_profile_requirements(e64a63f0b99072ff).(profile, (const char **)features);
784 if (requirements == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) {
785 ERRORcxx . . $ `src/common/common.h:71:9`!("Unable to read profile requirements!");
786 ret = EFAULTcxx . . $ `<external>/8987895939074593727/errno-base.h:18:9`!;
787 goto done;
788 }
789
790 ret = perform_backupcxx . . $ perform_backup(704025c2f01734e3).(quiet, backup, backup_name);
791 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
792 CLI_ERRORcxx . . $ `src/cli/main.c:37:9`!("Unable to backup current configuration [%d]: %s\n",
793 ret, strerror(ret));
794 goto done;
795 }
796
797 ret = authselect_feature_enablecxx . . $ authselect_feature_enable(5c4306d8553b3696).(feature);
798 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
799 CLI_ERRORcxx . . $ `src/cli/main.c:37:9`!("Unable to enable feature [%d]: %s\n", ret, strerror(ret));
800 goto done;
801 }
802
803 if (requirements[0] != '\0') {
804 CLI_MSGcxx . . $ `src/cli/main.c:40:9`!(quiet, "%s\n", requirements);
805 }
806
807 ret = EOKcxx . . $ `src/common/errno_t.h:34:9`!;
808
809 done:
810 freecxx . . $ free(5d22bdacc48458e8).(profile_id);
811 freecxx . . $ free(5d22bdacc48458e8).(requirements);
812 freecxx . . $ free(5d22bdacc48458e8).(feature);
813 authselect_profile_freecxx . . $ authselect_profile_free(56572ca77072da15).(profile);
814
815 return ret;
816 }
817
818 static errno_tcxx . . $ errno_t# disablecxx . . $ disable(b6d55c42bf71c8b5).(struct cli_cmdlinecxx . . $ cli_cmdline# *cmdline)
819 {
820 int backup = 0;
821 char *backup_name = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
822 char *feature;
823 errno_tcxx . . $ errno_t# ret;
824
825 struct poptOptioncxx . . $ poptOption# options[] = {
826 {NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, 'b', POPT_ARG_VALcxx . . $ `<external>/16232926639102580118/popt.h:31:9`!, &backup, 1, _cxx . . $ `src/common/common.h:33:9`!("Backup system files before activating profile (generate unique name)"), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! },
827 {"backup", '\0', POPT_ARG_STRINGcxx . . $ `<external>/16232926639102580118/popt.h:19:9`! | POPT_ARG_NONEcxx . . $ `<external>/16232926639102580118/popt.h:18:9`!, &backup_name, 0, _cxx . . $ `src/common/common.h:33:9`!("Backup system files before activating profile"), _cxx . . $ `src/common/common.h:33:9`!("NAME") },
828 POPT_TABLEENDcxx . . $ `<external>/16232926639102580118/popt.h:161:9`!
829 };
830
831 ret = cli_tool_popt_excxx . . $ cli_tool_popt_ex(6e0400684c960c82).(cmdline, options, CLI_TOOL_OPT_OPTIONALcxx . . $ CLI_TOOL_OPT_OPTIONAL.,
832 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, "FEATURE", _cxx . . $ `src/common/common.h:33:9`!("Feature to disable."),
833 &feature, falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
834 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
835 ERRORcxx . . $ `src/common/common.h:71:9`!("Unable to parse command arguments");
836 goto done;
837 }
838
839 ret = perform_backupcxx . . $ perform_backup(704025c2f01734e3).(falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!, backup, backup_name);
840 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
841 goto done;
842 }
843
844 ret = authselect_feature_disablecxx . . $ authselect_feature_disable(5c4306d8553b3696).(feature);
845 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
846 CLI_ERRORcxx . . $ `src/cli/main.c:37:9`!("Unable to disable feature [%d]: %s\n", ret, strerror(ret));
847 goto done;
848 }
849
850 done:
851 freecxx . . $ free(5d22bdacc48458e8).(feature);
852 return ret;
853 }
854
855 static errno_tcxx . . $ errno_t# is_enabledcxx . . $ is_enabled(b6d55c42bf71c8b5).(struct cli_cmdlinecxx . . $ cli_cmdline# *cmdline)
856 {
857 char *feature;
858 errno_tcxx . . $ errno_t# ret;
859
860 ret = cli_tool_popt_excxx . . $ cli_tool_popt_ex(6e0400684c960c82).(cmdline, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, CLI_TOOL_OPT_OPTIONALcxx . . $ CLI_TOOL_OPT_OPTIONAL.,
861 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, "FEATURE", _cxx . . $ `src/common/common.h:33:9`!("Feature to check."),
862 &feature, falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
863 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
864 ERRORcxx . . $ `src/common/common.h:71:9`!("Unable to parse command arguments");
865 goto done;
866 }
867
868 ret = authselect_feature_enabledcxx . . $ authselect_feature_enabled(5c4306d8553b3696).(feature);
869 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`! && ret != ENOENTcxx . . $ `<external>/8987895939074593727/errno-base.h:6:9`!) {
870 CLI_ERRORcxx . . $ `src/cli/main.c:37:9`!("Unable to check feature [%d]: %s\n", ret, strerror(ret));
871 goto done;
872 }
873
874 done:
875 freecxx . . $ free(5d22bdacc48458e8).(feature);
876 return ret;
877 }
878
879 static errno_tcxx . . $ errno_t# createcxx . . $ create(b6d55c42bf71c8b5).(struct cli_cmdlinecxx . . $ cli_cmdline# *cmdline)
880 {
881 char *name;
882 const char *base_id = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
883 enum authselect_profile_typecxx . . $ authselect_profile_type# type = AUTHSELECT_PROFILE_CUSTOMcxx . . $ AUTHSELECT_PROFILE_CUSTOM.;
884 enum authselect_profile_typecxx . . $ authselect_profile_type# base_type = AUTHSELECT_PROFILE_ANYcxx . . $ AUTHSELECT_PROFILE_ANY.;
885 int symlink_flags = AUTHSELECT_SYMLINK_NONEcxx . . $ `include/authselect.h:543:9`!;
886 const char **symlinks = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
887 char *path = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
888 errno_tcxx . . $ errno_t# ret;
889
890 struct poptOptioncxx . . $ poptOption# options[] = {
891 {"vendor", 'v', POPT_ARG_VALcxx . . $ `<external>/16232926639102580118/popt.h:31:9`!, &type, AUTHSELECT_PROFILE_VENDORcxx . . $ AUTHSELECT_PROFILE_VENDOR., _cxx . . $ `src/common/common.h:33:9`!("Create new profile as a vendor profile instead of a custom profile"), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! },
892 {"base-on", 'b', POPT_ARG_STRINGcxx . . $ `<external>/16232926639102580118/popt.h:19:9`!, &base_id, 0, _cxx . . $ `src/common/common.h:33:9`!("ID of a profile that should be used as a base for the new profile"), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! },
893 {"base-on-default", '\0', POPT_ARG_VALcxx . . $ `<external>/16232926639102580118/popt.h:31:9`!, &base_type, AUTHSELECT_PROFILE_DEFAULTcxx . . $ AUTHSELECT_PROFILE_DEFAULT., _cxx . . $ `src/common/common.h:33:9`!("Base new profile on a default profile even if vendor profile with the same name exists"), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! },
894 {"symlink-meta", '\0', POPT_ARG_VALcxx . . $ `<external>/16232926639102580118/popt.h:31:9`! | POPT_ARGFLAG_ORcxx . . $ `<external>/16232926639102580118/popt.h:52:9`!, &symlink_flags, AUTHSELECT_SYMLINK_METAcxx . . $ `include/authselect.h:548:9`!, _cxx . . $ `src/common/common.h:33:9`!("Symlink meta files from the base profile instead of copying them"), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! },
895 {"symlink-nsswitch", '\0', POPT_ARG_VALcxx . . $ `<external>/16232926639102580118/popt.h:31:9`! | POPT_ARGFLAG_ORcxx . . $ `<external>/16232926639102580118/popt.h:52:9`!, &symlink_flags, AUTHSELECT_SYMLINK_NSSWITCHcxx . . $ `include/authselect.h:553:9`!, _cxx . . $ `src/common/common.h:33:9`!("Symlink nsswitch files from the base profile instead of copying them"), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! },
896 {"symlink-pam", '\0', POPT_ARG_VALcxx . . $ `<external>/16232926639102580118/popt.h:31:9`! | POPT_ARGFLAG_ORcxx . . $ `<external>/16232926639102580118/popt.h:52:9`!, &symlink_flags, AUTHSELECT_SYMLINK_PAMcxx . . $ `include/authselect.h:558:9`!, _cxx . . $ `src/common/common.h:33:9`!("Symlink pam files from the base profile instead of copying them"), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! },
897 {"symlink-dconf", '\0', POPT_ARG_VALcxx . . $ `<external>/16232926639102580118/popt.h:31:9`! | POPT_ARGFLAG_ORcxx . . $ `<external>/16232926639102580118/popt.h:52:9`!, &symlink_flags, AUTHSELECT_SYMLINK_DCONFcxx . . $ `include/authselect.h:563:9`!, _cxx . . $ `src/common/common.h:33:9`!("Symlink dconf files from the base profile instead of copying them"), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! },
898 {"symlink", 's', POPT_ARG_ARGVcxx . . $ `<external>/16232926639102580118/popt.h:37:9`!, &symlinks, 0, _cxx . . $ `src/common/common.h:33:9`!("Symlink specific file (can be set multiple times)"), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! },
899 POPT_TABLEENDcxx . . $ `<external>/16232926639102580118/popt.h:161:9`!
900 };
901
902 ret = cli_tool_popt_excxx . . $ cli_tool_popt_ex(6e0400684c960c82).(cmdline, options, CLI_TOOL_OPT_OPTIONALcxx . . $ CLI_TOOL_OPT_OPTIONAL.,
903 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, "NAME", _cxx . . $ `src/common/common.h:33:9`!("New profile name."),
904 &name, falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
905 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
906 ERRORcxx . . $ `src/common/common.h:71:9`!("Unable to parse command arguments");
907 goto done;
908 }
909
910 ret = authselect_profile_createcxx . . $ authselect_profile_create(4f52199d544410a4).(name, type, base_id, base_type,
911 symlink_flags, symlinks, &path);
912 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
913 CLI_ERRORcxx . . $ `src/cli/main.c:37:9`!("Unable to create new profile [%d]: %s\n", ret, strerror(ret));
914 goto done;
915 }
916
917 CLI_PRINTcxx . . $ `src/cli/main.c:39:9`!("New profile was created at %s\n", path);
918
919 done:
920 freecxx . . $ free(5d22bdacc48458e8).(path);
921 freecxx . . $ free(5d22bdacc48458e8).(name);
922 return ret;
923 }
924
925 static errno_tcxx . . $ errno_t# backup_listcxx . . $ backup_list(b6d55c42bf71c8b5).(struct cli_cmdlinecxx . . $ cli_cmdline# *cmdline)
926 {
927 int raw_output = 0;
928 char fmttime[255];
929 struct statcxx . . $ stat# st;
930 struct tmcxx . . $ tm# tm;
931 char **names;
932 char *path;
933 int max = 0;
934 int len;
935 errno_tcxx . . $ errno_t# ret;
936 int i;
937
938 struct poptOptioncxx . . $ poptOption# options[] = {
939 {"raw", 'r', POPT_ARG_VALcxx . . $ `<external>/16232926639102580118/popt.h:31:9`!, &raw_output, 1,
940 _cxx . . $ `src/common/common.h:33:9`!("Print backup names without any formatting and additional information"), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! },
941 POPT_TABLEENDcxx . . $ `<external>/16232926639102580118/popt.h:161:9`!
942 };
943
944 ret = cli_tool_poptcxx . . $ cli_tool_popt(56747616750755be).(cmdline, options, CLI_TOOL_OPT_OPTIONALcxx . . $ CLI_TOOL_OPT_OPTIONAL., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
945 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
946 ERRORcxx . . $ `src/common/common.h:71:9`!("Unable to parse command arguments");
947 return ret;
948 }
949
950 names = authselect_backup_listcxx . . $ authselect_backup_list(de5739791ae7584).();
951 if (names == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) {
952 ERRORcxx . . $ `src/common/common.h:71:9`!("Unable to list available backups!");
953 return ENOMEMcxx . . $ `<external>/8987895939074593727/errno-base.h:16:9`!;
954 }
955
956 if (raw_output) {
957 for (i = 0; names[i] != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; i++) {
958 printfcxx . . $ printf(581fddd72a8db8fc).("%s\n", names[i]);
959 }
960 } else {
961 for (i = 0; names[i] != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; i++) {
962 len = strlencxx . . $ strlen(751346f8406fd082).(names[i]);
963 if (max < len) {
964 max = len;
965 }
966 }
967
968 for (i = 0; names[i] != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; i++) {
969 path = formatcxx . . $ format(a849077ff1b8d812).("%s/%s", AUTHSELECT_BACKUP_DIRcxx . . $ `<built-in>:414:9`!, names[i]);
970 if (path == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) {
971 ERRORcxx . . $ `src/common/common.h:71:9`!("Out of memory!");
972 ret = ENOMEMcxx . . $ `<external>/8987895939074593727/errno-base.h:16:9`!;
973 goto done;
974 }
975
976 ret = statcxx . . $ stat(a9cd1e23e96f423c).(path, &st);
977 if (ret < 0) {
978 ret = errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!;
979 ERRORcxx . . $ `src/common/common.h:71:9`!("Unable to stat [%s] [%d]: %s", path, ret, strerror(ret));
980 freecxx . . $ free(5d22bdacc48458e8).(path);
981 goto done;
982 }
983 freecxx . . $ free(5d22bdacc48458e8).(path);
984
985 localtime_rcxx . . $ localtime_r(92e3d173686db852).(&st.st_ctimcxx . . $ stat#st_ctim..tv_seccxx . . $ timespec#tv_sec., &tm);
986 memsetcxx . . $ memset(d1de1e4fb215f1c6).(fmttime, '\0', sizeof(fmttime));
987 strftimecxx . . $ strftime(98e75925167c4f1b).(fmttime, 255, "%c", &tm);
988
989 printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `src/common/common.h:33:9`!("%-*s (created at %s)\n"), max, names[i], fmttime);
990 }
991 }
992
993 ret = EOKcxx . . $ `src/common/errno_t.h:34:9`!;
994
995 done:
996 authselect_array_freecxx . . $ authselect_array_free(3ed91490e421178f).(names);
997
998 return ret;
999 }
1000
1001 static errno_tcxx . . $ errno_t# backup_removecxx . . $ backup_remove(b6d55c42bf71c8b5).(struct cli_cmdlinecxx . . $ cli_cmdline# *cmdline)
1002 {
1003 char *name;
1004 errno_tcxx . . $ errno_t# ret;
1005
1006 ret = cli_tool_popt_excxx . . $ cli_tool_popt_ex(6e0400684c960c82).(cmdline, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, CLI_TOOL_OPT_OPTIONALcxx . . $ CLI_TOOL_OPT_OPTIONAL.,
1007 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, "BACKUP",
1008 _cxx . . $ `src/common/common.h:33:9`!("Name of the backup to remove."),
1009 &name, falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
1010 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
1011 ERRORcxx . . $ `src/common/common.h:71:9`!("Unable to parse command arguments");
1012 goto done;
1013 }
1014
1015 ret = authselect_backup_removecxx . . $ authselect_backup_remove(5c4306d8553b3696).(name);
1016 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
1017 CLI_ERRORcxx . . $ `src/cli/main.c:37:9`!("Unable to remove backup [%s] [%d]: %s\n",
1018 name, ret, strerror(ret));
1019 goto done;
1020 }
1021
1022 done:
1023 freecxx . . $ free(5d22bdacc48458e8).(name);
1024 return ret;
1025 }
1026
1027 static errno_tcxx . . $ errno_t# backup_restorecxx . . $ backup_restore(b6d55c42bf71c8b5).(struct cli_cmdlinecxx . . $ cli_cmdline# *cmdline)
1028 {
1029 char *name;
1030 errno_tcxx . . $ errno_t# ret;
1031
1032 ret = cli_tool_popt_excxx . . $ cli_tool_popt_ex(6e0400684c960c82).(cmdline, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, CLI_TOOL_OPT_OPTIONALcxx . . $ CLI_TOOL_OPT_OPTIONAL.,
1033 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, "BACKUP",
1034 _cxx . . $ `src/common/common.h:33:9`!("Name of the backup to restore from."),
1035 &name, falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
1036 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
1037 ERRORcxx . . $ `src/common/common.h:71:9`!("Unable to parse command arguments");
1038 goto done;
1039 }
1040
1041 ret = authselect_backup_restorecxx . . $ authselect_backup_restore(5c4306d8553b3696).(name);
1042 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
1043 CLI_ERRORcxx . . $ `src/cli/main.c:37:9`!("Unable to restore backup [%s] [%d]: %s\n",
1044 name, ret, strerror(ret));
1045 goto done;
1046 }
1047
1048 done:
1049 freecxx . . $ free(5d22bdacc48458e8).(name);
1050 return ret;
1051 }
1052
1053 static errno_tcxx . . $ errno_t# uninstallcxx . . $ uninstall(b6d55c42bf71c8b5).(struct cli_cmdlinecxx . . $ cli_cmdline# *cmdline)
1054 {
1055 errno_tcxx . . $ errno_t# ret;
1056
1057 ret = authselect_uninstallcxx . . $ authselect_uninstall(b126dc7c1de90089).();
1058 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
1059 CLI_ERRORcxx . . $ `src/cli/main.c:37:9`!("Unable to uninstall authselect configuration [%d]: %s\n",
1060 ret, strerror(ret));
1061 return ret;
1062 }
1063
1064 return EOKcxx . . $ `src/common/errno_t.h:34:9`!;
1065 }
1066
1067 static errno_tcxx . . $ errno_t# versioncxx . . $ version(b6d55c42bf71c8b5).(struct cli_cmdlinecxx . . $ cli_cmdline# *cmdline)
1068 {
1069 putscxx . . $ puts(5c4306d8553b3696).(PACKAGE_VERSIONcxx . . $ `config.h:105:9`!);
1070
1071 return EOKcxx . . $ `src/common/errno_t.h:34:9`!;
1072 }
1073
1074 static errno_tcxx . . $ errno_t#
1075 setup_gettextcxx . . $ setup_gettext(d1b40a211a1a4e4c).()
1076 {
1077 char *c;
1078
1079 /* Setup gettext even if we were unable to setup locale. */
1080 setlocalecxx . . $ setlocale(10ed28bce9115888).(LC_ALLcxx . . $ `<external>/3736975272097309885/locale.h:41:9`!, "");
1081
1082 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = 0;
1083 c = bindtextdomaincxx . . $ bindtextdomain(a713fe7b9a57cf96).(PACKAGEcxx . . $ `config.h:87:9`!, LOCALEDIRcxx . . $ `<built-in>:413:9`!);
1084 if (c == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) {
1085 return errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!;
1086 }
1087
1088 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = 0;
1089 c = textdomaincxx . . $ textdomain(a8b8e32347182212).(PACKAGEcxx . . $ `config.h:87:9`!);
1090 if (c == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) {
1091 return errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!;
1092 }
1093
1094 return EOKcxx . . $ `src/common/errno_t.h:34:9`!;
1095 }
1096
1097 int maincxx . . $ main(d8e43b79a186046c).(int argc, const char **argv)
1098 {
1099 errno_tcxx . . $ errno_t# ret;
1100
1101 ret = setup_gettextcxx . . $ setup_gettext(d1b40a211a1a4e4c).();
1102 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
1103 /* We can't use gettext here since it would crash. */
1104 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Unable to setup gettext!\n");
1105 return 1;
1106 }
1107
1108 struct cli_route_cmdcxx . . $ cli_route_cmd# commands[] = {
1109 CLI_TOOL_COMMANDcxx . . $ `src/cli/cli_tool.h:36:9`!("select", "Select profile", CLI_CMD_REQUIRE_ROOTcxx . . $ `src/cli/cli_tool.h:33:9`!, activate),
1110 CLI_TOOL_COMMANDcxx . . $ `src/cli/cli_tool.h:36:9`!("apply-changes", "Regenerate configuration for currently selected command", CLI_CMD_REQUIRE_ROOTcxx . . $ `src/cli/cli_tool.h:33:9`!, apply_changes),
1111 CLI_TOOL_COMMANDcxx . . $ `src/cli/cli_tool.h:36:9`!("list", "List available profiles", CLI_CMD_NONEcxx . . $ `src/cli/cli_tool.h:32:9`!, list),
1112 CLI_TOOL_COMMANDcxx . . $ `src/cli/cli_tool.h:36:9`!("list-features", "List available profile features", CLI_CMD_NONEcxx . . $ `src/cli/cli_tool.h:32:9`!, list_features),
1113 CLI_TOOL_COMMANDcxx . . $ `src/cli/cli_tool.h:36:9`!("show", "Show profile information", CLI_CMD_NONEcxx . . $ `src/cli/cli_tool.h:32:9`!, show),
1114 CLI_TOOL_COMMANDcxx . . $ `src/cli/cli_tool.h:36:9`!("requirements", "Print profile requirements", CLI_CMD_NONEcxx . . $ `src/cli/cli_tool.h:32:9`!, requirements),
1115 CLI_TOOL_COMMANDcxx . . $ `src/cli/cli_tool.h:36:9`!("current", "Get identifier of currently selected profile", CLI_CMD_NONEcxx . . $ `src/cli/cli_tool.h:32:9`!, current),
1116 CLI_TOOL_COMMANDcxx . . $ `src/cli/cli_tool.h:36:9`!("check", "Check if the current configuration is valid", CLI_CMD_NONEcxx . . $ `src/cli/cli_tool.h:32:9`!, check),
1117 CLI_TOOL_COMMANDcxx . . $ `src/cli/cli_tool.h:36:9`!("test", "Print changes that would be otherwise written", CLI_CMD_NONEcxx . . $ `src/cli/cli_tool.h:32:9`!, test),
1118 CLI_TOOL_COMMANDcxx . . $ `src/cli/cli_tool.h:36:9`!("enable-feature", "Enable feature in currently selected profile", CLI_CMD_REQUIRE_ROOTcxx . . $ `src/cli/cli_tool.h:33:9`!, enable),
1119 CLI_TOOL_COMMANDcxx . . $ `src/cli/cli_tool.h:36:9`!("disable-feature", "Disable feature in currently selected profile", CLI_CMD_REQUIRE_ROOTcxx . . $ `src/cli/cli_tool.h:33:9`!, disable),
1120 CLI_TOOL_COMMANDcxx . . $ `src/cli/cli_tool.h:36:9`!("is-feature-enabled", "Check if feature is enabled in currently selected profile", CLI_CMD_NONEcxx . . $ `src/cli/cli_tool.h:32:9`!, is_enabled),
1121 CLI_TOOL_COMMANDcxx . . $ `src/cli/cli_tool.h:36:9`!("create-profile", "Create new authselect profile", CLI_CMD_REQUIRE_ROOTcxx . . $ `src/cli/cli_tool.h:33:9`!, create),
1122 CLI_TOOL_DELIMITERcxx . . $ `src/cli/cli_tool.h:38:9`!("Backup commands:"),
1123 CLI_TOOL_COMMANDcxx . . $ `src/cli/cli_tool.h:36:9`!("backup-list", "List available backups", CLI_CMD_NONEcxx . . $ `src/cli/cli_tool.h:32:9`!, backup_list),
1124 CLI_TOOL_COMMANDcxx . . $ `src/cli/cli_tool.h:36:9`!("backup-remove", "Remove backup", CLI_CMD_REQUIRE_ROOTcxx . . $ `src/cli/cli_tool.h:33:9`!, backup_remove),
1125 CLI_TOOL_COMMANDcxx . . $ `src/cli/cli_tool.h:36:9`!("backup-restore", "Restore from backup", CLI_CMD_REQUIRE_ROOTcxx . . $ `src/cli/cli_tool.h:33:9`!, backup_restore),
1126 CLI_TOOL_DELIMITERcxx . . $ `src/cli/cli_tool.h:38:9`!("Other:"),
1127 CLI_TOOL_COMMANDcxx . . $ `src/cli/cli_tool.h:36:9`!("opt-out", "Opt-out from authselect managed configuration", CLI_CMD_REQUIRE_ROOTcxx . . $ `src/cli/cli_tool.h:33:9`!, uninstall),
1128 /* Hidden commands */
1129 CLI_TOOL_COMMANDcxx . . $ `src/cli/cli_tool.h:36:9`!("version", "Print authselect version", CLI_CMD_HIDDENcxx . . $ `src/cli/cli_tool.h:34:9`!, version),
1130 CLI_TOOL_LASTcxx . . $ `src/cli/cli_tool.h:39:9`!
1131 };
1132
1133 return cli_tool_maincxx . . $ cli_tool_main(d9b5b3c5de31f8fa).(argc, argv, commands, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
1134 }