rpms/upstart/devel upstart-audit-events.patch, 1.2, 1.3 upstart.spec, 1.40, 1.41

Petr Lautrbach plautrba at fedoraproject.org
Thu Dec 17 09:56:57 UTC 2009


Author: plautrba

Update of /cvs/pkgs/rpms/upstart/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv15425

Modified Files:
	upstart-audit-events.patch upstart.spec 
Log Message:
audit events patch rebased for 0.6 (#470661)


upstart-audit-events.patch:
 Makefile.in |    5 +++++
 reboot.c    |   26 +++++++++++++++++++++++++-
 sysv.c      |   44 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 74 insertions(+), 1 deletion(-)

Index: upstart-audit-events.patch
===================================================================
RCS file: /cvs/pkgs/rpms/upstart/devel/upstart-audit-events.patch,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -p -r1.2 -r1.3
--- upstart-audit-events.patch	27 Apr 2009 20:07:46 -0000	1.2
+++ upstart-audit-events.patch	17 Dec 2009 09:56:57 -0000	1.3
@@ -1,36 +1,92 @@
-diff -urp upstart-0.3.9.orig/compat/sysv/reboot.c upstart-0.3.9/compat/sysv/reboot.c
---- upstart-0.3.9.orig/compat/sysv/reboot.c	2008-11-03 12:29:30.000000000 -0500
-+++ upstart-0.3.9/compat/sysv/reboot.c	2008-11-05 08:16:22.000000000 -0500
-@@ -37,6 +37,9 @@
- #include <string.h>
- #include <unistd.h>
- #include <utmp.h>
+diff --git a/util/Makefile.in b/util/Makefile.in
+index 26025ce..f7b61a3 100644
+--- a/util/Makefile.in
++++ b/util/Makefile.in
+@@ -376,6 +376,7 @@ reboot_SOURCES = \
+ reboot_LDFLAGS = -static
+ reboot_LDADD = \
+ 	../nih/libnih.la \
++	-laudit \
+ 	$(LTLIBINTL)
+ 
+ runlevel_SOURCES = \
+@@ -399,6 +400,7 @@ shutdown_LDFLAGS = -static
+ shutdown_LDADD = \
+ 	../nih/libnih.la \
+ 	../nih-dbus/libnih-dbus.la \
++	-laudit \
+ 	$(LTLIBINTL) \
+ 	$(DBUS_LIBS)
+ 
+@@ -414,6 +416,7 @@ telinit_LDFLAGS = -static
+ telinit_LDADD = \
+ 	../nih/libnih.la \
+ 	../nih-dbus/libnih-dbus.la \
++	-laudit \
+ 	$(LTLIBINTL) \
+ 	$(DBUS_LIBS)
+ 
+@@ -477,6 +480,7 @@ test_sysv_LDADD = \
+ 	sysv.o utmp.o \
+ 	../nih/libnih.la \
+ 	../nih-dbus/libnih-dbus.la \
++	-laudit \
+ 	$(LTLIBINTL) \
+ 	$(DBUS_LIBS)
+ 
+@@ -489,6 +493,7 @@ test_telinit_LDADD = \
+ 	com.ubuntu.Upstart.Job.o com.ubuntu.Upstart.Instance.o \
+ 	../nih/libnih.la \
+ 	../nih-dbus/libnih-dbus.la \
++	-laudit \
+ 	$(DBUS_LIBS)
+ 
+ all: $(BUILT_SOURCES)
+diff --git a/util/reboot.c b/util/reboot.c
+index dda2935..eef9ed2 100644
+--- a/util/reboot.c
++++ b/util/reboot.c
+@@ -36,6 +36,10 @@
+ #include <nih/logging.h>
+ #include <nih/error.h>
+ 
 +#if 1 /* HAVE_LIBAUDIT */
 +#include <libaudit.h>
 +#endif
++
+ #include "utmp.h"
  
- #include <linux/if.h>
- #include <linux/hdreg.h>
-@@ -87,6 +90,7 @@ enum {
- /* Prototypes for static functions */
- static void down_drives     (void);
- static void down_interfaces (void);
-+static void send_audit_event(void);
  
+@@ -96,7 +100,6 @@ static int poweroff = FALSE;
+  **/
+ static int exit_only = FALSE;
  
+-
  /**
-@@ -277,6 +281,7 @@ main (int   argc,
- 	 */
+  * options:
+  *
+@@ -119,6 +122,7 @@ static NihOption options[] = {
+ 	NIH_OPTION_LAST
+ };
+ 
++static void send_audit_event(void);
+ 
+ int
+ main (int   argc,
+@@ -216,6 +220,8 @@ main (int   argc,
+ 	/* Re-enable Control-Alt-Delete in case it breaks */
  	reboot (RB_ENABLE_CAD);
- 	kill (1, SIGTSTP);
+ 
 +	send_audit_event ();
++
+ 	/* Do the syscall */
+ 	switch (mode) {
+ 	case REBOOT:
+@@ -237,3 +243,21 @@ main (int   argc,
  
- 	/* Sync the disks */
- 	chdir ("/");
-@@ -315,6 +320,23 @@ main (int   argc,
  	return 0;
  }
- 
++
 +/**
 + * send_audit_event
 + *
@@ -40,57 +96,48 @@ diff -urp upstart-0.3.9.orig/compat/sysv
 +send_audit_event (void)
 +{
 +#if 1 /* HAVE_LIBAUDIT */
-+        int fd = audit_open ();
-+        if (fd < 0)
-+                return;
-+        audit_log_user_message (fd, AUDIT_SYSTEM_SHUTDOWN, "init",
-+                NULL, NULL, NULL, 1);
-+        close (fd);
++	int fd = audit_open ();
++	if (fd < 0)
++		return;
++	audit_log_user_message (fd, AUDIT_SYSTEM_SHUTDOWN, "init",
++		NULL, NULL, NULL, 1);
++	close (fd);
 +#endif
 +}
+diff --git a/util/sysv.c b/util/sysv.c
+index fbca39f..32b5540 100644
+--- a/util/sysv.c
++++ b/util/sysv.c
+@@ -36,6 +36,9 @@
+ #include <nih/logging.h>
+ #include <nih/error.h>
  
- /**
-  * down_drives:
-diff -urp upstart-0.3.9.orig/compat/sysv/runlevel.c upstart-0.3.9/compat/sysv/runlevel.c
---- upstart-0.3.9.orig/compat/sysv/runlevel.c	2008-11-03 12:29:30.000000000 -0500
-+++ upstart-0.3.9/compat/sysv/runlevel.c	2008-11-05 08:22:17.000000000 -0500
-@@ -33,6 +33,9 @@
- #include <stdlib.h>
- #include <string.h>
- #include <unistd.h>
-+#if 1 /* HAVE_LIBAUDIT */
++#include <unistd.h>
 +#include <libaudit.h>
-+#endif
++
+ #include "dbus/upstart.h"
  
- #include <nih/macros.h>
- #include <nih/alloc.h>
-@@ -44,6 +47,7 @@
+ #include "utmp.h"
+@@ -54,6 +57,7 @@
  
  /* Prototypes for static functions */
- static void store (short type, pid_t pid, const char *user);
+ static void error_handler (NihError **err, NihDBusMessage *message);
 +static void send_audit_event (int old, int level);
  
  
  /**
-@@ -109,6 +113,7 @@ main (int   argc,
- 	/* Store the reboot time? */
- 	if (reboot) {
- 		store (BOOT_TIME, 0, "reboot");
-+		send_audit_event (0, 0);
- 		exit (0);
- 	}
- 
-@@ -143,6 +148,7 @@ main (int   argc,
- 		prev = cur;
- 		if (! prev)
- 			prev = 'N';
-+		send_audit_event (prev, set[0]);
- 
- 		cur = set[0];
- 	}
-@@ -203,3 +209,35 @@ store (short       type,
- 	/* Write wtmp entry */
- 	updwtmp (WTMP_FILE, &utmp);
+@@ -161,6 +165,8 @@ sysv_change_runlevel (int           runlevel,
+ 				 runlevel, prevlevel) < 0)
+ 		nih_free (nih_error_get ());
+ 
++	send_audit_event(prevlevel, runlevel);
++
+ 	/* Make the EmitEvent call, we don't wait for the event to finish
+ 	 * because sysvinit never did.
+ 	 */
+@@ -199,3 +205,41 @@ error_handler (NihError **     err,
+ {
+ 	*err = nih_error_steal ();
  }
 +
 +/**
@@ -98,7 +145,7 @@ diff -urp upstart-0.3.9.orig/compat/sysv
 + * @old: current run level
 + * @level: new run level
 + *
-+ * Send system runlevel change audit event. If level is 0, then 
++ * Send system runlevel change audit event. If level is 0, then
 + * we consider this to be a reboot event.
 + **/
 +static void
@@ -110,90 +157,23 @@ diff -urp upstart-0.3.9.orig/compat/sysv
 +        if (fd < 0)
 +                return;
 +
-+	if (level) {
-+		char buf[64];
++	/* first runlevel change after boot */
++	if (old == 'N')
++		audit_log_user_message (fd, AUDIT_SYSTEM_BOOT, "init",
++			NULL, NULL, NULL, 1);
 +
-+	        snprintf (buf, sizeof (buf),
-+			"old-level=%c new-level=%c", old, level);
-+        	audit_log_user_message (fd, AUDIT_SYSTEM_RUNLEVEL, buf,
-+                	NULL, NULL, NULL, 1);
-+	} else
-+        	audit_log_user_message (fd, AUDIT_SYSTEM_BOOT, "init",
-+                	NULL, NULL, NULL, 1);
-+        close (fd);
-+#endif
-+}
++	char buf[64];
 +
-diff -urp upstart-0.3.9.orig/compat/sysv/shutdown.c upstart-0.3.9/compat/sysv/shutdown.c
---- upstart-0.3.9.orig/compat/sysv/shutdown.c	2008-11-03 12:29:30.000000000 -0500
-+++ upstart-0.3.9/compat/sysv/shutdown.c	2008-11-05 08:16:22.000000000 -0500
-@@ -38,6 +38,9 @@
- #include <stdlib.h>
- #include <string.h>
- #include <unistd.h>
-+#if 1 /* HAVE_LIBAUDIT */
-+#include <libaudit.h>
-+#endif
- 
- #include <nih/macros.h>
- #include <nih/alloc.h>
-@@ -452,6 +455,23 @@ runlevel_setter (NihOption  *option,
- 	return 0;
- }
- 
-+/**
-+ * send_audit_event
-+ *
-+ * Send system shutdown audit event
-+ **/
-+static void
-+send_audit_event (void)
-+{
-+#if 1 /* HAVE_LIBAUDIT */
-+	int fd = audit_open ();
-+	if (fd < 0)
-+		return;
-+	audit_log_user_message (fd, AUDIT_SYSTEM_SHUTDOWN, "init",
++	snprintf (buf, sizeof (buf),
++		"old-level=%c new-level=%c", old, level);
++	audit_log_user_message (fd, AUDIT_SYSTEM_RUNLEVEL, buf,
 +		NULL, NULL, NULL, 1);
++
++	/* shutdown or reboot */
++	if (level == '0' || level == '6')
++		audit_log_user_message (fd, AUDIT_SYSTEM_SHUTDOWN, "init",
++			NULL, NULL, NULL, 1);
++
 +	close (fd);
 +#endif
 +}
- 
- /**
-  * shutdown_now:
-@@ -496,6 +516,7 @@ shutdown_now (void)
- 	NIH_MUST (message = upstart_message_new (NULL, UPSTART_INIT_DAEMON,
- 						 UPSTART_EVENT_EMIT,
- 						 "runlevel", args, env));
-+	send_audit_event ();
- 
- 	/* Send the message */
- 	if (nih_io_message_send (message, sock) < 0) {
-@@ -513,7 +534,6 @@ shutdown_now (void)
- 		nih_fatal (_("Unable to send message: %s"), err->message);
- 		exit (1);
- 	}
--
- 	unlink (ETC_NOLOGIN);
- 	nih_main_unlink_pidfile ();
- 
-diff -up upstart-0.3.9/compat/sysv/Makefile.in.foo upstart-0.3.9/compat/sysv/Makefile.in
---- upstart-0.3.9/compat/sysv/Makefile.in.foo	2009-04-27 15:53:35.000000000 -0400
-+++ upstart-0.3.9/compat/sysv/Makefile.in	2009-04-27 15:53:55.000000000 -0400
-@@ -280,13 +280,13 @@ EXTRA_DIST = $(manpages)
- @COMPAT_SYSV_TRUE at man_MANS = $(manpages)
- reboot_SOURCES = reboot.c
- reboot_LDFLAGS = -static
--reboot_LDADD = ../../upstart/libupstart.la ../../nih/libnih.la $(LTLIBINTL)
-+reboot_LDADD = ../../upstart/libupstart.la ../../nih/libnih.la $(LTLIBINTL) -laudit
- runlevel_SOURCES = runlevel.c
- runlevel_LDFLAGS = -static
--runlevel_LDADD = ../../nih/libnih.la $(LTLIBINTL)
-+runlevel_LDADD = ../../nih/libnih.la $(LTLIBINTL) -laudit
- shutdown_SOURCES = shutdown.c
- shutdown_LDFLAGS = -static
--shutdown_LDADD = ../../upstart/libupstart.la ../../nih/libnih.la $(LTLIBINTL)
-+shutdown_LDADD = ../../upstart/libupstart.la ../../nih/libnih.la $(LTLIBINTL) -laudit
- telinit_SOURCES = telinit.c
- telinit_LDFLAGS = -static
- telinit_LDADD = ../../upstart/libupstart.la ../../nih/libnih.la $(LTLIBINTL)


Index: upstart.spec
===================================================================
RCS file: /cvs/pkgs/rpms/upstart/devel/upstart.spec,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -p -r1.40 -r1.41
--- upstart.spec	3 Dec 2009 20:00:00 -0000	1.40
+++ upstart.spec	17 Dec 2009 09:56:57 -0000	1.41
@@ -1,6 +1,6 @@
 Name:           upstart
 Version:        0.6.3
-Release:        3%{?dist}
+Release:        4%{?dist}
 Summary:        An event-driven init system
 
 Group:          System Environment/Base
@@ -10,6 +10,7 @@ Source0:        http://upstart.ubuntu.co
 # remove tests which fail in koji
 Patch0:         upstart-remove-tests.patch
 Patch1:		upstart-telinit.patch
+Patch2:		upstart-audit-events.patch
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 Obsoletes: SysVinit < 2.86-24, sysvinit < 2.86-24
 Provides: SysVinit = 2.86-24, sysvinit = 2.86-24
@@ -25,6 +26,7 @@ during shutdown and supervising them whi
 %setup -q
 %patch0 -p1 -b .tests
 %patch1 -p1 -b .u
+%patch2 -p1 -b .audit
 
 %build
 %configure --sbindir=/sbin --libdir=/%{_lib}
@@ -103,6 +105,9 @@ rm -rf %{buildroot}
 %{_mandir}/man8/telinit.8.gz
 
 %changelog
+* Wed Dec 16 2009 Petr Lautrbach <plautrba at redhat.com> 0.6.3-4
+- audit events patch rebased for 0.6 (#470661)
+
 * Thu Dec  3 2009 Bill Nottingham <notting at redhat.com> 0.6.3-3
 - make 'telinit u' a no-op, temporarily
 




More information about the scm-commits mailing list