Debian Codegraph @

src/lib/files/nsswitch.c

raw symbols SCIP
1 /*
2 Authors:
3 Pavel Březina <[email protected]>
4
5 Copyright (C) 2021 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 <errno.h>
24 #include <regex.h>
25 #include <string.h>
26 #include <stdlib.h>
27
28 #include "common/common.h"cxx . . $ `<file>/src/common/common.h`/
29 #include "lib/constants.h"cxx . . $ `<file>/src/lib/constants.h`/
30 #include "lib/util/util.h"cxx . . $ `<file>/src/lib/util/util.h`/
31 #include "lib/files/files.h"cxx . . $ `<file>/src/lib/files/files.h`/
32
33 #define RE_NSScxx . . $ `src/lib/files/nsswitch.c:33:9`! "^\\s*([^[:space:]:]+):.*$"
34 #define RE_NSS_MATCHEScxx . . $ `src/lib/files/nsswitch.c:34:9`! 2
35
36 errno_tcxx . . $ errno_t#
37 authselect_nsswitch_find_mapscxx . . $ authselect_nsswitch_find_maps(bd420b23a2195fdd).(char *content,
38 char ***_maps)
39 {
40 char *match_string;
41 regmatch_tcxx . . $ regmatch_t# m[RE_NSS_MATCHEScxx . . $ `src/lib/files/nsswitch.c:34:9`!];
42 regex_tcxx . . $ regex_t# regex;
43 errno_tcxx . . $ errno_t# ret;
44 char **maps;
45 int reret;
46
47 maps = string_array_createcxx . . $ string_array_create(4d3fbc76ec7ad0ba).(10);
48 if (maps == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) {
49 return ENOMEMcxx . . $ `<external>/8987895939074593727/errno-base.h:16:9`!;
50 }
51
52 reret = regcompcxx . . $ regcomp(aa05013d3db24b3e).(&regex, RE_NSScxx . . $ `src/lib/files/nsswitch.c:33:9`!, REG_EXTENDEDcxx . . $ `<external>/18190116149591951179/regex.h:310:9`! | REG_NEWLINEcxx . . $ `<external>/18190116149591951179/regex.h:319:9`!);
53 if (reret != REG_NOERRORcxx . . $ `<external>/18190116149591951179/regex.h:376:9`!) {
54 ERRORcxx . . $ `src/common/common.h:71:9`!("Unable to compile regular expression: regex error %d", reret);
55 ret = EFAULTcxx . . $ `<external>/8987895939074593727/errno-base.h:18:9`!;
56 goto done;
57 }
58
59 match_string = content;
60 while ((reret = regexeccxx . . $ regexec(7b724a18a85d26ac).(&regex, match_string, 2, m, 0)) == REG_NOERRORcxx . . $ `<external>/18190116149591951179/regex.h:376:9`!) {
61 maps = string_array_add_value_safecxx . . $ string_array_add_value_safe(dfc2d168ddb15878).(maps, match_string + m[1].rm_socxx . . $ $anonymous_type_2410a2af4c2f900a_1#rm_so.,
62 m[1].rm_eocxx . . $ $anonymous_type_2410a2af4c2f900a_1#rm_eo. - m[1].rm_socxx . . $ $anonymous_type_2410a2af4c2f900a_1#rm_so., truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!);
63 if (maps == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) {
64 ret = ENOMEMcxx . . $ `<external>/8987895939074593727/errno-base.h:16:9`!;
65 goto done;
66 }
67
68 match_string += m[0].rm_eocxx . . $ $anonymous_type_2410a2af4c2f900a_1#rm_eo.;
69 }
70
71 if (reret != REG_NOMATCHcxx . . $ `<external>/18190116149591951179/regex.h:377:9`!) {
72 ERRORcxx . . $ `src/common/common.h:71:9`!("Unable to search string: regex error %d", reret);
73 ret = EFAULTcxx . . $ `<external>/8987895939074593727/errno-base.h:18:9`!;
74 goto done;
75 }
76
77 *_maps = maps;
78
79 ret = EOKcxx . . $ `src/common/errno_t.h:34:9`!;
80
81 done:
82 regfreecxx . . $ regfree(b1814a8fd6af504b).(&regex);
83 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
84 string_array_freecxx . . $ string_array_free(3ed91490e421178f).(maps);
85 }
86
87 return ret;
88 }
89
90 errno_tcxx . . $ errno_t#
91 authselect_nsswitch_generatecxx . . $ authselect_nsswitch_generate(bd92be699d7b007a).(const char *template,
92 const char **features,
93 char **_content)
94 {
95 char *content;
96
97 content = template_generatecxx . . $ template_generate(e6b3452e8157deef).(template, features);
98 if (content == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) {
99 return ENOMEMcxx . . $ `<external>/8987895939074593727/errno-base.h:16:9`!;
100 }
101
102 *_content = content;
103
104 return EOKcxx . . $ `src/common/errno_t.h:34:9`!;
105 }