Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ebuild backend #274

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

SUBDIRS = src init doc rules.d
SUBDIRS = src extra doc rules.d
EXTRA_DIST = ChangeLog AUTHORS NEWS README.md INSTALL fapolicyd.spec dnf/fapolicyd-dnf-plugin.py autogen.sh

clean-generic:
Expand Down
209 changes: 112 additions & 97 deletions README.md

Large diffs are not rendered by default.

15 changes: 13 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,20 @@ if test x$use_deb = xyes ; then
AC_CHECK_LIB(md, MD5Final, , [AC_MSG_ERROR([libmd is missing])], -lmd)
fi
AM_CONDITIONAL(WITH_DEB, test x$use_deb = xyes)

AM_CONDITIONAL(NEED_MD5, test x$use_deb = xyes)

withval=""
AC_ARG_WITH(ebuild,
AS_HELP_STRING([--with-ebuild],[Use the ebuild database as a trust source]),
use_ebuild=$withval,use_ebuild=no)

if test x$use_ebuild = xyes ; then

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use AS_IF. Bare if has issues with quoting and is no longer recommended in the autoconf manual.

AC_DEFINE(USE_EBUILD,1,[Define if you want to use the ebuild database as trust source.])
AC_CHECK_LIB(md, MD5Final, , [AC_MSG_ERROR([libmd is missing])], -lmd)
fi
AM_CONDITIONAL(WITH_EBUILD, test x$use_ebuild = xyes)
AM_CONDITIONAL(NEED_MD5, test x$use_ebuild = xyes)

dnl FIXME some day pass this on the command line
def_systemdsystemunitdir=${prefix}/lib/systemd/system
AC_SUBST([systemdsystemunitdir], [$def_systemdsystemunitdir])
Expand All @@ -177,7 +188,7 @@ AC_CHECK_LIB(lmdb, mdb_env_create, , [AC_MSG_ERROR([liblmdb not found])], -llmdb

LD_SO_PATH

AC_CONFIG_FILES([Makefile src/Makefile src/tests/Makefile init/Makefile doc/Makefile rules.d/Makefile])
AC_CONFIG_FILES([Makefile src/Makefile src/tests/Makefile extra/Makefile doc/Makefile rules.d/Makefile])
AC_OUTPUT

echo .
Expand Down
38 changes: 38 additions & 0 deletions extra/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
EXTRA_DIST = \
data/fapolicyd-filter.conf \
data/fapolicyd.conf \
data/fapolicyd.trust \
openrc/conf.d/fapolicyd \
openrc/init.d/fapolicyd \
systemd/fapolicyd.service \
fapolicyd-tmpfiles.conf \
fapolicyd-magic \
fapolicyd.bash_completion \
fagenrules

fapolicyddir = $(sysconfdir)/fapolicyd

dist_fapolicyd_DATA = \
data/fapolicyd.conf \
data/fapolicyd-filter.conf \
data/fapolicyd.trust

systemdservicedir = $(systemdsystemunitdir)
dist_systemdservice_DATA = systemd/fapolicyd.service

openrcinitdir = $(sysconfdir)/init.d
dist_openrcinit_DATA = openrc/init.d/fapolicyd
openrcconfdir = $(sysconfdir)/conf.d
dist_openrcconf_DATA = openrc/conf.d/fapolicyd

sbin_SCRIPTS = fagenrules

completiondir = $(sysconfdir)/bash_completion.d/
dist_completion_DATA = fapolicyd.bash_completion

MAGIC = fapolicyd-magic.mgc
pkgdata_DATA = ${MAGIC}
CLEANFILES = ${MAGIC}

${MAGIC}: $(EXTRA_DIST)
file -C -m ${top_srcdir}/extra/fapolicyd-magic
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion init/fapolicyd-magic → extra/fapolicyd-magic
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
0 string/wt #!\ /bin/rc Plan 9 shell script text executable
!:mime text/x-plan9-shellscript

0 string/wb #!\ /usr/bin/ocamlrun Ocaml byte-compiled executable
0 string/wb #!\ /usr/bin/ocamlrun Ocaml byte-compiled executable
!:mime application/x-bytecode.ocaml

0 string/wt #!\ /usr/bin/lua Lua script text executable
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions extra/openrc/conf.d/fapolicyd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fapolicyd_opts="--permissive --debug"
19 changes: 19 additions & 0 deletions extra/openrc/init.d/fapolicyd
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/sbin/openrc-run

name=$RC_SVCNAME
cfgfile="/etc/$RC_SVCNAME/$RC_SVCNAME.conf"
command="/usr/sbin/fapolicyd"
command_args="${fapolicyd_opts}"
command_user="fapolicyd"
pidfile="/run/$RC_SVCNAME/$RC_SVCNAME.pid"

# Depend on local disks being mounted
depend() {
need localmount
}

# Before starting the service update the rulesfile in /etc/fapolicyd
# from the fragments in /etc/fapolicyd/rules.d
start_pre() {
/usr/sbin/fagenrules
}
File renamed without changes.
4 changes: 3 additions & 1 deletion fapolicyd.spec
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ popd

%install
%make_install
install -p -m 644 -D init/%{name}-tmpfiles.conf %{buildroot}/%{_tmpfilesdir}/%{name}.conf
install -p -m 644 -D extra/%{name}-tmpfiles.conf %{buildroot}/%{_tmpfilesdir}/%{name}.conf
mkdir -p %{buildroot}/%{_localstatedir}/lib/%{name}
mkdir -p %{buildroot}/run/%{name}
mkdir -p %{buildroot}%{_sysconfdir}/%{name}/trust.d
Expand Down Expand Up @@ -254,6 +254,8 @@ fi
%attr(644,root,%{name}) %{_datadir}/%{name}/default-ruleset.known-libs
%attr(644,root,%{name}) %{_datadir}/%{name}/sample-rules/*
%attr(644,root,%{name}) %{_datadir}/%{name}/fapolicyd-magic.mgc
%exclude %{_sysconfdir}/init.d/%{name}
%exclude %{_sysconfdir}/conf.d/%{name}
%attr(750,root,%{name}) %dir %{_sysconfdir}/%{name}
%attr(750,root,%{name}) %dir %{_sysconfdir}/%{name}/trust.d
%attr(750,root,%{name}) %dir %{_sysconfdir}/%{name}/rules.d
Expand Down
31 changes: 0 additions & 31 deletions init/Makefile.am

This file was deleted.

18 changes: 14 additions & 4 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,26 @@ libfapolicyd_la_SOURCES += \

endif

if NEED_MD5
libfapolicyd_la_SOURCES += \
library/md5-backend.c \
library/md5-backend.h
endif

if WITH_DEB
libfapolicyd_la_SOURCES += library/deb-backend.c
libfapolicyd_la_SOURCES += library/deb-backend.c \
library/md5-backend.c \
library/md5-backend.h
fapolicyd_CFLAGS += -DLIBDPKG_VOLATILE_API
fapolicyd_LDFLAGS += -ldpkg
endif

if NEED_MD5
libfapolicyd_la_SOURCES += \
if WITH_EBUILD
libfapolicyd_la_SOURCES += library/ebuild-backend.c \
library/md5-backend.c \
Kangie marked this conversation as resolved.
Show resolved Hide resolved
library/md5-backend.h
library/md5-backend.h \
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since WITH_EBUILD pulls in NEED_MD5 now, this should be removable. I would similarly suggest that WITH_DEB should be checked to ensure it does, and remove that from the WITH_DEB chunk as well.

library/filter.c \
library/filter.h
endif

fapolicyd_cli_CFLAGS = $(fapolicyd_CFLAGS)
Expand Down
7 changes: 6 additions & 1 deletion src/library/backend-manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ extern backend rpm_backend;
#ifdef USE_DEB
extern backend deb_backend;
#endif
#ifdef USE_EBUILD
extern backend ebuild_backend;
#endif

static backend* compiled[] =
{
Expand All @@ -49,6 +52,9 @@ static backend* compiled[] =
#endif
#ifdef USE_DEB
&deb_backend,
#endif
#ifdef USE_EBUILD
&ebuild_backend,
#endif
NULL,
};
Expand Down Expand Up @@ -167,4 +173,3 @@ backend_entry* backend_get_first(void)
{
return backends;
}

2 changes: 2 additions & 0 deletions src/library/database.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ const char *lookup_tsource(unsigned int tsource)
return "rpmdb";
case SRC_DEB:
return "debdb";
case SRC_EBUILD:
return "ebuilddb";
case SRC_FILE_DB:
return "filedb";
}
Expand Down
Loading
Loading