mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-22 10:07:12 +00:00
* fix small memory leak in parser_main.c
* fixup instances of my inability to spell separator * minor code formatting cleanup in parser_lex.l
This commit is contained in:
parent
ed86641695
commit
da52731c75
@ -186,7 +186,7 @@ void parse_default_paths(void)
|
||||
while (fgetline(f, buf, 1024)) {
|
||||
if (stripcomment(buf) && (t = strstr(buf, "SUBDOMAIN_PATH="))) {
|
||||
t += 15;
|
||||
/* handle : seperating path elements */
|
||||
/* handle : separating path elements */
|
||||
do {
|
||||
s = strchr(t, ':');
|
||||
if (s)
|
||||
|
@ -78,13 +78,15 @@ void include_filename(char *filename, int search)
|
||||
struct stat my_stat;
|
||||
char *fullpath = NULL;
|
||||
|
||||
if (search) include_file = search_path(filename, &fullpath);
|
||||
else {
|
||||
if (search) {
|
||||
include_file = search_path(filename, &fullpath);
|
||||
} else {
|
||||
fullpath = strdup(filename);
|
||||
include_file = fopen(fullpath, "r");
|
||||
}
|
||||
|
||||
if (!include_file) yyerror(_("Could not open '%s'"), fullpath);
|
||||
if (!include_file)
|
||||
yyerror(_("Could not open '%s'"), fullpath);
|
||||
|
||||
if (fstat(fileno(include_file), &my_stat))
|
||||
yyerror(_("fstat failed for '%s'"), fullpath);
|
||||
@ -113,8 +115,9 @@ void include_filename(char *filename, int search)
|
||||
if (dirent->d_name[0] == '.')
|
||||
continue;
|
||||
|
||||
if (dirent_path) free(dirent_path);
|
||||
if (asprintf(&dirent_path, "%s/%s", fullpath, dirent->d_name)<0)
|
||||
if (dirent_path)
|
||||
free(dirent_path);
|
||||
if (asprintf(&dirent_path, "%s/%s", fullpath, dirent->d_name) < 0)
|
||||
yyerror("Out of memory");
|
||||
|
||||
name_len = strlen(dirent->d_name);
|
||||
@ -137,10 +140,11 @@ void include_filename(char *filename, int search)
|
||||
if (!(yyin = fopen(dirent_path,"r")))
|
||||
yyerror(_("Could not open '%s'"), filename);
|
||||
PDEBUG("Opened include \"%s\"\n", filename);
|
||||
yypush_buffer_state(yy_create_buffer( yyin, YY_BUF_SIZE ));
|
||||
yypush_buffer_state(yy_create_buffer(yyin, YY_BUF_SIZE));
|
||||
}
|
||||
}
|
||||
if (dirent_path) free(dirent_path);
|
||||
if (dirent_path)
|
||||
free(dirent_path);
|
||||
closedir(dir);
|
||||
}
|
||||
}
|
||||
@ -153,7 +157,7 @@ CLOSE_BRACE \}
|
||||
SLASH \/
|
||||
COLON :
|
||||
END_OF_RULE [,]
|
||||
SEPERATOR {UP}
|
||||
SEPARATOR {UP}
|
||||
RANGE -
|
||||
MODE_CHARS ([RrWwaLlMmkXx])|(([Uu]|[Pp]|[Cc])[Xx])|(([Pp]|[Cc])?[Ii][Xx])
|
||||
MODES {MODE_CHARS}+
|
||||
@ -231,7 +235,7 @@ LT_EQUAL <=
|
||||
* without any spaces in between (because it's
|
||||
* a longer match). So now, when I want to
|
||||
* match any random string, I go into a
|
||||
* seperate state. */
|
||||
* separate state. */
|
||||
yylval = (YYSTYPE) processunquoted(yytext, yyleng);
|
||||
PDEBUG("Found sub name: \"%s\"\n", yylval);
|
||||
BEGIN(INITIAL);
|
||||
@ -244,7 +248,7 @@ LT_EQUAL <=
|
||||
* without any spaces in between (because it's
|
||||
* a longer match). So now, when I want to
|
||||
* match any random string, I go into a
|
||||
* seperate state. */
|
||||
* separate state. */
|
||||
yylval = (YYSTYPE) processquoted(yytext, yyleng);
|
||||
PDEBUG("Found sub name: \"%s\"\n", yylval);
|
||||
BEGIN(INITIAL);
|
||||
@ -265,7 +269,7 @@ LT_EQUAL <=
|
||||
* without any spaces in between (because it's
|
||||
* a longer match). So now, when I want to
|
||||
* match any random string, I go into a
|
||||
* seperate state. */
|
||||
* separate state. */
|
||||
yylval = (YYSTYPE) processunquoted(yytext, yyleng);
|
||||
PDEBUG("Found sub name: \"%s\"\n", yylval);
|
||||
BEGIN(INITIAL);
|
||||
@ -278,7 +282,7 @@ LT_EQUAL <=
|
||||
* without any spaces in between (because it's
|
||||
* a longer match). So now, when I want to
|
||||
* match any random string, I go into a
|
||||
* seperate state. */
|
||||
* separate state. */
|
||||
yylval = (YYSTYPE) processquoted(yytext, yyleng);
|
||||
PDEBUG("Found sub name: \"%s\"\n", yylval);
|
||||
BEGIN(INITIAL);
|
||||
@ -384,7 +388,7 @@ LT_EQUAL <=
|
||||
* without any spaces in between (because it's
|
||||
* a longer match). So now, when I want to
|
||||
* match any random string, I go into a
|
||||
* seperate state. */
|
||||
* separate state. */
|
||||
yylval = (YYSTYPE) processunquoted(yytext, yyleng);
|
||||
PDEBUG("Found sub name: \"%s\"\n", yylval);
|
||||
BEGIN(INITIAL);
|
||||
@ -397,7 +401,7 @@ LT_EQUAL <=
|
||||
* without any spaces in between (because it's
|
||||
* a longer match). So now, when I want to
|
||||
* match any random string, I go into a
|
||||
* seperate state. */
|
||||
* separate state. */
|
||||
yylval = (YYSTYPE) processquoted(yytext, yyleng);
|
||||
PDEBUG("Found sub name: \"%s\"\n", yylval);
|
||||
BEGIN(INITIAL);
|
||||
@ -425,8 +429,8 @@ LT_EQUAL <=
|
||||
|
||||
{END_OF_RULE} { return TOK_END_OF_RULE; }
|
||||
|
||||
{SEPERATOR} {
|
||||
PDEBUG("Matched a seperator\n");
|
||||
{SEPARATOR} {
|
||||
PDEBUG("Matched a separator\n");
|
||||
yylval = (YYSTYPE) yytext;
|
||||
BEGIN(SUB_NAME);
|
||||
return TOK_SEP;
|
||||
|
@ -427,6 +427,7 @@ static void get_flags_string(void) {
|
||||
//fprintf(stderr, "flags string: %s\n", flags_string);
|
||||
//fprintf(stderr, "changehat %d\n", flag_changehat_version);
|
||||
}
|
||||
free(flags_string);
|
||||
return;
|
||||
|
||||
fail:
|
||||
|
@ -86,9 +86,6 @@ SD_EV_PIDFILE=/var/run/sd-event-dispatch.init.pid
|
||||
SD_STATUS=/usr/sbin/subdomain_status
|
||||
SECURITYFS=/sys/kernel/security
|
||||
|
||||
SUBDOMAINFS_MOUNTPOINT=$(grep subdomainfs /etc/fstab | \
|
||||
sed -e 's|^[[:space:]]*[^[:space:]]\+[[:space:]]\+\(/[^[:space:]]*\)[[:space:]]\+subdomainfs.*$|\1|' 2> /dev/null)
|
||||
|
||||
if [ -d "/var/lib/${MODULE}" ] ; then
|
||||
APPARMOR_TMPDIR="/var/lib/${MODULE}"
|
||||
elif [ -d "/var/lib/${OLD_MODULE}" ] ; then
|
||||
@ -103,21 +100,9 @@ STATUS=0
|
||||
|
||||
# Test if the apparmor "module" is present.
|
||||
is_apparmor_present() {
|
||||
local modules=$1
|
||||
shift
|
||||
|
||||
while [ $# -gt 0 ] ; do
|
||||
modules="$modules|$1"
|
||||
shift
|
||||
done
|
||||
|
||||
# check for subdomainfs version of module
|
||||
grep -qE "^($modules)[[:space:]]" /proc/modules
|
||||
|
||||
if [ $? -ne 0 ] ; then
|
||||
ls /sys/module/apparmor 2>/dev/null | grep -qE "^($modules)"
|
||||
fi
|
||||
local module=$1
|
||||
|
||||
test -d "/sys/module/$module"
|
||||
return $?
|
||||
}
|
||||
|
||||
@ -256,13 +241,8 @@ is_apparmor_loaded() {
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ -f "${SUBDOMAINFS_MOUNTPOINT}/profiles" ]; then
|
||||
SFS_MOUNTPOINT=${SUBDOMAINFS_MOUNTPOINT}
|
||||
return 0
|
||||
fi
|
||||
|
||||
# check for subdomainfs version of module
|
||||
is_apparmor_present apparmor subdomain
|
||||
is_apparmor_present ${MODULE}
|
||||
|
||||
return $?
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user