mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-28 21:07:56 +00:00
use libapparmor's find mountpoint fn to find the interface
Drop support for the old subdomainfs mountpoint and use the fn exported by libapparmor. Signed-off-by: John Johansen <john.johansen@canonical.com> Acked-by: Seth Arnold <seth.arnold@canonical.com>
This commit is contained in:
parent
d22b985e3f
commit
f85bf5fa68
@ -86,6 +86,7 @@ AAREDIR= libapparmor_re
|
|||||||
AAREOBJECT = ${AAREDIR}/libapparmor_re.a
|
AAREOBJECT = ${AAREDIR}/libapparmor_re.a
|
||||||
AAREOBJECTS = $(AAREOBJECT) libstdc++.a
|
AAREOBJECTS = $(AAREOBJECT) libstdc++.a
|
||||||
AARE_LDFLAGS=-static-libgcc -L.
|
AARE_LDFLAGS=-static-libgcc -L.
|
||||||
|
AALIB = -lapparmor
|
||||||
|
|
||||||
LEX_C_FILES = parser_lex.c
|
LEX_C_FILES = parser_lex.c
|
||||||
YACC_C_FILES = parser_yacc.c parser_yacc.h
|
YACC_C_FILES = parser_yacc.c parser_yacc.h
|
||||||
@ -154,7 +155,7 @@ libstdc++.a:
|
|||||||
|
|
||||||
apparmor_parser: $(OBJECTS) $(AAREOBJECTS)
|
apparmor_parser: $(OBJECTS) $(AAREOBJECTS)
|
||||||
$(CXX) $(LDFLAGS) $(EXTRA_CFLAGS) -o $@ $(OBJECTS) $(LIBS) \
|
$(CXX) $(LDFLAGS) $(EXTRA_CFLAGS) -o $@ $(OBJECTS) $(LIBS) \
|
||||||
${LEXLIB} $(AAREOBJECTS) $(AARE_LDFLAGS)
|
${LEXLIB} $(AAREOBJECTS) $(AARE_LDFLAGS) $(AALIB)
|
||||||
|
|
||||||
parser_yacc.c parser_yacc.h: parser_yacc.y parser.h profile.h
|
parser_yacc.c parser_yacc.h: parser_yacc.y parser.h profile.h
|
||||||
$(YACC) $(YFLAGS) -o parser_yacc.c parser_yacc.y
|
$(YACC) $(YFLAGS) -o parser_yacc.c parser_yacc.y
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <mntent.h>
|
|
||||||
#include <libintl.h>
|
#include <libintl.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
@ -42,6 +41,7 @@
|
|||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <sys/apparmor.h>
|
||||||
|
|
||||||
#include "lib.h"
|
#include "lib.h"
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
@ -607,58 +607,10 @@ static int process_config_file(const char *name)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline char *try_subdomainfs_mountpoint(const char *mntpnt,
|
|
||||||
const char *path)
|
|
||||||
{
|
|
||||||
char *proposed_base = NULL;
|
|
||||||
char *retval = NULL;
|
|
||||||
struct stat buf;
|
|
||||||
|
|
||||||
if (asprintf(&proposed_base, "%s%s", mntpnt, path)<0 || !proposed_base) {
|
|
||||||
PERROR(_("%s: Could not allocate memory for subdomainbase mount point\n"),
|
|
||||||
progname);
|
|
||||||
exit(ENOMEM);
|
|
||||||
}
|
|
||||||
if (stat(proposed_base, &buf) == 0) {
|
|
||||||
retval = proposed_base;
|
|
||||||
} else {
|
|
||||||
free(proposed_base);
|
|
||||||
}
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
int find_subdomainfs_mountpoint(void)
|
int find_subdomainfs_mountpoint(void)
|
||||||
{
|
{
|
||||||
FILE *mntfile;
|
if (aa_find_mountpoint(&subdomainbase) == -1) {
|
||||||
struct mntent *mntpt;
|
|
||||||
|
|
||||||
if ((mntfile = setmntent(MOUNTED_FS, "r"))) {
|
|
||||||
while ((mntpt = getmntent(mntfile))) {
|
|
||||||
char *proposed = NULL;
|
|
||||||
if (strcmp(mntpt->mnt_type, "securityfs") == 0) {
|
|
||||||
proposed = try_subdomainfs_mountpoint(mntpt->mnt_dir, "/" MODULE_NAME);
|
|
||||||
if (proposed != NULL) {
|
|
||||||
subdomainbase = proposed;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
proposed = try_subdomainfs_mountpoint(mntpt->mnt_dir, "/" OLD_MODULE_NAME);
|
|
||||||
if (proposed != NULL) {
|
|
||||||
subdomainbase = proposed;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (strcmp(mntpt->mnt_type, "subdomainfs") == 0) {
|
|
||||||
proposed = try_subdomainfs_mountpoint(mntpt->mnt_dir, "");
|
|
||||||
if (proposed != NULL) {
|
|
||||||
subdomainbase = proposed;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
endmntent(mntfile);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!subdomainbase) {
|
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
if (stat(DEFAULT_APPARMORFS, &buf) == -1) {
|
if (stat(DEFAULT_APPARMORFS, &buf) == -1) {
|
||||||
PERROR(_("Warning: unable to find a suitable fs in %s, is it "
|
PERROR(_("Warning: unable to find a suitable fs in %s, is it "
|
||||||
@ -672,7 +624,6 @@ int find_subdomainfs_mountpoint(void)
|
|||||||
return (subdomainbase == NULL);
|
return (subdomainbase == NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int have_enough_privilege(void)
|
int have_enough_privilege(void)
|
||||||
{
|
{
|
||||||
uid_t uid, euid;
|
uid_t uid, euid;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user