diff options
Diffstat (limited to 'src/login')
-rw-r--r-- | src/login/logind-button.c | 2 | ||||
-rw-r--r-- | src/login/logind-inhibit.c | 12 | ||||
-rw-r--r-- | src/login/logind-session.c | 18 | ||||
-rw-r--r-- | src/login/logind.c | 6 | ||||
-rw-r--r-- | src/login/pam-module.c | 2 | ||||
-rw-r--r-- | src/login/test-inhibit.c | 4 |
6 files changed, 15 insertions, 29 deletions
diff --git a/src/login/logind-button.c b/src/login/logind-button.c index 060978dd34..2561d13c67 100644 --- a/src/login/logind-button.c +++ b/src/login/logind-button.c @@ -72,7 +72,7 @@ void button_free(Button *b) { if (b->fd >= 0) { /* If the device has been unplugged close() returns * ENODEV, let's ignore this, hence we don't use - * close_nointr_nofail() */ + * safe_close() */ close(b->fd); } diff --git a/src/login/logind-inhibit.c b/src/login/logind-inhibit.c index d19d648129..8b329abd79 100644 --- a/src/login/logind-inhibit.c +++ b/src/login/logind-inhibit.c @@ -253,8 +253,7 @@ int inhibitor_load(Inhibitor *i) { int fd; fd = inhibitor_create_fifo(i); - if (fd >= 0) - close_nointr_nofail(fd); + safe_close(fd); } return 0; @@ -320,13 +319,8 @@ int inhibitor_create_fifo(Inhibitor *i) { void inhibitor_remove_fifo(Inhibitor *i) { assert(i); - if (i->event_source) - i->event_source = sd_event_source_unref(i->event_source); - - if (i->fifo_fd >= 0) { - close_nointr_nofail(i->fifo_fd); - i->fifo_fd = -1; - } + i->event_source = sd_event_source_unref(i->event_source); + i->fifo_fd = safe_close(i->fifo_fd); if (i->fifo_path) { unlink(i->fifo_path); diff --git a/src/login/logind-session.c b/src/login/logind-session.c index 33ab09ea52..8c517f46a7 100644 --- a/src/login/logind-session.c +++ b/src/login/logind-session.c @@ -407,8 +407,7 @@ int session_load(Session *s) { trigger the EOF. */ fd = session_create_fifo(s); - if (fd >= 0) - close_nointr_nofail(fd); + safe_close(fd); } if (realtime) { @@ -864,13 +863,8 @@ int session_create_fifo(Session *s) { static void session_remove_fifo(Session *s) { assert(s); - if (s->fifo_event_source) - s->fifo_event_source = sd_event_source_unref(s->fifo_event_source); - - if (s->fifo_fd >= 0) { - close_nointr_nofail(s->fifo_fd); - s->fifo_fd = -1; - } + s->fifo_event_source = sd_event_source_unref(s->fifo_event_source); + s->fifo_fd = safe_close(s->fifo_fd); if (s->fifo_path) { unlink(s->fifo_path); @@ -950,7 +944,7 @@ static int session_open_vt(Session *s) { s->vtfd = open(path, O_RDWR | O_CLOEXEC | O_NONBLOCK | O_NOCTTY); if (s->vtfd < 0) { log_error("cannot open VT %s of session %s: %m", path, s->id); - return -1; + return -errno; } return s->vtfd; @@ -1022,13 +1016,13 @@ void session_restore_vt(Session *s) { if (read_one_line_file("/sys/module/vt/parameters/default_utf8", &utf8) >= 0 && *utf8 == '1') kb = K_UNICODE; + ioctl(vt, KDSKBMODE, kb); mode.mode = VT_AUTO; ioctl(vt, VT_SETMODE, &mode); - close_nointr_nofail(vt); - s->vtfd = -1; + s->vtfd = safe_close(s->vtfd); } bool session_is_controller(Session *s, const char *sender) { diff --git a/src/login/logind.c b/src/login/logind.c index 8ba8a9155b..db9882323f 100644 --- a/src/login/logind.c +++ b/src/login/logind.c @@ -149,8 +149,7 @@ void manager_free(Manager *m) { sd_event_source_unref(m->udev_button_event_source); sd_event_source_unref(m->lid_switch_ignore_event_source); - if (m->console_active_fd >= 0) - close_nointr_nofail(m->console_active_fd); + safe_close(m->console_active_fd); if (m->udev_seat_monitor) udev_monitor_unref(m->udev_seat_monitor); @@ -169,8 +168,7 @@ void manager_free(Manager *m) { sd_bus_unref(m->bus); sd_event_unref(m->event); - if (m->reserve_vt_fd >= 0) - close_nointr_nofail(m->reserve_vt_fd); + safe_close(m->reserve_vt_fd); strv_free(m->kill_only_users); strv_free(m->kill_exclude_users); diff --git a/src/login/pam-module.c b/src/login/pam-module.c index 195d4d574e..9873dd547a 100644 --- a/src/login/pam-module.c +++ b/src/login/pam-module.c @@ -484,7 +484,7 @@ _public_ PAM_EXTERN int pam_sm_open_session( r = pam_set_data(handle, "systemd.session-fd", INT_TO_PTR(session_fd+1), NULL); if (r != PAM_SUCCESS) { pam_syslog(handle, LOG_ERR, "Failed to install session fd."); - close_nointr_nofail(session_fd); + safe_close(session_fd); return r; } } diff --git a/src/login/test-inhibit.c b/src/login/test-inhibit.c index 70b8314e3f..70780c30af 100644 --- a/src/login/test-inhibit.c +++ b/src/login/test-inhibit.c @@ -101,11 +101,11 @@ int main(int argc, char*argv[]) { assert(fd2 >= 0); print_inhibitors(bus); - close_nointr_nofail(fd1); + safe_close(fd1); sleep(1); print_inhibitors(bus); - close_nointr_nofail(fd2); + safe_close(fd2); sleep(1); print_inhibitors(bus); |