resolved.c   resolved.c 
skipping to change at line 24 skipping to change at line 24
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details. Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>. along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/ ***/
#include "sd-event.h" #include "sd-event.h"
#include "sd-daemon.h" #include "sd-daemon.h"
#include "resolved.h"
#include "mkdir.h" #include "mkdir.h"
#include "capability.h" #include "capability.h"
#include "resolved-manager.h"
#include "resolved-conf.h"
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
_cleanup_manager_free_ Manager *m = NULL; _cleanup_(manager_freep) Manager *m = NULL;
const char *user = "systemd-resolve"; const char *user = "systemd-resolve";
uid_t uid; uid_t uid;
gid_t gid; gid_t gid;
int r; int r;
log_set_target(LOG_TARGET_AUTO); log_set_target(LOG_TARGET_AUTO);
log_parse_environment(); log_parse_environment();
log_open(); log_open();
umask(0022); umask(0022);
if (argc != 1) { if (argc != 1) {
log_error("This program takes no arguments."); log_error("This program takes no arguments.");
r = -EINVAL; r = -EINVAL;
goto out; goto finish;
} }
r = get_user_creds(&user, &uid, &gid, NULL, NULL); r = get_user_creds(&user, &uid, &gid, NULL, NULL);
if (r < 0) { if (r < 0) {
log_error("Cannot resolve user name %s: %s", user, strerror (-r)); log_error("Cannot resolve user name %s: %s", user, strerror (-r));
goto out; goto finish;
} }
/* Always create the directory where resolv.conf will live */ /* Always create the directory where resolv.conf will live */
r = mkdir_safe_label("/run/systemd/resolve", 0755, uid, gid); r = mkdir_safe_label("/run/systemd/resolve", 0755, uid, gid);
if (r < 0) { if (r < 0) {
log_error("Could not create runtime directory: %s", log_error("Could not create runtime directory: %s", strerro
strerror(-r)); r(-r));
goto out; goto finish;
} }
r = drop_privileges(uid, gid, 0); r = drop_privileges(uid, gid, 0);
if (r < 0) if (r < 0)
goto out; goto finish;
assert_se(sigprocmask_many(SIG_BLOCK, SIGTERM, SIGINT, -1) == 0);
r = manager_new(&m); r = manager_new(&m);
if (r < 0) { if (r < 0) {
log_error("Could not create manager: %s", strerror(-r)); log_error("Could not create manager: %s", strerror(-r));
goto out; goto finish;
} }
r = manager_network_monitor_listen(m); r = manager_parse_config_file(m);
if (r < 0) { if (r < 0)
log_error("Could not listen for network events: %s", strerr log_warning("Failed to parse configuration file: %s", strer
or(-r)); ror(-r));
goto out;
}
/* write out default resolv.conf to avoid a r = manager_start(m);
* dangling symlink */
r = manager_update_resolv_conf(m);
if (r < 0) { if (r < 0) {
log_error("Could not create resolv.conf: %s", strerror(-r)) log_error("Failed to start manager: %s", strerror(-r));
; goto finish;
goto out;
} }
/* Write finish default resolv.conf to avoid a dangling
* symlink */
r = manager_write_resolv_conf(m);
if (r < 0)
log_warning("Could not create resolv.conf: %s", strerror(-r
));
sd_notify(false, sd_notify(false,
"READY=1\n" "READY=1\n"
"STATUS=Processing requests..."); "STATUS=Processing requests...");
r = sd_event_loop(m->event); r = sd_event_loop(m->event);
if (r < 0) { if (r < 0) {
log_error("Event loop failed: %s", strerror(-r)); log_error("Event loop failed: %s", strerror(-r));
goto out; goto finish;
} }
out: sd_event_get_exit_code(m->event, &r);
sd_notify(false,
"STATUS=Shutting down..."); finish:
sd_notify(false, "STATUS=Shutting down...");
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
} }
 End of changes. 14 change blocks. 
27 lines changed or deleted 32 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/