Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MakeFilePrivate ¶
MakeFilePrivate ensures that the given file is accessible only by its owner. A file is considered already private if no group or other bits are set in its mode (e.g. 0600, 0400, 0500); in that case this is a no-op and the returned bool is false. If the file had looser permissions, they are tightened to 0600 and the returned bool is true. An error is returned if the file cannot be opened, if it is not a regular file, if chmod is required but the file is owned by a different user, or if chmod fails.
The file is opened with O_NOFOLLOW and subsequent stat/chmod operations use the file descriptor rather than the path, to close the TOCTOU window where the path could be replaced between operations. O_NONBLOCK prevents a FIFO planted at the config path from blocking the open indefinitely; the regular-file check below then rejects it.
func ReadPrivateFile ¶
Read a file, first verifying that it can only be read by the current user.
func WritePrivateFile ¶
Make a private file that is only readable by the current user.
Types ¶
This section is empty.