Skip to content

Commit 33bb058

Browse files
committed
fix(daemon): scope the /home log-path alias to FreeBSD only
private_log_directory_path_copy shared the /home root-owned alias between __APPLE__ and __FreeBSD__. macOS never needed /home resolved in this security-sensitive step; split the alias list so Darwin keeps {/tmp, /var} and only FreeBSD gains /home -> /usr/home. Signed-off-by: Pedro Ramos <131530838+pr9000@users.noreply.github.com>
1 parent 4ed8d38 commit 33bb058

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

‎src/daemon/ipc.c‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,12 +1337,18 @@ static bool private_log_base_name_valid(const char *base_name) {
13371337
}
13381338

13391339
static char *private_log_directory_path_copy(const char *directory_path) {
1340-
#ifdef __APPLE__
1341-
/* Darwin exposes the trusted top-level aliases /tmp -> /private/tmp and
1342-
* /var -> /private/var. Resolve only those root-owned aliases before the
1340+
#if defined(__APPLE__) || defined(__FreeBSD__)
1341+
/* Resolve only those root-owned aliases before the
13431342
* component-wise O_NOFOLLOW walk. Canonicalizing the complete caller path
13441343
* would follow an attacker-controlled cache/log symlink and is forbidden. */
1344+
#if defined(__APPLE__)
1345+
/* Darwin exposes the trusted top-level aliases /tmp -> /private/tmp and
1346+
* /var -> /private/var. */
13451347
static const char *const aliases[] = {"/tmp", "/var"};
1348+
#else
1349+
/* FreeBSD additionally exposes /home -> /usr/home as a root-owned alias. */
1350+
static const char *const aliases[] = {"/tmp", "/var", "/home"};
1351+
#endif
13461352
for (size_t index = 0; index < sizeof(aliases) / sizeof(aliases[0]); index++) {
13471353
const char *alias = aliases[index];
13481354
size_t alias_length = strlen(alias);

0 commit comments

Comments
 (0)