commit 1e005e229ab471b56dede57ccdc7b97253a533a8 Author: overweight <5324761+overweight@user.noreply.gitee.com> Date: Mon Sep 30 10:31:51 2019 -0400 Package init diff --git a/0067-Fix-minor-memory-leak-in-auditd-kerberos-credentials.patch b/0067-Fix-minor-memory-leak-in-auditd-kerberos-credentials.patch new file mode 100644 index 0000000..099b410 --- /dev/null +++ b/0067-Fix-minor-memory-leak-in-auditd-kerberos-credentials.patch @@ -0,0 +1,43 @@ +From c34481d21c51241e571873627a8da17556e153d2 Mon Sep 17 00:00:00 2001 +From: Steve Grubb +Date: Tue, 22 Jan 2019 08:10:30 +0100 +Subject: [PATCH 67/99] Fix minor memory leak in auditd kerberos credentials + code + +--- + src/auditd-listen.c | 11 +++++++++-- + 1 files changed, 9 insertions(+), 2 deletions(-) + +diff --git a/src/auditd-listen.c b/src/auditd-listen.c +index 613cae6..bce8ca0 100644 +--- a/src/auditd-listen.c ++++ b/src/auditd-listen.c +@@ -1107,7 +1107,11 @@ next_try: + } + } + +- server_acquire_creds(princ, &server_creds); ++ if (server_acquire_creds(princ, &server_creds)) { ++ free(my_service_name); ++ my_service_name = NULL; ++ return -1; ++ } + } + #endif + +@@ -1127,8 +1131,11 @@ void auditd_tcp_listen_uninit(struct ev_loop *loop, struct daemon_conf *config) + } + + #ifdef USE_GSSAPI +- if (USE_GSS) ++ if (USE_GSS) { + gss_release_cred(&status, &server_creds); ++ free(my_service_name); ++ my_service_name = NULL; ++ } + #endif + + while (client_chain) { +-- +1.8.3.1 + diff --git a/Fix-a-couple-more-fuzzer-induced-bugs.patch b/Fix-a-couple-more-fuzzer-induced-bugs.patch new file mode 100644 index 0000000..7169756 --- /dev/null +++ b/Fix-a-couple-more-fuzzer-induced-bugs.patch @@ -0,0 +1,43 @@ +From bbbebbef926376a7bec116a2cc3aadd86af75bb4 Mon Sep 17 00:00:00 2001 +From: Steve Grubb +Date: Sat, 15 Dec 2018 14:12:56 -0500 +Subject: [PATCH 209/217] Fix a couple more fuzzer induced bugs + +--- + src/ausearch-parse.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/src/ausearch-parse.c b/src/ausearch-parse.c +index 44499c7..311f699 100644 +--- a/src/ausearch-parse.c ++++ b/src/ausearch-parse.c +@@ -603,6 +603,8 @@ static int parse_syscall(lnode *n, search_items *s) + if (s->key) { + char *saved; + char *keyptr = unescape(str); ++ if (keyptr == NULL) ++ return 45; + char *kptr = strtok_r(keyptr, + key_sep, &saved); + while (kptr) { +@@ -1599,6 +1601,8 @@ static int parse_sockaddr(const lnode *n, search_items *s) + str += 6; + len = strlen(str)/2; + s->hostname = unescape(str); ++ if (s->hostname == NULL) ++ return 4; + saddr = (struct sockaddr *)s->hostname; + if (saddr->sa_family == AF_INET) { + if (len < sizeof(struct sockaddr_in)) { +@@ -2300,6 +2304,8 @@ static int parse_simple_message(const lnode *n, search_items *s) + if (s->key) { + char *saved; + char *keyptr = unescape(ptr); ++ if (keyptr == NULL) ++ return 8; + char *kptr = strtok_r(keyptr, + key_sep, &saved); + while (kptr) { +-- +1.8.3.1 + diff --git a/Fix-memleak-in-auparse-caused-by-corrected-event-ordering.patch b/Fix-memleak-in-auparse-caused-by-corrected-event-ordering.patch new file mode 100644 index 0000000..7ef151b --- /dev/null +++ b/Fix-memleak-in-auparse-caused-by-corrected-event-ordering.patch @@ -0,0 +1,67 @@ +From 1af601fed7c23849ae50cacf0eff15fa7dc781a8 Mon Sep 17 00:00:00 2001 +From: Steve Grubb +Date: Tue, 26 Mar 2019 09:18:00 -0400 +Subject: [PATCH 1/2] Fix memleak in auparse caused by corrected event ordering + +--- + auparse/auparse.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/auparse/auparse.c b/auparse/auparse.c +index 042ea2b..af5dc7b 100644 +--- a/auparse/auparse.c ++++ b/auparse/auparse.c +@@ -266,6 +266,14 @@ static event_list_t *au_get_ready_event(auparse_state_t *au, int is_test) + au_lolnode *ptr = lowest; + while (ptr->status == EBS_EMPTY && lol->maxi > 0) { + lol->maxi--; ++ if (ptr->l) { ++ aup_list_clear(ptr->l); ++ free(ptr->l); ++ ptr->l = NULL; ++ au->le = NULL; // this should crash ++ // usage of au->le ++ // until reset ++ } + ptr = &lol->array[lol->maxi]; + } + } + +From a4ed2001dd9db902764256ee08bd53e2039f217e Mon Sep 17 00:00:00 2001 +From: Steve Grubb +Date: Tue, 26 Mar 2019 17:24:37 -0400 +Subject: [PATCH 2/2] Fix memleak in auparse caused by corrected event ordering + part 2 + +--- + auparse/auparse.c | 17 ----------------- + 1 file changed, 17 deletions(-) + +diff --git a/auparse/auparse.c b/auparse/auparse.c +index af5dc7b..7662b85 100644 +--- a/auparse/auparse.c ++++ b/auparse/auparse.c +@@ -260,23 +260,6 @@ static event_list_t *au_get_ready_event(auparse_state_t *au, int is_test) + if (lowest && lowest->status == EBS_COMPLETE) { + lowest->status = EBS_EMPTY; + au->au_ready--; +- // Try to consolidate the array so that we iterate +- // over a smaller portion next time +- if (lowest == &lol->array[lol->maxi]) { +- au_lolnode *ptr = lowest; +- while (ptr->status == EBS_EMPTY && lol->maxi > 0) { +- lol->maxi--; +- if (ptr->l) { +- aup_list_clear(ptr->l); +- free(ptr->l); +- ptr->l = NULL; +- au->le = NULL; // this should crash +- // usage of au->le +- // until reset +- } +- ptr = &lol->array[lol->maxi]; +- } +- } + return lowest->l; + } + diff --git a/Fix-memory-leak-when-logs-are-corrupted.patch b/Fix-memory-leak-when-logs-are-corrupted.patch new file mode 100644 index 0000000..f692c0b --- /dev/null +++ b/Fix-memory-leak-when-logs-are-corrupted.patch @@ -0,0 +1,29 @@ +From cc434ad723bba5c7da4d8e440130f55a9437961c Mon Sep 17 00:00:00 2001 +From: Steve Grubb +Date: Sat, 15 Dec 2018 09:55:29 -0500 +Subject: [PATCH 206/217] Fix memory leak when logs are corrupted + +--- + auparse/ellist.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/auparse/ellist.c b/auparse/ellist.c +index 90a0524..fd45fac 100644 +--- a/auparse/ellist.c ++++ b/auparse/ellist.c +@@ -331,8 +331,11 @@ int aup_list_append(event_list_t *l, char *record, int list_idx, + + // Then parse the record up into nvlist + rc = parse_up_record(r); +- if (r->cwd) ++ if (r->cwd) { ++ // Should never be 2 cwd records unless log is corrupted ++ free(l->cwd); + l->cwd = r->cwd; ++ } + return rc; + } + +-- +1.8.3.1 + diff --git a/More-fuzzer-induced-bug-fixes.patch b/More-fuzzer-induced-bug-fixes.patch new file mode 100644 index 0000000..b5f6ffd --- /dev/null +++ b/More-fuzzer-induced-bug-fixes.patch @@ -0,0 +1,56 @@ +From c218a04655b2426b46d303d711863f9038f15917 Mon Sep 17 00:00:00 2001 +From: Steve Grubb +Date: Sat, 15 Dec 2018 14:58:31 -0500 +Subject: [PATCH 210/217] More fuzzer induced bug fixes + +--- + auparse/normalize.c | 10 +++++----- + src/ausearch-parse.c | 4 +++- + 2 files changed, 8 insertions(+), 6 deletions(-) + +diff --git a/auparse/normalize.c b/auparse/normalize.c +index 45d8821..5f15712 100644 +--- a/auparse/normalize.c ++++ b/auparse/normalize.c +@@ -44,11 +44,11 @@ + * Both record and field are 0 based. Simple records are always 0. Compound + * records start at 0 and go up. + */ +-#define UNSET 0xFFFF +-#define get_record(y) ((y >> 16) & 0x0000FFFF) +-#define set_record(y, x) (((x & 0x0000FFFF) << 16) | (y & 0x0000FFFF)) +-#define get_field(y) (y & 0x0000FFFF) +-#define set_field(y, x) ((y & 0xFFFF0000) | (x & 0x0000FFFF)) ++#define UNSET 0xFFFFU ++#define get_record(y) ((y >> 16) & 0x0000FFFFU) ++#define set_record(y, x) (((x & 0x0000FFFFU) << 16) | (y & 0x0000FFFFU)) ++#define get_field(y) (y & 0x0000FFFFU) ++#define set_field(y, x) ((y & 0xFFFF0000U) | (x & 0x0000FFFFU)) + #define is_unset(y) (get_record(y) == UNSET) + #define D au->norm_data + +diff --git a/src/ausearch-parse.c b/src/ausearch-parse.c +index 311f699..cc2a06c 100644 +--- a/src/ausearch-parse.c ++++ b/src/ausearch-parse.c +@@ -40,7 +40,7 @@ + #include "ausearch-parse.h" + #include "auparse-idata.h" + +-#define NAME_OFFSET 36 ++#define NAME_OFFSET 28 + static const char key_sep[2] = { AUDIT_KEY_SEPARATOR, 0 }; + + static int parse_task_info(lnode *n, search_items *s); +@@ -714,6 +714,8 @@ static int common_path_parser(search_items *s, char *path) + sn.str = unescape(path); + *term = ' '; + } ++ if (sn.str == NULL) ++ return 7; + // Attempt to rebuild path if relative + if ((sn.str[0] == '.') && ((sn.str[1] == '.') || + (sn.str[1] == '/')) && s->cwd) { +-- +1.8.3.1 + diff --git a/Port-af_unix-plugin-to-libev.patch b/Port-af_unix-plugin-to-libev.patch new file mode 100644 index 0000000..129571b --- /dev/null +++ b/Port-af_unix-plugin-to-libev.patch @@ -0,0 +1,279 @@ +From 6d6c65e8e374ce31037e20b1cdc314808efd0e3c Mon Sep 17 00:00:00 2001 +From: Steve Grubb +Date: Sat, 24 Nov 2018 10:06:08 -0500 +Subject: [PATCH] Port af_unix plugin to libev + +--- + audisp/Makefile.am | 3 ++- + audisp/audispd-builtins.c | 42 +++++++++++++++++++++++++++++++-------- + audisp/audispd-builtins.h | 9 ++------- + audisp/audispd.c | 38 ----------------------------------- + src/auditd.c | 18 ++++++++--------- + 5 files changed, 47 insertions(+), 63 deletions(-) + +diff --git a/audisp/Makefile.am b/audisp/Makefile.am +index 5aa1d09..852169e 100644 +--- a/audisp/Makefile.am ++++ b/audisp/Makefile.am +@@ -22,7 +22,7 @@ + + SUBDIRS = plugins + CONFIG_CLEAN_FILES = *.rej *.orig +-AM_CPPFLAGS = -D_GNU_SOURCE -fPIC -DPIC -I${top_srcdir} -I${top_srcdir}/lib -I${top_srcdir}/src ++AM_CPPFLAGS = -D_GNU_SOURCE -fPIC -DPIC -I${top_srcdir} -I${top_srcdir}/lib -I${top_srcdir}/src -I${top_srcdir}/src/libev + LIBS = -L${top_builddir}/lib -laudit + LDADD = -lpthread + +@@ -30,5 +30,6 @@ noinst_HEADERS = audispd-pconfig.h audispd-llist.h audispd-config.h \ + queue.h audispd-builtins.h libdisp.h + libdisp_a_SOURCES = audispd.c audispd-pconfig.c queue.c \ + audispd-llist.c audispd-builtins.c ++libdisp_a_CFLAGS = -fno-strict-aliasing + noinst_LIBRARIES = libdisp.a + +diff --git a/audisp/audispd-builtins.c b/audisp/audispd-builtins.c +index 1fbe680..024faec 100644 +--- a/audisp/audispd-builtins.c ++++ b/audisp/audispd-builtins.c +@@ -1,6 +1,6 @@ + /* + * audispd-builtins.c - some common builtin plugins +-* Copyright (c) 2007,2010,2013 Red Hat Inc., Durham, North Carolina. ++* Copyright (c) 2007,2010,2013,2018 Red Hat Inc., Durham, North Carolina. + * All Rights Reserved. + * + * This software may be freely redistributed and/or modified under the +@@ -35,12 +35,17 @@ + #include // writev + #include + #include ++#include "ev.h" + #include "audispd-pconfig.h" + #include "audispd-builtins.h" + ++// Global data ++extern struct ev_loop *loop; ++ + // Local data + static volatile int sock = -1, conn = -1; + static char *path = NULL; ++static struct ev_io af_unix_watcher; + + // Local prototypes + static void init_af_unix(const plugin_conf_t *conf); +@@ -63,21 +68,37 @@ void stop_builtin(plugin_conf_t *conf) + syslog(LOG_ERR, "Unknown builtin %s", conf->path); + } + +-static void af_unix_accept(int fd) ++static int watching = 0; ++static void stop_watching(void) ++{ ++ if (watching) { ++ ev_io_stop(loop, &af_unix_watcher); ++ watching = 0; ++ } ++} ++ ++static void af_unix_accept(struct ev_loop *l, struct ev_io *_io, int revents) + { + int cmd; + + do { +- conn = accept(fd, NULL, NULL); ++ conn = accept(_io->fd, NULL, NULL); + } while (conn < 0 && errno == EINTR); + + // De-register since this is intended to be one listener + if (conn >= 0) +- remove_event(fd); ++ stop_watching(); + cmd = fcntl(conn, F_GETFD); + fcntl(conn, F_SETFD, cmd|FD_CLOEXEC); + } + ++static void start_watching(void) ++{ ++ ev_io_init(&af_unix_watcher, af_unix_accept, sock, EV_READ); ++ ev_io_start(loop, &af_unix_watcher); ++ watching = 1; ++} ++ + static int create_af_unix_socket(const char *path, int mode) + { + struct sockaddr_un addr; +@@ -122,8 +143,8 @@ static int create_af_unix_socket(const char *path, int mode) + // Make socket listening...won't block + (void)listen(sock, 5); + +- // Register socket with poll +- add_event(sock, af_unix_accept); ++ // Register socket with libev ++ start_watching(); + return 0; + } + +@@ -213,7 +234,8 @@ void send_af_unix_string(const char *s, unsigned int len) + if (rc < 0 && errno == EPIPE) { + close(conn); + conn = -1; +- add_event(sock, af_unix_accept); ++ stop_watching(); ++ start_watching(); + } + } + } +@@ -237,7 +259,8 @@ void send_af_unix_binary(event_t *e) + if (rc < 0 && errno == EPIPE) { + close(conn); + conn = -1; +- add_event(sock, af_unix_accept); ++ stop_watching(); ++ start_watching(); + } + } + } +@@ -250,10 +273,13 @@ void destroy_af_unix(void) + conn = -1; + did_something = 1; + } ++ stop_watching(); + if (sock >= 0) { ++ + close(sock); + sock = -1; + did_something = 1; ++ + } + if (path) { + unlink(path); +diff --git a/audisp/audispd-builtins.h b/audisp/audispd-builtins.h +index 2083775..2d344ea 100644 +--- a/audisp/audispd-builtins.h ++++ b/audisp/audispd-builtins.h +@@ -1,6 +1,6 @@ + /* +-* audispd-builtins.h - Minimal linked list library +-* Copyright (c) 2007,2013 Red Hat Inc., Durham, North Carolina. ++* audispd-builtins.h - Interface to builtin plugins ++* Copyright (c) 2007,2013,2018 Red Hat Inc., Durham, North Carolina. + * All Rights Reserved. + * + * This software may be freely redistributed and/or modified under the +@@ -33,10 +33,5 @@ void send_af_unix_string(const char *s, unsigned int len); + void send_af_unix_binary(event_t *e); + void destroy_af_unix(void); + +-typedef void (*poll_callback_ptr)(int fd); +-int add_event(int fd, poll_callback_ptr cb); +-int remove_event(int fd); +- +- + #endif + +diff --git a/audisp/audispd.c b/audisp/audispd.c +index e9584b7..9c3a118 100644 +--- a/audisp/audispd.c ++++ b/audisp/audispd.c +@@ -31,7 +31,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -578,43 +577,6 @@ static int event_loop(void) + return 1; + } + +-static struct pollfd pfd[4]; +-static poll_callback_ptr pfd_cb[4]; +-static volatile int pfd_cnt=0; +-int add_event(int fd, poll_callback_ptr cb) +-{ +- if (pfd_cnt > 3) +- return -1; +- +- pfd[pfd_cnt].fd = fd; +- pfd[pfd_cnt].events = POLLIN; +- pfd[pfd_cnt].revents = 0; +- pfd_cb[pfd_cnt] = cb; +- pfd_cnt++; +- return 0; +-} +- +-int remove_event(int fd) +-{ +- int start, i; +- if (pfd_cnt == 0) +- return -1; +- +- for (start=0; start < pfd_cnt; start++) { +- if (pfd[start].fd == fd) +- break; +- } +- for (i=start; i<(pfd_cnt-1); i++) { +- pfd[i].events = pfd[i+1].events; +- pfd[i].revents = pfd[i+1].revents; +- pfd[i].fd = pfd[i+1].fd; +- pfd_cb[i] = pfd_cb[i+1]; +- } +- +- pfd_cnt--; +- return 0; +-} +- + /* returns > 0 if plugins and 0 if none */ + int libdisp_active(void) + { +diff --git a/src/auditd.c b/src/auditd.c +index bd7e3b8..22bdc9b 100644 +--- a/src/auditd.c ++++ b/src/auditd.c +@@ -581,6 +581,7 @@ static void close_pipes(void) + close(pipefds[1]); + } + ++struct ev_loop *loop; + int main(int argc, char *argv[]) + { + struct sigaction sa; +@@ -598,7 +599,6 @@ int main(int argc, char *argv[]) + enum startup_state opt_startup = startup_enable; + extern char *optarg; + extern int optind; +- struct ev_loop *loop; + struct ev_io netlink_watcher; + struct ev_io pipe_watcher; + struct ev_signal sigterm_watcher; +@@ -749,14 +749,6 @@ int main(int argc, char *argv[]) + return 1; + } + +- if (init_dispatcher(&config)) { +- if (pidfile) +- unlink(pidfile); +- tell_parent(FAILURE); +- free_config(&config); +- return 1; +- } +- + /* Get machine name ready for use */ + if (resolve_node(&config)) { + if (pidfile) +@@ -892,6 +884,14 @@ int main(int argc, char *argv[]) + /* Depending on value of opt_startup (-s) set initial audit state */ + loop = ev_default_loop (EVFLAG_NOENV); + ++ if (init_dispatcher(&config)) { ++ if (pidfile) ++ unlink(pidfile); ++ tell_parent(FAILURE); ++ free_config(&config); ++ return 1; ++ } ++ + if (!opt_aggregate_only) { + ev_io_init (&netlink_watcher, netlink_handler, fd, EV_READ); + ev_io_start (loop, &netlink_watcher); diff --git a/audit-3.0-alpha5.tar.gz b/audit-3.0-alpha5.tar.gz new file mode 100644 index 0000000..51f3d17 Binary files /dev/null and b/audit-3.0-alpha5.tar.gz differ diff --git a/audit.spec b/audit.spec new file mode 100644 index 0000000..ee9a643 --- /dev/null +++ b/audit.spec @@ -0,0 +1,266 @@ +%{!?python_sitearch: %define python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")} + +Summary: User space tools for kernel auditing +Name: audit +Version: 3.0 +Release: 2 +License: GPLv2+ and LGPLv2+ +URL: http://people.redhat.com/sgrubb/audit/ +Source0: http://people.redhat.com/sgrubb/audit/%{name}-%{version}-alpha5.tar.gz +Source1: https://www.gnu.org/licenses/lgpl-2.1.txt + +Patch6000: bindings-swig-src-auditswig.i-Do-not-hardcode-the-pa.patch +Patch6001: Fix-memory-leak-when-logs-are-corrupted.patch +Patch6002: fix-out-of-bound-read-on-shutdown.patch +Patch6003: Fix-a-couple-more-fuzzer-induced-bugs.patch +Patch6004: More-fuzzer-induced-bug-fixes.patch +Patch6005: Fix-memleak-in-auparse-caused-by-corrected-event-ordering.patch +Patch6006: Port-af_unix-plugin-to-libev.patch +Patch6007: 0067-Fix-minor-memory-leak-in-auditd-kerberos-credentials.patch + +Patch9000: bugfix-audit-support-armv7b.patch +Patch9001: bugfix-audit-userspace-missing-syscalls-for-aarm64.patch +Patch9002: bugfix-audit-reload-coredump.patch + +BuildRequires: gcc swig libtool +BuildRequires: openldap-devel +BuildRequires: krb5-devel libcap-ng-devel +BuildRequires: kernel-headers >= 2.6.29 +BuildRequires: python2 python-unversioned-command +%ifarch %{golang_arches} +BuildRequires: golang +%endif +BuildRequires: systemd +Requires: openldap +Requires(post): systemd coreutils +Requires(preun): systemd +Requires(postun): systemd coreutils + +Provides: audit-libs = %{version}-%{release} +Provides: audit-libs%{?_isa} = %{version}-%{release} +Provides: audispd-plugins = %{version}-%{release} +Provides: audispd-plugins-zos = %{version}-%{release} +Obsoletes: audit-libs < %{version}-%{release} +Obsoletes: audit-libs%{?_isa} < %{version}-%{release} +Obsoletes: audispd-plugins < %{version}-%{release} +Obsoletes: audispd-plugins-zos < %{version}-%{release} + +%description +The audit package contains the user space utilities for +storing and searching the audit records generated by +the audit subsystem in the Linux 2.6 and later kernels. + +%package devel +Summary: Header files for libaudit +License: LGPLv2+ +Requires: %{name}%{?_isa} = %{version}-%{release} +Requires: kernel-headers >= 2.6.29 + +%description devel +The audit-libs-devel package contains the header files needed for +developing applications that need to use the audit framework libraries. + +%package -n python2-audit +Summary: Python2 bindings for libaudit +License: LGPLv2+ +BuildRequires: python2-devel +Requires: %{name}%{?_isa} = %{version}-%{release} +Provides: audit-libs-python = %{version}-%{release} +Provides: audit-libs-python%{?_isa} = %{version}-%{release} +Obsoletes: audit-libs-python < %{version}-%{release} +Provides: audit-libs-python2 = %{version}-%{release} +Provides: audit-libs-python2%{?_isa} = %{version}-%{release} +Obsoletes: audit-libs-python2 < %{version}-%{release} + +%description -n python2-audit +The python2-audit package contains the bindings so that libaudit +and libauparse can be used by python2. + +%package -n python3-audit +Summary: Python3 bindings for libaudit +License: LGPLv2+ +BuildRequires: python3-devel +Requires: %{name}%{?_isa} = %{version}-%{release} +Provides: audit-libs-python3 = %{version}-%{release} +Provides: audit-libs-python3%{?_isa} = %{version}-%{release} +Obsoletes: audit-libs-python3 < %{version}-%{release} + +%description -n python3-audit +The python3-audit package contains the bindings so that libaudit +and libauparse can be used by python3. + +%package help +Summary: Documents for %{name} +Buildarch: noarch +Requires: man info + +%description help +Man pages and other related documents for %{name}. + +%prep +%autosetup -n %{name}-%{version} -p1 +cp %{SOURCE1} . +autoreconf -f -i + +%build +%configure --sbindir=/sbin --libdir=/%{_lib} --with-python=yes \ + --with-python3=yes \ + --enable-gssapi-krb5=yes --with-arm --with-aarch64 \ + --with-libcap-ng=yes --enable-zos-remote \ +%ifarch %{golang_arches} + --with-golang \ +%endif + --enable-systemd + +make CFLAGS="%{optflags}" %{?_smp_mflags} + +%install +mkdir -p $RPM_BUILD_ROOT/{sbin,etc/audit/plugins.d,etc/audit/rules.d} +mkdir -p $RPM_BUILD_ROOT/%{_mandir}/{man5,man8} +mkdir -p $RPM_BUILD_ROOT/%{_lib} +mkdir -p $RPM_BUILD_ROOT/%{_libdir}/audit +mkdir -p --mode=0700 $RPM_BUILD_ROOT/%{_var}/log/audit +mkdir -p $RPM_BUILD_ROOT/%{_var}/spool/audit +make DESTDIR=$RPM_BUILD_ROOT install + +mkdir -p $RPM_BUILD_ROOT/%{_libdir} +mv $RPM_BUILD_ROOT/%{_lib}/libaudit.a $RPM_BUILD_ROOT%{_libdir} +mv $RPM_BUILD_ROOT/%{_lib}/libauparse.a $RPM_BUILD_ROOT%{_libdir} +curdir=`pwd` +cd $RPM_BUILD_ROOT/%{_libdir} +LIBNAME=`basename \`ls $RPM_BUILD_ROOT/%{_lib}/libaudit.so.1.*.*\`` +ln -s ../../%{_lib}/$LIBNAME libaudit.so +LIBNAME=`basename \`ls $RPM_BUILD_ROOT/%{_lib}/libauparse.so.0.*.*\`` +ln -s ../../%{_lib}/$LIBNAME libauparse.so +cd $curdir +rm -f $RPM_BUILD_ROOT/%{_lib}/libaudit.so +rm -f $RPM_BUILD_ROOT/%{_lib}/libauparse.so + +find $RPM_BUILD_ROOT -name '*.la' -delete +find $RPM_BUILD_ROOT/%{_libdir}/python?.?/site-packages -name '*.a' -delete + +mv $RPM_BUILD_ROOT/%{_lib}/pkgconfig $RPM_BUILD_ROOT%{_libdir} + +touch -r ./audit.spec $RPM_BUILD_ROOT/etc/libaudit.conf +touch -r ./audit.spec $RPM_BUILD_ROOT/usr/share/man/man5/libaudit.conf.5.gz + +%check +%ifarch %{golang_arches} +make check +%endif +rm -f rules/Makefile* + +%post +/sbin/ldconfig +files=`ls /etc/audit/rules.d/ 2>/dev/null | wc -w` +if [ "$files" -eq 0 ] ; then + if [ -e /usr/share/doc/audit/rules/10-no-audit.rules ] ; then + cp /usr/share/doc/audit/rules/10-no-audit.rules /etc/audit/rules.d/audit.rules + else + touch /etc/audit/rules.d/audit.rules + fi + chmod 0600 /etc/audit/rules.d/audit.rules +fi +%systemd_post auditd.service + +%preun +%systemd_preun auditd.service + +%postun +/sbin/ldconfig +if [ $1 -ge 1 ]; then + /sbin/service auditd condrestart > /dev/null 2>&1 || : +fi + + +%files +%doc README ChangeLog rules init.d/auditd.cron +%{!?_licensedir:%global license %%doc} +%license COPYING lgpl-2.1.txt +%attr(755,root,root) /sbin/auditctl +%attr(755,root,root) /sbin/auditd +%attr(755,root,root) /sbin/ausearch +%attr(755,root,root) /sbin/aureport +%attr(750,root,root) /sbin/autrace +%attr(755,root,root) /sbin/augenrules +%attr(755,root,root) %{_bindir}/aulast +%attr(755,root,root) %{_bindir}/aulastlog +%attr(755,root,root) %{_bindir}/ausyscall +%attr(755,root,root) %{_bindir}/auvirt +/%{_lib}/libaudit.so.1* +/%{_lib}/libauparse.* +%attr(644,root,root) %{_unitdir}/auditd.service +%attr(750,root,root) %dir %{_libexecdir}/initscripts/legacy-actions/auditd +%attr(750,root,root) %{_libexecdir}/initscripts/legacy-actions/auditd/condrestart +%attr(750,root,root) %{_libexecdir}/initscripts/legacy-actions/auditd/reload +%attr(750,root,root) %{_libexecdir}/initscripts/legacy-actions/auditd/restart +%attr(750,root,root) %{_libexecdir}/initscripts/legacy-actions/auditd/resume +%attr(750,root,root) %{_libexecdir}/initscripts/legacy-actions/auditd/rotate +%attr(750,root,root) %{_libexecdir}/initscripts/legacy-actions/auditd/state +%attr(750,root,root) %{_libexecdir}/initscripts/legacy-actions/auditd/stop +%ghost %{_localstatedir}/run/auditd.state +%attr(750,root,root) %dir %{_var}/log/audit +%attr(750,root,root) %dir /etc/audit +%attr(750,root,root) %dir /etc/audit/rules.d +%attr(750,root,root) %dir /etc/audit/plugins.d +%config(noreplace) %attr(640,root,root) /etc/audit/auditd.conf +%ghost %config(noreplace) %attr(600,root,root) /etc/audit/rules.d/audit.rules +%ghost %config(noreplace) %attr(640,root,root) /etc/audit/audit.rules +%config(noreplace) %attr(640,root,root) /etc/audit/audit-stop.rules +%config(noreplace) %attr(640,root,root) /etc/audit/plugins.d/af_unix.conf +%config(noreplace) %attr(640,root,root) /etc/audit/audisp-remote.conf +%config(noreplace) %attr(640,root,root) /etc/audit/plugins.d/au-remote.conf +%config(noreplace) %attr(640,root,root) /etc/audit/plugins.d/syslog.conf +%config(noreplace) %attr(640,root,root) /etc/libaudit.conf +%attr(750,root,root) /sbin/audisp-remote +%attr(750,root,root) /sbin/audisp-syslog +%attr(700,root,root) %dir %{_var}/spool/audit +%config(noreplace) %attr(640,root,root) /etc/audit/plugins.d/audispd-zos-remote.conf +%config(noreplace) %attr(640,root,root) /etc/audit/zos-remote.conf +%attr(750,root,root) /sbin/audispd-zos-remote + + +%files devel +%defattr(-,root,root) +%doc contrib/plugin +%{!?_licensedir:%global license %%doc} +%license lgpl-2.1.txt +%{_libdir}/libaudit.so +%{_libdir}/libauparse.so +%ifarch %{golang_arches} +%dir %{_prefix}/lib/golang/src/pkg/redhat.com/audit +%{_prefix}/lib/golang/src/pkg/redhat.com/audit/audit.go +%endif +%{_includedir}/libaudit.h +%{_includedir}/auparse.h +%{_includedir}/auparse-defs.h +%{_datadir}/aclocal/audit.m4 +%{_libdir}/pkgconfig/audit.pc +%{_libdir}/pkgconfig/auparse.pc +%{_libdir}/libaudit.a +%{_libdir}/libauparse.a + + +%files -n python2-audit +%attr(755,root,root) %{python_sitearch}/_audit.so +%attr(755,root,root) %{python_sitearch}/auparse.so +%{python2_sitearch}/audit.py* + +%files -n python3-audit +%attr(755,root,root) %{python3_sitearch}/* + + +%files help +%defattr(-,root,root) +%attr(644,root,root) %{_mandir}/man8/*.8.gz +%attr(644,root,root) %{_mandir}/man7/*.7.gz +%attr(644,root,root) %{_mandir}/man5/*.5.gz +%attr(644,root,root) %{_mandir}/man3/* + + +%changelog +* Sun Sep 29 2019 openEuler Buildteam - 3.0-2 +- Fix the auditctl error + +* Sat Sep 21 2019 openEuler Buildteam - 3.0-1 +- Package init diff --git a/bindings-swig-src-auditswig.i-Do-not-hardcode-the-pa.patch b/bindings-swig-src-auditswig.i-Do-not-hardcode-the-pa.patch new file mode 100644 index 0000000..0746ffc --- /dev/null +++ b/bindings-swig-src-auditswig.i-Do-not-hardcode-the-pa.patch @@ -0,0 +1,33 @@ +From 5d206ce4ac545595170d1ed1490d4824b442bd19 Mon Sep 17 00:00:00 2001 +From: Helmut Grohne +Date: Mon, 1 Oct 2018 07:48:54 +0200 +Subject: [PATCH 177/217] bindings/swig/src/auditswig.i: Do not hardcode the + path of stdint.h + +auditswig.i hard codes the path to stdint.h. That will fail to work with +non-glibc libcs and after moving glibc's headers (#798955). The path is +hard coded, because swig's %include does not search the standard header +search path. Rather than using %include here, we can use #include, +because stdint.h does not declare any functions. Thus swig entirely +ignores stdint.h and leaves the search to the C compiler. + +https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=909967 +--- + bindings/swig/src/auditswig.i | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/bindings/swig/src/auditswig.i b/bindings/swig/src/auditswig.i +index 356a5ab..7ebb373 100644 +--- a/bindings/swig/src/auditswig.i ++++ b/bindings/swig/src/auditswig.i +@@ -41,6 +41,6 @@ typedef unsigned __u32; + typedef unsigned uid_t; + %include "/usr/include/linux/audit.h" + #define __extension__ /*nothing*/ +-%include "/usr/include/stdint.h" ++#include + %include "../lib/libaudit.h" + +-- +1.8.3.1 + diff --git a/bugfix-audit-reload-coredump.patch b/bugfix-audit-reload-coredump.patch new file mode 100644 index 0000000..44186ce --- /dev/null +++ b/bugfix-audit-reload-coredump.patch @@ -0,0 +1,77 @@ +diff -Nur audit-3.0.org/src/auditd.c audit-3.0/src/auditd.c +--- audit-3.0.org/src/auditd.c 2019-07-30 09:29:49.420000000 +0800 ++++ audit-3.0/src/auditd.c 2019-07-30 09:58:30.484000000 +0800 +@@ -76,6 +76,7 @@ + static int usr1_info_requested = 0, usr2_info_requested = 0; + static char subj[SUBJ_LEN]; + static uint32_t session; ++static int hup_flag = 0; + + /* Local function prototypes */ + int send_audit_event(int type, const char *str); +@@ -502,12 +503,24 @@ + if (hup_info_requested) { + audit_msg(LOG_DEBUG, + "HUP detected, starting config manager"); +- reconfig_ev = cur_event; +- if (start_config_manager(cur_event)) { +- send_audit_event( +- AUDIT_DAEMON_CONFIG, +- "op=reconfigure state=no-change " +- "auid=-1 pid=-1 subj=? res=failed"); ++ if(hup_flag == 0) ++ { ++ hup_flag = 1; ++ reconfig_ev = cur_event; ++ if (start_config_manager(cur_event)) { ++ send_audit_event( ++ AUDIT_DAEMON_CONFIG, ++ "op=reconfigure state=no-change " ++ "auid=-1 pid=-1 subj=? res=failed"); ++ hup_flag = 0; ++ } ++ } ++ else ++ { ++ send_audit_event( ++ AUDIT_DAEMON_CONFIG, ++ "op=reconfigure state=no-change " ++ "auid=-1 pid=-1 subj=? res=failed"); + } + cur_event = NULL; + hup_info_requested = 0; +@@ -565,9 +578,15 @@ + // Drain the pipe - won't block because libev sets non-blocking mode + read(pipefds[0], buf, sizeof(buf)); + enqueue_event(reconfig_ev); ++ hup_flag = 0; + reconfig_ev = NULL; + } + ++void reconfig_pthread_failed(void) ++{ ++ hup_flag = 0; ++} ++ + void reconfig_ready(void) + { + const char *msg = "ready\n"; +diff -Nur audit-3.0.org/src/auditd-reconfig.c audit-3.0/src/auditd-reconfig.c +--- audit-3.0.org/src/auditd-reconfig.c 2019-07-30 09:29:49.420000000 +0800 ++++ audit-3.0/src/auditd-reconfig.c 2019-07-30 10:00:05.232000000 +0800 +@@ -35,6 +35,7 @@ + + /* externs we need to know about */ + extern void reconfig_ready(void); ++extern void reconfig_pthread_failed(void); + + /* This is the configuration manager code */ + static pthread_t config_thread; +@@ -125,6 +126,7 @@ + //send_audit_event(AUDIT_DAEMON_CONFIG, txt); + free_config(&new_config); + free(e); ++ reconfig_pthread_failed(); + } + + pthread_mutex_unlock(&config_lock); diff --git a/bugfix-audit-support-armv7b.patch b/bugfix-audit-support-armv7b.patch new file mode 100644 index 0000000..05cfebd --- /dev/null +++ b/bugfix-audit-support-armv7b.patch @@ -0,0 +1,28 @@ +From bfef4279f55301e84873f092c48d543609b8793f Mon Sep 17 00:00:00 2001 +From: jinbo +Date: Mon, 12 Nov 2018 22:11:01 +0800 +Subject: [PATCH] audit: support armv7b + +API_change: n +reason: reconsitution audit support armv7b + +Signed-off-by: jinbo +--- + lib/machinetab.h | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/lib/machinetab.h b/lib/machinetab.h +index 7172d58..c44d656 100644 +--- a/lib/machinetab.h ++++ b/lib/machinetab.h +@@ -41,6 +41,7 @@ _S(MACH_ARM, "armv5tejl") + _S(MACH_ARM, "armv5tel") + _S(MACH_ARM, "armv6l") + _S(MACH_ARM, "armv7l") ++_S(MACH_ARM, "armv7b") + #endif + #ifdef WITH_AARCH64 + _S(MACH_AARCH64, "aarch64" ) +-- +1.8.5.6 + diff --git a/bugfix-audit-userspace-missing-syscalls-for-aarm64.patch b/bugfix-audit-userspace-missing-syscalls-for-aarm64.patch new file mode 100644 index 0000000..3d0f311 --- /dev/null +++ b/bugfix-audit-userspace-missing-syscalls-for-aarm64.patch @@ -0,0 +1,70 @@ +From ad68debcab63df34dc7b1fc4b4fd4fc4f01b8d7c Mon Sep 17 00:00:00 2001 +From: jinbo +Date: Mon, 12 Nov 2018 21:54:29 +0800 +Subject: [PATCH] audit: userspace missing syscalls for aarm64 + +API_change: n +reason: reconsitution userspace audit missing syscalls for aarm64 + +Signed-off-by: jinbo +--- + lib/aarch64_table.h | 44 +++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 44 insertions(+) + +diff --git a/lib/aarch64_table.h b/lib/aarch64_table.h +index c61aa91..ea634c1 100644 +--- a/lib/aarch64_table.h ++++ b/lib/aarch64_table.h +@@ -295,5 +295,49 @@ _S(287, "pwritev2") + _S(288, "pkey_mprotect") + _S(289, "pkey_alloc") + _S(290, "pkey_free") + _S(291, "statx") + _S(292, "io_pgetevents") ++_S(1024, "open") ++_S(1025, "link") ++_S(1026, "unlink") ++_S(1027, "mknod") ++_S(1028, "chmod") ++_S(1029, "chown") ++_S(1030, "mkdir") ++_S(1031, "rmdir") ++_S(1032, "lchown") ++_S(1033, "access") ++_S(1034, "rename") ++_S(1035, "readlink") ++_S(1036, "symlink") ++_S(1037, "utimes") ++_S(1038, "stat64") ++_S(1039, "lstat64") ++_S(1040, "pipe") ++_S(1041, "dup2") ++_S(1042, "epoll_create") ++_S(1043, "inotify_init") ++_S(1044, "eventfd") ++_S(1045, "signalfd") ++_S(1049, "newstat") ++_S(1050, "newlstat") ++_S(1059, "alarm") ++_S(1060, "getpgrp") ++_S(1061, "pause") ++_S(1062, "time") ++_S(1063, "utime") ++_S(1064, "creat") ++_S(1066, "futimesat") ++_S(1067, "select") ++_S(1068, "poll") ++_S(1069, "epoll_wait") ++_S(1070, "ustat") ++_S(1071, "vfork") ++_S(1073, "recv") ++_S(1074, "send") ++_S(1075, "bdflush") ++_S(1076, "oldumount") ++_S(1077, "uselib") ++_S(1078, "sysctl") ++_S(1079, "fork") ++ +-- +1.8.5.6 + diff --git a/fix-out-of-bound-read-on-shutdown.patch b/fix-out-of-bound-read-on-shutdown.patch new file mode 100644 index 0000000..6462fe3 --- /dev/null +++ b/fix-out-of-bound-read-on-shutdown.patch @@ -0,0 +1,25 @@ +From 5b62b99bcdba4bf9cc3c03a0ffc26d6b9b7a56ce Mon Sep 17 00:00:00 2001 +From: Steve Grubb +Date: Sat, 15 Dec 2018 13:35:29 -0500 +Subject: [PATCH 208/217] fix out of bound read on shutdown + +--- + src/auditd-listen.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/auditd-listen.c b/src/auditd-listen.c +index 9db5f35..a2560ad 100644 +--- a/src/auditd-listen.c ++++ b/src/auditd-listen.c +@@ -1118,7 +1118,7 @@ + #endif + + ev_io_stop(loop, &tcp_listen_watcher); +- while (nlsocks >= 0) { ++ while (nlsocks > 0) { + nlsocks--; + close(listen_socket[nlsocks]); + } +-- +1.8.3.1 + diff --git a/lgpl-2.1.txt b/lgpl-2.1.txt new file mode 100644 index 0000000..4362b49 --- /dev/null +++ b/lgpl-2.1.txt @@ -0,0 +1,502 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it!