Skip to content

Commit

Permalink
Create a common internal library to reduce code
Browse files Browse the repository at this point in the history
  • Loading branch information
RH-steve-grubb committed Jun 28, 2018
1 parent 1271b20 commit 01135fd
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 172 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Merge auditd and audispd code
- Close on execute init_pipe fd (#1587995)
- Breakout audisp syslog plugin to be standalone program
- Create a common internal library to reduce code

2.8.3
- Correct msg function name in LRU debug code
Expand Down
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# Rickard E. (Rik) Faith <[email protected]>
#

SUBDIRS = lib auparse audisp src/libev src tools bindings init.d \
SUBDIRS = common lib auparse audisp src/libev src tools bindings init.d \
m4 docs rules
EXTRA_DIST = ChangeLog AUTHORS NEWS README INSTALL audit.spec \
COPYING COPYING.LIB \
Expand Down
9 changes: 5 additions & 4 deletions audisp/plugins/remote/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,22 @@

CONFIG_CLEAN_FILES = *.loT *.rej *.orig
EXTRA_DIST = au-remote.conf audisp-remote.conf notes.txt $(man_MANS)
AM_CPPFLAGS = -I${top_srcdir} -I${top_srcdir}/lib
AM_CPPFLAGS = -I${top_srcdir} -I${top_srcdir}/lib -I${top_srcdir}/common
prog_confdir = $(sysconfdir)/audisp
prog_conf = audisp-remote.conf
plugin_confdir=$(prog_confdir)/plugins.d
plugin_conf = au-remote.conf
sbin_PROGRAMS = audisp-remote
noinst_HEADERS = remote-config.h queue.h remote-fgets.h
noinst_HEADERS = remote-config.h queue.h
man_MANS = audisp-remote.8 audisp-remote.conf.5
check_PROGRAMS = test-queue
TESTS = $(check_PROGRAMS)

audisp_remote_SOURCES = audisp-remote.c remote-config.c queue.c remote-fgets.c
audisp_remote_DEPENDENCIES = ${top_builddir}/common/libaucommon.a
audisp_remote_SOURCES = audisp-remote.c remote-config.c queue.c
audisp_remote_CFLAGS = -fPIE -DPIE -g -D_REENTRANT -D_GNU_SOURCE -Wundef
audisp_remote_LDFLAGS = -pie -Wl,-z,relro -Wl,-z,now $(gss_libs)
audisp_remote_LDADD = $(CAPNG_LDADD)
audisp_remote_LDADD = $(CAPNG_LDADD) -L${top_builddir}/common -laucommon

test_queue_SOURCES = queue.c test-queue.c

Expand Down
8 changes: 4 additions & 4 deletions audisp/plugins/remote/audisp-remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#include "private.h"
#include "remote-config.h"
#include "queue.h"
#include "remote-fgets.h"
#include "common.h"

#define CONFIG_FILE "/etc/audisp/audisp-remote.conf"
#define BUF_SIZE 32
Expand Down Expand Up @@ -551,7 +551,7 @@ int main(int argc, char *argv[])
// See if input fd is also set
if (FD_ISSET(ifd, &rfd)) {
do {
if (remote_fgets(event, sizeof(event), ifd)) {
if (audit_fgets(event, sizeof(event), ifd)) {
if (!transport_ok && remote_ended &&
config.remote_ending_action ==
FA_RECONNECT) {
Expand Down Expand Up @@ -583,9 +583,9 @@ int main(int argc, char *argv[])
else
queue_error();
}
} else if (remote_fgets_eof())
} else if (audit_fgets_eof())
stop = 1;
} while (remote_fgets_more(sizeof(event)));
} while (audit_fgets_more(sizeof(event)));
}
// See if output fd is also set
if (sock >= 0 && FD_ISSET(sock, &wfd)) {
Expand Down
123 changes: 0 additions & 123 deletions audisp/plugins/remote/remote-fgets.c

This file was deleted.

33 changes: 0 additions & 33 deletions audisp/plugins/remote/remote-fgets.h

This file was deleted.

8 changes: 4 additions & 4 deletions audisp/plugins/syslog/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@

CONFIG_CLEAN_FILES = *.loT *.rej *.orig
EXTRA_DIST = syslog.conf
AM_CPPFLAGS = -I${top_srcdir} -I${top_srcdir}/lib
AM_CPPFLAGS = -I${top_srcdir} -I${top_srcdir}/lib -I${top_srcdir}/common
prog_confdir = $(sysconfdir)/audisp
plugin_confdir=$(prog_confdir)/plugins.d
plugin_conf = syslog.conf
sbin_PROGRAMS = audisp-syslog
noinst_HEADERS = audit-fgets.h

audisp_syslog_SOURCES = audisp-syslog.c audit-fgets.c
audisp_syslog_DEPENDENCIES = ${top_builddir}/common/libaucommon.a
audisp_syslog_SOURCES = audisp-syslog.c
audisp_syslog_CFLAGS = -fPIE -DPIE -g -D_GNU_SOURCE -Wundef
audisp_syslog_LDFLAGS = -pie -Wl,-z,relro -Wl,-z,now
audisp_syslog_LDADD = $(CAPNG_LDADD)
audisp_syslog_LDADD = $(CAPNG_LDADD) -L${top_builddir}/common -laucommon

install-data-hook:
mkdir -p -m 0750 ${DESTDIR}${plugin_confdir}
Expand Down
2 changes: 1 addition & 1 deletion audisp/plugins/syslog/audisp-syslog.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include <cap-ng.h>
#endif
#include "libaudit.h"
#include "audit-fgets.h"
#include "common.h"

/* Global Data */
static volatile int stop = 0;
Expand Down
29 changes: 29 additions & 0 deletions common/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Makefile.am--
# Copyright 2018 Red Hat Inc., Durham, North Carolina.
# All Rights Reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Authors:
# Steve Grubb <[email protected]>
#

CONFIG_CLEAN_FILES = *.rej *.orig
AM_CPPFLAGS = -D_GNU_SOURCE -fPIC -DPIC -I${top_srcdir}

noinst_HEADERS = common.h
libaucommon_a_SOURCES = audit-fgets.c
noinst_LIBRARIES = libaucommon.a

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include "audit-fgets.h"
#include "common.h"

#define BUF_SIZE 8192
static char buffer[2*BUF_SIZE+1] = { 0 };
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ AC_SUBST(LIBWRAP_LIBS)
AC_SUBST(LIBPRELUDE_CFLAGS)
AC_SUBST(LIBPRELUDE_LDFLAGS)

AC_OUTPUT(Makefile lib/Makefile lib/audit.pc lib/test/Makefile auparse/Makefile auparse/test/Makefile auparse/auparse.pc src/Makefile src/libev/Makefile src/test/Makefile docs/Makefile rules/Makefile init.d/Makefile audisp/Makefile audisp/plugins/Makefile audisp/plugins/builtins/Makefile audisp/plugins/remote/Makefile audisp/plugins/zos-remote/Makefile audisp/plugins/syslog/Makefile bindings/Makefile bindings/python/Makefile bindings/python/python2/Makefile bindings/python/python3/Makefile bindings/golang/Makefile bindings/swig/Makefile bindings/swig/src/Makefile bindings/swig/python/Makefile bindings/swig/python3/Makefile tools/Makefile tools/aulast/Makefile tools/aulastlog/Makefile tools/ausyscall/Makefile tools/auvirt/Makefile m4/Makefile)
AC_OUTPUT(Makefile common/Makefile lib/Makefile lib/audit.pc lib/test/Makefile auparse/Makefile auparse/test/Makefile auparse/auparse.pc src/Makefile src/libev/Makefile src/test/Makefile docs/Makefile rules/Makefile init.d/Makefile audisp/Makefile audisp/plugins/Makefile audisp/plugins/builtins/Makefile audisp/plugins/remote/Makefile audisp/plugins/zos-remote/Makefile audisp/plugins/syslog/Makefile bindings/Makefile bindings/python/Makefile bindings/python/python2/Makefile bindings/python/python3/Makefile bindings/golang/Makefile bindings/swig/Makefile bindings/swig/src/Makefile bindings/swig/python/Makefile bindings/swig/python3/Makefile tools/Makefile tools/aulast/Makefile tools/aulastlog/Makefile tools/ausyscall/Makefile tools/auvirt/Makefile m4/Makefile)

echo .
echo "
Expand Down

0 comments on commit 01135fd

Please sign in to comment.