Skip to content

Commit 00411ce

Browse files
committed
fix(cli): handle trusted Linux system aliases during install activation
Signed-off-by: DavidHLP <144919470+DavidHLP@users.noreply.github.com>
1 parent 0b51555 commit 00411ce

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

‎src/cli/activation_transaction.c‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -890,8 +890,12 @@ static bool activation_posix_acl_empty(int descriptor) {
890890
}
891891

892892
static char *activation_posix_walk_path(const char *directory) {
893-
#ifdef __APPLE__
894-
static const char *const aliases[] = {"/tmp", "/var"};
893+
#if defined(__APPLE__) || defined(__linux__)
894+
/* macOS and immutable Linux layouts can expose writable trees through
895+
* root-owned aliases (for example /tmp and /home on Atomic systems).
896+
* Resolve only these trusted system aliases; arbitrary user symlinks must
897+
* still fail the O_NOFOLLOW walk below. */
898+
static const char *const aliases[] = {"/tmp", "/var", "/home"};
895899
for (size_t index = 0; index < sizeof(aliases) / sizeof(aliases[0]); index++) {
896900
const char *alias = aliases[index];
897901
size_t alias_length = strlen(alias);
@@ -901,8 +905,13 @@ static char *activation_posix_walk_path(const char *directory) {
901905
}
902906
struct stat alias_status;
903907
char resolved[4096];
904-
if (lstat(alias, &alias_status) != 0 || !S_ISLNK(alias_status.st_mode) ||
905-
alias_status.st_uid != 0 || !realpath(alias, resolved)) {
908+
if (lstat(alias, &alias_status) != 0) {
909+
return NULL;
910+
}
911+
if (!S_ISLNK(alias_status.st_mode)) {
912+
continue;
913+
}
914+
if (alias_status.st_uid != 0 || !realpath(alias, resolved)) {
906915
return NULL;
907916
}
908917
struct stat resolved_status;

0 commit comments

Comments
 (0)