fix(credentials): open secret files with O_NOFOLLOW|O_NONBLOCK; drop dup includes
secret_file_open() previously opened --password-file/--early-input with plain O_RDONLY, so a symlinked path was followed before the owner/mode fstat gate ran, and an empty/planted FIFO could block fgets forever. Open with O_NOFOLLOW|O_NONBLOCK|O_CLOEXEC (mirroring the dummy-key sidecar): ELOOP now fails closed, and a writer-less FIFO yields EOF/EAGAIN instead of hanging. Clear O_NONBLOCK again for regular files, where it is a no-op, so their stdio read path is unchanged. file.c: drop the duplicate <fcntl.h>/<unistd.h> includes (kept the first occurrences). Tests: a symlinked password file is rejected, and a writer-less named FIFO fails cleanly without hanging.
This commit is contained in:
@@ -25,8 +25,6 @@
|
||||
#include "utils.h"
|
||||
#include "protocol.h"
|
||||
#include "xattr.h"
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* Files larger than this are not loaded whole for transfer (the sender streams
|
||||
* them); a whole-file digest is computed from the path instead. Kept in sync
|
||||
|
||||
Reference in New Issue
Block a user