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:
@@ -102,7 +102,11 @@ static int touch_ask_password_directory(AskPasswordFlags flags) {
|
||||
if (r <= 0)
|
||||
return r;
|
||||
|
||||
r = touch(p);
|
||||
_cleanup_close_ int fd = open_mkdir(p, O_CLOEXEC, 0755);
|
||||
if (fd < 0)
|
||||
return fd;
|
||||
|
||||
r = touch_fd(fd, USEC_INFINITY);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user