Your message dated Sat, 21 Apr 2012 12:03:50 +0000
with message-id <[email protected]>
and subject line Bug#660824: fixed in sysvinit 2.88dsf-23
has caused the Debian Bug report #660824,
regarding sysvinit: Please include support for upstart in startpar
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
660824: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=660824
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: sysvinit
Version: 2.88dsf-22
Severity: wishlist

Hi there,

It seems that the discussion about this patch petered out long ago on
pkg-sysvinit-devel
(http://lists.alioth.debian.org/pipermail/pkg-sysvinit-devel/2011-October/005345.html),
so it's probably time to submit a proper bug report to the BTS (especially
since sysvinit appears to be under new maintenance).

Pursuant to bug #591791 against Debian Policy about permitting alternate
init systems in Debian, I've prepared a patch against sysvinit which would
make startpar aware that a given job is implemented as an upstart job
instead of a SysV init script and that startpar should defer to upstart to
satisfy the dependency.

This enables insserv/startpar-based dependency boot to be used for sysvinit
in conjunction with upstart as /sbin/init and native upstart jobs as
dependencies, and is the first step towards having upstart be genuinely
usable on Debian.  It also rolls back the previous /lib/init/upstart-job
approach, which never worked right with startpar due to the inability to
express dependency information.  As a result, packages shipping upstart jobs
should now ship real init scripts in parallel (per the policy bug
discussion), which means some changes to debhelper are wanted before this
goes into effect.

It does *not* allow bidirectional dependencies between upstart jobs and init
scripts.  It's assumed that a system that runs upstart will be converted
from the bottom up - starting with rcS.d, which more or less needs to be
converted as a block anyway.

I've tested this patch to be regression-free on sysvinit as well as working
with upstart, and verified that the package still builds on non-Linux Debian
ports after applying (upstart doesn't run there anyway, so it's a simple
#ifdef :P).  I've also taken care to avoid adding any new runtime library
dependencies here; it would have been nice to use libdbus for talking to
upstart, but I guess some might resist such a change. :-)

The patch includes two mostly unrelated changes that warrant a mention:

 - debian/rules has been patched to pass CFLAGS from dpkg-buildflags to the
   startpar makefile.  Not really related, but was invaluable for having a
   proper debug build when testing.

 - The patch to startpar.c includes a change to call checkdevpts() early on.
   this is a bugfix in its own right; unless devpts support is checked at
   the top of the loop, tasks will be launched as "interactive", meaning
   they won't be run in parallel.  This at least impacts the first process
   launched, I haven't checked if it affects others.  Apparently SuSE never
   had to deal with this bug because the runtime devpts checking code was
   ifdef'ed out there.  In any case, I found a strange interaction between
   interactive tasks and upstart jobs; so this fix is something of a
   prerequisite (and may indicate a latent bug in my patch).

Please consider including this patch in sysvinit for wheezy.

Thanks,
-- 
Steve Langasek                   Give me a lever long enough and a Free OS
Debian Developer                   to set it on, and I can move the world.
Ubuntu Developer                                    http://www.debian.org/
[email protected]                                     [email protected]
diff -Nru sysvinit-2.88dsf/debian/changelog sysvinit-2.88dsf/debian/changelog
--- sysvinit-2.88dsf/debian/changelog	2012-01-30 23:45:48.000000000 +0000
+++ sysvinit-2.88dsf/debian/changelog	2012-02-22 07:39:36.000000000 +0000
@@ -1,3 +1,10 @@
+sysvinit (2.88dsf-22.1) UNRELEASED; urgency=low
+
+  * Fix startpar to not run init scripts that have matching upstart jobs,
+    instead waiting for a signal from upstart.
+
+ -- Steve Langasek <[email protected]>  Tue, 21 Feb 2012 15:49:11 -0800
+
 sysvinit (2.88dsf-22) unstable; urgency=low
 
   [ Roger Leigh ]
diff -Nru sysvinit-2.88dsf/debian/patches/series sysvinit-2.88dsf/debian/patches/series
--- sysvinit-2.88dsf/debian/patches/series	2012-01-28 11:12:47.000000000 +0000
+++ sysvinit-2.88dsf/debian/patches/series	2012-02-22 07:39:34.000000000 +0000
@@ -12,3 +12,4 @@
 92_kfreebsd_ifdown.patch
 93_run_initctl.patch
 94_kfreebsd_xterm.patch
+upstart_support.patch
diff -Nru sysvinit-2.88dsf/debian/patches/upstart_support.patch sysvinit-2.88dsf/debian/patches/upstart_support.patch
--- sysvinit-2.88dsf/debian/patches/upstart_support.patch	1970-01-01 00:00:00.000000000 +0000
+++ sysvinit-2.88dsf/debian/patches/upstart_support.patch	2012-02-22 07:39:34.000000000 +0000
@@ -0,0 +1,630 @@
+=== modified file 'Makefile'
+Index: sysvinit-2.88dsf/startpar/Makefile
+===================================================================
+--- sysvinit-2.88dsf.orig/startpar/Makefile	2012-02-21 15:46:09.000000000 -0800
++++ sysvinit-2.88dsf/startpar/Makefile	2012-02-21 15:56:20.000000000 -0800
+@@ -9,8 +9,8 @@
+ man8dir		= $(mandir)/man8
+ 
+ SRCS		= startpar.c makeboot.c proc.c
+-HDRS		= makeboot.h proc.h
+-REST		= COPYING Makefile startpar.8
++HDRS		= makeboot.h proc.h startpar.h
++REST		= COPYING Makefile startpar.8 startpar-upstart-inject.c
+ OBJS		= $(SRCS:.c=.o)
+ 
+ ifneq ($(INC),)
+Index: sysvinit-2.88dsf/startpar/makeboot.c
+===================================================================
+--- sysvinit-2.88dsf.orig/startpar/makeboot.c	2012-02-21 15:46:09.000000000 -0800
++++ sysvinit-2.88dsf/startpar/makeboot.c	2012-02-21 16:04:20.000000000 -0800
+@@ -21,6 +21,7 @@
+  */
+ 
+ #include <stdio.h>
++#include <stddef.h>
+ #include <string.h>
+ #include <malloc.h>
+ #include <ctype.h>
+@@ -30,6 +31,8 @@
+ #include <stdarg.h>
+ #include <errno.h>
+ #include <limits.h>
++#include <sys/socket.h>
++#include <sys/un.h>
+ #if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >= 600
+ # include <sys/types.h>
+ # include <sys/stat.h>
+@@ -47,6 +50,7 @@
+ #endif
+ #include "makeboot.h"
+ 
++#define DBUS_ADDRESS_UPSTART "@/com/ubuntu/upstart"
+ 
+ int tree_entries = 0;
+ struct makenode *tree_list = NULL;
+@@ -57,7 +61,7 @@
+  *
+  * FIXME: we should use hash for the effective search.
+  */
+-static struct makenode *lookup_target(const char *name)
++struct makenode *lookup_target(const char *name)
+ {
+ 	struct makenode *t;
+ 
+@@ -409,6 +413,105 @@
+ 	}
+ }
+ 
++#ifdef __linux__
++/*
++ * mark upstart services as finished.
++ *
++ * action is either boot, start or stop.
++ */
++int check_upstart_jobs(const char *action, const struct makenode **nodevec)
++{
++	struct makenode *t;
++	int count = 0;
++
++	if (!init_is_upstart())
++		return 0;
++
++	for (t = tree_list; t; t = t->next)
++	{
++		char path[131]; /* three bytes longer than the max allowed init script name... */
++		struct stat job;
++
++		snprintf(path, sizeof(path), "/etc/init/%s.conf", t->name);
++		if (!stat(path,&job)) {
++			int ret;
++			char *command;
++
++			t->upstart = 1;
++			/* Upstart jobs are never interactive in this sense */
++			t->interactive = 0;
++			if (!strcmp(action,"start") || !strcmp(action,"boot"))
++			{
++				asprintf(&command,
++				         "/sbin/initctl status %s | grep -q start/running",
++				         t->name);
++			} else {
++				asprintf(&command,
++				         "/sbin/initctl status %s | grep -q stop/waiting",
++				         t->name);
++			}
++			ret = system(command);
++			if (WEXITSTATUS(ret) == 0) {
++				nodevec[count] = t;
++				finish_task(t);
++				count++;
++			}
++			free(command);
++		}
++	}
++	return count;
++}
++
++/*
++ * return true if PID 1 is upstart, false otherwise.
++ */
++boolean init_is_upstart(void) {
++	static int is_upstart = -1;
++	int fd;
++	struct sockaddr_un saddr;
++	socklen_t addrlen;
++	struct ucred ucred;
++	socklen_t slen;
++
++	if (is_upstart != -1)
++		return is_upstart;
++
++	fd = socket(AF_LOCAL, SOCK_STREAM, 0);
++	/* Weird, but we'll just have to assume no upstart. */
++	if (fd < 0)
++		goto fail;
++
++	saddr.sun_family = AF_LOCAL;
++	strcpy(saddr.sun_path, DBUS_ADDRESS_UPSTART);
++	addrlen = offsetof(struct sockaddr_un, sun_path) + strlen(saddr.sun_path);
++
++	/* translate leading '@' to abstract namespace */
++	if (saddr.sun_path[0] == '@')
++		saddr.sun_path[0] = '\0';
++
++	if (connect(fd, (struct sockaddr *)&saddr, addrlen) < 0)
++		goto fail;
++
++	/* Make sure it's really upstart and not something lying to us! */
++	slen = sizeof(ucred);
++	if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &ucred, &slen) < 0)
++		goto fail;
++
++	close(fd);
++	if (ucred.uid == 0)
++		is_upstart = 1;
++	else
++		is_upstart = 0;
++
++	return is_upstart;
++
++fail:
++	if (fd >= 0)
++		close(fd);
++	is_upstart = 0;
++	return is_upstart;
++}
++#endif
+ 
+ /*
+  * call blogd
+@@ -461,6 +564,8 @@
+ 
+ 	if (! node)
+ 		return;
++	/* Ignore any further upstart signals for this job */
++	node->upstart = 0;
+ 	for (n = node->select; n; n = n->next)
+ 		n->node->num_deps--;
+ #if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >= 600
+Index: sysvinit-2.88dsf/startpar/makeboot.h
+===================================================================
+--- sysvinit-2.88dsf.orig/startpar/makeboot.h	2012-02-21 15:46:09.000000000 -0800
++++ sysvinit-2.88dsf/startpar/makeboot.h	2012-02-21 15:56:20.000000000 -0800
+@@ -23,6 +23,8 @@
+ 	T_READY, T_RUNNING, T_FINISHED
+ };
+ 
++typedef enum _boolean {false, true} boolean;
++
+ /* target nodes */
+ struct makenode {
+ 	char *name;
+@@ -34,6 +36,7 @@
+ 	int status;
+ 	struct makenode *next;
+ 	int interactive;
++	int upstart;
+ 	int importance;
+ 	int filter_prefix;
+ };
+@@ -49,10 +52,13 @@
+ 
+ extern void parse_makefile(const char *path);
+ extern void check_run_files(const char *action, const char *prev, const char *run);
++extern int check_upstart_jobs(const char *action, const struct makenode **nodevec);
+ extern struct makenode *pickup_task(void);
++extern struct makenode *lookup_target(const char *name);
+ extern void finish_task(struct makenode *n);
+ extern void *xcalloc(size_t nmemb, size_t size);
+ extern void print_run_result(int *resvec, struct makenode **nodevec, const char *action);
++extern boolean init_is_upstart(void);
+ 
+ #define alignof(type)		((sizeof(type)+(sizeof(void*)-1)) & ~(sizeof(void*)-1))
+ #define strsize(string)		((strlen(string)+1)*sizeof(char))
+Index: sysvinit-2.88dsf/startpar/startpar.c
+===================================================================
+--- sysvinit-2.88dsf.orig/startpar/startpar.c	2012-02-21 15:46:09.000000000 -0800
++++ sysvinit-2.88dsf/startpar/startpar.c	2012-02-21 23:34:04.000000000 -0800
+@@ -1,4 +1,5 @@
+ /* Copyright (c) 2003 SuSE Linux AG
++ * Copyright 2011 Canonical Ltd
+  *
+  * 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
+@@ -30,6 +31,7 @@
+ # define CHECK_FORDEVPTS
+ #endif
+ #include <stdio.h>
++#include <stddef.h>
+ #include <termios.h>
+ #include <signal.h>
+ #include <sys/types.h>
+@@ -51,6 +53,7 @@
+ #include <string.h>
+ #include <stdlib.h>
+ #include <unistd.h>
++#include <poll.h>
+ #ifdef USE_BLOGD
+ # include <libblogger.h>
+ #else
+@@ -59,6 +62,7 @@
+ #endif
+ #include "makeboot.h"
+ #include "proc.h"
++#include "startpar.h"
+ 
+ #if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)
+ # ifndef  inline
+@@ -80,7 +84,6 @@
+ 
+ #define timerdiff(n,l) (extension({ (((n).tv_sec-(l).tv_sec)*1000)+(((n).tv_usec-(l).tv_usec)/1000); }))
+ 
+-typedef enum _boolean {false, true} boolean;
+ extern char *optarg;
+ extern int optind;
+ 
+@@ -114,6 +117,7 @@
+   pid_t pid;
+   struct timeval lastio;
+   int splashadd;
++  int upstart;
+   int status;
+   int flags;
+   size_t len;
+@@ -831,6 +835,9 @@
+   int limit;
+   int notty = 0;
+   int *resvec;
++#ifdef __linux__
++  int upstart_fd = -1;
++#endif
+   struct timeval tv;
+   struct prg *p;
+   struct prg *gtimo_running = 0;
+@@ -919,6 +926,36 @@
+ 	  splashopt = 0;
+ 	}
+     }
++#ifdef __linux__
++  if (init_is_upstart())
++  {
++    struct sockaddr_un saddr;
++    socklen_t addrlen;
++    upstart_fd = socket(AF_LOCAL, SOCK_SEQPACKET|SOCK_NONBLOCK|SOCK_CLOEXEC, 0);
++    if (upstart_fd < 0)
++      fprintf(stderr, "Failed to open control socket for upstart events\n");
++
++    saddr.sun_family = AF_LOCAL;
++    strcpy(saddr.sun_path, UPSTART_SOCKET_PATH);
++    addrlen = offsetof(struct sockaddr_un, sun_path) + strlen(saddr.sun_path);
++    /* translate leading '@' to abstract namespace */
++    if (saddr.sun_path[0] == '@')
++      saddr.sun_path[0] = '\0';
++    if (bind(upstart_fd, (struct sockaddr *)&saddr, addrlen) < 0)
++    {
++      fprintf(stderr, "Failed to bind address for upstart events: %m\n");
++      close(upstart_fd);
++      upstart_fd = -1;
++    }
++    if (listen(upstart_fd, 0))
++    {
++      fprintf(stderr, "Failed to listen for upstart events: %m\n");
++      close(upstart_fd);
++      upstart_fd = -1;
++    }
++  }
++#endif
++
+   if (run_mode)
+     {
+       char makefile[64];
+@@ -993,6 +1030,12 @@
+   for (i = 0; i < argc; i++)
+     resvec[i] = 255;
+ 
++#ifdef __linux__
++  num += check_upstart_jobs(run_mode, nodevec);
++  for (i = 0; i < num; i++)
++    resvec[i] = 0;
++#endif
++
+   if (argc == 1)
+     {
+       if (run_mode)
+@@ -1102,7 +1145,10 @@
+   for (;;)
+     {
+ #ifdef CHECK_FORDEVPTS
+-      int devpts = 0;
++      /* if we don't initialize this to a proper value, jobs get marked as
++         interactive when they shouldn't be and get lost when there are
++         upstart jobs in the mix. */
++      int devpts = checkdevpts();
+ #endif
+       int maxfd = -1;
+       int last = -1;
+@@ -1114,6 +1160,14 @@
+       gettimeofday(&now, 0);
+       pid = (pid_t)-1;
+       FD_ZERO(&rset);
++
++#ifdef __linux__
++      if (upstart_fd >= 0)
++	FD_SET(upstart_fd, &rset);
++      if (upstart_fd > maxfd)
++	maxfd = upstart_fd;
++#endif
++
+       tv = now;
+ 
+       if ((diff = timerdiff(now, lastlim)) >= 300 || diff < 0)
+@@ -1134,7 +1188,7 @@
+ 	  p = prgs + s;
+ 	  if (p == interactive_task)
+ 	    continue;				/* don't count this here */
+-	  if (p->fd == 0)
++	  if (p->fd == 0 && p->upstart == 0)
+ 	    {
+ 	      if (interactive_task)
+ 		continue;			/* dont't start new processes */
+@@ -1153,6 +1207,7 @@
+ 			interactive_task = p;
+ 		      p->name = nodevec[num]->name;
+ 		      p->arg0 = nodevec[num]->arg0 ? nodevec[num]->arg0 : nodevec[num]->name;
++		      p->upstart = nodevec[num]->upstart;
+ 		    }
+ 		  else {
+ 		    p->name = *argv++;
+@@ -1161,15 +1216,16 @@
+ 		  p->splashadd = calcsplash(num, argc, splashopt);
+ 		  p->num = num++;
+ #ifdef CHECK_FORDEVPTS
+-		  if (!devpts)
++		  if (!devpts && !p->upstart)
+ 		    interactive_task = p;	/* no /dev/pts, treat as interactive */
+ #endif
+-		  if (notty)
++		  if (notty && !p->upstart)
+ 		    interactive_task = p;	/* no tty, treat as interactive */
+ 		  if (interactive_task)
+ 		    continue;			/* don't start this here */
+-		  run(p);
+-		  if (p->pid == 0)
++		  if (p->upstart == 0)
++		    run(p);
++		  if (p->pid == 0 && p->upstart == 0)
+ 		    {
+ 		      resvec[p->num] = 1;
+ 		      if (run_mode)
+@@ -1192,6 +1248,8 @@
+ 		}
+ 	    }
+ 
++	  if (p->upstart)
++	    continue;
+ 	  FD_SET(p->fd, &rset);
+ 	  if (p->fd > maxfd)
+ 	    maxfd = p->fd;
+@@ -1393,6 +1451,120 @@
+ 	}
+       else
+ 	{
++#ifdef __linux__
++	  if (upstart_fd >= 0 && FD_ISSET(upstart_fd, &rset))
++	  {
++	    int client;
++	    /* Process new upstart events, marking the related process
++	       as started */
++	    while ((client = accept4(upstart_fd, NULL, NULL, SOCK_CLOEXEC)) >= 0)
++	    {
++	      struct ucred *cred;
++	      char cred_msg[CMSG_SPACE(sizeof(struct ucred))];
++	      ssize_t size;
++	      char buf[8192];
++	      struct iovec iov;
++	      struct msghdr smsg;
++	      struct cmsghdr *cmsg;
++	      struct makenode *node;
++	      char *event, *name;
++	      int b = true;
++
++	      if (setsockopt(client, SOL_SOCKET, SO_PASSCRED, &b, sizeof(b)) < 0)
++	      {
++		/* Without this, we can't trust the client. */
++		close(client);
++		continue;
++	      }
++
++	      /* Wait for the actual message */
++	      for (;;) {
++		/* Yes, we're already using select elsewhere, but let's not
++		   perpetuate the badness more than necessary. */
++		struct pollfd pfd[1];
++		int r;
++
++		pfd[0].fd = client;
++		pfd[0].events = POLLIN;
++
++		r = poll(pfd, 1, 2000);
++		if (r < 0) {
++		  if (errno == EINTR)
++		    continue;
++		  close(client);
++		  client = -1;
++		}
++		if (r == 0 || !(pfd[0].revents & POLLIN)) {
++		  close(client);
++		  client = -1;
++		}
++		break;
++	      }
++	      /* Error waiting for read, move along */
++	      if (client == -1)
++		continue;
++
++	      memset(&smsg, 0, sizeof(struct msghdr));
++	      iov.iov_base = &buf;
++	      iov.iov_len = sizeof(buf);
++	      smsg.msg_iov = &iov;
++	      smsg.msg_iovlen = 1;
++	      smsg.msg_control = cred_msg;
++	      smsg.msg_controllen = sizeof(cred_msg);
++
++	      size = recvmsg(client, &smsg, 0);
++
++	      /* Each client is only allowed one message. */
++	      close(client);
++	      if (size <= 0)
++		continue;
++
++	      cmsg = CMSG_FIRSTHDR(&smsg);
++	      cred = (struct ucred *) CMSG_DATA(cmsg);
++	      if (cmsg == NULL || cmsg->cmsg_type != SCM_CREDENTIALS
++	          || cred->uid != 0)
++	      {
++		/* we don't trust the client. */
++		continue;
++	      }
++
++	      /* Make sure our message is NUL-terminated... */
++	      buf[size-1] = '\0';
++	      /* No room for the job name, malformed message */
++	      if (strlen(buf) >= size-2)
++		continue;
++	      event = buf;
++	      name = buf+strlen(event)+1;
++	      if ((!strcmp(run_mode, "boot") || !strcmp(run_mode, "start"))
++	          && strcmp(event,"started"))
++		continue;
++	      if ((!strcmp(run_mode, "halt") || !strcmp(run_mode, "stop"))
++	          && strcmp(event,"stopped"))
++		continue;
++	      node = lookup_target(name);
++	      if (node && node->upstart)
++	      {
++	        int found = 0;
++	        finish_task(node);
++	        for (s = 0; s < par; s++)
++		{
++		  p = prgs + s;
++		  /* FIXME: should have a better way to check the job
++		     identity besides strcmp */
++		  if (p->name && !strcmp(p->name,name))
++		  {
++		    found = 1;
++		    p->upstart = 0;
++		    active--;
++		    resvec[p->num] = 0;
++		  }
++		}
++		if (!found)
++		  nodevec[++num] = node;
++	      }
++	    }
++	  }
++#endif
+ 	  for (s = 0; s < par; s++)
+ 	    {
+ 	      p = prgs + s;
+Index: sysvinit-2.88dsf/startpar/startpar-upstart-inject.c
+===================================================================
+--- /dev/null	1970-01-01 00:00:00.000000000 +0000
++++ sysvinit-2.88dsf/startpar/startpar-upstart-inject.c	2012-02-21 15:56:20.000000000 -0800
+@@ -0,0 +1,90 @@
++/* Copyright 2011 Canonical Ltd.
++ *
++ * 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, 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 (see the file COPYING); if not, write to the
++ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
++ * MA 02110-1301, USA.
++ *
++ ****************************************************************
++ */
++
++#include <stddef.h>
++#include <sys/types.h>
++#include <sys/stat.h>
++#include <unistd.h>
++#include <fcntl.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include <sys/types.h>
++#include <sys/socket.h>
++#include <sys/un.h>
++#include <errno.h>
++#include "startpar.h"
++
++int main(int argc, char **argv)
++{
++	int fd, len;
++	ssize_t written = 0;
++	struct sockaddr_un saddr;
++	socklen_t addrlen;
++	char *buf;
++
++	if (argc < 4) {
++		fprintf(stderr, "Usage: %s jobname instance upstart_events\n",
++		        argv[0]);
++		exit(1);
++	}
++
++	fd = socket(AF_LOCAL, SOCK_SEQPACKET|SOCK_NONBLOCK, 0);
++	if (!fd)
++		exit(1);
++
++	saddr.sun_family = AF_LOCAL;
++	strcpy(saddr.sun_path, UPSTART_SOCKET_PATH);
++	addrlen = offsetof(struct sockaddr_un, sun_path) + strlen(saddr.sun_path);
++	/* translate leading '@' to abstract namespace */
++	if (saddr.sun_path[0] == '@')
++		saddr.sun_path[0] = '\0';
++
++	/* If the socket isn't there yet, we can assume startpar hasn't
++	 * started, and will catch this job itself once it does. */
++	if (connect(fd, (struct sockaddr *)&saddr, addrlen) < 0)
++		exit(0);
++
++	/* FIXME: should be able to unambiguously parse the arguments instead
++	 * of relying on whitespace. */
++	if (!strcmp(argv[3],"started") || !strcmp(argv[3],"stopped"))
++	{
++		len = asprintf(&buf, "%s %s %s",argv[3],argv[1],argv[2]);
++		buf[strlen(argv[3])] = '\0';
++		buf[strlen(argv[3])+strlen(argv[1])+1] = '\0';
++	}
++	else
++		/* Unhandled upstart event. */
++		exit(0);
++	if (len < 1)
++		exit(1);
++	do {
++		ssize_t s = send(fd, buf+written, len-written, MSG_NOSIGNAL);
++		if (s < 0 && errno != EINTR)
++		{
++			close(fd);
++			exit(1);
++		}
++		if (s > 0)
++			written += s;
++	} while (written < len);
++	close(fd);
++	exit(0);
++}
+Index: sysvinit-2.88dsf/startpar/startpar.h
+===================================================================
+--- /dev/null	1970-01-01 00:00:00.000000000 +0000
++++ sysvinit-2.88dsf/startpar/startpar.h	2012-02-21 15:56:20.000000000 -0800
+@@ -0,0 +1,21 @@
++/* Copyright 2011 Canonical Ltd.
++ *
++ * 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, 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 (see the file COPYING); if not, write to the
++ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
++ * MA 02110-1301, USA.
++ *
++ ****************************************************************
++ */
++
++#define UPSTART_SOCKET_PATH "@/com/ubuntu/upstart_startpar_bridge"
diff -Nru sysvinit-2.88dsf/debian/rules sysvinit-2.88dsf/debian/rules
--- sysvinit-2.88dsf/debian/rules	2011-12-22 22:59:18.000000000 +0000
+++ sysvinit-2.88dsf/debian/rules	2012-02-22 07:40:53.000000000 +0000
@@ -39,10 +39,16 @@
 
 override_dh_auto_build:
 	$(MAKE) $(CROSS) $(CONFFLAGS) -C src DISTRO=Debian LIBDIR=/usr/lib/$(DEB_HOST_MULTIARCH)
-	$(MAKE) $(CROSS) -C startpar
+	$(MAKE) $(CROSS) COPTS="$(shell dpkg-buildflags --get CFLAGS)" -C startpar
+ifeq ($(DEB_HOST_ARCH_OS),linux)
+	$(MAKE) $(CROSS) COPTS="$(shell dpkg-buildflags --get CFLAGS)" -C startpar startpar-upstart-inject
+endif
 
 override_dh_auto_install-arch:
 	$(MAKE) $(CROSS) -C startpar DESTDIR=$(utiltmp) install
+ifeq ($(DEB_HOST_ARCH_OS),linux)
+	install -m755 startpar/startpar-upstart-inject $(utiltmp)/sbin/
+endif
 	$(MAKE) -C debian/src/bootlogd install DESTDIR=$(bootlogdtmp)
 	$(MAKE) -C debian/src/initscripts install DESTDIR=$(inittmp)
 	$(MAKE) -C src $(CROSS) ROOT=$(tmp) DISTRO=Debian install
@@ -129,9 +135,15 @@
 	# Neither rc, rcS nor README are conffiles
 	$(RM) $(rctmp)/DEBIAN/conffiles
 
+override_dh_installinit-arch:
+	dh_installinit --name startpar-bridge --upstart-only -n
+
 override_dh_clean:
 	dh_clean debian/copyright
 	$(MAKE) -C src clobber
 	$(MAKE) -C startpar clean
+ifeq ($(DEB_HOST_ARCH_OS),linux)
+	rm -f startpar/startpar-upstart-inject
+endif
 
 .PHONY: override_dh_auto_build override_dh_auto_install-arch override_dh_auto_install-indep override_dh_installchangelogs-arch override_dh_installchangelogs-indep override_dh_fixperms override_dh_installdeb-arch override_dh_installdeb-indep override_dh_clean install-arch
diff -Nru sysvinit-2.88dsf/debian/sysvinit-utils.startpar-bridge.upstart sysvinit-2.88dsf/debian/sysvinit-utils.startpar-bridge.upstart
--- sysvinit-2.88dsf/debian/sysvinit-utils.startpar-bridge.upstart	1970-01-01 00:00:00.000000000 +0000
+++ sysvinit-2.88dsf/debian/sysvinit-utils.startpar-bridge.upstart	2012-02-22 07:39:37.000000000 +0000
@@ -0,0 +1,15 @@
+# startpar-bridge - inject upstart start/stop events into startpar
+#
+# This job serves as a bridge to make startpar aware when an upstart job has
+# started or stopped, in order to make a soft transition between sysvinit
+# scripts and upstart jobs possible
+
+description	"startpar bridge for notification of upstart job start/stop"
+author		"Steve Langasek <[email protected]>"
+
+start on started JOB!=startpar-bridge
+instance $JOB-$INSTANCE-$UPSTART_EVENTS
+
+task
+
+exec startpar-upstart-inject "$JOB" "$INSTANCE" "$UPSTART_EVENTS"

--- End Message ---
--- Begin Message ---
Source: sysvinit
Source-Version: 2.88dsf-23

We believe that the bug you reported is fixed in the latest version of
sysvinit, which is due to be installed in the Debian FTP archive:

bootlogd_2.88dsf-23_amd64.deb
  to main/s/sysvinit/bootlogd_2.88dsf-23_amd64.deb
initscripts_2.88dsf-23_amd64.deb
  to main/s/sysvinit/initscripts_2.88dsf-23_amd64.deb
sysv-rc_2.88dsf-23_all.deb
  to main/s/sysvinit/sysv-rc_2.88dsf-23_all.deb
sysvinit-utils_2.88dsf-23_amd64.deb
  to main/s/sysvinit/sysvinit-utils_2.88dsf-23_amd64.deb
sysvinit_2.88dsf-23.debian.tar.gz
  to main/s/sysvinit/sysvinit_2.88dsf-23.debian.tar.gz
sysvinit_2.88dsf-23.dsc
  to main/s/sysvinit/sysvinit_2.88dsf-23.dsc
sysvinit_2.88dsf-23_amd64.deb
  to main/s/sysvinit/sysvinit_2.88dsf-23_amd64.deb



A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Roger Leigh <[email protected]> (supplier of updated sysvinit package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Format: 1.8
Date: Sat, 21 Apr 2012 12:11:45 +0100
Source: sysvinit
Binary: sysvinit sysvinit-utils sysv-rc initscripts bootlogd
Architecture: source amd64 all
Version: 2.88dsf-23
Distribution: experimental
Urgency: low
Maintainer: Debian sysvinit maintainers 
<[email protected]>
Changed-By: Roger Leigh <[email protected]>
Description: 
 bootlogd   - daemon to log boot messages
 initscripts - scripts for initializing and shutting down the system
 sysv-rc    - System-V-like runlevel change mechanism
 sysvinit   - System-V-like init utilities
 sysvinit-utils - System-V-like utilities
Closes: 55707 232569 385172 403863 438895 518249 539261 540448 543793 545401 
545438 550425 558000 562500 567539 585540 587923 596284 596479 596480 596481 
596482 596483 614895 623051 634146 636054 652625 659480 659490 660824 664816 
665995 666871 667745 668312
Changes: 
 sysvinit (2.88dsf-23) experimental; urgency=low
 .
   [ Roger Leigh ]
   * Acknowledge NMU for translation updates.  Thanks to Christian
     Perrier.
   * debian/control:
     - Upgrade to Standards-Version 3.9.3.
     - Build-Depend on debhelper v9.
     - Correct Vcs-Git URL.
   * debian/rules:
     - Use DEB_HOST_ARCH_OS = hurd rather than
       DEB_HOST_ARCH = hurd-i386.   Thanks to Pino Toscano.
   * debian/patches:
     - 11_lfs_cflags.patch: Add patch for enabling large file support,
       needed on GNU/Hurd, but useful for all platforms.
     - 73_lfs_cflags.patch: Add patch for enabling large file support
       in startpar.
   * initscripts:
     - Moved RAM* settings from /etc/default/rcS to /etc/default/tmpfs.
       This ensures that the settings are equivalent for upgrades and
       new installations, but will require manual configuration of the
       settings for upgrades (no migration from /etc/default/rcS to
       /etc/default/tmpfs will take place, due to tmpfs being a
       conffile).  tmpf(5) manual page added to document all aspects
       of tmpfs configuration, including the existing documentation in
       rcS(5).
     - Drop the use of .ramfs dotfiles in /run and /run/lock.  These
       were a legacy of /lib/init/rw and were not actually used by
       anything.  Closes: #403863.
     - Drop /etc/init.d/mountoverflowtmp.  This has been merged into
       the general tmpfs on /tmp handling functions.  This means the
       generic RAMTMP configuration is used for the overflowtmp.
       Closes: #567539.
     - It is now possible to configure a tmpfs mount size limit as a
       percentage of the total VM size (%VM) as well as a percentage
       of the RAM size (%).  This is computed by tmpfs.sh and the
       tmpfs mounts are remounted with the updated size limit after
       swap becomes available.
     - An fstab entry for /tmp overrides RAMTMP.  Document tmpfs
       override and tmpfs defaults in tmpfs(5), also undeprecating the
       tmpfs settings.  Closes: #585540, #665995.
     - An fstab entry for /run/lock or /run/shm overrides RAMLOCK and
       RAMSHM.
     - bootclean cleans /tmp, /run and /run/lock before any filesystems
       are mounted as well as after local and network mounts.  This
       permits cleaning of directories which would otherwise be hidden
       by mountpoints later in the boot process.
       Closes: #55707, #558000, #666871.  Additionally clean up
       /lib/init/rw in case any files were hidden by the (now removed)
       tmpfs mount at this location.  Closes: #652625.
     - Removed last trace of the long-removed EDITMOTD from the
       postinst.  Closes: #438895.
     - Removed documentation of #346342 in rcS(5).  This is no longer
       an issue now tzdata keeps a copy of the data on the rootfs.
       Closes: #385172.
     - Correct description of TMPTIME in rcS(5).  Thanks to Alan J.
       Greenberger.  Closes: #562500.
     - urandom: Applied a series of patches from John Denker to
       improve the integrity of random number generation.  Many thanks.
       Closes: #596479, #596480, #596481, #596482, #596483.
   * sysv-rc:
     - Remove old upgrade logic from maintainer scripts not required
       for wheezy.
     - Migrate users of obsolete static boot ordering to dynamic boot
       ordering.
     - Remove use of /etc/init.d/.legacy-bootordering.  Closes: #668312.
     - Improve help text of debconf message when it is not possible to
       automatically enable dynamic boot ordering.  Provide explicit
       instructions for how to purge obsolete init scripts.
       Closes: #550425.
     - etc/init.d/rc: Ensure linprocfs is mounted on kFreeBSD.  Thanks
       to Robert Millan.  Closes: #659480.
     - Drop undocumented CONCURRENCY setting from /etc/init.d/rc.
       Closes: #518249, #540448, #539261.  Note that this still contains
       internal fallbacks to support non-insserv booting, which may be
       removed at a later date.
     - invoke-rc.d:
       + Minor manual page corrections.  Thanks to Anthony Fiumara.
         Closes: #664816.
       + Remove mention of the "dpkg Programmers' Manual" and replace
         with references to Debian Policy.  Closes: #543793.
     - update-rc.d:
       + Correctly warn about non-LSB standard runlevels.  Thanks to
         Chris Hiestand for this patch.  Closes: #614895.
       + Remove obsolete documentation of
         /var/lib/sysv-rc/legacy-bootsequence.  Thanks to Thomas Hood.
         Closes: #623051.
   * sysvinit:
     - Minor corrections for halt(8) manual page.  Thanks to
       Christoph Anton Mitterer.  Closes: #587923.
     - Installation with debootstrap --variant=fakechroot now works, due
       to only migrating the old control channel when it is still
       present.  Thanks to Michael Gilbert.  Closes: #596284.
   * sysvinit-utils:
     - Recommend bootlogd.  Closes: #659490.  This means that booklogd
       will be installed by default, but will be removable.
       Closes: #232569.
     - Correct documentation of the startpar -i option.  Closes: #545438.
     - Correct startpar(8) SEE ALSO section.  Closes: #634146.
     - Correct wording in service(8).  Thanks to Joey Hess and Regid
       Ichira.  Closes: #545401, #667745.
 .
   [ Steve Langasek ]
   * debian/service/service: fix upstart compatibility to not try to use the
     upstart commands when init isn't upstart.  Closes: #636054.
   * debian/rules: pass CFLAGS when building startpar.
   * Fix startpar to not run init scripts that have matching upstart jobs,
     instead waiting for a signal from upstart.  Closes: #660824.
       to Robert Millan.  (Closes: #659480)
   * sysvinit:
     - Don't restart or perform initctl migration if systemd is
       running.
Checksums-Sha1: 
 bc1ce99e8e897bd0c09caa53a6bee6b5ad99a6a4 2333 sysvinit_2.88dsf-23.dsc
 9c2501aee21b742339e08a1bb4f92abd6d666cbc 198218 
sysvinit_2.88dsf-23.debian.tar.gz
 e5610d9550f696b538297e6d5cb76710578b25eb 129982 sysvinit_2.88dsf-23_amd64.deb
 8ccbeb22e36f6be85e92cc69db2b7d16d3ee48c1 94998 
sysvinit-utils_2.88dsf-23_amd64.deb
 68fd3ee6ccea7bc77440b5ed3ec18e5a9e3259c5 74006 sysv-rc_2.88dsf-23_all.deb
 691f64ebd720902076b313d299e0f44f37a260d8 85272 initscripts_2.88dsf-23_amd64.deb
 8b74707590af2e06e45eac57ac867eb91a51dd54 51100 bootlogd_2.88dsf-23_amd64.deb
Checksums-Sha256: 
 22389c9a4e1c9117a57669c143f9f6208fa3dbe684e898b1eecf7a4fad24792b 2333 
sysvinit_2.88dsf-23.dsc
 19a631f10b37266365ed017073331c30a58cab9e0d654cc04e4b39dbb22ee8be 198218 
sysvinit_2.88dsf-23.debian.tar.gz
 f6eb82ff03cca907c7f93690402b0e79b10d573eb30bcb5d78248f6debd34e4f 129982 
sysvinit_2.88dsf-23_amd64.deb
 e239b598ded96eade6150733b185bc7ba62f23af661dba52900026eec8dbd6b8 94998 
sysvinit-utils_2.88dsf-23_amd64.deb
 7ae267f015c5d86d478903410557c6fb9ab7cda7b2550e309ee964db3cad52c0 74006 
sysv-rc_2.88dsf-23_all.deb
 e078c31ffa9b5c340934ea482e0fa83fbf0a896899349d0fbbf90cfdd5cfafd1 85272 
initscripts_2.88dsf-23_amd64.deb
 de9638eeaf51ebcdc9b125dcb3d2a05788207db6bb87eb817a67d75eb28b2a4d 51100 
bootlogd_2.88dsf-23_amd64.deb
Files: 
 aff54f9648762cdd27ad03953114ab55 2333 admin required sysvinit_2.88dsf-23.dsc
 73382e2cc02513aa75dd970e903c0449 198218 admin required 
sysvinit_2.88dsf-23.debian.tar.gz
 aa83f92a867553ef07a037d1d6bcfc36 129982 admin required 
sysvinit_2.88dsf-23_amd64.deb
 430350412b6147dcb2f55b91f57e63a0 94998 admin required 
sysvinit-utils_2.88dsf-23_amd64.deb
 d8594c369ef0512c9b4923e5cd850684 74006 admin required 
sysv-rc_2.88dsf-23_all.deb
 9f887829de6e3d8ec42a7623c0d316e2 85272 admin required 
initscripts_2.88dsf-23_amd64.deb
 9a58745baa4dc323748af477184eb89f 51100 admin optional 
bootlogd_2.88dsf-23_amd64.deb

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iQIcBAEBCgAGBQJPkp4iAAoJEOJSSsUKn1xZN3kQAIO3o9ZgT4W4niORSj9vIoZk
m+pSKb1Q9aP0KOPpJeRIFIyeVFSxHNjBeQg0VMerG8jSU0N5LZHa2hEZg+Oji4VI
pbX7kk2a46iH3VJvkGzGSWc7M83n5ymQ9pUT2gz8YBW0vPsOrcZapLLO8nspczFe
VI1iw5tB95/sl8MfQ5oKcOEsZYXz58MRpPfuXeMFi+/kXfQ+OJo95UEjYJH6Jj6T
YxXKiKdVRs49iM/9XlVIUwd8mLfc129DI5kVgXlNokxlqFd5WE9CBeWRckjsWwFF
ntxJSnnN7iwWLmBcZdCuLdiyG+LCu3Hxq6wzp9qL04rpaW3AMRUHyTElqp4U7d8X
AkDtmN18AEvaNrAkpwVLIQrJ3FIblaXDZ5i0Mvh0WB//onuLlQG+hTtRA1a9oJGJ
BeHgDTfXPYTOlcibn4RUNVh/qKLXUS+h+gjHs9K4+W6G5MfLaMnaw6Lcnohdxm+l
02a5il+x+oxAl6BKS9O1qlyNvU71TEUU0OGkiDQruXM0qi63P1dphV1MNhve1w8j
yndjZ7pgHaC/lqzEgkR5t5XPG+WKHNgr34usKg4CT3k35DqIIdg5ZY+oPHI6lRvA
uZIj9FzL95oeuh6TnknbMRZR/gZgMhp2vUQOsFI9ScH6zNCfuaMcRl77R0sazgxP
0iDzU8ik31qzCebdAk5r
=RV6U
-----END PGP SIGNATURE-----



--- End Message ---
_______________________________________________
Pkg-sysvinit-devel mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-sysvinit-devel

Reply via email to