mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 00:14:32 +09:00
sd-dhcp-server: reopen fd only when it is valid
Fixes a bug in 11b88419ae.
This commit is contained in:
@@ -1605,9 +1605,13 @@ int sd_dhcp_server_set_lease_file(sd_dhcp_server *server, int dir_fd, const char
|
||||
if (!path_is_safe(path))
|
||||
return -EINVAL;
|
||||
|
||||
_cleanup_close_ int fd = fd_reopen(dir_fd, O_CLOEXEC | O_DIRECTORY | O_PATH);
|
||||
if (fd < 0)
|
||||
return fd;
|
||||
_cleanup_close_ int fd = AT_FDCWD; /* Unlike our usual coding style, AT_FDCWD needs to be set,
|
||||
* to pass a 'valid' fd. */
|
||||
if (dir_fd >= 0) {
|
||||
fd = fd_reopen(dir_fd, O_CLOEXEC | O_DIRECTORY | O_PATH);
|
||||
if (fd < 0)
|
||||
return fd;
|
||||
}
|
||||
|
||||
r = free_and_strdup(&server->lease_file, path);
|
||||
if (r < 0)
|
||||
|
||||
Reference in New Issue
Block a user