mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 06:06:02 -06:00
landlock: fix profile entries processed in reverse
When a new landlock entry is parsed from a profile, the first entry in
the `cfg.lprofile` list is being set as the next/second entry and the
new entry is being set as the first entry in the list, so all entries
are being processed from last to first.
This commit makes the behavior of ll_add_profile() match the one from
profile_add() in src/firejail/profile.c so that the entries are
processed in the same order that they are parsed.
This amends commit b94cc754a ("landlock: apply rules in sandbox before
app start", 2023-10-26).
This commit is contained in:
parent
87af6c8eaa
commit
5c7150a21a
1 changed files with 16 additions and 8 deletions
|
|
@ -280,16 +280,24 @@ void ll_add_profile(int type, const char *data) {
|
|||
while (*data == ' ' || *data == '\t')
|
||||
data++;
|
||||
|
||||
LandlockEntry *ptr = malloc(sizeof(LandlockEntry));
|
||||
if (!ptr)
|
||||
LandlockEntry *entry = malloc(sizeof(LandlockEntry));
|
||||
if (!entry)
|
||||
errExit("malloc");
|
||||
memset(ptr, 0, sizeof(LandlockEntry));
|
||||
ptr->type = type;
|
||||
ptr->data = strdup(data);
|
||||
if (!ptr->data)
|
||||
memset(entry, 0, sizeof(LandlockEntry));
|
||||
entry->type = type;
|
||||
entry->data = strdup(data);
|
||||
if (!entry->data)
|
||||
errExit("strdup");
|
||||
ptr->next = cfg.lprofile;
|
||||
cfg.lprofile = ptr;
|
||||
|
||||
// add entry to the list
|
||||
if (cfg.lprofile == NULL) {
|
||||
cfg.lprofile = entry;
|
||||
return;
|
||||
}
|
||||
LandlockEntry *ptr = cfg.lprofile;
|
||||
while (ptr->next != NULL)
|
||||
ptr = ptr->next;
|
||||
ptr->next = entry;
|
||||
}
|
||||
|
||||
#endif /* HAVE_LANDLOCK */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue