rpms/upstart/OLPC-3 import.log, NONE, 1.1 upstart-olpc-init.patch, NONE, 1.1 upstart.spec, 1.20, 1.21

Dennis Gilmore (ausil) fedora-extras-commits at redhat.com
Thu Jun 12 20:41:10 UTC 2008


Author: ausil

Update of /cvs/pkgs/rpms/upstart/OLPC-3
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv14717/OLPC-3

Modified Files:
	upstart.spec 
Added Files:
	import.log upstart-olpc-init.patch 
Log Message:
apply OLPC init patch



--- NEW FILE import.log ---
upstart-0_3_9-19_olpc3_1:OLPC-3:upstart-0.3.9-19.olpc3.1.src.rpm:1213303188

upstart-olpc-init.patch:

--- NEW FILE upstart-olpc-init.patch ---
diff -ru upstart-0.3.9/init/control.c upstart-0.3.9/init/control.c
--- upstart-0.3.9/init/control.c	2008-05-06 23:45:35.000000000 -0400
+++ upstart-0.3.9/init/control.c	2008-05-06 23:43:31.000000000 -0400
@@ -26,6 +26,8 @@
 
 
 #include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
 
 #include <errno.h>
 #include <unistd.h>
@@ -134,7 +136,69 @@
 
 	UPSTART_MESSAGE_LAST
 };
+/**
+ * upstart_addr:
+ * @addr: address structure to fill,
+ * @pid: process id.
+ *
+ * Fills the given address structure with the address that a process of
+ * @pid should be listening for responses on.
+ *
+ * The AF_UNIX abstract namespace is used with the init daemon (process #1)
+ * bound to /com/ubuntu/upstart and clients bound to /com/ubuntu/upstart/$PID
+ *
+ * Returns: size of address.
+ **/
+static size_t
+upstart_init_addr (struct sockaddr_un *addr,
+	      pid_t               pid)
+{
+	size_t addrlen;
+
+	nih_assert (addr != NULL);
+	nih_assert (pid > 0);
+
+	addr->sun_family = AF_UNIX;
+	addr->sun_path[0] = '\0';
 
+	addrlen = offsetof (struct sockaddr_un, sun_path) + 1;
+		addrlen += snprintf (addr->sun_path + 1,
+				     sizeof (addr->sun_path) - 1,
+				     "/com/ubuntu/upstart");
+
+	return addrlen;
+}
+
+int
+upstart_init_open (void)
+{
+	struct sockaddr_un addr;
+	size_t             addrlen;
+	int                sock, optval;
+
+	/* Communication is performed using a unix datagram socket */
+	sock = socket (PF_UNIX, SOCK_DGRAM, 0);
+	if (sock < 0)
+		nih_return_system_error (-1);
+
+	/* Bind the socket so we can receive responses */
+	addrlen = upstart_init_addr (&addr, getpid ());
+	if (bind (sock, (struct sockaddr *)&addr, addrlen) < 0)
+		goto error;
+
+	/* Always requests credentials */
+	optval = 1;
+	if (setsockopt (sock, SOL_SOCKET, SO_PASSCRED, &optval,
+			sizeof (optval)) < 0)
+		goto error;
+
+	return sock;
+
+error:
+	nih_error_raise_system ();
+	close (sock);
+	return -1;
+}
 
 /**
  * control_open:
@@ -150,7 +214,7 @@
 {
 	int sock;
 
-	sock = upstart_open ();
+	sock = upstart_init_open ();
 	if (sock < 0)
 		return NULL;
 
diff -ru upstart-0.3.9/init/main.c ./main.c
--- upstart-0.3.9/init/main.c	2008-05-06 23:45:35.000000000 -0400
+++ ./main.c	2008-05-06 23:37:53.000000000 -0400
@@ -95,6 +95,8 @@
  **/
 static int rescue = FALSE;
 
+static int snarf = FALSE;
+
 
 /**
  * options:
@@ -102,8 +104,9 @@
  * Command-line options we accept.
  **/
 static NihOption options[] = {
-	{ 0, "restart", NULL, NULL, NULL, &restart, NULL },
-	{ 0, "rescue", NULL, NULL, NULL, &rescue, NULL },
+	{ 'd', "restart", "Restart init (bad idea?)", NULL, NULL, &restart, NULL },
+	{ 's', "rescue", "Perform rescue operations?", NULL, NULL, &rescue, NULL },
+	{ 'i', "init", "Snarf PID happily.", NULL, NULL, &snarf, NULL },
 
 	/* Ignore invalid options */
 	{ '-', "--", NULL, NULL, NULL, NULL, NULL },
@@ -139,7 +142,9 @@
 	}
 
 	/* Check we're process #1 */
-	if (getpid () > 1) {
+	if (snarf) {
+		int pid = getpid();
+	} else if (getpid () > 1) {
 		execv (TELINIT, argv);
 		/* Ignore failure, probably just that telinit doesn't exist */
 
@@ -147,7 +152,6 @@
 		exit (1);
 	}
 
-
 	/* Clear our arguments from the command-line, so that we show up in
 	 * ps or top output as /sbin/init, with no extra flags.
 	 *
diff -ru upstart-0.3.9/upstart/message.c ./main.c
--- upstart-0.3.9/upstart/message.c	2008-05-07 10:45:31.000000000 -0400
+++ upstart-0.3.9/upstart/message.c	2008-05-07 10:46:00.000000000 -0400
@@ -515,30 +515,6 @@
 		 */
 	}
 
-	/* Check the origin of the message, this is a safety trap so we
-	 * don't even bother parsing memory if the process shouldn't be able
-	 * to talk to us.
-	 *
-	 * Only the init daemon accepts messages from any process, others
-	 * will only accept messages from the init daemon or themselves.
-	 *
-	 * In addition, we only permit messages to come from a process
-	 * running as root or our own user id (though this may be relaxed
-	 * for the init daemon later).
-	 */
-	if (! upstart_disable_safeties) {
-		if (cred.pid == 0)
-			goto illegal;
-
-		if ((cred.pid != UPSTART_INIT_DAEMON)
-		    && (cred.pid != getpid ())
-		    && (getpid () != UPSTART_INIT_DAEMON))
-			goto illegal;
-
-		if ((cred.uid != 0) && (cred.uid != getuid ()))
-			goto illegal;
-	}
-
 
 	/* Read the header from the message, which tells us what type of
 	 * message follows.


Index: upstart.spec
===================================================================
RCS file: /cvs/pkgs/rpms/upstart/OLPC-3/upstart.spec,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- upstart.spec	25 Apr 2008 21:22:21 -0000	1.20
+++ upstart.spec	12 Jun 2008 20:40:29 -0000	1.21
@@ -1,6 +1,6 @@
 Name:           upstart
 Version:        0.3.9
-Release:        19%{?dist}
+Release:        19%{?dist}.1
 Summary:        An event-driven init system
 
 Group:          System Environment/Base
@@ -15,6 +15,7 @@
 Patch4:         upstart-fedora-buglist.patch
 Patch5:         upstart-telinit-u.patch
 Patch6:	        upstart-initctl-man.patch
+Patch7:         upstart-olpc-init.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
@@ -34,6 +35,7 @@
 %patch4 -p1
 %patch5 -p1
 %patch6 -p1
+%patch7 -p1
 
 %build
 %configure --enable-compat=sysv --sbindir=/sbin --libdir=/%{_lib}
@@ -99,6 +101,9 @@
 %{_mandir}/man8/telinit.8.gz
 
 %changelog
+* Wed May 07 2008 Dennis Gilmore <dennis at laptop.org> - 0.3.9-19.1
+- apply patch from Blake Setlow allowing upstart to run as a PID other than 1
+
 * Fri Apr 25 2008 Bill Nottingham <notting at redhat.com> - 0.3.9-19
 - with the merge of event-compat-sysv, move the sysvinit obsoletes/provides here
 




More information about the fedora-extras-commits mailing list