Skip to content

Commit 5b4be65

Browse files
authored
Merge pull request DeusData#2203 from DavidHLP/fix/issue-2175
fix(cli): handle trusted Linux system aliases during install activation
2 parents 36f7708 + e176ae5 commit 5b4be65

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

‎src/cli/activation_transaction.c‎

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

892892
static char *activation_posix_walk_path(const char *directory) {
893-
#ifdef __APPLE__
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+
#ifdef __linux__
899+
static const char *const aliases[] = {"/tmp", "/var", "/home"};
900+
#else
894901
static const char *const aliases[] = {"/tmp", "/var"};
902+
#endif
895903
for (size_t index = 0; index < sizeof(aliases) / sizeof(aliases[0]); index++) {
896904
const char *alias = aliases[index];
897905
size_t alias_length = strlen(alias);
@@ -901,8 +909,13 @@ static char *activation_posix_walk_path(const char *directory) {
901909
}
902910
struct stat alias_status;
903911
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)) {
912+
if (lstat(alias, &alias_status) != 0) {
913+
continue;
914+
}
915+
if (!S_ISLNK(alias_status.st_mode)) {
916+
continue;
917+
}
918+
if (alias_status.st_uid != 0 || !realpath(alias, resolved)) {
906919
return NULL;
907920
}
908921
struct stat resolved_status;

0 commit comments

Comments
 (0)