login,user-sessions: always warn when we fail to remove nologin file
This usually is very annoying to users who then cannot log in, so
make sure we always warn if that happens (selinux, or whatever other reason).
This reverts a790812cb3.
This commit is contained in:
@@ -554,6 +554,17 @@ int tmp_dir(const char **ret) {
|
||||
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;
|
||||
}
|
||||
|
||||
int inotify_add_watch_fd(int fd, int what, uint32_t mask) {
|
||||
char path[STRLEN("/proc/self/fd/") + DECIMAL_STR_MAX(int) + 1];
|
||||
int r;
|
||||
|
||||
@@ -64,6 +64,8 @@ int get_files_in_directory(const char *path, char ***list);
|
||||
int tmp_dir(const char **ret);
|
||||
int var_tmp_dir(const char **ret);
|
||||
|
||||
int unlink_or_warn(const char *filename);
|
||||
|
||||
#define INOTIFY_EVENT_MAX (sizeof(struct inotify_event) + NAME_MAX + 1)
|
||||
|
||||
#define FOREACH_INOTIFY_EVENT(e, buffer, sz) \
|
||||
|
||||
Reference in New Issue
Block a user