| 131 | /* *INDENT-ON* */ |
| 132 | |
| 133 | int |
| 134 | main(int argc, char **argv) |
| 135 | { |
| 136 | int flag; |
| 137 | int rc = 0; |
| 138 | int index = 0; |
| 139 | int argerr = 0; |
| 140 | struct passwd *pwentry = NULL; |
| 141 | |
| 142 | crm_log_init(NULL, LOG_INFO, TRUE, FALSE, argc, argv, FALSE); |
| 143 | crm_set_options(NULL, "[options]", |
| 144 | long_options, "Daemon for storing and replicating the cluster configuration"); |
| 145 | |
| 146 | mainloop_add_signal(SIGTERM, cib_shutdown); |
| 147 | mainloop_add_signal(SIGPIPE, cib_enable_writes); |
| 148 | |
| 149 | cib_writer = mainloop_add_trigger(G_PRIORITY_LOW, write_cib_contents, NULL); |
| 150 | |
| 151 | crm_peer_init(); |
| 152 | client_list = g_hash_table_new(crm_str_hash, g_str_equal); |
| 153 | |
| 154 | while (1) { |
| 155 | flag = crm_get_option(argc, argv, &index); |
| 156 | if (flag == -1) |
| 157 | break; |
| 158 | |
| 159 | switch (flag) { |
| 160 | case 'V': |
| 161 | crm_bump_log_level(argc, argv); |
| 162 | break; |
| 163 | case 's': |
| 164 | stand_alone = TRUE; |
| 165 | preserve_status = TRUE; |
| 166 | cib_writes_enabled = FALSE; |
| 167 | |
| 168 | pwentry = getpwnam(CRM_DAEMON_USER); |
| 169 | CRM_CHECK(pwentry != NULL, |
| 170 | crm_perror(LOG_ERR, "Invalid uid (%s) specified", CRM_DAEMON_USER); |
| 171 | return 100); |
| 172 | |
| 173 | rc = setgid(pwentry->pw_gid); |
| 174 | if (rc < 0) { |
| 175 | crm_perror(LOG_ERR, "Could not set group to %d", pwentry->pw_gid); |
| 176 | return 100; |
| 177 | } |
| 178 | |
| 179 | rc = setuid(pwentry->pw_uid); |
| 180 | if (rc < 0) { |
| 181 | crm_perror(LOG_ERR, "Could not set user to %d", pwentry->pw_uid); |
| 182 | return 100; |
| 183 | } |
| 184 | break; |
| 185 | case '?': /* Help message */ |
| 186 | crm_help(flag, EX_OK); |
| 187 | break; |
| 188 | case 'w': |
| 189 | cib_writes_enabled = TRUE; |
| 190 | break; |
nothing calls this directly
no test coverage detected