blob: 49a4cae5a644879b378c99f0fbd1cf141e9234c0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#include "plugin.h"
#include <sys/wait.h>
static char * options;
static char * name;
rpmPluginHook PLUGIN_HOOKS = \
PLUGINHOOK_INIT | \
PLUGINHOOK_CLEANUP | \
PLUGINHOOK_COLL_POST_ANY;
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)
{
options = _free(options);
name = _free(name);
return RPMRC_OK;
}
rpmRC PLUGINHOOK_COLL_POST_ANY_FUNC(void)
{
rpmRC rc = RPMRC_FAIL;
if (rpmChrootIn()) {
goto exit;
}
if (options) {
int status = system(options);
if (!WIFEXITED(status) || WEXITSTATUS(status)) {
rpmlog(RPMLOG_ERR, "%s collection action failed\n", name);
goto exit;
}
}
rc = RPMRC_OK;
exit:
if (rpmChrootOut()) {
rc = RPMRC_FAIL;
}
return rc;
}
|