ask-password-api: don't accidentally create a dir, when we don't want one

Previously, we were using touch(), which usually works fine, because the
path should always refer to an existing directory, in which case it just
updates the timestamp. However, if the dir does not exist yet (which
shouldn't happen), it would be created as regular file, which is just
wrong.

Hence, let's instead create the dir as dir if it is missing, and then
update its timestamp.
This commit is contained in:
Lennart Poettering
2024-10-21 14:14:16 +02:00
parent f4c3bafd10
commit 2ee6fa552e
3 changed files with 21 additions and 11 deletions
+2
View File
@@ -54,6 +54,8 @@ int stat_warn_permissions(const char *path, const struct stat *st);
#define access_nofollow(path, mode) \
RET_NERRNO(faccessat(AT_FDCWD, (path), (mode), AT_SYMLINK_NOFOLLOW))
int touch_fd(int fd, usec_t stamp);
int touch_file(const char *path, bool parents, usec_t stamp, uid_t uid, gid_t gid, mode_t mode);
static inline int touch(const char *path) {