return tmp_dir_internal("/tmp", ret);
}
+int unlink_or_warn(const char *filename) {
+ if (unlink(filename) < 0 && errno != ENOENT)
+ /* If the file doesn't exist and the fs simply was read-only (in which
+ * case unlink() returns EROFS even if the file doesn't exist), don't
+ * complain */
+ if (errno != EROFS || access(filename, F_OK) >= 0)
+ return log_error_errno(errno, "Failed to remove \"%s\": %m", filename);
+
+ return 0;
+}
+
#if 0 /// UNNEEDED by elogind
int inotify_add_watch_fd(int fd, int what, uint32_t mask) {
char path[STRLEN("/proc/self/fd/") + DECIMAL_STR_MAX(int) + 1];
#include "dirent-util.h"
#include "fd-util.h"
#include "format-util.h"
+//#include "fs-util.h"
#include "logind.h"
//#include "process-util.h"
#include "selinux-util.h"
udev_unref(m->udev);
if (m->unlink_nologin)
- (void) unlink("/run/nologin");
+ (void) unlink_or_warn("/run/nologin");
bus_verify_polkit_async_registry_free(m->polkit_registry);
LIST_REMOVE(gc_queue, m->seat_gc_queue, seat);
seat->in_gc_queue = false;
- if (seat_may_gc(seat, drop_not_started)) {
+ if (!seat_check_gc(seat, drop_not_started)) {
seat_stop(seat, false);
seat_free(seat);
}
session->in_gc_queue = false;
/* First, if we are not closing yet, initiate stopping */
- if (session_may_gc(session, drop_not_started) &&
+ if (!session_check_gc(session, drop_not_started) &&
session_get_state(session) != SESSION_CLOSING)
session_stop(session, false);
/* Normally, this should make the session referenced
* again, if it doesn't then let's get rid of it
* immediately */
- if (session_may_gc(session, drop_not_started)) {
+ if (!session_check_gc(session, drop_not_started)) {
session_finalize(session);
session_free(session);
}
user->in_gc_queue = false;
/* First step: queue stop jobs */
- if (user_may_gc(user, drop_not_started))
+ if (!user_check_gc(user, drop_not_started))
user_stop(user, false);
/* Second step: finalize user */
- if (user_may_gc(user, drop_not_started)) {
+ if (!user_check_gc(user, drop_not_started)) {
user_finalize(user);
user_free(user);
}