Further adjust our plugins wrt the new hook system
- Make the hook functions static now that its possible - Directly include what the plugins need, dont include plugin.h - Eliminate now unnecessary plugin.h
This commit is contained in:
parent
2b840edcf5
commit
504bc846f1
|
@ -15,17 +15,17 @@ pluginsdir = $(libdir)/rpm-plugins
|
|||
|
||||
plugins_LTLIBRARIES = exec.la
|
||||
|
||||
exec_la_SOURCES = plugin.h exec.c
|
||||
exec_la_SOURCES = exec.c
|
||||
exec_la_LIBADD = $(top_builddir)/lib/librpm.la $(top_builddir)/rpmio/librpmio.la
|
||||
|
||||
if SELINUX
|
||||
selinux_la_SOURCES = plugin.h selinux.c
|
||||
selinux_la_SOURCES = selinux.c
|
||||
selinux_la_LIBADD = $(top_builddir)/lib/librpm.la $(top_builddir)/rpmio/librpmio.la @WITH_SELINUX_LIB@
|
||||
plugins_LTLIBRARIES += selinux.la
|
||||
|
||||
# XXX: merge this into selinux plugin, for now we need to disable
|
||||
# as it relies on in-core selinux knowledge which we no longer have...
|
||||
#sepolicy_la_SOURCES = plugin.h sepolicy.c
|
||||
#sepolicy_la_SOURCES = sepolicy.c
|
||||
#sepolicy_la_LIBADD = $(top_builddir)/lib/librpm.la $(top_builddir)/rpmio/librpmio.la @WITH_SELINUX_LIB@ @WITH_SEMANAGE_LIB@
|
||||
#plugins_LTLIBRARIES += sepolicy.la
|
||||
endif
|
||||
|
@ -37,6 +37,6 @@ systemd_inhibit_la_LIBADD = $(top_builddir)/lib/librpm.la $(top_builddir)/rpmio/
|
|||
plugins_LTLIBRARIES += systemd_inhibit.la
|
||||
endif
|
||||
|
||||
syslog_la_SOURCES = plugin.h syslog.c
|
||||
syslog_la_SOURCES = syslog.c
|
||||
syslog_la_LIBADD = $(top_builddir)/lib/librpm.la $(top_builddir)/rpmio/librpmio.la
|
||||
plugins_LTLIBRARIES += syslog.la
|
||||
|
|
|
@ -1,25 +1,28 @@
|
|||
#include "plugin.h"
|
||||
|
||||
#include "system.h"
|
||||
#include <sys/wait.h>
|
||||
#include <rpm/rpmlog.h>
|
||||
#include "lib/rpmplugins.h"
|
||||
#include "lib/rpmchroot.h"
|
||||
#include "debug.h"
|
||||
|
||||
static char * options;
|
||||
static char * name;
|
||||
|
||||
rpmRC PLUGINHOOK_INIT_FUNC(rpmts ts, const char *name, const char *opts)
|
||||
static rpmRC PLUGINHOOK_INIT_FUNC(rpmts ts, const char *name, const char *opts)
|
||||
{
|
||||
options = strdup(opts);
|
||||
name = strdup(name);
|
||||
return RPMRC_OK;
|
||||
}
|
||||
|
||||
rpmRC PLUGINHOOK_CLEANUP_FUNC(void)
|
||||
static rpmRC PLUGINHOOK_CLEANUP_FUNC(void)
|
||||
{
|
||||
options = _free(options);
|
||||
name = _free(name);
|
||||
return RPMRC_OK;
|
||||
}
|
||||
|
||||
rpmRC PLUGINHOOK_COLL_POST_ANY_FUNC(void)
|
||||
static rpmRC PLUGINHOOK_COLL_POST_ANY_FUNC(void)
|
||||
{
|
||||
rpmRC rc = RPMRC_FAIL;
|
||||
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
#include "system.h"
|
||||
|
||||
#include <rpm/rpmlib.h>
|
||||
#include <rpm/rpmlog.h>
|
||||
#include <rpm/rpmts.h>
|
||||
#include <rpm/rpmfi.h>
|
||||
|
||||
#include "lib/rpmplugins.h"
|
||||
#include "lib/rpmchroot.h"
|
||||
|
||||
/* general plugin hooks */
|
||||
rpmRC PLUGINHOOK_INIT_FUNC(rpmts ts, const char * name, const char * opts);
|
||||
rpmRC PLUGINHOOK_CLEANUP_FUNC(void);
|
||||
|
||||
/* collection plugin hooks */
|
||||
rpmRC PLUGINHOOK_OPENTE_FUNC(rpmte te);
|
||||
rpmRC PLUGINHOOK_COLL_POST_ANY_FUNC(void);
|
||||
rpmRC PLUGINHOOK_COLL_POST_ADD_FUNC(void);
|
||||
rpmRC PLUGINHOOK_COLL_PRE_REMOVE_FUNC(void);
|
||||
|
||||
/* per transaction plugin hooks */
|
||||
rpmRC PLUGINHOOK_TSM_PRE_FUNC(rpmts ts);
|
||||
rpmRC PLUGINHOOK_TSM_POST_FUNC(rpmts ts, int res);
|
||||
|
||||
/* per transaction element plugin hooks */
|
||||
rpmRC PLUGINHOOK_PSM_PRE_FUNC(rpmte te);
|
||||
rpmRC PLUGINHOOK_PSM_POST_FUNC(rpmte te, int res);
|
||||
|
||||
/*per scriptlet plugin hooks */
|
||||
rpmRC PLUGINHOOK_SCRIPTLET_PRE_FUNC(const char *s_name, int type);
|
||||
rpmRC PLUGINHOOK_SCRIPTLET_FORK_POST_FUNC(const char *path, int type);
|
||||
rpmRC PLUGINHOOK_SCRIPTLET_POST_FUNC(const char *s_name, int type, int res);
|
||||
|
||||
/*per file plugin hooks */
|
||||
rpmRC PLUGINHOOK_FSM_FILE_PRE_FUNC(const char* path, mode_t file_mode, rpmFsmOp op);
|
||||
rpmRC PLUGINHOOK_FSM_FILE_POST_FUNC(const char* path, mode_t file_mode, rpmFsmOp op, int res);
|
||||
rpmRC PLUGINHOOK_FSM_FILE_PREPARE_FUNC(const char *path, const char *dest, mode_t file_mode, rpmFsmOp op);
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
#include <selinux/avc.h>
|
||||
#include <rpm/rpmlog.h>
|
||||
#include <rpm/rpmts.h>
|
||||
#include "plugin.h"
|
||||
#include "lib/rpmplugins.h"
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
|
@ -51,17 +51,17 @@ static rpmRC sehandle_init(int open_status)
|
|||
return (sehandle != NULL) ? RPMRC_OK : RPMRC_FAIL;
|
||||
}
|
||||
|
||||
rpmRC PLUGINHOOK_INIT_FUNC(rpmts ts, const char *name, const char *opts)
|
||||
static rpmRC PLUGINHOOK_INIT_FUNC(rpmts ts, const char *name, const char *opts)
|
||||
{
|
||||
return RPMRC_OK;
|
||||
}
|
||||
|
||||
rpmRC PLUGINHOOK_CLEANUP_FUNC(void)
|
||||
static rpmRC PLUGINHOOK_CLEANUP_FUNC(void)
|
||||
{
|
||||
return RPMRC_OK;
|
||||
}
|
||||
|
||||
rpmRC PLUGINHOOK_TSM_PRE_FUNC(rpmts ts)
|
||||
static rpmRC PLUGINHOOK_TSM_PRE_FUNC(rpmts ts)
|
||||
{
|
||||
rpmRC rc = RPMRC_OK;
|
||||
|
||||
|
@ -78,7 +78,7 @@ rpmRC PLUGINHOOK_TSM_PRE_FUNC(rpmts ts)
|
|||
return rc;
|
||||
}
|
||||
|
||||
rpmRC PLUGINHOOK_TSM_POST_FUNC(rpmts ts, int rc)
|
||||
static rpmRC PLUGINHOOK_TSM_POST_FUNC(rpmts ts, int rc)
|
||||
{
|
||||
if (sehandle) {
|
||||
sehandle_fini(1);
|
||||
|
@ -86,7 +86,7 @@ rpmRC PLUGINHOOK_TSM_POST_FUNC(rpmts ts, int rc)
|
|||
return RPMRC_OK;
|
||||
}
|
||||
|
||||
rpmRC PLUGINHOOK_PSM_PRE_FUNC(rpmte te)
|
||||
static rpmRC PLUGINHOOK_PSM_PRE_FUNC(rpmte te)
|
||||
{
|
||||
rpmRC rc = RPMRC_OK;
|
||||
|
||||
|
@ -97,7 +97,7 @@ rpmRC PLUGINHOOK_PSM_PRE_FUNC(rpmte te)
|
|||
return rc;
|
||||
}
|
||||
|
||||
rpmRC PLUGINHOOK_SCRIPTLET_FORK_POST_FUNC(const char *path, int type)
|
||||
static rpmRC PLUGINHOOK_SCRIPTLET_FORK_POST_FUNC(const char *path, int type)
|
||||
{
|
||||
rpmRC rc = RPMRC_FAIL;
|
||||
security_context_t mycon = NULL, fcon = NULL, newcon = NULL;
|
||||
|
@ -145,7 +145,7 @@ exit:
|
|||
return rc;
|
||||
}
|
||||
|
||||
rpmRC PLUGINHOOK_FSM_FILE_PREPARE_FUNC(const char *path, const char *dest,
|
||||
static rpmRC PLUGINHOOK_FSM_FILE_PREPARE_FUNC(const char *path, const char *dest,
|
||||
mode_t file_mode, rpmFsmOp op)
|
||||
{
|
||||
rpmRC rc = RPMRC_FAIL; /* assume failure */
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include "plugin.h"
|
||||
|
||||
#include "system.h"
|
||||
#include <errno.h>
|
||||
#include <selinux/selinux.h>
|
||||
#include <semanage/semanage.h>
|
||||
|
@ -10,9 +9,15 @@
|
|||
#include <rpm/rpmfileutil.h>
|
||||
#include <rpm/rpmmacro.h>
|
||||
#include <rpm/rpmbase64.h>
|
||||
#include <rpm/rpmts.h>
|
||||
#include <rpm/rpmlog.h>
|
||||
#include <rpm/header.h>
|
||||
|
||||
#include "lib/rpmte_internal.h"
|
||||
#include "lib/rpmts_internal.h" /* rpmtsSELabelFoo() */
|
||||
#include "lib/rpmchroot.h"
|
||||
#include "lib/rpmplugins.h"
|
||||
#include "debug.h"
|
||||
|
||||
typedef enum sepolAction {
|
||||
SEPOL_ACTION_IGNORE,
|
||||
|
@ -616,7 +621,7 @@ static rpmRC sepolAddTE(rpmte te)
|
|||
|
||||
|
||||
|
||||
rpmRC PLUGINHOOK_INIT_FUNC(rpmts _ts, const char *_name, const char *_opts)
|
||||
static rpmRC PLUGINHOOK_INIT_FUNC(rpmts _ts, const char *_name, const char *_opts)
|
||||
{
|
||||
ts = _ts;
|
||||
name = strdup(_name);
|
||||
|
@ -624,7 +629,7 @@ rpmRC PLUGINHOOK_INIT_FUNC(rpmts _ts, const char *_name, const char *_opts)
|
|||
return RPMRC_OK;
|
||||
}
|
||||
|
||||
rpmRC PLUGINHOOK_CLEANUP_FUNC(void)
|
||||
static rpmRC PLUGINHOOK_CLEANUP_FUNC(void)
|
||||
{
|
||||
_free(name);
|
||||
ts = NULL;
|
||||
|
@ -632,17 +637,17 @@ rpmRC PLUGINHOOK_CLEANUP_FUNC(void)
|
|||
return RPMRC_OK;
|
||||
}
|
||||
|
||||
rpmRC PLUGINHOOK_OPENTE_FUNC(rpmte te)
|
||||
static rpmRC PLUGINHOOK_OPENTE_FUNC(rpmte te)
|
||||
{
|
||||
return sepolAddTE(te);
|
||||
}
|
||||
|
||||
rpmRC PLUGINHOOK_COLL_POST_ADD_FUNC(void)
|
||||
static rpmRC PLUGINHOOK_COLL_POST_ADD_FUNC(void)
|
||||
{
|
||||
return sepolGo();
|
||||
}
|
||||
|
||||
rpmRC PLUGINHOOK_COLL_PRE_REMOVE_FUNC(void)
|
||||
static rpmRC PLUGINHOOK_COLL_PRE_REMOVE_FUNC(void)
|
||||
{
|
||||
return sepolGo();
|
||||
}
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
#include <syslog.h>
|
||||
|
||||
#include "plugin.h"
|
||||
#include <rpm/rpmts.h>
|
||||
#include "lib/rpmplugins.h"
|
||||
|
||||
static int logging = 0;
|
||||
static unsigned int scriptfail = 0;
|
||||
static unsigned int pkgfail = 0;
|
||||
|
||||
rpmRC PLUGINHOOK_INIT_FUNC(rpmts ts, const char * name, const char * opts)
|
||||
static rpmRC PLUGINHOOK_INIT_FUNC(rpmts ts, const char * name, const char * opts)
|
||||
{
|
||||
/* XXX make this configurable? */
|
||||
const char * log_ident = "[RPM]";
|
||||
|
@ -15,13 +16,13 @@ rpmRC PLUGINHOOK_INIT_FUNC(rpmts ts, const char * name, const char * opts)
|
|||
return RPMRC_OK;
|
||||
}
|
||||
|
||||
rpmRC PLUGINHOOK_CLEANUP_FUNC(void)
|
||||
static rpmRC PLUGINHOOK_CLEANUP_FUNC(void)
|
||||
{
|
||||
closelog();
|
||||
return RPMRC_OK;
|
||||
}
|
||||
|
||||
rpmRC PLUGINHOOK_TSM_PRE_FUNC(rpmts ts)
|
||||
static rpmRC PLUGINHOOK_TSM_PRE_FUNC(rpmts ts)
|
||||
{
|
||||
/* Reset counters */
|
||||
scriptfail = 0;
|
||||
|
@ -45,7 +46,7 @@ rpmRC PLUGINHOOK_TSM_PRE_FUNC(rpmts ts)
|
|||
return RPMRC_OK;
|
||||
}
|
||||
|
||||
rpmRC PLUGINHOOK_TSM_POST_FUNC(rpmts ts, int res)
|
||||
static rpmRC PLUGINHOOK_TSM_POST_FUNC(rpmts ts, int res)
|
||||
{
|
||||
if (logging) {
|
||||
if (pkgfail || scriptfail) {
|
||||
|
@ -60,7 +61,7 @@ rpmRC PLUGINHOOK_TSM_POST_FUNC(rpmts ts, int res)
|
|||
return RPMRC_OK;
|
||||
}
|
||||
|
||||
rpmRC PLUGINHOOK_PSM_POST_FUNC(rpmte te, int res)
|
||||
static rpmRC PLUGINHOOK_PSM_POST_FUNC(rpmte te, int res)
|
||||
{
|
||||
if (logging) {
|
||||
int lvl = LOG_NOTICE;
|
||||
|
@ -80,7 +81,7 @@ rpmRC PLUGINHOOK_PSM_POST_FUNC(rpmte te, int res)
|
|||
return RPMRC_OK;
|
||||
}
|
||||
|
||||
rpmRC PLUGINHOOK_SCRIPTLET_POST_FUNC(const char *s_name, int type, int res)
|
||||
static rpmRC PLUGINHOOK_SCRIPTLET_POST_FUNC(const char *s_name, int type, int res)
|
||||
{
|
||||
if (logging && res) {
|
||||
syslog(LOG_WARNING, "scriptlet %s failure: %d\n", s_name, res);
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
#include <dbus/dbus.h>
|
||||
#include <rpm/rpmlog.h>
|
||||
#include <rpm/rpmts.h>
|
||||
#include "plugin.h"
|
||||
#include "lib/rpmplugins.h"
|
||||
|
||||
static int lock_fd = -1;
|
||||
|
||||
rpmRC PLUGINHOOK_INIT_FUNC(rpmts ts, const char *name, const char *opts)
|
||||
static rpmRC PLUGINHOOK_INIT_FUNC(rpmts ts, const char *name, const char *opts)
|
||||
{
|
||||
return RPMRC_OK;
|
||||
}
|
||||
|
||||
rpmRC PLUGINHOOK_CLEANUP_FUNC(void)
|
||||
static rpmRC PLUGINHOOK_CLEANUP_FUNC(void)
|
||||
{
|
||||
return RPMRC_OK;
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ static int inhibit(void)
|
|||
return fd;
|
||||
}
|
||||
|
||||
rpmRC PLUGINHOOK_TSM_PRE_FUNC(rpmts ts)
|
||||
static rpmRC PLUGINHOOK_TSM_PRE_FUNC(rpmts ts)
|
||||
{
|
||||
if (rpmtsFlags(ts) & (RPMTRANS_FLAG_TEST|RPMTRANS_FLAG_BUILD_PROBS))
|
||||
return RPMRC_OK;
|
||||
|
@ -82,7 +82,7 @@ rpmRC PLUGINHOOK_TSM_PRE_FUNC(rpmts ts)
|
|||
return RPMRC_OK;
|
||||
}
|
||||
|
||||
rpmRC PLUGINHOOK_TSM_POST_FUNC(rpmts ts, int res)
|
||||
static rpmRC PLUGINHOOK_TSM_POST_FUNC(rpmts ts, int res)
|
||||
{
|
||||
if (lock_fd >= 0) {
|
||||
close(lock_fd);
|
||||
|
|
Loading…
Reference in New Issue