2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-29 13:28:19 +00:00

Merge libapparamor: Define a portable version of gnu basename

Since musl 1.2.5, basename(3) prototype is only provided in libgen.h
(as mandated by POSIX) and not in strings.h. Also there is a major
difference between the gnu basename and the one defined in libgen.h,
the latter modify the argument string making them incompatible.

Fix this by defining a portable version of basename using strchr.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1234
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: Georgia Garcia <georgia.garcia@canonical.com>
This commit is contained in:
Georgia Garcia 2024-05-17 07:16:04 +00:00
commit 452f7fa739

View File

@ -1,5 +1,3 @@
#define _GNU_SOURCE /* for glibc's basename version */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -7,6 +5,12 @@
#include <aalogparse.h>
static const char *basename(const char *path)
{
const char *p = strrchr(path, '/');
return p ? p + 1 : path;
}
int print_results(aa_log_record *record);
int main(int argc, char **argv)