Debian Codegraph @

src/lib/profiles/activate.c

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 #include <errno.h>
22 #include <string.h>
23 #include <stdlib.h>
24
25 #include "common/common.h"cxx . . $ `<file>/src/common/common.h`/
26 #include "lib/constants.h"cxx . . $ `<file>/src/lib/constants.h`/
27 #include "lib/files/files.h"cxx . . $ `<file>/src/lib/files/files.h`/
28 #include "lib/profiles/profiles.h"cxx . . $ `<file>/src/lib/profiles/profiles.h`/
29 #include "lib/util/util.h"cxx . . $ `<file>/src/lib/util/util.h`/
30
31 errno_tcxx . . $ errno_t#
32 authselect_profile_dconf_updatecxx . . $ authselect_profile_dconf_update(b126dc7c1de90089).()
33 {
34 errno_tcxx . . $ errno_t# ret;
35 int sysret;
36
37 ret = file_check_accesscxx . . $ file_check_access(cb7559238bb26814).(AUTHSELECT_DCONF_BINcxx . . $ `<built-in>:421:9`!, X_OKcxx . . $ `<external>/14710646456994434043/fcntl.h:130:11`!);
38 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
39 return ret;
40 }
41
42 sysret = systemcxx . . $ system(5c4306d8553b3696).(AUTHSELECT_DCONF_BINcxx . . $ `<built-in>:421:9`! " update &> /dev/null");
43 if (sysret != 0) {
44 ERRORcxx . . $ `src/common/common.h:71:9`!("%s update failed: %d", AUTHSELECT_DCONF_BINcxx . . $ `<built-in>:421:9`!, sysret);
45 return EIOcxx . . $ `<external>/8987895939074593727/errno-base.h:9:9`!;
46 }
47
48 return EOKcxx . . $ `src/common/errno_t.h:34:9`!;
49 }
50
51 errno_tcxx . . $ errno_t#
52 authselect_profile_copy_checksumcxx . . $ authselect_profile_copy_checksum(d1b40a211a1a4e4c).()
53 {
54 INFOcxx . . $ `src/common/common.h:63:9`!("Copying [%s] to [%s]", PATH_CHECKSUM_ORIGcxx . . $ `src/lib/paths.h:75:9`!, PATH_CHECKSUM_COPYcxx . . $ `src/lib/paths.h:76:9`!);
55 return file_copycxx . . $ file_copy(f8e1a36fd0133965).(PATH_CHECKSUM_ORIGcxx . . $ `src/lib/paths.h:75:9`!, AUTHSELECT_STATE_DIRcxx . . $ `<built-in>:414:9`!, "checksum",
56 AUTHSELECT_DIR_MODEcxx . . $ `src/lib/constants.h:29:9`!);
57 }
58
59 errno_tcxx . . $ errno_t#
60 authselect_profile_activatecxx . . $ authselect_profile_activate(91f62ebacbff91ef).(struct authselect_profilecxx . . $ authselect_profile# *profile,
61 const char **features)
62 {
63 errno_tcxx . . $ errno_t# ret;
64
65 /* Check that all directories are writable. */
66 if (!authselect_config_locations_writablecxx . . $ authselect_config_locations_writable(c9857a73d68e59ba).()) {
67 ERRORcxx . . $ `src/common/common.h:71:9`!("Some directories are not accessible by authselect!");
68 return EACCEScxx . . $ `<external>/8987895939074593727/errno-base.h:17:9`!;
69 }
70
71 ret = authselect_system_writecxx . . $ authselect_system_write(36f2feb53451c8f1).(features, profile->filescxx . . $ authselect_profile#files.);
72 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
73 ERRORcxx . . $ `src/common/common.h:71:9`!("Unable to write generated system files [%d]: %s",
74 ret, strerror(ret));
75 return ret;
76 }
77
78 ret = authselect_config_writecxx . . $ authselect_config_write(2ef3bc9ee8f8b3e9).(profile->idcxx . . $ authselect_profile#id., features);
79 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
80 ERRORcxx . . $ `src/common/common.h:71:9`!("Unable to write configuration [%d]: %s", ret, strerror(ret));
81 return ret;
82 }
83
84 ret = authselect_symlinks_writecxx . . $ authselect_symlinks_write(b126dc7c1de90089).();
85 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
86 ERRORcxx . . $ `src/common/common.h:71:9`!("Unable to create symbolic links [%d]: %s", ret, strerror(ret));
87 return ret;
88 }
89
90 ret = authselect_profile_dconf_updatecxx . . $ authselect_profile_dconf_update(b126dc7c1de90089).();
91 if (ret == ENOENTcxx . . $ `<external>/8987895939074593727/errno-base.h:6:9`!) {
92 INFOcxx . . $ `src/common/common.h:63:9`!("Dconf is not installed on your system");
93 } else if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
94 ERRORcxx . . $ `src/common/common.h:71:9`!("Unable to update dconf database [%d]: %s", ret, strerror(ret));
95 return ret;
96 }
97
98 ret = authselect_profile_copy_checksumcxx . . $ authselect_profile_copy_checksum(d1b40a211a1a4e4c).();
99 if (ret != EOKcxx . . $ `src/common/errno_t.h:34:9`!) {
100 /* This is not a fatal error. */
101 WARNcxx . . $ `src/common/common.h:67:9`!("Unable to copy profiles checksum [%d]: %s", ret, strerror(ret));
102 }
103
104 return EOKcxx . . $ `src/common/errno_t.h:34:9`!;
105 }