--- upstart-1.3.orig/ChangeLog +++ upstart-1.3/ChangeLog @@ -1,3 +1,56 @@ +2011-11-09 James Hunt + + * ChangeLog: Updated. + * extra/upstart-udev-bridge.c: Change default behaviour to strip control + characters from udev data to avoid nasty side-effects. A new option + "--no-strip" is provided to allow the old behaviour of passing the + udev data through unmolested (LP: #829980). + * extra/man/upstart-udev-bridge.8: Update for new "--no-strip" option + and added missing options: "--debug", "--verbose" and "--help". + +2011-07-25 James Hunt + + * init/job_process.c: job_process_spawn(): + - Added dup2() return check. + * TESTING.sessions: Updated with information on user sessions. + * init/job_process.c: + - job_process_spawn(): + - Change group before user and do it as early as possible. + - Ensure non-priv user is able to read script fd. Default system + behaviour is seemingly not consistent/defined, so force it + to be (LP: #813052) + - Ensure cwd for user job is home directory by default. + - job_process_error_read(): + - Added handling for JOB_PROCESS_ERROR_SETUID and + JOB_PROCESS_ERROR_SETGID (LP: #807293). + - Added new entry for JOB_PROCESS_ERROR_CHOWN. + * init/job_process.h: + - Added entry for JOB_PROCESS_ERROR_CHOWN in JobProcessErrorType. + * init/man/init.5: Update for user jobs explaining behaviour of stanzas + which manipulate system resource limits and when the init + daemon reads the users job directory. + * util/tests/test_user_sessions.sh: New script for testing user sessions + (NOTE: this is *NOT* run automatically). + * init/session.c: session_from_dbus(): Handle case where a users + home directory is changed or where a uid is re-used for a + different username. + * init/session.h: Updated comments for Session object. + * init/man/init.5: Explain that symbolic links are not supported. + +2011-07-22 James Hunt + + * util/man/initctl.8: Clarify semantics of restart(8) + command (LP: #731225). + +2011-07-20 James Hunt + + * util/tests/test_initctl.c: + - test_show_config(): /* fall through :) */ + - test_check_config(): Manually start and stop dbus-daemon to work + around change in dbus autostart behaviour which causes issues when + running the tests in a chroot and non-X11 environment (see dbus commit + cea055514a9dfc74e7f0515cf4a256da10a891bc). + 2011-06-14 James Hunt * NEWS: Release 1.3 --- upstart-1.3.orig/TESTING.sessions +++ upstart-1.3/TESTING.sessions @@ -0,0 +1,289 @@ +.. contents:: + +============================= +Testing Sessions with Upstart +============================= + +Upstart now has support for two types of "sessions": + +* user sessions + +* chroots sessions + +Such sessions are implemented by asociating a separate Upstart session +with every chroot environment and every non-privileged user. + +The session support does not yet provide full tests (as would be run by +"``make check``"). This is mostly due to the complexity of automatically +testing some of the scenarios below. + +This document attempts to outline the minimum set of tests that should +be performed to ensure that session support works as expected. + +Assumptions +=========== + +You are running an Ubuntu or Debian system. + +User Sessions +============= + +User sessions can be minimally tested using the script provided:: + + util/tests/test_user_sessions.sh + +Notes: + +- Run "``test_user_sessions.sh -h``" to understand what this script does. + +- that this script needs to be run on a system where the version of + ``/sbin/init`` has session support since the ``/sbin/init`` binary + itself will be tested. For this reason, the script cannot be run as part + of the "``make check``" run. + +- The script will complain loudly if any of the tests fail and tell you + how to raise a bug. + +Chroot Sessions +=============== + +Setup +----- + +#. Install a chroot environement (such as ``schroot(1)``) and configure it. +#. run, "``debootstrap(8)``" to install the same release as you are running into your chroot. +#. Create the following files *outside* your chroot. + + - ``/etc/init/foo.conf``:: + + start on wibble + + script + exec 2>>/tmp/foo.$$.log + set -x + echo "foo: stat=`stat /`" + echo "foo: env=`env`" + sleep 999 + end script + + - ``/etc/init/outside_chroot.conf``:: + + start on A + + script + exec 2>>/tmp/outside_chroot.$$.log + set -x + echo "in_chroot: stat=`stat /`" + echo "in_chroot: env=`env`" + sleep 999 + end script + +#. Create following files inside chroot environment. + + - ``/path/to/chroot/etc/init/foo.conf``:: + + start on wibble + + script + exec 2>>/tmp/foo.$$.log + set -x + echo "foo: stat=`stat /`" + echo "foo: env=`env`" + sleep 999 + end script + + - ``/path/to/chroot/etc/init/in_chroot.conf``:: + + start on A + + script + exec 2>>/tmp/in_chroot.$$.log + set -x + echo "in_chroot: stat=`stat /`" + echo "in_chroot: env=`env`" + sleep 999 + end script + + +Run as non-``root`` with no chroot +---------------------------------- + +- ``initctl list`` + + Ensure list is contents of ``/etc/init/``: the command below should + return no output:: + + cmp <(initctl list|awk '{print $1}'|sort -u) <(cd /etc/init && ls *.conf|cut -d: -f2-|sed 's/\.conf//g'|sort -u) + +- ``initctl status cron`` + + Should work. + +- ``initctl show-config`` + + Should work. + +- ``initctl check-config`` + + Should work. + +- ``start foo`` + + Should fail ("``initctl: Rejected send message``"). + +- ``stop cron`` + + Should fail ("``initctl: Rejected send message``"). + +- ``restart cron`` + + Should fail ("``initctl: Rejected send message``"). + +- ``initctl emit bar`` + + Should fail ("``initctl: Rejected send message``"). + +Run as ``root`` with no chroot +------------------------------ + +- ``initctl list`` + + Ensure list is contents of ``/etc/init/``: command below should return no output:: + + cmp <(initctl list|awk '{print $1}'|sort -u) <(cd /etc/init && ls *.conf|cut -d: -f2-|sed 's/\.conf//g'|sort -u) + +- ``initctl status outside_chroot`` + + Should work. + +- ``initctl status in_chroot`` + + Should fail with message:: + + initct: Unknown job: in_chroot + +- ``initctl show-config`` + + Should work. + +- ``initctl check-config`` + + Should work. + +- ``start in_chroot`` + + Should fail with message:: + + initct: Unknown job: in_chroot + +- ``start outside_chroot`` + + Should work. + +- ``stop in_chroot`` + + Should fail with message:: + + initct: Unknown job: in_chroot + +- ``restart outside_chroot`` + + Should work. + +- ``stop outside_chroot`` + + Should work. + +- ``initctl emit wibble`` + + - Ensure ``/etc/init/foo.conf`` runs by looking at the log and ensuring + the inode for the stat of '``/``' is the same as running "``stat /``" on + the command-line. + + * Ensure ``/path/to/chroot/etc/init/foo.conf`` does *NOT* run. + +- ``initctl emit A`` + + - Ensure ``/etc/init/outside_chroot.conf`` runs. + + - Ensure ``/path/to/chroot/etc/init/in_chroot.conf`` does *NOT* run. + +Run as ``root`` inside a chroot +------------------------------- + +- ``initctl list`` + + Ensure list is contents of ``/path/to/chroot/etc/init/``: command below should return no output:: + + cmp <(initctl list|awk '{print $1}'|sort -u) <(cd /etc/init && ls *.conf|cut -d: -f2-|sed 's/\.conf//g'|sort -u) + +- ``initctl status in_chroot`` + + Should work. + +- ``initctl status outside_chroot`` + + Should fail with message:: + + initct: Unknown job: outside_chroot + +- ``initctl show-config`` + + Should work. + +- ``initctl check-config`` + + Should work. + +- ``start outside_chroot`` + + Should fail with message:: + + initct: Unknown job: outside_chroot + +- ``stop outside_chroot`` + + Should fail with message:: + + initct: Unknown job: outside_chroot + +- ``start in_chroot`` + + Should work. + +- ``restart in_chroot`` + + Should work. + +- ``stop in_chroot`` + + Should work. + +- ``initctl emit wibble`` + + - Ensure ``/path/to/chroot/etc/init/foo.conf`` runs by looking at the log and ensuring + the inode for the stat of '``/``' is the same as running "``stat /``" on the command-line. + + - Ensure ``/etc/init/foo.conf`` does *NOT* run. + +- ``initctl emit A`` + + - Ensure ``/path/to/chroot/etc/init/in_chroot.conf`` runs. + + - Ensure ``/etc/init/outside_chroot.conf`` does *NOT* run. + +Run as non-root inside a chroot +------------------------------- + +Not supported. + +Run with ``--no-sessions`` +-------------------------- + +The "``--no-sessions``" option makes Upstart behave as it used to prior to +the introduction of session support. + +#. Reboot system and specify "``--no-sessions``" on kernel command-line. + +#. Ensure "``initctl list``" within a chroot displays the same list as + "``initctl list``" run outside of any chroot environment. --- upstart-1.3.orig/NEWS +++ upstart-1.3/NEWS @@ -1,3 +1,5 @@ +1.4 xxxx-xx-xx + 1.3 2011-06-14 "Concordia" * New upstart-socket-bridge application which allows jobs to be --- upstart-1.3.orig/conf/rc.conf +++ upstart-1.3/conf/rc.conf @@ -6,13 +6,18 @@ description "System V runlevel compatibility" author "Scott James Remnant " +emits deconfiguring-networking +emits unmounted-remote-filesystems + start on runlevel [0123456] stop on runlevel [!$RUNLEVEL] export RUNLEVEL export PREVLEVEL +console output +env INIT_VERBOSE + task -console output exec /etc/init.d/rc $RUNLEVEL --- upstart-1.3.orig/conf/rc-sysinit.conf +++ upstart-1.3/conf/rc-sysinit.conf @@ -6,7 +6,7 @@ description "System V initialisation compatibility" author "Scott James Remnant " -start on startup +start on (filesystem and static-network-up) or failsafe-boot stop on runlevel # Default runlevel, this may be overriden on the kernel command-line @@ -23,9 +23,11 @@ env RUNLEVEL= env PREVLEVEL= +console output +env INIT_VERBOSE + task -console owner script # Check for default runlevel in /etc/inittab if [ -r /etc/inittab ] --- upstart-1.3.orig/debian/upstart.install +++ upstart-1.3/debian/upstart.install @@ -0,0 +1,4 @@ +debian/conf/*.conf etc/init/ +debian/upstart-job lib/init/ +debian/apparmor-profile-load lib/init/ +debian/migrate-inittab.pl usr/lib/upstart/ --- upstart-1.3.orig/debian/control +++ upstart-1.3/debian/control @@ -0,0 +1,21 @@ +Source: upstart +Section: admin +Priority: required +Maintainer: James Hunt +Uploaders: Scott James Remnant +Standards-Version: 3.8.4.0 +Build-Depends: debhelper (>= 7.3.15ubuntu2), pkg-config (>= 0.22), libnih-dev (>= 1.0.3), libnih-dbus-dev (>= 1.0.3), nih-dbus-tool (>= 1.0.3), libdbus-1-dev (>= 1.2.16), libexpat1-dev (>= 2.0.0), libudev-dev (>= 151-5), dbus, bash-completion +Homepage: http://upstart.ubuntu.com/ + +Package: upstart +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, sysvinit-utils, sysv-rc, initscripts, mountall, ifupdown (>= 0.6.10ubuntu5) +Suggests: python, graphviz, bash-completion +Replaces: upstart-job, sysvinit, upstart-compat-sysv, startup-tasks, system-services +Conflicts: upstart-job, sysvinit, upstart-compat-sysv, startup-tasks, system-services +Provides: upstart-job, upstart-compat-sysv, startup-tasks, system-services +Breaks: libc6 (<< 2.12.1-0ubuntu12), friendly-recovery (<< 0.2.13) +Description: event-based init daemon + upstart is a replacement for the /sbin/init daemon which handles + starting of tasks and services during boot, stopping them during + shutdown and supervising them while the system is running. --- upstart-1.3.orig/debian/README.Debian +++ upstart-1.3/debian/README.Debian @@ -0,0 +1,200 @@ +upstart +======= + +Upstart is a replacement for the traditional sysvinit package, and +runs as process #1. Through upstart, we are able to have an +event-driven process, whilst at the same time retaining compatibility +for the original sysvinit behaviour. + +This file documents how to do a few common operations with the new +system. + + +Where are initscripts installed? +-------------------------------- + +This has not changed, they are installed in /etc/init.d. See +/etc/init.d/README. + +Important system jobs are no longer shipped as initscripts, but as +upstart jobs. These are installed in /etc/init + + +How are initscripts started and stopped? +---------------------------------------- + +This has not changed, symlinks are made from the initscript in the +/etc/init.d directory to the /etc/rc?.d directories. See +/etc/init.d/README and /etc/rc?.d/README. + + +What order are initscripts started and stopped in? +-------------------------------------------------- + +This has not changed, the symlinks are named SNNname or KNNname, where +NN is a number from 00 to 99. The K scripts are run first in +numerical order, followed by the S scripts in numerical order. + + +How do I find the current/previous runlevel? +-------------------------------------------- + +This has not changed, use the "runlevel" command. See runlevel(8). + + +How do I change the runlevel? +----------------------------- + +This has not changed, use the "telinit" command or just invoke "init" +directly. See telinit(8). + + +How do I change the default runlevel? +------------------------------------- + +If you have an /etc/inittab file, edit it. Locate the following line: + + id:N:initdefault: + +Where N is the default runlevel, change this to match. + +Most people won't have that file, you can edit /etc/init/rc-sysinit.conf +and change the following line: + + env DEFAULT_RUNLEVEL=2 + + +How do I shutdown the machine? +------------------------------ + +This has not changed, use the "shutdown" command provided by the +upstart package; you may also use the "reboot"/"halt"/"poweroff" +commands as a short-cut. See shutdown(8) and reboot(8). + +You can also press Control-Alt-Delete on a console to reboot the +machine. + + +How do I change the behaviour of Control-Alt-Delete? +---------------------------------------------------- + +Edit the /etc/init/control-alt-delete.conf file, the line beginning +"exec" is what upstart will run when this key combination is pressed. + +To not do anything, you can simply delete this file. + + +How do I enter single-user mode? +-------------------------------- + +This hasn't changed, choose the "(recovery mode)" option from GRUB; +add "-s", "S" or "single" to the kernel command-line; or from a +running machine, run "telinit 1" or "shutdown now". + + +How do I reduce the number of gettys? +------------------------------------- + +Also see "How do I change which runlevels gettys are run in?" + +In /etc/init there is a file named ttyN.conf for each getty that will be +started, where N is numbered 1 to 6. Remove any that you do not +want. + +This will not take immediate effect, however you can run "stop ttyN" +to stop one that is running. + + +How do I change getty parameters? +--------------------------------- + +In /etc/init there is a file named ttyN.conf for each getty that will be +started, where N is numbered 1 to 6. Edit these files, the line +beginning "respawn" is what upstart will run. + +This will not take immediate effect, run "stop ttyN" followed by +"start ttyN" or just kill the running getty to respawn with the new +parameters. + + +How do I change which runlevels gettys are run in? +-------------------------------------------------- + +In /etc/init there is a file named ttyN.conf for each getty that will be +started, where N is numbered 1 to 6. Edit these files, there are two +lines: + + start on runlevel [2345] + stop on runlevel [!2345] + +Change the set of runlevels to match your taste. + +This will not take immediate effect, however you can run "stop ttyN" +to stop one that is running or "start ttyN" to start one that isn't. + + +How do I increase the number of gettys? +--------------------------------------- + +In /etc/init there is a file named ttyN.conf for each getty that will be +started, where N is numbered 1 to 6. + +Copy one of these files to a new name, we suggest you simply name it +after the tty, e.g. "ttyS0". + +Edit that file, change the "respawn" line to match your requirements; +in particular you'll need to change the tty the getty should be run +on. + +This will not take immediate effect, however you can run "start ttyN" +to start the getty. + + +How do I add a serial console? +------------------------------ + +See "How do I increase the number of gettys?" + + +How can I see boot messages on the console? +------------------------------------------- + +This is nothing to do with upstart, but I'll answer this anyway. +Remove "quiet" from the kernel command-line. + +To make this permanent, edit /boot/grub/menu.lst and edit the line +that begins "# defoptions=" (yes, it looks like a comment). + +This will change both usplash and the LSB init logging. + + +Upstart isn't working, how do I debug it? +----------------------------------------- + +Add "--debug" to the kernel command-line, and be sure to remove "quiet" +and "splash". You'll now see debugging messages as upstart works. + + +Can I query upstart for a list of jobs? +--------------------------------------- + +Yes, "initctl list" will list the known jobs and their status. + + +How do I manually start or stop a job? +-------------------------------------- + +Use "start JOB" or "stop JOB". + + +How do I find the status of a job? +---------------------------------- + +Use "status JOB". + + +Can I emit an event by hand? +---------------------------- + +Yes, "initctl emit EVENT" will emit the named event and cause any +jobs waiting for it to be started or stopped as appropriate. --- upstart-1.3.orig/debian/migrate-inittab.pl +++ upstart-1.3/debian/migrate-inittab.pl @@ -0,0 +1,143 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +my %gettys; +my $have_cad = 0; + + +#-----------------------------------------------------------------------------# +# Parse /etc/inittab +#-----------------------------------------------------------------------------# + +open INITTAB, "/etc/inittab" + or die "Unable to open /etc/inittab: $!"; + +while () { + chomp; + s/^\s*//; + + next if /^\#/; + next unless length; + + my ($id, $rlevel, $action, $process) = split /:/, $_, 4; + + warn "missing id field" and next + unless defined $id and length $id; + warn "missing runlevel field" and next + unless defined $rlevel; + warn "missing action field" and next + unless defined $action and length $action; + warn "missing process field" and next + unless defined $process; + + + $have_cad = 1 if $action eq "ctrlaltdel"; + $gettys{$1} = [ $rlevel, $process ] if $process =~ /getty.*\b(tty\w+)/; +} + +close INITTAB + or warn "Error while closing /etc/inittab: $!"; + + +#-----------------------------------------------------------------------------# +# Alter /etc/event.d +#-----------------------------------------------------------------------------# + +unlink "/etc/init/control-alt-delete.conf" + unless $have_cad; + +foreach (qw/tty1 tty2 tty3 tty4 tty5 tty6/) { + unlink "/etc/init/$_.conf" + unless exists $gettys{$_}; +} + +foreach (sort keys %gettys) { + my ($rlevel, $process) = @{$gettys{$_}}; + + my @job; + if (-f "/etc/event.d/$_") { + open JOB, "/etc/event.d/$_" + or warn "Unable to open /etc/event.d/$_: $!" and next; + @job = ; + chomp @job; + close JOB + or warn "Error while closing /etc/event,d/$_: $!" and next; + + foreach my $rl (qw/2 3 4 5/) { + my $idx; + for ($idx = 0; $idx < @job; $idx++) { + last if $job[$idx] =~ /^\s*(start|stop)\s+on\s+runlevel\s+$rl\b/; + } + + if ($idx < @job) { + if ($rlevel =~ /$rl/) { + $job[$idx] =~ s/^(\s*)stop(\s+)/$1start$2/; + } else { + $job[$idx] =~ s/^(\s*)start(\s+)/$1stop$2/; + } + } else { + if ($rlevel =~ /$rl/) { + push @job, "start on runlevel $rl"; + } else { + push @job, "stop on runlevel $rl"; + } + } + } + + my $idx; + for ($idx = 0; $idx < @job; $idx++) { + last if $job[$idx] =~ /^\s*respawn\s*/; # match bare 'respawn' too + } + + if ($idx < @job) { + # only match old-style 'respawn process', not bare 'respawn' + $job[$idx] =~ s/^(\s*respawn\s+).*/$1$process/; + } else { + push @job, "respawn"; + push @job, "exec $process"; + } + + # Try to fix up effects of previous broken migrations + if (@job and $job[$#job] =~ /.*(.+?)exec (\1)$/) { + $job[$#job] = "exec $1"; + } + + } else { + push @job, "# $_ - getty"; + push @job, "#"; + push @job, "# Converted from /etc/inittab entry"; + push @job, ""; + + foreach my $rl (qw/2 3 4 5/) { + if ($rlevel =~ /$rl/) { + push @job, "start on runlevel $rl"; + } else { + push @job, "stop on runlevel $rl"; + } + } + push @job, ""; + + push @job, "stop on shutdown"; + push @job, ""; + + push @job, "respawn"; + push @job, "exec $process"; + } + + open JOB, ">/etc/event.d/.$_" + or warn "Unable to write to /etc/event.d/.$_: $!" and next; + print JOB map { "$_\n" } @job; + unless (close JOB) { + warn "Error while closing /etc/event.d/.$_: $!"; + unlink "/etc/event.d/.$_"; + next; + } + + unless (rename "/etc/event.d/.$_", "/etc/event.d/$_") { + warn "Unable to replace /etc/event.d/$_: $!"; + unlink "/etc/event.d/.$_"; + next; + } +} --- upstart-1.3.orig/debian/apparmor-profile-load +++ upstart-1.3/debian/apparmor-profile-load @@ -0,0 +1,27 @@ +#!/bin/sh +# apparmor-profile-load +# +# Helper for loading an AppArmor profile in pre-start scripts. + +[ -z "$1" ] && exit 1 # require a profile name + +[ -d /rofs/etc/apparmor.d ] && exit 0 # do not load if running liveCD + +profile=/etc/apparmor.d/"$1" +[ -e "$profile" ] || exit 0 # skip when missing profile + +module=/sys/module/apparmor +[ -d $module ] || exit 0 # do not load without AppArmor in kernel + +[ -x /sbin/apparmor_parser ] || exit 0 # do not load without parser + +aafs=/sys/kernel/security/apparmor +[ -d $aafs ] || exit 0 # do not load if unmounted +[ -w $aafs/.load ] || exit 1 # fail if cannot load profiles + +params=$module/parameters +[ -r $params/enabled ] || exit 0 # do not load if missing +read enabled < $params/enabled || exit 1 # if this fails, something went wrong +[ "$enabled" = "Y" ] || exit 0 # do not load if disabled + +/sbin/apparmor_parser -r -W "$profile" --- upstart-1.3.orig/debian/rules +++ upstart-1.3/debian/rules @@ -0,0 +1,26 @@ +#!/usr/bin/make -f +%: + dh --with bash-completion $@ + + +CFLAGS = -Wall -g -fstack-protector -fPIE +LDFLAGS = -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -pie + +# Disable optimisations if noopt found in $DEB_BUILD_OPTIONS +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) + CFLAGS += -O0 + LDFLAGS += -Wl,-O0 +else + CFLAGS += -Os + LDFLAGS += -Wl,-O1 +endif + +override_dh_auto_configure: + dh_auto_configure -- CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ + --exec-prefix= + +override_dh_fixperms: + dh_fixperms + chmod 755 debian/upstart/lib/init/upstart-job + chmod 755 debian/upstart/lib/init/apparmor-profile-load + chmod 755 debian/upstart/usr/lib/upstart/migrate-inittab.pl --- upstart-1.3.orig/debian/compat +++ upstart-1.3/debian/compat @@ -0,0 +1 @@ +7 --- upstart-1.3.orig/debian/upstart-job +++ upstart-1.3/debian/upstart-job @@ -0,0 +1,85 @@ +#!/bin/sh -e +# upstart-job +# +# Symlink target for initscripts that have been converted to Upstart. + +set -e + +INITSCRIPT="$(basename "$0")" +JOB="${INITSCRIPT%.sh}" + +if [ "$JOB" = "upstart-job" ]; then + if [ -z "$1" ]; then + echo "Usage: upstart-job JOB COMMAND" 1>&2 + exit 1 + fi + + JOB="$1" + INITSCRIPT="$1" + shift +else + if [ -z "$1" ]; then + echo "Usage: $0 COMMAND" 1>&2 + exit 1 + fi +fi + +COMMAND="$1" +shift + + +if [ -z "$DPKG_MAINTSCRIPT_PACKAGE" ]; then + ECHO=echo +else + ECHO=: +fi + +$ECHO "Rather than invoking init scripts through /etc/init.d, use the service(8)" +$ECHO "utility, e.g. service $INITSCRIPT $COMMAND" + +case $COMMAND in +status) + $ECHO + $ECHO "Since the script you are attempting to invoke has been converted to an" + $ECHO "Upstart job, you may also use the $COMMAND(8) utility, e.g. $COMMAND $JOB" + $COMMAND "$JOB" + ;; +start|stop) + $ECHO + $ECHO "Since the script you are attempting to invoke has been converted to an" + $ECHO "Upstart job, you may also use the $COMMAND(8) utility, e.g. $COMMAND $JOB" + if status "$JOB" 2>/dev/null | grep -q ' start/'; then + RUNNING=1 + fi + if [ -z "$RUNNING" ] && [ "$COMMAND" = "stop" ]; then + exit 0 + elif [ -n "$RUNNING" ] && [ "$COMMAND" = "start" ]; then + exit 0 + fi + $COMMAND "$JOB" + ;; +restart) + $ECHO + $ECHO "Since the script you are attempting to invoke has been converted to an" + $ECHO "Upstart job, you may also use the stop(8) and then start(8) utilities," + $ECHO "e.g. stop $JOB ; start $JOB. The restart(8) utility is also available." + if status "$JOB" 2>/dev/null | grep -q ' start/'; then + RUNNING=1 + fi + if [ -n "$RUNNING" ] ; then + stop "$JOB" + fi + start "$JOB" + ;; +reload|force-reload) + $ECHO + $ECHO "Since the script you are attempting to invoke has been converted to an" + $ECHO "Upstart job, you may also use the reload(8) utility, e.g. reload $JOB" + reload "$JOB" + ;; +*) + $ECHO + $ECHO "The script you are attempting to invoke has been converted to an Upstart" 1>&2 + $ECHO "job, but $COMMAND is not supported for Upstart jobs." 1>&2 + exit 1 +esac --- upstart-1.3.orig/debian/upstart.postinst +++ upstart-1.3/debian/upstart.postinst @@ -0,0 +1,62 @@ +#!/bin/sh -e +# This script can be called in the following ways: +# +# After the package was installed: +# configure +# +# +# If prerm fails during upgrade or fails on failed upgrade: +# abort-upgrade +# +# If prerm fails during deconfiguration of a package: +# abort-deconfigure in-favour +# removing +# +# If prerm fails during replacement due to conflict: +# abort-remove in-favour + + +# Remove a no-longer used conffile +rm_conffile() +{ + CONFFILE="$1" + + if [ -e "$CONFFILE".dpkg-obsolete ]; then + echo "Removing obsolete conffile $CONFFILE" + rm -f "$CONFFILE".dpkg-obsolete + fi +} + + +case "$1" in + configure) + if dpkg --compare-versions "$2" lt-nl 0.6.0; then + # We're upgrading from a version of Upstart that doesn't use + # D-Bus for its IPC. We have to tell it to re-exec into one + # that does. It'll lose all state, but we didn't keep much + # in those days. + telinit u + else + # Before we shutdown or reboot, we need to re-exec so that we + # can safely remount the root filesystem; we can't just do that + # here because we lose state. + touch /var/run/init.upgraded || : + fi + + # Upgrade from karmic development version + if dpkg --compare-versions "$2" lt-nl 0.6.3-7; then + rm_conffile /etc/init/dbus-reconnect.conf + fi + ;; + + abort-upgrade|abort-deconfigure|abort-remove) + ;; + + *) + echo "$0 called with unknown argument \`$1'" 1>&2 + exit 1 + ;; +esac + +#DEBHELPER# +exit 0 --- upstart-1.3.orig/debian/copyright +++ upstart-1.3/debian/copyright @@ -0,0 +1,18 @@ +This is the Ubuntu package of upstart, the event-based init daemon. + +Copyright © 2009 Canonical Ltd. +Copyright © 2009 Scott James Remnant + +Licence: + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License version 2, as +published by the Free Software Foundation. + +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. + +On Ubuntu systems, the complete text of the GNU General Public License +can be found in ‘/usr/share/common-licenses/GPL’. --- upstart-1.3.orig/debian/upstart.docs +++ upstart-1.3/debian/upstart.docs @@ -0,0 +1,2 @@ +AUTHORS +NEWS --- upstart-1.3.orig/debian/upstart.bash-completion +++ upstart-1.3/debian/upstart.bash-completion @@ -0,0 +1 @@ +contrib/bash_completion/upstart --- upstart-1.3.orig/debian/upstart.manpages +++ upstart-1.3/debian/upstart.manpages @@ -0,0 +1 @@ +debian/manpages/* --- upstart-1.3.orig/debian/upstart.postrm +++ upstart-1.3/debian/upstart.postrm @@ -0,0 +1,81 @@ +#!/bin/sh -e +# This script can be called in the following ways: +# +# After the package was removed: +# remove +# +# After the package was purged: +# purge +# +# After the package was upgraded: +# upgrade +# if that fails: +# failed-upgrade +# +# +# After all of the packages files have been replaced: +# disappear +# +# +# If preinst fails during install: +# abort-install +# +# If preinst fails during upgrade of removed package: +# abort-install +# +# If preinst fails during upgrade: +# abort-upgrade + + +# Undo removal of a no-longer used conffile +undo_rm_conffile() +{ + CONFFILE="$1" + + if [ ! -e "$CONFFILE" ]; then + if [ -e "$CONFFILE".dpkg-bak ]; then + echo "Restoring modified conffile $CONFFILE" + mv -f "$CONFFILE".dpkg-bak "$CONFFILE" + elif [ -e "$CONFFILE".dpkg-obsolete ]; then + mv -f "$CONFFILE".dpkg-obsolete "$CONFFILE" + fi + fi +} + +# Finish removal of a no-longer used conffile +finish_rm_conffile() +{ + CONFFILE="$1" + + if [ -e "$CONFFILE".dpkg-bak ]; then + rm -f "$CONFFILE".dpkg-bak + fi +} + + +case "$1" in + remove) + ;; + + purge) + finish_rm_conffile /etc/init/dbus-reconnect.conf + ;; + + upgrade|failed-upgrade|disappear) + ;; + + abort-install|abort-upgrade) + # Abort upgrade from karmic development version + if dpkg --compare-versions "$2" lt-nl 0.6.3-7; then + undo_rm_conffile /etc/init/dbus-reconnect.conf + fi + ;; + + *) + echo "$0 called with unknown argument \`$1'" 1>&2 + exit 1 + ;; +esac + +#DEBHELPER# +exit 0 --- upstart-1.3.orig/debian/upstart.preinst +++ upstart-1.3/debian/upstart.preinst @@ -0,0 +1,54 @@ +#!/bin/sh -e +# This script can be called in the following ways: +# +# Before the package is installed: +# install +# +# Before removed package is upgraded: +# install +# +# Before the package is upgraded: +# upgrade +# +# +# If postrm fails during upgrade or fails on failed upgrade: +# abort-upgrade + + +# Prepare to remove a no-longer used conffile +prep_rm_conffile() +{ + CONFFILE="$1" + + if [ -e "$CONFFILE" ]; then + md5sum="`md5sum \"$CONFFILE\" | sed -e \"s/ .*//\"`" + old_md5sum="`sed -n -e \"/^Conffiles:/,/^[^ ]/{\\\\' $CONFFILE '{s/ obsolete$//;s/.* //;p}}\" /var/lib/dpkg/status`" + if [ "$md5sum" != "$old_md5sum" ]; then + echo "Obsolete conffile $CONFFILE has been modified by you, renaming to .dpkg-bak" + mv -f "$CONFFILE" "$CONFFILE".dpkg-bak + else + mv -f "$CONFFILE" "$CONFFILE".dpkg-obsolete + fi + fi +} + + +case "$1" in + install|upgrade) + # Upgrade from karmic development version + if dpkg --compare-versions "$2" lt-nl 0.6.3-7; then + prep_rm_conffile /etc/init/dbus-reconnect.conf + fi + ;; + + abort-upgrade) + ;; + + *) + echo "$0 called with unknown argument \`$1'" 1>&2 + exit 1 + ;; +esac + +#DEBHELPER# +exit 0 --- upstart-1.3.orig/debian/changelog +++ upstart-1.3/debian/changelog @@ -0,0 +1,1036 @@ +upstart (1.3-0ubuntu12~bug829980) oneiric; urgency=low + + * ChangeLog: Updated. + * extra/upstart-udev-bridge.c: Change default behaviour to strip control + characters from udev data to avoid nasty side-effects. A new option + "--no-strip" is provided to allow the old behaviour of passing the + udev data through unmolested (LP: #829980). + * extra/man/upstart-udev-bridge.8: Update for new "--no-strip" option + and added missing options: "--debug", "--verbose" and "--help". + + -- James Hunt Wed, 09 Nov 2011 12:04:59 +0000 + +upstart (1.3-0ubuntu11) oneiric-proposed; urgency=low + + * debian/conf/failsafe.conf: stop on static-network-up, so that a slow + runlevel switch doesn't leave a confusing message on screen about + starting up without networking. LP: #881079. + + -- Steve Langasek Wed, 26 Oct 2011 12:05:47 -0700 + +upstart (1.3-0ubuntu10) oneiric; urgency=low + + [ Clint Byrum ] + * debian/conf/failsafe.conf: do delay as script, not pre-start, so + that the messages/delays are stopped on runlevel immediately. emit + as an event, failsafe-boot, to provide finer grained control. + (LP: #863864) + * conf/rc-sysinit.conf: change from 'started failsafe' to 'failsafe-boot' + to accomodate changes to failsafe.conf. + + [ Steve Langasek ] + * Document device-not-ready in upstart-events(7). LP: #805510. + * Document desktop-shutdown in upstart-events(7). LP: #854329. + * Mention lightdm in the list of example DMs in upstart-events(7), since + it's now the default... + + -- Steve Langasek Mon, 03 Oct 2011 18:37:04 -0700 + +upstart (1.3-0ubuntu9) oneiric; urgency=low + + * Update rcS.conf to only start single user mode but not friendly-recovery. + (LP: #575469) + * Mark upstart as breaking friendly-recovery << 0.2.13 + + -- Stéphane Graber Thu, 15 Sep 2011 16:04:17 -0400 + +upstart (1.3-0ubuntu8) oneiric; urgency=low + + * debian/conf/failsafe.conf: Add plymouth messages to help users + understand why the system boot takes longer when they have + static network interfaces defined. (LP: #847782) + + -- Clint Byrum Wed, 14 Sep 2011 18:53:10 -0700 + +upstart (1.3-0ubuntu7) oneiric; urgency=low + + * debian/conf/failsafe.conf: raise timeout to 120 seconds to + allow for very slow DHCP interfaces to come up on servers. + (LP: #839595) + + -- Clint Byrum Sun, 04 Sep 2011 09:29:27 -0700 + +upstart (1.3-0ubuntu6) oneiric; urgency=low + + [ Steve Langasek ] + * Fix maintainer field to be compliant with policy definition + + [ Clint Byrum ] + * conf/rc.conf: document events that are emitted by sysvinit + jobs to quiet 'initctl check-config' + * extra/conf/upstart-udev-bridge.conf: narrow definition to + only the events actually emitted. (LP: #819928) + * debian/conf/failsafe.conf: new job for critical services to + start on. + * conf/rc-sysinit.conf: start after static-network-up or failsafe + so that runlevel 2 is only entered with all static net interfaces + up. (LP: #580319) + + -- Clint Byrum Wed, 10 Aug 2011 08:44:43 -0500 + +upstart (1.3-0ubuntu5) oneiric; urgency=low + + * Upstream cherry-pick for user session fixes + ("bzr merge -r 1318..1324 lp:upstart"). + + -- James Hunt Mon, 25 Jul 2011 17:09:47 +0100 + +upstart (1.3-0ubuntu4) oneiric; urgency=low + + * init/main.c: main(): Add support for "/run" directory with fallback to + old location for initramfs state passing (LP: #810956). + * Upstream cherry-pick to get dbus fix ("bzr merge -r 1314.. lp:upstart"). + + -- James Hunt Wed, 20 Jul 2011 14:51:04 +0100 + +upstart (1.3-0ubuntu3) oneiric; urgency=low + + * init/paths.h: Syned with upstream since Ubuntu file appears to have + diff applied twice, causing redefines. + + -- James Hunt Fri, 17 Jun 2011 09:59:49 +0100 + +upstart (1.3-0ubuntu2) oneiric; urgency=low + + * init/Makefile.am: Sync up from upstream, dropping TEST define which is + no longer required now we set UPSTART_NO_SESSIONS for init/tests/*.c + and specify "--no-sessions" for util/tests/*.c. + + -- James Hunt Fri, 17 Jun 2011 09:47:36 +0100 + +upstart (1.3-0ubuntu1) oneiric; urgency=low + + * Merge of Upstart 1.3 (lp:upstart @ 1.3 release tag). + + -- James Hunt Thu, 16 Jun 2011 15:09:41 +0100 + +upstart (0.9.7-3) oneiric; urgency=low + + * Merge of upstream lp:~upstart-devel/upstart/0.9: Updates for + init-checkconf. + + -- James Hunt Wed, 27 Apr 2011 15:19:47 +0100 + +upstart (0.9.7-2) oneiric; urgency=low + + * Add wait-for-state generic "wait job". + + -- Clint Byrum Wed, 04 May 2011 08:32:04 -0700 + +upstart (0.9.7-1) natty; urgency=low + + * New upstream release 0.9.7: Important session fix (LP: #767053). + + -- James Hunt Wed, 20 Apr 2011 17:44:41 +0100 + +upstart (0.9.6-1ubuntu1) natty; urgency=low + + [ James Hunt ] + * init/man/init.5: Remove mention of user jobs since facility is + disabled. + + [ Clint Byrum ] + * Noting bugs fixed by 0.9.6 release of upstart: (LP: #728531 , LP: #766206) + + -- Clint Byrum Tue, 19 Apr 2011 13:16:46 -0700 + +upstart (0.9.6-1) natty; urgency=low + + * New upstream release 0.9.6: Important session+chroot fixes. + + -- James Hunt Fri, 15 Apr 2011 15:36:40 +0100 + +upstart (0.9.5-1ubuntu1) natty; urgency=low + + [ Clint Byrum ] + * debian/upstart-job: change behavior to reload job configuration on + restart, which more closely matches expected sysvinit script + behavior. (LP: #707479) + + -- James Hunt Wed, 06 Apr 2011 17:50:53 +0100 + +upstart (0.9.5-1) natty; urgency=low + + * New upstream release 0.9.5. + + -- James Hunt Wed, 06 Apr 2011 17:45:38 +0100 + +upstart (0.9.4-1ubuntu1) natty; urgency=low + + * debian/manpages/upstart-events.7: + - Corrected reference to Upstart man page (actually init). + - Changed to using proper troff quotes. + - Escaped dashes in event names. + - Updated date. + - Table 1: + - Improved name. + - Sorted columns: Events, References, and Notes. + - Added unmounted-remote-filesystems event. + + -- James Hunt Thu, 24 Mar 2011 14:34:12 +0000 + +upstart (0.9.4-1) natty; urgency=low + + * New upstream release 0.9.4: + - scripts/initctl2dot.py: Fixes to handle 'emits' glob syntax. + + -- James Hunt Thu, 24 Mar 2011 14:31:26 +0000 + +upstart (0.9.3-1) natty; urgency=low + + * New upstream release 0.9.3: + - Added missing emits stanzas for supplied .conf files. + - Added wildcard/globbing facility to initctl.c (for check-config + command). + - Updated man page on emits stanza syntax. + + -- James Hunt Tue, 15 Mar 2011 11:57:11 +0000 + +upstart (0.9.2-1) natty; urgency=low + + * Merge of upstream lp:~upstart-devel/upstart/0.9. + + -- James Hunt Fri, 11 Mar 2011 10:34:39 +0000 + +upstart (0.9.1-1ubuntu5) natty; urgency=low + + * Merge of upstream lp:~upstart-devel/upstart/0.9. + + -- James Hunt Thu, 10 Mar 2011 14:23:28 +0000 + +upstart (0.9.1-1ubuntu4) natty; urgency=low + + * Merge of upstream lp:~upstart-devel/upstart/0.9. + + -- James Hunt Mon, 07 Mar 2011 15:08:35 +0000 + +upstart (0.9.1-1ubuntu3) natty; urgency=low + + * debian/upstart.bash-completion: Fixed path so dh_bash-completion + considers it a file, not a snippet. + + -- James Hunt Fri, 04 Mar 2011 21:26:27 +0000 + +upstart (0.9.1-1ubuntu2) natty; urgency=low + + * debian/control: Added Suggests for python, graphviz and + bash-completion. + * debian/rules: Invoke bash-completion add-on explicitly. + * debian/manpages/upstart-events.7: New man page. + * debian/upstart.bash-completion: Install bash completion. + * debian/upstart.manpages: Install upstart-events.7. + + -- James Hunt Fri, 04 Mar 2011 17:16:26 +0000 + +upstart (0.9.1-1ubuntu1) natty; urgency=low + + * Merge of upstream lp:~upstart-devel/upstart/0.9. + + -- James Hunt Fri, 04 Mar 2011 15:13:35 +0000 + +upstart (0.9.1-1) natty; urgency=low + + * Merge of upstream lp:~upstart-devel/upstart/0.9. + + -- James Hunt Thu, 03 Mar 2011 20:52:16 +0000 + +upstart (0.9.0-1ubuntu3) natty; urgency=low + + * Revert dbus/Upstart.conf to the version in 0.6.7, disabling user session + support until such time as it has comprehensive test suite coverage. + + -- Colin Watson Mon, 28 Feb 2011 20:29:01 +0000 + +upstart (0.9.0-1ubuntu2) natty; urgency=low + + * Added extra/Makefile.in to avoid build failing. These files need removing + at a later date and debian/rules updating to call dh-autoreconf. + + -- James Hunt Thu, 24 Feb 2011 16:39:28 +0000 + +upstart (0.9.0-1ubuntu1) natty; urgency=low + + * debian/control: Updated for nih version 1.0.3 (required for nih-dbus-tool + and DBUS_TYPE_UNIX_FD). + * removed binary message catalog files causing build issues: + - po/en@boldquot.gmo + - po/en@quot.gmo + + -- James Hunt Thu, 24 Feb 2011 16:06:13 +0000 + +upstart (0.9.0-1) natty; urgency=low + + * New upstream release: + - Session support (chroots, sessions and user-session). + - Socket bridge. + - Override file support. + + -- James Hunt Thu, 24 Feb 2011 14:22:14 +0000 + +upstart (0.6.7-7) natty; urgency=low + + * Re-add upstream r977 to allow proper re-exec on shutdown (LP: #672177) + * debian/control: adding Breaks on eglibc version that disables + telinit u to avoid accidentally installing a version of libc6 that + will cause upstart to re-exec and lose its state. + + -- Clint Byrum Fri, 21 Jan 2011 08:39:13 -0800 + +upstart (0.6.7-6) natty; urgency=low + + * debian/apparmor-profile-load: check for correct AppArmor profile loading + interface file (LP: #710649). + + -- Kees Cook Thu, 03 Feb 2011 13:45:32 -0800 + +upstart (0.6.7-5) natty; urgency=low + + * debian/upstart-job: properly handle jobs that are in state 'start/running' + with no PID, by checking only if the goal is 'start'. LP: #603934, + #707971. + + -- Steve Langasek Wed, 26 Jan 2011 14:05:43 -0800 + +upstart (0.6.7-4) natty; urgency=low + + * debian/apparmor-profile-load: allow profiles to be missing for saner + packaging integration. + + -- Kees Cook Fri, 14 Jan 2011 13:46:12 -0800 + +upstart (0.6.7-3) natty; urgency=low + + * debian/rules: make sure apparmor-profile-load is executable. + + -- Kees Cook Wed, 22 Dec 2010 10:55:09 -0800 + +upstart (0.6.7-2) natty; urgency=low + + * debian/apparmor-profile-load: common AppArmor profile loading helper + which can be used by any upstart services, regardless of the state + of AppArmor (LP: #692801). + + -- Kees Cook Mon, 20 Dec 2010 16:03:33 -0800 + +upstart (0.6.7-1) natty; urgency=low + + * New upstream release: + - Added manual stanza. + - Added debug stanza. + - Added start_on, stop_on and emits properties. + - Added GoalChanged, StateChanged and Failed signals. + - Documentation updates. + + * Added myself as a maintainer. + + -- James Hunt Tue, 14 Dec 2010 17:15:57 +0000 + +upstart (0.6.6-3) maverick; urgency=low + + * Ubuntu seems to have stopped installing Recommends of Build-Depends, + add a Build-Depend on dbus. LP: #602130. + + -- Scott James Remnant Thu, 12 Aug 2010 16:38:05 -0400 + +upstart (0.6.6-2) maverick; urgency=low + + * Apply patch from trunk to use /dev/null when /dev/console is unavailable + due to kernel bugs. This isn't a fix for those bugs, but it does work + around it for now. LP: #554172. + + -- Scott James Remnant Thu, 12 Aug 2010 09:52:07 -0400 + +upstart (0.6.6-1ubuntu1) maverick; urgency=low + + * Try buying with -fPIE/-pie on armel again; we have a shiny new armel + toolchain and this part of the rules was broken in 0.6.6-1 anyway. + + -- Loïc Minier Fri, 23 Jul 2010 14:54:11 +0200 + +upstart (0.6.6-1) maverick; urgency=low + + * New upstream release: + - All changes were previously merged into this package. + + * debian/upstart-job: + - Fix output for the force-reload command to only refer to reload(8). + LP: #532862. + + * Add debian/source/format with "1.0" to be future compatible. + * Add missing ${misc:Depends}. + * Bump standards version. + * Convert rules to dh7 format. + + -- Scott James Remnant Tue, 27 Apr 2010 13:41:18 -0700 + +upstart (0.6.5-6) lucid; urgency=low + + * Merge fixes from trunk: + - double-quoting of NIH_CFLAGS and NIH_DBUS_CFLAGS on --with-local-libnih + - document "env KEY" behaviour + * conf/rc.conf, conf/rc-sysinit.conf: + - enable console output. LP: #548954. + - pass value of INIT_VERBOSE from kernel command-line. + + -- Scott James Remnant Thu, 01 Apr 2010 19:25:36 +0100 + +upstart (0.6.5-5) lucid; urgency=low + + * init/main.c: + - Don't change the settings of the foreground console, this is often + owned by plymouth and not supposed to be in Canonical Mode; all other + paths have stty sane settings anyway (which these are not), so there + really isn't need for init to do this. LP: #540256. + + -- Scott James Remnant Wed, 17 Mar 2010 22:34:55 +0000 + +upstart (0.6.5-4) lucid; urgency=low + + * debian/control: + - change Pre-Depends back to Depends, this was a holdover from when we + attempted to make Upstart Essential to solve early sysvinit→upstart + upgrade issues, we backed out the Essential bit but never the use of + Pre-Depends. LP: #527722. + - add versioned-dependencies on ifupdown for loopback fix that can + prevent initscripts from being run. LP: #527830. + + * Merge patches from trunk to use /proc/self/fd instead of /dev/fd, and + to always mount /proc and /sys on boot. + + -- Scott James Remnant Fri, 26 Feb 2010 15:40:58 +0000 + +upstart (0.6.5-3) lucid; urgency=low + + * udev/upstart-udev-bridge.c: use right variable name, fixing a build + failure. (LP: #524484) + + -- Scott Moser Fri, 19 Feb 2010 10:21:33 -0500 + +upstart (0.6.5-2) lucid; urgency=low + + * udev/upstart-udev-bridge.c: + - Increase receiving buffer size for uevents so we don't miss any. + LP: #504883. + + -- Scott James Remnant Wed, 17 Feb 2010 15:50:40 +0000 + +upstart (0.6.5-1) lucid; urgency=low + + * New upstream release: + - libnih has been separated out into its own project. + - "start on" and "stop on" now support != matches. LP: #513035. + - Fixed crash in child when unable to spawn job. LP: #451917. + - No longer holds /dev/console open so SAK won't kill init. LP: #486005. + - Added missing OPTIONS section to init(8). LP: #449883. + + [ Scott James Remnant ] + * Build-depend on libnih-dev, libnih-dbus-dev and nih-dbus-tool to use + the separated out libnih. + - This has the fix for LP: #436758. + - Remove changelog.nih from the doc directory. + * Bump udev build-dependency to 147 to match upstream. + * udev/Makefile.am: Update to use external libnih + + [ Johan Kiviniemi ] + * udev/upstart-udev-bridge.c: Change -device-remove to -device-removed to + match -device-added and -device-changed. LP: #516698. + + -- Scott James Remnant Thu, 04 Feb 2010 16:30:10 -0800 + +upstart (0.6.3-11build1) lucid; urgency=low + + * Rebuild to pick up relaxed dependency on libc6, after checking that + __abort_msg is available with the same signature in eglibc 2.11. + LP: #508702. + + -- Matthias Klose Mon, 18 Jan 2010 16:10:11 +0100 + +upstart (0.6.3-11) karmic-proposed; urgency=low + + * Make rc-sysinit.conf wait on the loopback interface, to ensure that the + interface is up before we process the scripts in /etc/rc?.d. LP: #461725. + + -- Steve Langasek Tue, 08 Dec 2009 12:58:37 -0800 + +upstart (0.6.3-10) karmic; urgency=low + + * Retain the "telinit u" for the case when we're upgrading from pre-0.6 + (ie. hardy or jaunty). Whups. LP: #451556. + + -- Scott James Remnant Thu, 15 Oct 2009 17:48:47 +0100 + +upstart (0.6.3-9) karmic; urgency=low + + * Restore the call to sync() in reboot, have been observing some issues + and it looks like ext4 might not be explicitly flushing the disk when + remounting read-only. + + -- Scott James Remnant Wed, 14 Oct 2009 16:40:32 +0100 + +upstart (0.6.3-8) karmic; urgency=low + + * Rather than calling "telinit u" after upgrade, which will lose state, + have the umountroot initscript take care of it for us by setting a + flag. LP: #441796. + * Don't lose the original default runlevel if /etc/inittab exists without + an initdefault line. LP: #405847. + * Fix "unhandled error" in shutdown when unable to change runlevel, + e.g. due to previous Ubiquity bug. LP: #426332. + * Merge change from trunk that makes it possible to build Upstart using + a previously built copy of nih-dbus-tool, especially useful when + cross-compiling. LP: #426740. + * Merge change from libnih to store our assertion messages in the + glibc __abort_msg symbol so apport can pick them up. LP: #429411. + * Merge change from libnih to fix compilation issue with eglibc due + to changed alphasort() prototype. + + -- Scott James Remnant Wed, 14 Oct 2009 05:34:13 +0100 + +upstart (0.6.3-7) karmic; urgency=low + + * Ignore initramfs pids that don't exist. LP: #440071. + - you still need to ensure that the pid's parent is init, there's no + cheap way to test for that. + * Remove "console owner" and "console output" from rc scripts. + * Try harder to remove dbus-reconnect.conf + + -- Scott James Remnant Fri, 02 Oct 2009 21:09:03 +0100 + +upstart (0.6.3-6) karmic; urgency=low + + * Don't use "telinit q" to reconnect to D-Bus, since that breaks + lots of things. Invent another secret way instead. + + [ Steve Langasek ] + * upstart-job's restart target must also not fail when the service is not + yet started. LP: #430883. + + -- Scott James Remnant Thu, 01 Oct 2009 15:26:19 +0100 + +upstart (0.6.3-5) karmic; urgency=low + + * Update autoconf and automake files. LP: #435252. + + -- Scott James Remnant Wed, 23 Sep 2009 14:16:34 -0700 + +upstart (0.6.3-4) karmic; urgency=low + + [ Scott James Remnant ] + * Reduce the priority of the stopped by/continued by messages so that + they are only shown when --verbose on the kernel command-line. + LP: #401333. + * Add a hack to look for /dev/.initramfs/*.pid files on startup and + "fake" start jobs of those names. Basically this means that "status" + and "stop" work for things like bootchart and usplash. + * Implement a "reload" command in initctl that retrieves the current pid + of the job and sends it the HUP signal. LP: #433544. + + [ Steve Langasek ] + * debian/upstart-job: + - give proper policy-compliant behavior of the start command: detect if + the job is already running using upstart status, and if so return success. + - same for the stop command: return success if the job is already stopped. + - when $DPKG_MAINTSCRIPT_PACKAGE is set, don't spit warnings out because + it's not the user's fault - we're being invoked by a maintainer script. + + -- Scott James Remnant Tue, 22 Sep 2009 13:56:48 -0700 + +upstart (0.6.3-3) karmic; urgency=low + + * debian/upstart-job: + - force-reload should only send a HUP signal, since it may not be wise + to actually restart (cf. dbus) + + -- Scott James Remnant Wed, 16 Sep 2009 00:10:13 +0100 + +upstart (0.6.3-2) karmic; urgency=low + + FFE LP: #427356. + + * debian/upstart-job: + - Remove trailing "s" from file + - Support direct invocation better. + * udev/upstart-udev-bridge.c: + - New tool to capture events from the udev netlink socket and + convert into upstart events. + * conf/rc-sysinit.conf: + - Run once all filesystems are mounted, rather than on startup + * debian/control: + - Add dependency on mountall for the filesystem event. + + -- Scott James Remnant Tue, 15 Sep 2009 03:19:09 +0100 + +upstart (0.6.3-1) karmic; urgency=low + + * New upstream release: + - Fixed assertion when a job exits while stopping. LP: #406408. + - Fixed compilation on ia64. + - nih-dbus-tool(1) manpage no longer installed. + + -- Scott James Remnant Mon, 03 Aug 2009 23:58:47 +0100 + +upstart (0.6.2-1) karmic; urgency=low + + * New upstream release: + - Fixed assertion when stopping a job during its starting event. + - Fixed fork following to not stop on exec() before fork() + - Fixed missing chdir() in crash handler. + + -- Scott James Remnant Wed, 22 Jul 2009 10:39:50 +0100 + +upstart (0.6.1-1) karmic; urgency=low + + * New upstream release: + - Fixed race condition in ptrace() code. LP: #264711. + - Fixed runlevel to output "unknown" not "N N". LP: #400248. + - Fixed runlevel to prefix error messages with filename. LP: #400241. + + * Provide/Conflict/Replace the agreed "upstart-job" meta-package. + LP: #399799. + * Bump dpkg dependency to 1.2.16 + + -- Scott James Remnant Thu, 16 Jul 2009 18:26:23 +0100 + +upstart (0.6.0-5) karmic; urgency=low + + * Cherry-pick patch from -r1188 to fix "expect fork" and "expect daemon" + LP: #264711. + + -- Scott James Remnant Tue, 14 Jul 2009 15:19:17 +0100 + +upstart (0.6.0-4) karmic; urgency=low + + * Don't build the testsuite with -fPIE on armel; LP: #398403. + + -- Loïc Minier Mon, 13 Jul 2009 22:12:34 +0200 + +upstart (0.6.0-3) karmic; urgency=low + + * Add Conflicts on older Upstart packages to make update-manager's + job easier. + + -- Scott James Remnant Fri, 10 Jul 2009 10:11:21 +0100 + +upstart (0.6.0-2) karmic; urgency=low + + * Bump D-Bus build dependency to ensure we get the container abandonment + patches, and the GIT version bump. + * Actually ship /lib/init/upstart-job + + -- Scott James Remnant Thu, 09 Jul 2009 17:29:59 +0100 + +upstart (0.6.0-1) karmic; urgency=low + + * New upstream release ("How appropriate, you fight like a cow") + - my customary changes list since pointless, it's basically a + complete rewrite. + - Handles /bin/sh symlink disappearing. LP: #65024. + - Boot parameters may be passed to init scripts. LP: #74664. + - reboot implies --force during shutdown. LP: #388738. + - reboot no longer iterates /proc/ide. LP: #92685. + - much improved documentation. LP: #60429, #72058, #388715. + + * Merge the various upstart packages into a single package, it makes + little sense to have it all spread out. + + -- Scott James Remnant Wed, 08 Jul 2009 23:12:03 +0100 + +upstart (0.3.10-2) karmic; urgency=low + + * debian/upstart.postinst: Use telinit u to re-exec, rather than + kill just in case it's not Upstart that's running. LP: #92177. + * debian/event.d/system-services/tty*: Run getty in 8-bit clean + mode. LP: #273189. + * debian/event.d/upstart-compat-sysv/rc-default: + - Don't use grep -w, instead split on $IFS and iterate. LP: #385911. + - Check for any valid runlevel, not just S. LP: #85014. + - Make console owner, since it may spawn sulogin. + * debian/event.d/upstart-compat-sysv/rcS: + - Spawn sulogin if given -b or "emergency". LP: #193810. + * debian/event.d/upstart-compat-sysv/rcS: + - Make console owner. LP: #211402. + * debian/event.d/upstart-compat-sysv/rcS-sulogin: + - Place the telinit code in post-stop, checking $UPSTART_EVENT first so + we don't change the runlevel if we were stopped due to a runlevel + change. LP: #66002. + + -- Scott James Remnant Thu, 18 Jun 2009 16:19:34 +0100 + +upstart (0.3.10-1) karmic; urgency=low + + * Compilation fixes. + * Fixed assertion caused by the post-start or pre-stop scripts + exiting after the main process of a respawning job had exited. + LP: #381048. + + -- Scott James Remnant Wed, 17 Jun 2009 13:33:40 +0100 + +upstart (0.3.9-8) intrepid; urgency=low + + * Do not attempt to continue communicating with the restarted upstart + (LP: #273761). + + -- Kees Cook Mon, 29 Sep 2008 13:35:21 -0700 + +upstart (0.3.9-7) intrepid; urgency=low + + * Implement "telinit u" by just sending Upstart SIGTERM with a slightly + different patch than Fedora. LP: #188925. + + -- Scott James Remnant Tue, 23 Sep 2008 09:01:09 -0700 + +upstart (0.3.9-6) intrepid; urgency=low + + * Really fix LP: #237276 properly this time, lost the change while mucking + around with bzr. + + -- Scott James Remnant Wed, 04 Jun 2008 22:29:48 +0100 + +upstart (0.3.9-5) intrepid; urgency=low + + * Correct build problem on amd64 and ia64 by only building libnih and + libupstart statically. The shared objects were unwanted, and conflict + with -fPIE. + + -- Scott James Remnant Wed, 04 Jun 2008 17:07:12 +0100 + +upstart (0.3.9-4) intrepid; urgency=low + + * Add missing limits.h, required to build with current libc. + + -- Scott James Remnant Wed, 04 Jun 2008 13:09:32 +0100 + +upstart (0.3.9-3) intrepid; urgency=low + + * Change dependency from sysvutils to sysvinit-utils. LP: #237276. + * Compile with stack -fstack-protector, -fPIE, -z relro, -z now and -pie + (MMmm, pie) + + -- Scott James Remnant Wed, 04 Jun 2008 12:59:11 +0100 + +upstart (0.3.9-2) hardy; urgency=low + + * Start the getty on tty1 after the rc script has stopped rather then + at the same time it starts to avoid overwriting by console messages. + tty2..6 will still be active if you want an early login. LP: #65230. + * If the recovery menu is available start that instead of sulogin when + entering single-user-mode. + + -- Scott James Remnant Fri, 11 Apr 2008 13:38:50 +0100 + +upstart (0.3.9-1) hardy; urgency=low + + * New upstream release: + - many bug fixes. + + * Update reference to "edgy" in README.Debian to "hardy". LP: #140037. + + -- Scott James Remnant Sun, 28 Oct 2007 10:51:59 -0400 + +upstart (0.3.8-2) gutsy; urgency=low + + * Fix broken migration of old-style 'respawn process' stanzas which + produced corrupted 'exec' stanzas. Try to fix up files previously + corrupted by this. LP: #95210 + + -- Scott James Remnant Sun, 28 Oct 2007 10:50:36 -0400 + +upstart (0.3.8-1) feisty; urgency=low + + * New upstream release: + - much improved initctl tool. + + * Update my standard prep_/undo_/rm_conffile functions to take into account + current dpkg behaviour wrt obsolete conffiles. The conffile is now moved + out of the way in preinst and the moved file deleted in postinst, or moved + back in postrm abort-upgrade. This means it's not there when dpkg + configures the new version, so the conffile is not left in the list. + * Purge backups of modified obsolete conffiles when the package is purged. + + * Update runlevel and respawn rule generated in migrate-inittab.pl + LP: #89314 + + * Drop 00-libnih-update.patch and 01-libnih-sparc-ftbfs.patch; new upstream + release includes an up-to-date libnih which contains both patches. + * Drop 10-cant-stop-execless-job.patch; included upstream. + * Drop 20-complex-event-config.patch; this is going to be significantly + changed upstream, and we don't want to ship something strange. + * Drop 30-fix-warnings.patch; included upstream. + + -- Scott James Remnant Sun, 11 Mar 2007 19:19:00 +0000 + +upstart (0.3.5-2) feisty; urgency=low + + * Changed "start script" to "pre-start script" in sulogin event, the former + is no longer recognised. + + * Applied 01-libnih-sparc-ftbfs.patch; this updates the signal name list + to exclude signals not available on that architecture, and add one that's + unique to it. + * Applied 30-fix-warnings.patch; this corrects a few warnings that spoiled + an otherwise clean build log. + + -- Scott James Remnant Tue, 13 Feb 2007 15:56:33 +0000 + +upstart (0.3.5-1) feisty; urgency=low + + * New upstream release: + - inotify file descriptor leak fixed. LP: #83099. + - inotify support is no longer required. LP: #68904. + - new job state machine + - new event structure, can now include arguments and environment + + * Applied 00-libnih-update.patch; this updates the libnih library to the + latest bzr trunk version, required for the complex-event-config patch. + * Applied 10-cant-stop-execless-job.patch from upstream; this corrects a + bug where jobs without an "exec" or "script" stanza cannot be stopped. + * Applied 20-complex-event-config.patch from upstream; this is an + experimental implementation of the "on" keyword that allows definition + of complex system states. + + * System V compatibility jobs updated to match new event names. + * rcS job now sets PREVLEVEL and RUNLEVEL. LP: #76304. + + * NOTE: After this upgrade, init will appear to have "forgotten" the + process ids of your gettys, etc. This is not a critical problem and + will be fixed before release. Shutdown will still work as normal. + + -- Scott James Remnant Mon, 12 Feb 2007 13:51:40 +0000 + +upstart (0.3.1-1) feisty; urgency=low + + * New upstream release: + - start, stop and status are now symlinks to initctl, not to a + different, separate utility. + - initctl completely rewritten to behave properly. + - some upstart-specific options to shutdown and reboot dropped, as + these are considered SysV-compat tools. + - "console none" fixed. LP: #70782. + - improved documentation. LP: #68805. + + * shutdown and reboot moved to upstart-compat-sysv. + + * Replace the /usr/share/doc/* directory in upstart-logd, + upstart-compat-sysv, system-services and startup-tasks with a symlink to + /usr/share/doc/upstart. This was actually done in a previous package, + but the migration missed. LP: #70895. + + -- Scott James Remnant Wed, 13 Dec 2006 17:27:37 +0000 + +upstart (0.2.7-7) edgy; urgency=low + + * Don't abort the postinst if we can't send init SIGTERM. Ubuntu: #64499. + + -- Scott James Remnant Tue, 10 Oct 2006 10:13:05 +0100 + +upstart (0.2.7-6) edgy; urgency=low + + * Don't start gettys on tty2 thru tty6 in runlevels 4 and 5 (matches + our sysvinit configuration). + * Migrate common changes made to /etc/inittab to /etc/event.d by + adjusting the installed conffiles. Ubuntu: #61539. + + * Include missing AUTHORS and NEWS file in the upstart package. + * Include README.Debian which answers common questions. Ubuntu: #60429. + + -- Scott James Remnant Thu, 5 Oct 2006 16:08:34 +0100 + +upstart (0.2.7-5) edgy; urgency=low + + * Don't set the current runlevel in /var/run/utmp to 0 or 6 if it is + already either of those two values. That way we don't end up with + either 0 or 6 in the PREVLEVEL variable, which can cause + /etc/init.d/rc to be "efficient" and not bother doing + anything. Ubuntu: #63852. + + -- Scott James Remnant Wed, 4 Oct 2006 14:06:18 +0100 + +upstart (0.2.7-4) edgy; urgency=low + + * Can't just start rc-default once in single-user mode, because if we + boot into that, that will just return us back to sulogin again. Copy + the script out of rc-default into rcS-sulogin to call telinit with the + right default runlevel. Ubuntu: #62189. + + * Add Build-Depend on dpkg-dev (>= 1.13.19) due to our use of + ${binary:Version}. Ubuntu: #61693. + + -- Scott James Remnant Tue, 26 Sep 2006 17:20:42 +0100 + +upstart (0.2.7-3) edgy; urgency=low + + * Set the runlevel to "S" when we enter sulogin so that it appears + in utmp. + + -- Scott James Remnant Thu, 21 Sep 2006 05:37:25 +0100 + +upstart (0.2.7-2) edgy; urgency=low + + * Ensure that the same version of upstart is installed as the version of + upstart-compat-sysv and upstart-logd; as the IPC protocol may change + between releases. + + * Adjust the rcS-sulogin job so that if sulogin exits the default runlevel + is entered; but if the job is stopped (e.g. by shutdown) it isn't. The + solves the regression introduced in the previous release. + + * Revert upstream logd/"quiet" change in favour of doing it in our + lsb logging functions instead; seems to work better (fsvo better). + + -- Scott James Remnant Thu, 21 Sep 2006 03:12:33 +0100 + +upstart (0.2.7-1) edgy; urgency=low + + * New upstream release: + - logd now writes to the console unless "quiet" is specified + - runaway jobs caught when they start rather than respawn. Ubuntu: #59807 + + * Fix failure to shutdown while in single-user mode, however this means + that for edgy you can't exit the sulogin shell to enter the default + runlevel; explicitly say what works. Ubuntu: #60626. + * Drop unnecessary dependency on util-linux. + * Drop sulogin hack, instead depend on the version of sysvutils that + includes the real one. Ubuntu: #60965. + + -- Scott James Remnant Wed, 20 Sep 2006 05:39:16 +0100 + +upstart (0.2.6-1) edgy; urgency=low + + * New upstream release: + - fix infinite loop caused by bad waitid() call. Ubuntu: #59459. + - halt now behaves as "shutdown -h now". Ubuntu: #59720. + + -- Scott James Remnant Wed, 13 Sep 2006 22:16:17 +0100 + +upstart (0.2.5-1) edgy; urgency=low + + * New upstream release: + - no longer spins when no stalled event handler. Ubuntu: #59170. + - shutdown works when under sysvinit. Ubuntu: #58523; + - shutdown -k implemented. Ubuntu: #58723. + - telinit sends shutdown event for 0, 1 and 6. Ubuntu: #58913. + - basic manual pages included. Ubuntu: #58724. + + * upstart-compat-sysv Replaces: sysvinit. Ubuntu: #59427. + * upstart Recommends: upstart-compat-sysv, startup-tasks & system-services. + + * New upstart-logd package includes the logd daemon that can will log + output of jobs with "console logged" (the default) in their description + to /var/log/boot. + + * Add /etc/event.d/rc0 that is run on the "halt" event (neither -H or -P + given), and modify rc0-halt to run on "system-halt" (-H given) and + rc0-poweroff to run on "power-off" (-P given). Ubuntu: #59134. + * Fix the control-alt-delete job to run on the "ctrlaltdel" event so + that it's triggered properly. Ubuntu: #59398. + * Fix single-user mode. + + -- Scott James Remnant Sat, 9 Sep 2006 05:10:12 +0100 + +upstart (0.2.1-7) edgy; urgency=low + + * Remove the Essential tags again, they didn't solve the problem we + hoped they would (dpkg/apt still won't remove sysvinit without + serious persuasion) and I don't think these packages should be. + + -- Scott James Remnant Thu, 7 Sep 2006 02:42:33 +0100 + +upstart (0.2.1-6) edgy; urgency=low + + * Make packages Essential, and change Depends to Pre-Depends so that the + packages work when unconfigured (nothing interesting is performed in + postinst). Ubuntu: #59005. + * Sync priority in debian/control with that in the archive (required) + * Drop warning of dire consequences if you install upstart, seeing as it's + installed by default. + + * Add new startup-tasks and system-services packages which will contain + the /etc/event.d files themselves (other than the main ones). + * Move tty definitions into system-services. + * Modify tty definitions to start when the rcS task has finished. This + puts them in the "right" place when compared to gdm. Ubuntu: #58630. + + * Correct rcS compatibility script to ignore any information in utmp so + that all scripts are always run. Ubuntu: #59203. + * Make rcS the console owner while it runs, temporary fix for + Ubuntu: #58609, #58794, #58796 + * Include default control-alt-delete handler that reboots the machine. + + -- Scott James Remnant Wed, 6 Sep 2006 21:52:48 +0100 + +upstart (0.2.1-5) edgy; urgency=low + + * upstart-compat-sysv Depends: initscripts (closes: Malone #58979). + + -- Colin Watson Tue, 5 Sep 2006 12:22:50 +0100 + +upstart (0.2.1-4) edgy; urgency=low + + * Add missing #! line to top of postrm + + -- Scott James Remnant Mon, 4 Sep 2006 08:11:16 +0100 + +upstart (0.2.1-3) edgy; urgency=low + + * Remove the rc0 configuration file shipped in 0.1.0 that causes all + reboots to become shutdowns. Ubuntu: #58557. + + -- Scott James Remnant Sun, 3 Sep 2006 23:24:41 +0100 + +upstart (0.2.1-2) edgy; urgency=low + + * Don't send the SIGTERM signal unless we're upgrading from a version + of upstart that supports re-exec; older versions would cause a kernel + PANIC and change from sysvinit does nothing. + + -- Scott James Remnant Sat, 2 Sep 2006 17:18:38 +0100 + +upstart (0.2.1-1) edgy; urgency=low + + * New upstream release: + - compilation fixes. + + -- Scott James Remnant Fri, 1 Sep 2006 19:51:41 +0100 + +upstart (0.2.0-1) edgy; urgency=low + + * New upstream release: + - upstart includes shutdown, reboot, halt, poweroff, start, stop, status, + runlevel and telinit utilities. + - "initctl list" will list active jobs. + - Events vastly simplified to just simple strings. + + * Compatibility tasks for old rc scripts, along with runlevel and telinit + utilities now shipped in upstart-compat-sysv package. + + -- Scott James Remnant Fri, 1 Sep 2006 02:38:44 +0100 + +upstart (0.1.1-1) edgy; urgency=low + + * New upstream release: + - set PATH and TERM in processes + + -- Scott James Remnant Fri, 25 Aug 2006 16:17:52 +0200 + +upstart (0.1.0-2) edgy; urgency=low + + * Oops, rename /sbin/init to /sbin/upstart as documented. Lost this + while battling bzr. + + -- Scott James Remnant Thu, 24 Aug 2006 16:30:54 +0200 + +upstart (0.1.0-1) edgy; urgency=low + + * Initial release. + + -- Scott James Remnant Thu, 24 Aug 2006 14:27:47 +0200 --- upstart-1.3.orig/debian/conf/tty1.conf +++ upstart-1.3/debian/conf/tty1.conf @@ -0,0 +1,10 @@ +# tty1 - getty +# +# This service maintains a getty on tty1 from the point the system is +# started until it is shut down again. + +start on stopped rc RUNLEVEL=[2345] +stop on runlevel [!2345] + +respawn +exec /sbin/getty -8 38400 tty1 --- upstart-1.3.orig/debian/conf/tty6.conf +++ upstart-1.3/debian/conf/tty6.conf @@ -0,0 +1,10 @@ +# tty6 - getty +# +# This service maintains a getty on tty6 from the point the system is +# started until it is shut down again. + +start on runlevel [23] +stop on runlevel [!23] + +respawn +exec /sbin/getty -8 38400 tty6 --- upstart-1.3.orig/debian/conf/wait-for-state.conf +++ upstart-1.3/debian/conf/wait-for-state.conf @@ -0,0 +1,60 @@ +author "Clint Byrum " +description "Waiting for state" + +task +normal exit 2 + +stop on started $WAIT_FOR or stopped $WAIT_FOR + +# These are all arguments for use influencing how this job waits +env TIMEOUT=30 +env MANUAL_OVERRIDE="N" +env WAIT_FOREVER="N" +env WAIT_STATE="started" +env TARGET_GOAL="start" + +# Required args w/ no sensible default, the tests at the beginning of +# the script are just to guard against WAITER="" or WAIT_FOR="", as the +# instance line will fail if they are not set, since they have no env +instance $WAITER$WAIT_FOR + +script + test -n "$WAIT_FOR" || exit 1 + test -n "$WAITER" || exit 1 + + # We don't want to override the manual stanza + # XXX: initctl show-config should share manual w/ us too + case $MANUAL_OVERRIDE in + N|n|0) + if grep -q "^\s*manual\s*$" /etc/init/$WAIT_FOR.conf ; then + exit 0 + fi + ;; + esac + + if [ "$WAIT_STATE" = "stopped" ] ; then + TARGET_GOAL="stop" + fi + + # Already running/stopped? + status $WAIT_FOR | grep -q "$TARGET_GOAL/$WAIT_STATE" && exit 0 + + # Give it a push + $TARGET_GOAL $WAIT_FOR || : + + # upstart will kill this shell on started/stopped $WAIT_FOR + while sleep $TIMEOUT ; do + case $WAIT_FOREVER in + N|n|0) + exit 100 + ;; + Y|y|1) + ;; + *) + exit 1 + ;; + esac + done + # Very strange, sleep returned non-zero? + exit 1 +end script --- upstart-1.3.orig/debian/conf/tty5.conf +++ upstart-1.3/debian/conf/tty5.conf @@ -0,0 +1,10 @@ +# tty5 - getty +# +# This service maintains a getty on tty5 from the point the system is +# started until it is shut down again. + +start on runlevel [23] +stop on runlevel [!23] + +respawn +exec /sbin/getty -8 38400 tty5 --- upstart-1.3.orig/debian/conf/tty4.conf +++ upstart-1.3/debian/conf/tty4.conf @@ -0,0 +1,10 @@ +# tty4 - getty +# +# This service maintains a getty on tty4 from the point the system is +# started until it is shut down again. + +start on runlevel [23] +stop on runlevel [!23] + +respawn +exec /sbin/getty -8 38400 tty4 --- upstart-1.3.orig/debian/conf/tty2.conf +++ upstart-1.3/debian/conf/tty2.conf @@ -0,0 +1,10 @@ +# tty2 - getty +# +# This service maintains a getty on tty2 from the point the system is +# started until it is shut down again. + +start on runlevel [23] +stop on runlevel [!23] + +respawn +exec /sbin/getty -8 38400 tty2 --- upstart-1.3.orig/debian/conf/rcS.conf +++ upstart-1.3/debian/conf/rcS.conf @@ -0,0 +1,28 @@ +# rcS - System V single-user mode compatibility +# +# This task handles the old System V-style single-user mode, this is +# distinct from the other runlevels since running the rc script would +# be bad. + +description "System V single-user mode compatibility" +author "Scott James Remnant " + +start on runlevel S +stop on runlevel [!S] + +console owner +script + exec /sbin/sulogin +end script + +post-stop script + # Don't switch runlevels if we were stopped by an event, since that + # means we're already switching runlevels + if [ -n "${UPSTART_STOP_EVENTS}" ] + then + exit 0 + fi + + # Switch, passing a magic flag + start --no-wait rc-sysinit FROM_SINGLE_USER_MODE=y +end script --- upstart-1.3.orig/debian/conf/tty3.conf +++ upstart-1.3/debian/conf/tty3.conf @@ -0,0 +1,10 @@ +# tty3 - getty +# +# This service maintains a getty on tty3 from the point the system is +# started until it is shut down again. + +start on runlevel [23] +stop on runlevel [!23] + +respawn +exec /sbin/getty -8 38400 tty3 --- upstart-1.3.orig/debian/conf/failsafe.conf +++ upstart-1.3/debian/conf/failsafe.conf @@ -0,0 +1,42 @@ +# failsafe + +description "Failsafe Boot Delay" +author "Clint Byrum " + +start on filesystem and net-device-up IFACE=lo +stop on static-network-up or runlevel + +console output + +script + # Determine if plymouth is available + if [ -x /bin/plymouth ] && /bin/plymouth --ping ; then + PLYMOUTH=/bin/plymouth + else + PLYMOUTH=":" + fi + + # The point here is to wait for 2 minutes before forcibly booting + # the system. Anything that is in an "or" condition with 'started + # failsafe' in rc-sysinit deserves consideration for mentioning in + # these messages. currently only static-network-up counts for that. + + sleep 20 + + # Plymouth errors should not stop the script because we *must* reach + # the end of this script to avoid letting the system spin forever + # waiting on it to start. + $PLYMOUTH message --text="Waiting for network configuration..." || : + sleep 40 + + $PLYMOUTH message --text="Waiting up to 60 more seconds for network configuration..." || : + sleep 59 + $PLYMOUTH message --text="Booting system without full network configuration..." || : + + # give user 1 second to see this message since plymouth will go + # away as soon as failsafe starts. + sleep 1 + exec initctl emit --no-wait failsafe-boot +end script + +post-start exec logger -t 'failsafe' -p daemon.warning "Failsafe of 120 seconds reached." --- upstart-1.3.orig/debian/source/format +++ upstart-1.3/debian/source/format @@ -0,0 +1 @@ +1.0 --- upstart-1.3.orig/debian/manpages/upstart-events.7 +++ upstart-1.3/debian/manpages/upstart-events.7 @@ -0,0 +1,280 @@ +'\" t +.TH upstart-events 7 2011-03-24 upstart +.\" +.SH NAME +upstart-events \- Well-known Upstart events summary +.\" +.SH Event Summary + +This manual page summarizes well-known events generated by the Upstart +.BR init (8) +daemon. +It is not an exhaustive list of all possible events, but rather details +a standard set of events expected to be generated on any Ubuntu system +running Upstart. + +The primary table, \fBTable 1\fP, encodes the well-known events, along +with the type of each event (listed in \fBTable 2\fP), the emitter of +the event (see \fBTable 3\fP) and the approximate time at which the +event could be generated. Additionally, the \fINote\fP column indexes +into \fBTable 4\fP for further details on a particular event. + +The \fIRef\fP (Reference) column is used to refer to individual +events succinctly in the \fITime\fP column. + +Note that the \(aq<\(aq and \(aq>\(aq characters in the \fITime\fP column denote +that the event in the \fIEvent\fP column occurs respectively before or +after the event specified in the \fITime\fP column (for example, the +\fBmounting\fP(7) event occurs "at some time" after the \fBstartup\fP(7) +event, and the \fBvirtual\-filesystems\fP(7) event occurs after the last +\fBmounted\fP(7) event relating to a virtual filesystem has been emitted). + +For further details on events, consult the manual pages and the job +configuration files, usually located in \fI/etc/init\fP. +.\" + +.\" Flush-left to allow table to be viewed on 80-col display without +.\" wrapping. +.nr old_po .po +.nr old_in .in +.po 0 +.in 0 +.sp 1 +\fBTable 1: Well-Known Event Summary.\fP +.TS +box, tab (@); +c | c | c | c | c | c +c | l | c | c | l | c. +Ref@Event@Type@Emit@Time@Note += + @\fBall\-swaps\fP@S@M@> (5)@ + @\fBcontrol\-alt\-delete\fP(7)@S@A@> (5)@A + @dbus\-activation@S@B@> D\-Bus client request@ + @device\-not\-ready@H@M@> (2)@N + @desktop\-session\-start@H@D@> \fBX\fP(7) session created@B + @desktop\-shutdown@H@D@> \fBX\fP(7) session ended@O + @drm\-device\-added@S@U@> (5)@C + @\fBfilesystem\fP@S@M@After last (1)@D + @graphics\-device\-added@S@U@> (5)@C + @\fBkeyboard\-request\fP(7)@S@A@> (5)@E + @\fBlocal\-filesystems\fP(7)@S@M@> (6)@ + @login\-session\-start@H@D@< DM running@F +1@\fBmounted\fP(7)@H@M@> associated (2)@G +2@\fBmounting\fP(7)@H@M@> (5)@H +3@net\-device\-added@S@U@> (5)@C + @net\-device\-changed@S@U@> (5)@C + @net\-device\-down@S@F@< (4)@C +4@net\-device\-removed@S@U@> (5)@C + @net\-device\-up@S@F,N@> (3)@C + @\fBpower\-\%status\-\%changed\fP(7)@S@I@> (5)@I + @\fBremote\-\%filesystems\fP(7)@S@M@> (6)@ + @\fBrunlevel\fP(7)@M@T@> (5)@ + @\fBsocket\fP(7)@S@S@> socket connection@ +5@\fBstartup\fP(7)@S@I@Boot@J + @\fBstarted\fP(7)@S@I@> job started@K + @\fBstarting\fP(7)@H@I@< job starts@K + @\fBstopped\fP(7)@S@I@> job stopped@K + @\fBstopping\fP(7)@H@I@< job stops@K + @T{ +unmounted\-\:remote\-\:filesystems +T}@H@V@T{ +> last remote FS unmounted +T}@L +6@\fBvirtual\-\:filesystems\fP(7)@S@M@> last virtual FS (1)@M +.TE +.po \n[old_po] +.in \n[old_in] +.P +Key: + \(aqFS\(aq is an abbreviation for filesystem. + \(aqDM\(aq is an abbreviation for Display Manager. + +.\" +.P +.sp 1 +.nr old_po .po +.nr old_in .in +.po 0 +.in 0 +\fBTable 2: Event Types.\fP +.TS +box, tab (@); +c | l |l +c | l |l. +Ref@Event Type@Notes += +H@Hook@T{ +Blocking. Waits for events that \fBstart on\fP or \fBstop on\fP this +event. +T} +M@Method@Blocking task. +S@Signal@Non-blocking. +.TE +.po \n[old_po] +.in \n[old_in] + +.\" +.P +.nr old_po .po +.nr old_in .in +.po 0 +.in 0 +.sp 1 +\fBTable 3: Event Emitters.\fP +.TS +box, tab (@); +c | l |l +c | l |l. +Ref@Emitter@Notes += +A@System Administrator (initiator)@Technically emitted by init(8). +B@\fBdbus\-daemon\fP(1)@Run with "\fI\-\-activation=upstart"\fP +D@Display Manager@e.g. lightdm/gdm/kdm/xdm. +F@\fBifup\fP(8) or \fBifdown\fP(8)@See \fI/etc/network/\fP. +I@\fBinit\fP(8)@ +M@\fBmountall\fP(8)@ +N@network\-interface job@ +S@\fBupstart\-socket\-bridge\fP(8)@ +T@\fBtelinit\fP(8), \fBshutdown\fP(8)@ +U@\fBupstart\-udev\-bridge\fP(8)@ +V@System V init system@ +.TE +.po \n[old_po] +.in \n[old_in] + +.\" +.P +.nr old_po .po +.nr old_in .in +.po 0 +.in 0 +\fBTable 4: Event Summary Notes.\fP +.TS +box, tab (@); +c | l +c | l. +Note@Detail += +A@T{ +Requires administrator to press Control-Alt-Delete key +combination on the console. +T} +B@Event generated when user performs graphical login. +C@T{ +These are specific examples. \fBupstart\-udev\-bridge\fP(8) will emit +events which match the pattern, "\fIS\fP\-device\-\fIA\fP" where +\(aqS\(aq is the udev \fIsubsystem\fP and \(aqA\(aq is the udev \fIaction\fP. See +\fBudev\fP(7) and for further details. If you have sysfs +mounted, you can look in \fI/sys/class/\fP for possible values for subsystem. +T} +D@Note this is in the singular - there is no \(aqfilesystems\(aq event. +E@T{ +Emitted when administrator presses Alt-UpArrow key combination on +the console. +T} +F@T{ +Denotes Display Manager running (about to be displayed), but no users +logged in yet. +T} +G@Generated for each mount that completes successfully. +H@T{ +Emitted when mount attempt for single entry from \fBfstab\fP(5) +for any filesystem type is about to begin. +T} +I@Emitted when Upstart receives the SIGPWR signal. +J@Initial event. +K@T{ +Although the events are emmitted by \fBinit\fP(8), the instigator may be +\fBinitctl\fP(8) if a System Administrator has manually started or +stopped a job. +T} +L@\fI/etc/init/umountnfs.sh\fP. +M@Emitted when all virtual filesystems (such as \fI/proc\fR) mounted. +N@T{ +Emitted when the \fI\-\-dev\-wait\-time\fP timeout is exceeded for +\fBmountall\fP(8). This defaults to 30 seconds. +T} +O@T{ +Emitted when the \fIX\fP(7) display manager exits at shutdown or reboot, to +hand off to the shutdown splash manager. +T} +.TE +.po \n[old_po] +.in \n[old_in] + +.SH Job lifecycle +.\" +.SS Starting a Job +.nr step 1 1 +.IP \n[step] 3 +Upstart emits the \fBstarting\fP(7) event denoting the job is +"about to start". The \fBstarting\fP(7) event completes. +.IP \n+[step] 3 +If the \fBpre\-start\fP stanza exists, the pre\-start process is +spawned. +.IP \n+[step] 3 +Upstart spawns the main process. +.sp +It then ascertains the \fIfinal\fP PID for the job which may be a +descendent of the immediate child process if \fBexpect fork\fP or +\fBexpect daemon\fP has been specified. +.IP \n+[step] 3 +If the \fBpost\-start\fP stanza exists, the post\-start process is +spawned. +.IP \n+[step] 3 +Upstart emits the \fBstarted\fP(7) event. +.sp 1 +For services, when this event completes the main process will now be fully +running. If the job refers to a task, it will now have completed. + +.SS Stopping a Job + +.nr step 1 1 +.IP \n[step] 3 +If the \fBpre\-stop\fP stanza exists, the pre\-stop process is +spawned. +.IP \n+[step] 3 +The main process is stopped: +.RS +.nr step2 1 1 +.af step2 i +.IP \n[step2] 3 +The SIGTERM signal is sent to the main process. +.sp 1 +See \fBsignal\fP(7). +.IP \n+[step2] 3 +Upstart waits for up to "kill timeout" seconds (default 5 seconds) for +the process to end. +.IP \n+[step2] 3 +If the process is still running after the timeout, a SIGKILL is sent to the process. +.RE +.IP \n+[step] 3 +Upstart emits the \fBstopping\fP(7) event. +.IP \n+[step] 3 +If the \fBpost\-stop\fP stanza exists, the post\-stop process is +spawned. +.IP \n+[step] 3 +Upstart emits the \fBstopped\fP(7) event. +.sp 1 +When this event completes, the job is fully stopped. + +.SH AUTHOR +Manual page written by James Hunt +.RB < james.hunt@ubuntu.com > +.\" +.SH REPORTING BUGS +Report bugs at +.RB < https://launchpad.net/ubuntu/+source/upstart/+bugs > +.\" +.SH COPYRIGHT +Copyright \(co 2011 Canonical Ltd. +.br +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +.\" +.SH SEE ALSO +.BR init (5) +.BR init (8) +.BR initctl (8) +.BR mountall (8) +.BR telinit (8) --- upstart-1.3.orig/util/tests/test_initctl.c +++ upstart-1.3/util/tests/test_initctl.c @@ -77,7 +77,9 @@ if (pid == 0) \ execlp (UPSTART_BINARY, UPSTART_BINARY, \ "--session", \ - "--no-startup-event", NULL); \ + "--no-startup-event", \ + "--no-sessions", \ + NULL); \ \ while (attempts) { \ attempts--; \ @@ -10927,7 +10929,8 @@ { char dirname[PATH_MAX]; nih_local char *cmd; - pid_t upstart_pid; + pid_t upstart_pid = 0; + pid_t dbus_pid = 0; char **output; size_t lines; char expected_output[] = "foo"; @@ -10940,6 +10943,7 @@ /* Use the "secret" interface */ TEST_EQ (setenv ("UPSTART_CONFDIR", dirname, 1), 0); + TEST_DBUS (dbus_pid); START_UPSTART (upstart_pid); TEST_FEATURE ("no emits, no start on, no stop on"); @@ -11380,6 +11384,7 @@ STOP_UPSTART (upstart_pid); TEST_EQ (unsetenv ("UPSTART_CONFDIR"), 0); + TEST_DBUS_END (dbus_pid); } void @@ -11387,7 +11392,8 @@ { char dirname[PATH_MAX]; nih_local char *cmd; - pid_t upstart_pid; + pid_t upstart_pid = 0; + pid_t dbus_pid = 0; char **output; size_t lines; @@ -11399,6 +11405,7 @@ /* Use the "secret" interface */ TEST_EQ (setenv ("UPSTART_CONFDIR", dirname, 1), 0); + TEST_DBUS (dbus_pid); START_UPSTART (upstart_pid); /*******************************************************************/ @@ -11833,6 +11840,7 @@ STOP_UPSTART (upstart_pid); TEST_EQ (unsetenv ("UPSTART_CONFDIR"), 0); + TEST_DBUS_END (dbus_pid); } --- upstart-1.3.orig/util/tests/test_user_sessions.sh +++ upstart-1.3/util/tests/test_user_sessions.sh @@ -0,0 +1,553 @@ +#!/bin/sh -u +#--------------------------------------------------------------------- +# Script to run minimal Upstart user session tests. +# +# Note that this script _cannot_ be run as part of the "make check" +# tests since those tests stimulate functions and features of the +# as-yet-uninstalled version of Upstart. However, this script needs to +# run on a system where the version of Upstart under test has _already_ +# been fully installed. +#--------------------------------------------------------------------- +# +# Copyright (C) 2011 Canonical Ltd. +# +# Author: James Hunt +# +# 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, version 3 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +#--------------------------------------------------------------------- + +script_name=${0##*/} +user_job_dir="$HOME/.init" +bug_url="https://bugs.launchpad.net/upstart/+filebug" +test_dir= +test_dir_suffix= +user_to_create= +uid= +gid= +opt= +OPTARG= + +# allow non-priv users to find 'initctl' +export PATH=$PATH:/sbin + +# for assertions +die() +{ + msg="$*" + echo "ERROR: $msg" >&2 + exit 1 +} + +TEST_FAILED() +{ + args="$*" + + [ -z "$args" ] && die "need args" + + printf "BAD: %s\n" "$args" + printf "\nPlease report a bug at $bug_url including the following details:\n" + printf "\nUpstart:\n" + /sbin/init --version|head -n1 + /sbin/initctl --version|head -n1 + echo + printf "cmdline:\n" + cat /proc/cmdline + echo + printf "Upstart Env:\n" + set|grep UPSTART_ + echo + printf "lsb:\n" + lsb_release -a + printf "\nuname:\n" + uname -a + echo + sync + exit 1 +} + +TEST_GROUP() +{ + name="$1" + + [ -z "$name" ] && die "need name" + + printf "Testing %s\n", "$name" +} + +TEST_FEATURE() +{ + feature="$1" + + [ -z "$feature" ] && die "need feature" + + printf "...%s\n" "$feature" +} + +TEST_NE() +{ + cmd="$1" + value="$2" + expected="$3" + + # XXX: no checks on value or expected since they might be blank + [ -z "$cmd" ] && die "need cmd" + + [ "$value" = "$expected" ] && TEST_FAILED \ + "wrong value for '$cmd', expected $expected got $value" +} + +TEST_EQ() +{ + cmd="$1" + value="$2" + expected="$3" + + # XXX: no checks on value or expected since they might be blank + [ -z "$cmd" ] && die "need cmd" + + [ "$value" != "$expected" ] && TEST_FAILED \ + "wrong value for '$cmd', expected '$expected' got '$value'" +} + +setup() +{ + uid=$(id -u) + gid=$(id -g) + + if [ "$uid" = 0 ] + then + [ -z "$user_to_create" ] && die "need '-u' option when running as root" + + getent passwd "$user_to_create" && \ + die "user '$user_to_create' already exists" + + echo "Creating user '$user_to_create'" + cmd="useradd -mU -c 'Upstart Test User' $user_to_create" + eval "$cmd" + TEST_EQ "$cmd" $? 0 + + echo "Locking account for user '$user_to_create'" + cmd="usermod -L $user_to_create" + eval "$cmd" + TEST_EQ "$cmd" $? 0 + + # Run ourselves again as the new user + su -c "$0 -a" "$user_to_create" + test_run_rc=$? + + if [ $test_run_rc -eq 0 ] + then + echo "Deleting user '$user_to_create'" + cmd="userdel -r \"$user_to_create\"" + eval "$cmd" + TEST_EQ "$cmd" $? 0 + fi + + exit $test_run_rc + fi + + # setup + if [ ! -d "$user_job_dir" ] + then + cmd="mkdir -p \"$user_job_dir\"" + eval $cmd + TEST_EQ "$cmd" $? 0 + + cmd="chmod 755 \"$user_job_dir\"" + eval "$cmd" + TEST_EQ "$cmd" $? 0 + fi + + # create somewhere to store user jobs + cmd="mktemp -d --tmpdir=\"$user_job_dir\"" + test_dir=$(eval "$cmd") + TEST_EQ "$cmd" $? 0 + TEST_NE "$test_dir" "$test_dir" "" + test_dir_suffix=${test_dir#${user_job_dir}/} + + # ensure files in this directory are accessible since + # mktemp sets directory perms to 0700 regardless of umask. + cmd="chmod 755 \"$test_dir\"" + eval "$cmd" + TEST_EQ "$cmd" $? 0 + + TEST_NE "HOME" "$HOME" "" +} + +cleanup() +{ + if [ -d "$test_dir" ] + then + echo "Removing test directory '$test_dir'" + cmd="rmdir \"$test_dir\"" + eval "$cmd" + TEST_EQ "$cmd" $? 0 + fi +} + +ensure_job_known() +{ + job="$1" + job_name="$2" + + [ -z "$job" ] && die "no job" + [ -z "$job_name" ] && die "no job name" + + TEST_FEATURE "ensure 'initctl' recognises job" + initctl list|grep -q "^$job " || \ + TEST_FAILED "job $job_name not known to initctl" + + TEST_FEATURE "ensure 'status' recognises job" + cmd="status ${job}" + eval "$cmd" + rc=$? + TEST_EQ "$cmd" $rc 0 +} + +run_user_job_tests() +{ + job_name="$1" + job_file="$2" + task="$3" + env="$4" + + # XXX: env can be empty + [ -z "$job_name" ] && die "no job name" + [ -z "$job_file" ] && die "no job file" + [ -z "$task" ] && die "no task value" + + job="${test_dir_suffix}/${job_name}" + + [ -f "$job_file" ] || TEST_FAILED "job file '$job_file' does not exist" + + ensure_job_known "$job" "$job_name" + + TEST_FEATURE "ensure job can be started" + cmd="start ${job} ${env}" + output=$(eval "$cmd") + rc=$? + TEST_EQ "$cmd" $rc 0 + + if [ "$task" = no ] + then + TEST_FEATURE "ensure 'start' shows job pid" + pid=$(echo "$output"|awk '{print $4}') + TEST_NE "pid" "$pid" "" + + TEST_FEATURE "ensure 'initctl' shows job is running with pid" + initctl list|grep -q "^$job start/running, process $pid" || \ + TEST_FAILED "job $job_name did not start" + + TEST_FEATURE "ensure 'status' shows job is running with pid" + cmd="status ${job}" + output=$(eval "$cmd") + echo "$output"|while read job_tmp state ignored status_pid + do + state=$(echo $state|tr -d ',') + TEST_EQ "job name" "$job_tmp" "$job" + TEST_EQ "job state" "$state" "start/running" + TEST_EQ "job pid" "$status_pid" "$pid" + done + + TEST_FEATURE "ensure job pid is running with correct uids" + pid_uids=$(ps --no-headers -p $pid -o euid,ruid) + for pid_uid in $pid_uids + do + TEST_EQ "pid uid" "$pid_uid" "$uid" + done + + TEST_FEATURE "ensure job pid is running with correct gids" + pid_gids=$(ps --no-headers -p $pid -o egid,rgid) + for pid_gid in $pid_gids + do + TEST_EQ "pid gid" "$pid_gid" "$gid" + done + + TEST_FEATURE "ensure process is running in correct directory" + cwd=$(readlink /proc/$pid/cwd) + TEST_EQ "cwd" "$cwd" "$HOME" + + TEST_FEATURE "ensure job can be stopped" + cmd="stop ${job}" + output=$(eval "$cmd") + rc=$? + TEST_EQ "$cmd" $rc 0 + + TEST_FEATURE "ensure job pid no longer exists" + pid_ids=$(ps --no-headers -p $pid -o euid,ruid,egid,rgid) + TEST_EQ "pid uids+gids" "$pid_ids" "" + fi + + remove_job_file "$job_file" + ensure_job_gone "$job" "$job_name" "$env" +} + +remove_job_file() +{ + job_file="$1" + + [ -z "$job_file" ] && die "no job file" + [ ! -f "$job_file" ] && TEST_FAILED "job file '$job_file' does not exist" + + cmd="rm $job_file" + eval "$cmd" + TEST_EQ "$cmd" $? 0 +} + +ensure_job_gone() +{ + job="$1" + job_name="$2" + env="$3" + + # XXX: no check on env since it can be empty + [ -z "$job" ] && die "no job" + [ -z "$job_name" ] && die "no job name" + + TEST_FEATURE "ensure 'initctl' no longer recognises job" + initctl list|grep -q "^$job " && \ + TEST_FAILED "deleted job $job_name still known to initctl" + + TEST_FEATURE "ensure 'status' no longer recognises job" + cmd="status ${job}" + eval "$cmd" + rc=$? + TEST_NE "$cmd" $rc 0 +} + +test_user_job() +{ + test_group="$1" + job_name="$2" + script="$3" + task="$4" + env="$5" + + # XXX: no test on script or env since they might be empty + [ -z "$test_group" ] && die "no test group" + [ -z "$job_name" ] && die "no job name" + [ -z "$task" ] && die "no task" + + TEST_GROUP "$test_group" + + job_file="${test_dir}/${job_name}.conf" + + echo "$script" > $job_file + + run_user_job_tests "$job_name" "$job_file" "$task" "$env" +} + +test_user_job_binary() +{ + group="user job running a binary" + job_name="binary_test" + script="exec sleep 999" + test_user_job "$group" "$job_name" "$script" no "" +} + +test_user_job_binary_task() +{ + group="user job running a binary task" + job_name="binary_task_test" + OUTFILE=$(mktemp) + + script="\ +task +exec true > $OUTFILE" + + test_user_job "$group" "$job_name" "$script" yes "OUTFILE=$OUTFILE" + rm -f $OUTFILE +} + +test_user_job_single_line_script() +{ + group="user job running a single-line script" + job_name="single_line_script_test" + script="\ +script + sleep 999 +end script" + test_user_job "$group" "$job_name" "$script" no "" +} + +test_user_job_single_line_script_task() +{ + group="user job running a single-line script task" + job_name="single_line_script_task_test" + OUTFILE=$(mktemp) + + script="\ +task +script + exec true > $OUTFILE +end script" + test_user_job "$group" "$job_name" "$script" yes "OUTFILE=$OUTFILE" + rm -f $OUTFILE +} + +test_user_job_multi_line_script() +{ + group="user job running a multi-line script" + job_name="multi_line_script_test" + script="\ +script + + true + true;true + sleep 999 + +end script" + test_user_job "$group" "$job_name" "$script" no "" +} + +test_user_job_multi_line_script_task() +{ + group="user job running a multi-line script task" + job_name="multi_line_script_task_test" + OUTFILE=$(mktemp) + + script="\ +task +script + + true + true + true + +end script" + test_user_job "$group" "$job_name" "$script" yes "OUTFILE=$OUTFILE" + rm -f $OUTFILE +} + +test_user_emit_events() +{ + job_name="start_on_foo" + + TEST_GROUP "user emitting an event" + initctl emit foo || TEST_FAILED "failed to emit event as user" + + TEST_GROUP "user emitting an event to start a job" + script="\ + start on foo BAR=2 + stop on baz cow=moo or hello + exec sleep 999" + + job_file="${test_dir}/${job_name}.conf" + job="${test_dir_suffix}/${job_name}" + + echo "$script" > $job_file + + ensure_job_known "$job" "$job_name" + + initctl list|grep -q "^$job stop/waiting" || \ + TEST_FAILED "job $job_name not stopped" + + TEST_FEATURE "ensure job can be started with event" + initctl emit foo BAR=2 || \ + TEST_FAILED "failed to emit event for user job" + + initctl status "$job"|grep -q "^$job start/running" || \ + TEST_FAILED "job $job_name failed to start" + + TEST_FEATURE "ensure job can be stopped with event" + initctl emit baz cow=moo || \ + TEST_FAILED "failed to emit event for user job" + + initctl list|grep -q "^$job stop/waiting" || \ + TEST_FAILED "job $job_name not stopped" + + rm -f "$job_file" +} + +test_user_jobs() +{ + test_user_job_binary + test_user_job_single_line_script + test_user_job_multi_line_script + + test_user_job_binary_task + test_user_job_single_line_script_task + test_user_job_multi_line_script_task + + test_user_emit_events +} + +tests() +{ + echo + echo -n "Running user session tests as user '`whoami`'" + echo " (uid $uid, gid $gid) in directory '$test_dir'" + echo + + test_user_jobs + + echo + echo "All tests completed successfully" + echo +} + +usage() +{ +cat < : Specify name of test user to create. + +DESCRIPTION: Run simple set of Upstart user session tests. + +WARNING: Note that this script is unavoidably invasive, so read what +WARNING: follows before running! + +If run as a non-root user, this script will create a uniquely-named +subdirectory below "\$HOME/.init/" to run its tests in. On successful +completion of these tests, the unique subdirectory and its contents will +be removed. + +If however, this script is invoked as the root user, the script will +refuse to run until given the name of a test user to create via the "-u" +option. If the user specified to this option already exists, this script +will exit with an error. If the user does not already exist, it will be +created, the script then run *as that user* and assuming successful +completion of the tests, the test user and their home directory will +then be deleted. + +EOT +} + +#--------------------------------------------------------------------- +# main +#--------------------------------------------------------------------- + +while getopts "hu:" opt +do + case "$opt" in + h) + usage + exit 0 + ;; + + u) + user_to_create="$OPTARG" + ;; + esac +done + +setup +tests +cleanup +exit 0 --- upstart-1.3.orig/util/man/initctl.8 +++ upstart-1.3/util/man/initctl.8 @@ -16,6 +16,12 @@ .BR init (8) daemon. +If D\-Bus has been configured to allow non\-privileged users to invoke all +Upstart D\-Bus methods, this command is also able to manage user jobs. +See +.BR init (5) +for further details. + When run as .BR initctl , the first non\-option argument is the @@ -163,8 +169,15 @@ Requests that an instance of the named .I JOB -be restarted (stopped and then started), outputting the status of the -job to standard output when the command completes. +be restarted, outputting the status of the job to standard output when +the command completes. + +The job instance being restarted will retain its original configuration. +To have the new instance run with the latest job configuration, +.B stop +the job and then +.B start +it again instead. See .B status --- upstart-1.3.orig/po/en@boldquot.po +++ upstart-1.3/po/en@boldquot.po @@ -32,8 +32,8 @@ msgstr "" "Project-Id-Version: upstart 1.3\n" "Report-Msgid-Bugs-To: new@bugs.launchpad.net\n" -"POT-Creation-Date: 2011-06-14 15:09+0100\n" -"PO-Revision-Date: 2011-06-14 15:09+0100\n" +"POT-Creation-Date: 2011-11-09 10:05+0000\n" +"PO-Revision-Date: 2011-11-09 10:05+0000\n" "Last-Translator: Automatically generated\n" "Language-Team: none\n" "Language: en\n" @@ -88,7 +88,7 @@ msgid "Disconnected from system bus" msgstr "Disconnected from system bus" -#: init/control.c:370 init/main.c:616 +#: init/control.c:370 init/main.c:754 msgid "Reloading configuration" msgstr "Reloading configuration" @@ -298,181 +298,196 @@ msgid "%s %s process (%d)" msgstr "%s %s process (%d)" -#: init/job_process.c:403 +#: init/job_process.c:409 #, c-format msgid "Pausing %s (%d) [pre-exec] for debug" msgstr "Pausing %s (%d) [pre-exec] for debug" -#: init/job_process.c:473 +#: init/job_process.c:559 #, c-format msgid "Failed to open system console: %s" msgstr "Failed to open system console: %s" -#: init/job_process.c:755 +#: init/job_process.c:790 #, c-format msgid "unable to move script fd: %s" msgstr "unable to move script fd: %s" -#: init/job_process.c:760 +#: init/job_process.c:795 #, c-format msgid "unable to open console: %s" msgstr "unable to open console: %s" -#: init/job_process.c:815 +#: init/job_process.c:850 #, c-format msgid "unable to set \"%s\" resource limit: %s" msgstr "unable to set “%s” resource limit: %s" -#: init/job_process.c:820 +#: init/job_process.c:855 #, c-format msgid "unable to set priority: %s" msgstr "unable to set priority: %s" -#: init/job_process.c:825 +#: init/job_process.c:860 #, c-format msgid "unable to set oom adjustment: %s" msgstr "unable to set oom adjustment: %s" -#: init/job_process.c:830 +#: init/job_process.c:865 #, c-format msgid "unable to change root directory: %s" msgstr "unable to change root directory: %s" -#: init/job_process.c:835 +#: init/job_process.c:870 #, c-format msgid "unable to change working directory: %s" msgstr "unable to change working directory: %s" -#: init/job_process.c:840 +#: init/job_process.c:875 #, c-format msgid "unable to set trace: %s" msgstr "unable to set trace: %s" -#: init/job_process.c:845 +#: init/job_process.c:880 #, c-format msgid "unable to execute: %s" msgstr "unable to execute: %s" -#: init/job_process.c:876 init/job_process.c:926 +#: init/job_process.c:885 +#, c-format +msgid "unable to setuid: %s" +msgstr "unable to setuid: %s" + +#: init/job_process.c:890 +#, c-format +msgid "unable to setgid: %s" +msgstr "unable to setgid: %s" + +#: init/job_process.c:895 +#, c-format +msgid "unable to chown: %s" +msgstr "unable to chown: %s" + +#: init/job_process.c:926 init/job_process.c:976 #, c-format msgid "Sending %s signal to %s %s process (%d)" msgstr "Sending %s signal to %s %s process (%d)" -#: init/job_process.c:885 init/job_process.c:935 +#: init/job_process.c:935 init/job_process.c:985 #, c-format msgid "Failed to send %s signal to %s %s process (%d): %s" msgstr "Failed to send %s signal to %s %s process (%d): %s" -#: init/job_process.c:996 +#: init/job_process.c:1046 #, c-format msgid "%s %s process (%d) terminated with status %d" msgstr "%s %s process (%d) terminated with status %d" -#: init/job_process.c:1001 +#: init/job_process.c:1051 #, c-format msgid "%s %s process (%d) exited normally" msgstr "%s %s process (%d) exited normally" -#: init/job_process.c:1016 +#: init/job_process.c:1066 #, c-format msgid "%s %s process (%d) killed by %s signal" msgstr "%s %s process (%d) killed by %s signal" -#: init/job_process.c:1020 +#: init/job_process.c:1070 #, c-format msgid "%s %s process (%d) killed by signal %d" msgstr "%s %s process (%d) killed by signal %d" -#: init/job_process.c:1034 +#: init/job_process.c:1084 #, c-format msgid "%s %s process (%d) stopped by %s signal" msgstr "%s %s process (%d) stopped by %s signal" -#: init/job_process.c:1038 +#: init/job_process.c:1088 #, c-format msgid "%s %s process (%d) stopped by signal %d" msgstr "%s %s process (%d) stopped by signal %d" -#: init/job_process.c:1052 +#: init/job_process.c:1102 #, c-format msgid "%s %s process (%d) continued by %s signal" msgstr "%s %s process (%d) continued by %s signal" -#: init/job_process.c:1056 +#: init/job_process.c:1106 #, c-format msgid "%s %s process (%d) continued by signal %d" msgstr "%s %s process (%d) continued by signal %d" -#: init/job_process.c:1191 +#: init/job_process.c:1241 #, c-format msgid "%s respawning too fast, stopped" msgstr "%s respawning too fast, stopped" -#: init/job_process.c:1197 +#: init/job_process.c:1247 #, c-format msgid "%s %s process ended, respawning" msgstr "%s %s process ended, respawning" -#: init/job_process.c:1437 +#: init/job_process.c:1487 #, c-format msgid "Failed to set ptrace options for %s %s process (%d): %s" msgstr "Failed to set ptrace options for %s %s process (%d): %s" -#: init/job_process.c:1450 init/job_process.c:1645 +#: init/job_process.c:1500 init/job_process.c:1695 #, c-format msgid "Failed to continue traced %s %s process (%d): %s" msgstr "Failed to continue traced %s %s process (%d): %s" -#: init/job_process.c:1490 init/job_process.c:1581 init/job_process.c:1636 +#: init/job_process.c:1540 init/job_process.c:1631 init/job_process.c:1686 #, c-format msgid "Failed to detach traced %s %s process (%d): %s" msgstr "Failed to detach traced %s %s process (%d): %s" -#: init/job_process.c:1530 +#: init/job_process.c:1580 #, c-format msgid "Failed to deliver signal to traced %s %s process (%d): %s" msgstr "Failed to deliver signal to traced %s %s process (%d): %s" -#: init/job_process.c:1565 +#: init/job_process.c:1615 #, c-format msgid "Failed to obtain child process id for %s %s process (%d): %s" msgstr "Failed to obtain child process id for %s %s process (%d): %s" -#: init/job_process.c:1572 +#: init/job_process.c:1622 #, c-format msgid "%s %s process (%d) became new process (%d)" msgstr "%s %s process (%d) became new process (%d)" -#: init/job_process.c:1631 +#: init/job_process.c:1681 #, c-format msgid "%s %s process (%d) executable changed" msgstr "%s %s process (%d) executable changed" -#: init/main.c:125 +#: init/main.c:129 msgid "specify alternative directory to load configuration files from" msgstr "specify alternative directory to load configuration files from" -#: init/main.c:128 +#: init/main.c:132 msgid "Disable user and chroot sessions" msgstr "Disable user and chroot sessions" -#: init/main.c:131 +#: init/main.c:135 msgid "do not emit any startup event (for testing)" msgstr "do not emit any startup event (for testing)" -#: init/main.c:136 +#: init/main.c:140 msgid "use D-Bus session bus rather than system bus (for testing)" msgstr "use D-Bus session bus rather than system bus (for testing)" -#: init/main.c:139 +#: init/main.c:143 msgid "specify an alternative initial event (for testing)" msgstr "specify an alternative initial event (for testing)" -#: init/main.c:159 +#: init/main.c:163 msgid "Process management daemon." msgstr "Process management daemon." -#: init/main.c:161 +#: init/main.c:165 msgid "" "This daemon is normally executed by the kernel and given process id 1 to " "denote its special status. When executed by a user process, it will " @@ -482,45 +497,55 @@ "denote its special status. When executed by a user process, it will " "actually run /sbin/telinit." -#: init/main.c:177 util/reboot.c:166 util/shutdown.c:363 util/telinit.c:148 +#: init/main.c:181 util/reboot.c:166 util/shutdown.c:363 util/telinit.c:148 msgid "Need to be root" msgstr "Need to be root" -#: init/main.c:186 +#: init/main.c:190 msgid "Not being executed as init" msgstr "Not being executed as init" -#: init/main.c:234 init/main.c:526 +#: init/main.c:238 init/main.c:611 msgid "Unable to set root directory" msgstr "Unable to set root directory" -#: init/main.c:245 +#: init/main.c:249 msgid "Unable to mount /proc filesystem" msgstr "Unable to mount /proc filesystem" -#: init/main.c:254 +#: init/main.c:258 msgid "Unable to mount /sys filesystem" msgstr "Unable to mount /sys filesystem" -#: init/main.c:350 +#: init/main.c:361 msgid "Unable to listen for private connections" msgstr "Unable to listen for private connections" -#: init/main.c:543 +#: init/main.c:628 #, c-format msgid "Caught %s, core dumped" msgstr "Caught %s, core dumped" -#: init/main.c:547 +#: init/main.c:632 #, c-format msgid "Caught %s, unable to dump core" msgstr "Caught %s, unable to dump core" -#: init/main.c:633 +#: init/main.c:661 +#, c-format +msgid "Re-executing %s" +msgstr "Re-executing %s" + +#: init/main.c:686 +#, c-format +msgid "Failed to re-execute %s: %s" +msgstr "Failed to re-execute %s: %s" + +#: init/main.c:771 msgid "Reconnecting to system bus" msgstr "Reconnecting to system bus" -#: init/main.c:639 +#: init/main.c:777 msgid "Unable to connect to the system bus" msgstr "Unable to connect to the system bus" @@ -1077,15 +1102,19 @@ msgid "%s: illegal runlevel: %s\n" msgstr "%s: illegal runlevel: %s\n" -#: extra/upstart-udev-bridge.c:76 +#: extra/upstart-udev-bridge.c:85 msgid "Detach and run in the background" msgstr "Detach and run in the background" -#: extra/upstart-udev-bridge.c:95 +#: extra/upstart-udev-bridge.c:87 +msgid "Do not strip non-printable bytes from udev message data" +msgstr "Do not strip non-printable bytes from udev message data" + +#: extra/upstart-udev-bridge.c:106 msgid "Bridge udev events into upstart" msgstr "Bridge udev events into upstart" -#: extra/upstart-udev-bridge.c:97 +#: extra/upstart-udev-bridge.c:108 msgid "" "By default, upstart-udev-bridge does not detach from the console and remains " "in the foreground. Use the --daemon option to have it detach." @@ -1093,18 +1122,18 @@ "By default, upstart-udev-bridge does not detach from the console and remains " "in the foreground. Use the --daemon option to have it detach." -#: extra/upstart-udev-bridge.c:111 +#: extra/upstart-udev-bridge.c:122 msgid "Could not connect to Upstart" msgstr "Could not connect to Upstart" -#: extra/upstart-udev-bridge.c:125 +#: extra/upstart-udev-bridge.c:136 msgid "Could not create Upstart proxy" msgstr "Could not create Upstart proxy" -#: extra/upstart-udev-bridge.c:149 +#: extra/upstart-udev-bridge.c:160 msgid "Unable to become daemon" msgstr "Unable to become daemon" -#: extra/upstart-udev-bridge.c:297 +#: extra/upstart-udev-bridge.c:334 msgid "Disconnected from Upstart" msgstr "Disconnected from Upstart" --- upstart-1.3.orig/po/en@quot.po +++ upstart-1.3/po/en@quot.po @@ -29,8 +29,8 @@ msgstr "" "Project-Id-Version: upstart 1.3\n" "Report-Msgid-Bugs-To: new@bugs.launchpad.net\n" -"POT-Creation-Date: 2011-06-14 15:09+0100\n" -"PO-Revision-Date: 2011-06-14 15:09+0100\n" +"POT-Creation-Date: 2011-11-09 10:05+0000\n" +"PO-Revision-Date: 2011-11-09 10:05+0000\n" "Last-Translator: Automatically generated\n" "Language-Team: none\n" "Language: en\n" @@ -85,7 +85,7 @@ msgid "Disconnected from system bus" msgstr "Disconnected from system bus" -#: init/control.c:370 init/main.c:616 +#: init/control.c:370 init/main.c:754 msgid "Reloading configuration" msgstr "Reloading configuration" @@ -295,181 +295,196 @@ msgid "%s %s process (%d)" msgstr "%s %s process (%d)" -#: init/job_process.c:403 +#: init/job_process.c:409 #, c-format msgid "Pausing %s (%d) [pre-exec] for debug" msgstr "Pausing %s (%d) [pre-exec] for debug" -#: init/job_process.c:473 +#: init/job_process.c:559 #, c-format msgid "Failed to open system console: %s" msgstr "Failed to open system console: %s" -#: init/job_process.c:755 +#: init/job_process.c:790 #, c-format msgid "unable to move script fd: %s" msgstr "unable to move script fd: %s" -#: init/job_process.c:760 +#: init/job_process.c:795 #, c-format msgid "unable to open console: %s" msgstr "unable to open console: %s" -#: init/job_process.c:815 +#: init/job_process.c:850 #, c-format msgid "unable to set \"%s\" resource limit: %s" msgstr "unable to set “%s” resource limit: %s" -#: init/job_process.c:820 +#: init/job_process.c:855 #, c-format msgid "unable to set priority: %s" msgstr "unable to set priority: %s" -#: init/job_process.c:825 +#: init/job_process.c:860 #, c-format msgid "unable to set oom adjustment: %s" msgstr "unable to set oom adjustment: %s" -#: init/job_process.c:830 +#: init/job_process.c:865 #, c-format msgid "unable to change root directory: %s" msgstr "unable to change root directory: %s" -#: init/job_process.c:835 +#: init/job_process.c:870 #, c-format msgid "unable to change working directory: %s" msgstr "unable to change working directory: %s" -#: init/job_process.c:840 +#: init/job_process.c:875 #, c-format msgid "unable to set trace: %s" msgstr "unable to set trace: %s" -#: init/job_process.c:845 +#: init/job_process.c:880 #, c-format msgid "unable to execute: %s" msgstr "unable to execute: %s" -#: init/job_process.c:876 init/job_process.c:926 +#: init/job_process.c:885 +#, c-format +msgid "unable to setuid: %s" +msgstr "unable to setuid: %s" + +#: init/job_process.c:890 +#, c-format +msgid "unable to setgid: %s" +msgstr "unable to setgid: %s" + +#: init/job_process.c:895 +#, c-format +msgid "unable to chown: %s" +msgstr "unable to chown: %s" + +#: init/job_process.c:926 init/job_process.c:976 #, c-format msgid "Sending %s signal to %s %s process (%d)" msgstr "Sending %s signal to %s %s process (%d)" -#: init/job_process.c:885 init/job_process.c:935 +#: init/job_process.c:935 init/job_process.c:985 #, c-format msgid "Failed to send %s signal to %s %s process (%d): %s" msgstr "Failed to send %s signal to %s %s process (%d): %s" -#: init/job_process.c:996 +#: init/job_process.c:1046 #, c-format msgid "%s %s process (%d) terminated with status %d" msgstr "%s %s process (%d) terminated with status %d" -#: init/job_process.c:1001 +#: init/job_process.c:1051 #, c-format msgid "%s %s process (%d) exited normally" msgstr "%s %s process (%d) exited normally" -#: init/job_process.c:1016 +#: init/job_process.c:1066 #, c-format msgid "%s %s process (%d) killed by %s signal" msgstr "%s %s process (%d) killed by %s signal" -#: init/job_process.c:1020 +#: init/job_process.c:1070 #, c-format msgid "%s %s process (%d) killed by signal %d" msgstr "%s %s process (%d) killed by signal %d" -#: init/job_process.c:1034 +#: init/job_process.c:1084 #, c-format msgid "%s %s process (%d) stopped by %s signal" msgstr "%s %s process (%d) stopped by %s signal" -#: init/job_process.c:1038 +#: init/job_process.c:1088 #, c-format msgid "%s %s process (%d) stopped by signal %d" msgstr "%s %s process (%d) stopped by signal %d" -#: init/job_process.c:1052 +#: init/job_process.c:1102 #, c-format msgid "%s %s process (%d) continued by %s signal" msgstr "%s %s process (%d) continued by %s signal" -#: init/job_process.c:1056 +#: init/job_process.c:1106 #, c-format msgid "%s %s process (%d) continued by signal %d" msgstr "%s %s process (%d) continued by signal %d" -#: init/job_process.c:1191 +#: init/job_process.c:1241 #, c-format msgid "%s respawning too fast, stopped" msgstr "%s respawning too fast, stopped" -#: init/job_process.c:1197 +#: init/job_process.c:1247 #, c-format msgid "%s %s process ended, respawning" msgstr "%s %s process ended, respawning" -#: init/job_process.c:1437 +#: init/job_process.c:1487 #, c-format msgid "Failed to set ptrace options for %s %s process (%d): %s" msgstr "Failed to set ptrace options for %s %s process (%d): %s" -#: init/job_process.c:1450 init/job_process.c:1645 +#: init/job_process.c:1500 init/job_process.c:1695 #, c-format msgid "Failed to continue traced %s %s process (%d): %s" msgstr "Failed to continue traced %s %s process (%d): %s" -#: init/job_process.c:1490 init/job_process.c:1581 init/job_process.c:1636 +#: init/job_process.c:1540 init/job_process.c:1631 init/job_process.c:1686 #, c-format msgid "Failed to detach traced %s %s process (%d): %s" msgstr "Failed to detach traced %s %s process (%d): %s" -#: init/job_process.c:1530 +#: init/job_process.c:1580 #, c-format msgid "Failed to deliver signal to traced %s %s process (%d): %s" msgstr "Failed to deliver signal to traced %s %s process (%d): %s" -#: init/job_process.c:1565 +#: init/job_process.c:1615 #, c-format msgid "Failed to obtain child process id for %s %s process (%d): %s" msgstr "Failed to obtain child process id for %s %s process (%d): %s" -#: init/job_process.c:1572 +#: init/job_process.c:1622 #, c-format msgid "%s %s process (%d) became new process (%d)" msgstr "%s %s process (%d) became new process (%d)" -#: init/job_process.c:1631 +#: init/job_process.c:1681 #, c-format msgid "%s %s process (%d) executable changed" msgstr "%s %s process (%d) executable changed" -#: init/main.c:125 +#: init/main.c:129 msgid "specify alternative directory to load configuration files from" msgstr "specify alternative directory to load configuration files from" -#: init/main.c:128 +#: init/main.c:132 msgid "Disable user and chroot sessions" msgstr "Disable user and chroot sessions" -#: init/main.c:131 +#: init/main.c:135 msgid "do not emit any startup event (for testing)" msgstr "do not emit any startup event (for testing)" -#: init/main.c:136 +#: init/main.c:140 msgid "use D-Bus session bus rather than system bus (for testing)" msgstr "use D-Bus session bus rather than system bus (for testing)" -#: init/main.c:139 +#: init/main.c:143 msgid "specify an alternative initial event (for testing)" msgstr "specify an alternative initial event (for testing)" -#: init/main.c:159 +#: init/main.c:163 msgid "Process management daemon." msgstr "Process management daemon." -#: init/main.c:161 +#: init/main.c:165 msgid "" "This daemon is normally executed by the kernel and given process id 1 to " "denote its special status. When executed by a user process, it will " @@ -479,45 +494,55 @@ "denote its special status. When executed by a user process, it will " "actually run /sbin/telinit." -#: init/main.c:177 util/reboot.c:166 util/shutdown.c:363 util/telinit.c:148 +#: init/main.c:181 util/reboot.c:166 util/shutdown.c:363 util/telinit.c:148 msgid "Need to be root" msgstr "Need to be root" -#: init/main.c:186 +#: init/main.c:190 msgid "Not being executed as init" msgstr "Not being executed as init" -#: init/main.c:234 init/main.c:526 +#: init/main.c:238 init/main.c:611 msgid "Unable to set root directory" msgstr "Unable to set root directory" -#: init/main.c:245 +#: init/main.c:249 msgid "Unable to mount /proc filesystem" msgstr "Unable to mount /proc filesystem" -#: init/main.c:254 +#: init/main.c:258 msgid "Unable to mount /sys filesystem" msgstr "Unable to mount /sys filesystem" -#: init/main.c:350 +#: init/main.c:361 msgid "Unable to listen for private connections" msgstr "Unable to listen for private connections" -#: init/main.c:543 +#: init/main.c:628 #, c-format msgid "Caught %s, core dumped" msgstr "Caught %s, core dumped" -#: init/main.c:547 +#: init/main.c:632 #, c-format msgid "Caught %s, unable to dump core" msgstr "Caught %s, unable to dump core" -#: init/main.c:633 +#: init/main.c:661 +#, c-format +msgid "Re-executing %s" +msgstr "Re-executing %s" + +#: init/main.c:686 +#, c-format +msgid "Failed to re-execute %s: %s" +msgstr "Failed to re-execute %s: %s" + +#: init/main.c:771 msgid "Reconnecting to system bus" msgstr "Reconnecting to system bus" -#: init/main.c:639 +#: init/main.c:777 msgid "Unable to connect to the system bus" msgstr "Unable to connect to the system bus" @@ -1074,15 +1099,19 @@ msgid "%s: illegal runlevel: %s\n" msgstr "%s: illegal runlevel: %s\n" -#: extra/upstart-udev-bridge.c:76 +#: extra/upstart-udev-bridge.c:85 msgid "Detach and run in the background" msgstr "Detach and run in the background" -#: extra/upstart-udev-bridge.c:95 +#: extra/upstart-udev-bridge.c:87 +msgid "Do not strip non-printable bytes from udev message data" +msgstr "Do not strip non-printable bytes from udev message data" + +#: extra/upstart-udev-bridge.c:106 msgid "Bridge udev events into upstart" msgstr "Bridge udev events into upstart" -#: extra/upstart-udev-bridge.c:97 +#: extra/upstart-udev-bridge.c:108 msgid "" "By default, upstart-udev-bridge does not detach from the console and remains " "in the foreground. Use the --daemon option to have it detach." @@ -1090,18 +1119,18 @@ "By default, upstart-udev-bridge does not detach from the console and remains " "in the foreground. Use the --daemon option to have it detach." -#: extra/upstart-udev-bridge.c:111 +#: extra/upstart-udev-bridge.c:122 msgid "Could not connect to Upstart" msgstr "Could not connect to Upstart" -#: extra/upstart-udev-bridge.c:125 +#: extra/upstart-udev-bridge.c:136 msgid "Could not create Upstart proxy" msgstr "Could not create Upstart proxy" -#: extra/upstart-udev-bridge.c:149 +#: extra/upstart-udev-bridge.c:160 msgid "Unable to become daemon" msgstr "Unable to become daemon" -#: extra/upstart-udev-bridge.c:297 +#: extra/upstart-udev-bridge.c:334 msgid "Disconnected from Upstart" msgstr "Disconnected from Upstart" --- upstart-1.3.orig/po/upstart.pot +++ upstart-1.3/po/upstart.pot @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: upstart 1.3\n" "Report-Msgid-Bugs-To: new@bugs.launchpad.net\n" -"POT-Creation-Date: 2011-06-14 15:09+0100\n" +"POT-Creation-Date: 2011-11-09 10:05+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -63,7 +63,7 @@ msgid "Disconnected from system bus" msgstr "" -#: init/control.c:370 init/main.c:616 +#: init/control.c:370 init/main.c:754 msgid "Reloading configuration" msgstr "" @@ -273,226 +273,251 @@ msgid "%s %s process (%d)" msgstr "" -#: init/job_process.c:403 +#: init/job_process.c:409 #, c-format msgid "Pausing %s (%d) [pre-exec] for debug" msgstr "" -#: init/job_process.c:473 +#: init/job_process.c:559 #, c-format msgid "Failed to open system console: %s" msgstr "" -#: init/job_process.c:755 +#: init/job_process.c:790 #, c-format msgid "unable to move script fd: %s" msgstr "" -#: init/job_process.c:760 +#: init/job_process.c:795 #, c-format msgid "unable to open console: %s" msgstr "" -#: init/job_process.c:815 +#: init/job_process.c:850 #, c-format msgid "unable to set \"%s\" resource limit: %s" msgstr "" -#: init/job_process.c:820 +#: init/job_process.c:855 #, c-format msgid "unable to set priority: %s" msgstr "" -#: init/job_process.c:825 +#: init/job_process.c:860 #, c-format msgid "unable to set oom adjustment: %s" msgstr "" -#: init/job_process.c:830 +#: init/job_process.c:865 #, c-format msgid "unable to change root directory: %s" msgstr "" -#: init/job_process.c:835 +#: init/job_process.c:870 #, c-format msgid "unable to change working directory: %s" msgstr "" -#: init/job_process.c:840 +#: init/job_process.c:875 #, c-format msgid "unable to set trace: %s" msgstr "" -#: init/job_process.c:845 +#: init/job_process.c:880 #, c-format msgid "unable to execute: %s" msgstr "" -#: init/job_process.c:876 init/job_process.c:926 +#: init/job_process.c:885 +#, c-format +msgid "unable to setuid: %s" +msgstr "" + +#: init/job_process.c:890 +#, c-format +msgid "unable to setgid: %s" +msgstr "" + +#: init/job_process.c:895 +#, c-format +msgid "unable to chown: %s" +msgstr "" + +#: init/job_process.c:926 init/job_process.c:976 #, c-format msgid "Sending %s signal to %s %s process (%d)" msgstr "" -#: init/job_process.c:885 init/job_process.c:935 +#: init/job_process.c:935 init/job_process.c:985 #, c-format msgid "Failed to send %s signal to %s %s process (%d): %s" msgstr "" -#: init/job_process.c:996 +#: init/job_process.c:1046 #, c-format msgid "%s %s process (%d) terminated with status %d" msgstr "" -#: init/job_process.c:1001 +#: init/job_process.c:1051 #, c-format msgid "%s %s process (%d) exited normally" msgstr "" -#: init/job_process.c:1016 +#: init/job_process.c:1066 #, c-format msgid "%s %s process (%d) killed by %s signal" msgstr "" -#: init/job_process.c:1020 +#: init/job_process.c:1070 #, c-format msgid "%s %s process (%d) killed by signal %d" msgstr "" -#: init/job_process.c:1034 +#: init/job_process.c:1084 #, c-format msgid "%s %s process (%d) stopped by %s signal" msgstr "" -#: init/job_process.c:1038 +#: init/job_process.c:1088 #, c-format msgid "%s %s process (%d) stopped by signal %d" msgstr "" -#: init/job_process.c:1052 +#: init/job_process.c:1102 #, c-format msgid "%s %s process (%d) continued by %s signal" msgstr "" -#: init/job_process.c:1056 +#: init/job_process.c:1106 #, c-format msgid "%s %s process (%d) continued by signal %d" msgstr "" -#: init/job_process.c:1191 +#: init/job_process.c:1241 #, c-format msgid "%s respawning too fast, stopped" msgstr "" -#: init/job_process.c:1197 +#: init/job_process.c:1247 #, c-format msgid "%s %s process ended, respawning" msgstr "" -#: init/job_process.c:1437 +#: init/job_process.c:1487 #, c-format msgid "Failed to set ptrace options for %s %s process (%d): %s" msgstr "" -#: init/job_process.c:1450 init/job_process.c:1645 +#: init/job_process.c:1500 init/job_process.c:1695 #, c-format msgid "Failed to continue traced %s %s process (%d): %s" msgstr "" -#: init/job_process.c:1490 init/job_process.c:1581 init/job_process.c:1636 +#: init/job_process.c:1540 init/job_process.c:1631 init/job_process.c:1686 #, c-format msgid "Failed to detach traced %s %s process (%d): %s" msgstr "" -#: init/job_process.c:1530 +#: init/job_process.c:1580 #, c-format msgid "Failed to deliver signal to traced %s %s process (%d): %s" msgstr "" -#: init/job_process.c:1565 +#: init/job_process.c:1615 #, c-format msgid "Failed to obtain child process id for %s %s process (%d): %s" msgstr "" -#: init/job_process.c:1572 +#: init/job_process.c:1622 #, c-format msgid "%s %s process (%d) became new process (%d)" msgstr "" -#: init/job_process.c:1631 +#: init/job_process.c:1681 #, c-format msgid "%s %s process (%d) executable changed" msgstr "" -#: init/main.c:125 +#: init/main.c:129 msgid "specify alternative directory to load configuration files from" msgstr "" -#: init/main.c:128 +#: init/main.c:132 msgid "Disable user and chroot sessions" msgstr "" -#: init/main.c:131 +#: init/main.c:135 msgid "do not emit any startup event (for testing)" msgstr "" -#: init/main.c:136 +#: init/main.c:140 msgid "use D-Bus session bus rather than system bus (for testing)" msgstr "" -#: init/main.c:139 +#: init/main.c:143 msgid "specify an alternative initial event (for testing)" msgstr "" -#: init/main.c:159 +#: init/main.c:163 msgid "Process management daemon." msgstr "" -#: init/main.c:161 +#: init/main.c:165 msgid "" "This daemon is normally executed by the kernel and given process id 1 to " "denote its special status. When executed by a user process, it will " "actually run /sbin/telinit." msgstr "" -#: init/main.c:177 util/reboot.c:166 util/shutdown.c:363 util/telinit.c:148 +#: init/main.c:181 util/reboot.c:166 util/shutdown.c:363 util/telinit.c:148 msgid "Need to be root" msgstr "" -#: init/main.c:186 +#: init/main.c:190 msgid "Not being executed as init" msgstr "" -#: init/main.c:234 init/main.c:526 +#: init/main.c:238 init/main.c:611 msgid "Unable to set root directory" msgstr "" -#: init/main.c:245 +#: init/main.c:249 msgid "Unable to mount /proc filesystem" msgstr "" -#: init/main.c:254 +#: init/main.c:258 msgid "Unable to mount /sys filesystem" msgstr "" -#: init/main.c:350 +#: init/main.c:361 msgid "Unable to listen for private connections" msgstr "" -#: init/main.c:543 +#: init/main.c:628 #, c-format msgid "Caught %s, core dumped" msgstr "" -#: init/main.c:547 +#: init/main.c:632 #, c-format msgid "Caught %s, unable to dump core" msgstr "" -#: init/main.c:633 +#: init/main.c:661 +#, c-format +msgid "Re-executing %s" +msgstr "" + +#: init/main.c:686 +#, c-format +msgid "Failed to re-execute %s: %s" +msgstr "" + +#: init/main.c:771 msgid "Reconnecting to system bus" msgstr "" -#: init/main.c:639 +#: init/main.c:777 msgid "Unable to connect to the system bus" msgstr "" @@ -972,32 +997,36 @@ msgid "%s: illegal runlevel: %s\n" msgstr "" -#: extra/upstart-udev-bridge.c:76 +#: extra/upstart-udev-bridge.c:85 msgid "Detach and run in the background" msgstr "" -#: extra/upstart-udev-bridge.c:95 +#: extra/upstart-udev-bridge.c:87 +msgid "Do not strip non-printable bytes from udev message data" +msgstr "" + +#: extra/upstart-udev-bridge.c:106 msgid "Bridge udev events into upstart" msgstr "" -#: extra/upstart-udev-bridge.c:97 +#: extra/upstart-udev-bridge.c:108 msgid "" "By default, upstart-udev-bridge does not detach from the console and remains " "in the foreground. Use the --daemon option to have it detach." msgstr "" -#: extra/upstart-udev-bridge.c:111 +#: extra/upstart-udev-bridge.c:122 msgid "Could not connect to Upstart" msgstr "" -#: extra/upstart-udev-bridge.c:125 +#: extra/upstart-udev-bridge.c:136 msgid "Could not create Upstart proxy" msgstr "" -#: extra/upstart-udev-bridge.c:149 +#: extra/upstart-udev-bridge.c:160 msgid "Unable to become daemon" msgstr "" -#: extra/upstart-udev-bridge.c:297 +#: extra/upstart-udev-bridge.c:334 msgid "Disconnected from Upstart" msgstr "" --- upstart-1.3.orig/dbus/Upstart.conf +++ upstart-1.3/dbus/Upstart.conf @@ -9,14 +9,12 @@ - - - + + + + + + + + + + + + + + + + + + --- upstart-1.3.orig/extra/upstart-udev-bridge.c +++ upstart-1.3/extra/upstart-udev-bridge.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -50,6 +51,7 @@ static void upstart_disconnected (DBusConnection *connection); static void emit_event_error (void *data, NihDBusMessage *message); +static char *make_safe_string (const void *parent, const char *original); /** * daemonise: @@ -66,6 +68,13 @@ **/ static NihDBusProxy *upstart = NULL; +/** + * no_strip_udev_data: + * + * If TRUE, do not modify any udev message data (old behaviour). + * If FALSE, use make_safe_string () to cleanse udev strings. + **/ +static int no_strip_udev_data = FALSE; /** * options: @@ -75,6 +84,8 @@ static NihOption options[] = { { 0, "daemon", N_("Detach and run in the background"), NULL, NULL, &daemonise, NULL }, + { 0, "no-strip", N_("Do not strip non-printable bytes from udev message data"), + NULL, NULL, &no_strip_udev_data, NULL }, NIH_OPTION_LAST }; @@ -179,25 +190,44 @@ NihIoEvents events) { struct udev_device * udev_device; - const char * subsystem; - const char * action; - const char * kernel; - const char * devpath; - const char * devname; + nih_local char * subsystem = NULL; + nih_local char * action = NULL; + nih_local char * kernel = NULL; + nih_local char * devpath = NULL; + nih_local char * devname = NULL; nih_local char * name = NULL; nih_local char ** env = NULL; size_t env_len = 0; DBusPendingCall * pending_call; + char *(*copy_string)(const void *, const char *) = NULL; + udev_device = udev_monitor_receive_device (udev_monitor); if (! udev_device) return; - subsystem = udev_device_get_subsystem (udev_device); - action = udev_device_get_action (udev_device); - kernel = udev_device_get_sysname (udev_device); - devpath = udev_device_get_devpath (udev_device); - devname = udev_device_get_devnode (udev_device); + copy_string = no_strip_udev_data ? nih_strdup : make_safe_string; + + subsystem = copy_string (NULL, udev_device_get_subsystem (udev_device)); + if (! action) + goto out; + + action = copy_string (NULL, udev_device_get_action (udev_device)); + if (! action) + goto out; + + kernel = copy_string (NULL, udev_device_get_sysname (udev_device)); + if (! kernel) + goto out; + + devpath = copy_string (NULL, udev_device_get_devpath (udev_device)); + if (! devpath) + goto out; + + devname = copy_string (NULL, udev_device_get_devnode (udev_device)); + if (! devname) + goto out; + if (! strcmp (action, "add")) { name = NIH_MUST (nih_sprintf (NULL, "%s-device-added", @@ -253,10 +283,10 @@ for (struct udev_list_entry *list_entry = udev_device_get_properties_list_entry (udev_device); list_entry != NULL; list_entry = udev_list_entry_get_next (list_entry)) { - const char * key; + nih_local char *key = NULL; nih_local char *var = NULL; - key = udev_list_entry_get_name (list_entry); + key = copy_string (NULL, udev_list_entry_get_name (list_entry)); if (! strcmp (key, "DEVPATH")) continue; if (! strcmp (key, "DEVNAME")) @@ -267,26 +297,33 @@ continue; var = NIH_MUST (nih_sprintf (NULL, "%s=%s", key, - udev_list_entry_get_value (list_entry))); + copy_string (NULL, udev_list_entry_get_value (list_entry)))); NIH_MUST (nih_str_array_addp (&env, NULL, &env_len, var)); } nih_debug ("%s %s", name, devname); - pending_call = NIH_SHOULD (upstart_emit_event (upstart, - name, env, FALSE, - NULL, emit_event_error, NULL, - NIH_DBUS_TIMEOUT_NEVER)); + pending_call = upstart_emit_event (upstart, + name, env, FALSE, + NULL, emit_event_error, NULL, + NIH_DBUS_TIMEOUT_NEVER); + if (! pending_call) { NihError *err; + int saved = errno; err = nih_error_get (); nih_warn ("%s", err->message); + + if (saved != ENOMEM && subsystem) + nih_warn ("Likely that udev '%s' event contains binary garbage", subsystem); + nih_free (err); } dbus_pending_call_unref (pending_call); +out: udev_device_unref (udev_device); } @@ -308,3 +345,75 @@ nih_warn ("%s", err->message); nih_free (err); } + +/** + * make_safe_string: + * @parent: parent, + * @original: original string. + * + * Strip non-printable and non-blank bytes from specified string. + * + * Notes: + * + * Sadly, this is necessary as some hardware (such as battery devices) + * exposes non-printable bytes in their descriptive registers to the + * kernel. Since neither the kernel nor udev specify any encoding for + * udev messages, these (probably bogus) bytes get passed up to userland + * to deal with. This is sub-optimal since it implies that _every_ + * application that processes udev messages must perform its own + * sanitizing on the messages. Let's just hope they all deal with the + * problem in the same way... + * + * Note that *iff* the kernel/udev did specify an encoding model, this + * problem could go away since one of the lower layers could then + * detect the out-of-bound data and deal with it at source. All instances + * of this issue seen so far seem to indicate the binary control data + * being presented by the hardware is in fact bogus ("corruption") and + * looks like some block of memory has not been initialized correctly. + * + * The approach taken here is to simulate the approach already adopted + * by 'upower' (up_device_supply_make_safe_string()), with the exception + * that we also allow blank characters (such as tabs). + * + * Returns a copy of @original stripped of all non-printable and + * non-blank characters, or NULL if insufficient memory. + **/ +char * +make_safe_string(const void *parent, const char *original) +{ + size_t len; + size_t i, j; + char *cleaned; + + nih_assert (original); + + + len = strlen (original); + + cleaned = nih_alloc (parent, len); + + if (! cleaned) + return NULL; + + for (i=0, j=0; i <= len; ) { + /* Skip over bogus bytes */ + if (! isprint (original[i]) && ! isblank (original[i])) { + i++; + continue; + } + + /* Copy what remains */ + cleaned[j] = original[i]; + i++; j++; + } + + /* Terminate */ + cleaned[j] = '\0'; + + if (i != j) + nih_debug ("removed bogus bytes in udev message data"); + + /* If substitutions were necessary, shrink the string */ + return i == j ? cleaned : nih_realloc (cleaned, parent, j); +} + --- upstart-1.3.orig/extra/conf/upstart-udev-bridge.conf +++ upstart-1.3/extra/conf/upstart-udev-bridge.conf @@ -5,7 +5,13 @@ description "Bridge udev events into upstart" -emits *-device-* +# From upstart-udev-bridge itself +emits *-device-added +emits *-device-removed +emits *-device-changed +# From http://www.kernel.org/pub/linux/utils/kernel/hotplug/libudev/libudev-udev-device.html +emits *-device-online +emits *-device-offline start on starting udev stop on stopped udev --- upstart-1.3.orig/extra/man/upstart-udev-bridge.8 +++ upstart-1.3/extra/man/upstart-udev-bridge.8 @@ -21,10 +21,46 @@ Assuming \fI/sys\fP is mounted, possible values for \fIsubsystem\fP for your system are viewable via \fI/sys/class/\fP. - +.\" +.SH OPTIONS +.\" +.TP +.B \-\-daemon +Detach and run in the background. +.\" +.TP +.B \-\-debug +Enable debugging output. +.\" +.TP +.B \-\-help +Show brief usage summary. +.\" +.TP +.B \-\-no\-strip +Do not modify udev message contents. By default, all udev data will have +non-printable bytes removed. This option reverts the behaviour to not +modifying the data in any way. This option is not recommended since +specifying it +.I could +result in +.BR udev (7) +events not being emitted as Upstart events should any of your +hardware expose non-printable characters to the kernel. You can establish +whether this is happening by running +.I without +specifying this option +but with the +.B --debug +option. +.\" +.TP +.B \-\-verbose +Enable verbose output. .\" .SH EXAMPLES +Some examples of Upstart events generated by this bridge: .IP net\-device\-added Event emitted when a network device is added. .IP net\-device\-removed --- upstart-1.3.orig/init/control.c +++ upstart-1.3/init/control.c @@ -65,7 +65,7 @@ /** * use_session_bus: * - * If TRUE, connect to the D-Bus sessio bus rather than the system bus. + * If TRUE, connect to the D-Bus session bus rather than the system bus. * * Used for testing. **/ --- upstart-1.3.orig/init/job_process.c +++ upstart-1.3/init/job_process.c @@ -373,14 +373,20 @@ int trace, int script_fd) { - sigset_t child_set, orig_set; - pid_t pid; - int i, fds[2]; - char filename[PATH_MAX]; - FILE *fd; + sigset_t child_set, orig_set; + pid_t pid; + int i, fds[2]; + char filename[PATH_MAX]; + FILE *fd; + int user_job = FALSE; + nih_local char *user_dir = NULL; + nih_assert (class != NULL); + if (class && class->session && class->session->user) + user_job = TRUE; + /* Create a pipe to communicate with the child process until it * execs so we know whether that was successful or an error occurred. */ @@ -440,6 +446,8 @@ if (fds[1] == JOB_PROCESS_SCRIPT_FD) { int tmp = dup2 (fds[1], fds[0]); close (fds[1]); + if (tmp < 0) + nih_return_system_error (-1); fds[1] = tmp; } nih_io_set_cloexec (fds[1]); @@ -460,6 +468,84 @@ */ setsid (); + /* Set the process environment from the function paramters. */ + environ = (char **)env; + + /* Handle unprivileged user job by dropping privileges to + * their level as soon as possible to avoid privilege + * escalations when we set resource limits. + */ + if (user_job) { + uid_t uid = class->session->user; + struct passwd *pw = NULL; + + /* D-Bus does not expose a public API call to allow + * us to query a users primary group. + * _dbus_user_info_fill_uid () seems to exist for this + * purpose, but is a "secret" API. It is unclear why + * D-Bus neglects the gid when it allows the uid + * to be queried directly. + * + * Our only recourse is to disallow user sessions in a + * chroot and assume that all other user sessions + * originate from the local system. In this way, we can + * bypass D-Bus and use getpwuid (). + */ + + if (class->session->chroot) { + /* We cannot determine the group id of the user + * session in the chroot via D-Bus, so disallow + * all jobs in such an environment. + */ + nih_return_error (-1, EPERM, "user jobs not supported in chroots"); + } + + pw = getpwuid (uid); + + if (!pw) + nih_return_system_error (-1); + + nih_assert (pw->pw_uid == uid); + + if (! pw->pw_dir) { + nih_local char *message = NIH_MUST (nih_sprintf (NULL, + "no home directory for user with uid %d", + uid)); + + nih_return_error (-1, ENOENT, message); + + } + + /* Note we don't use NIH_MUST since this could result in a + * DOS for a (low priority) user job in low-memory scenarios. + */ + user_dir = nih_strdup (NULL, pw->pw_dir); + + if (!user_dir) + nih_return_no_memory_error (-1); + + /* Ensure the file associated with fd 9 + * (/proc/self/fd/9) is owned by the user we're about to + * become to avoid EPERM. + */ + if (script_fd != -1 && fchown (script_fd, pw->pw_uid, pw->pw_gid) < 0) { + nih_error_raise_system (); + job_process_error_abort (fds[1], JOB_PROCESS_ERROR_CHOWN, 0); + } + + if (pw->pw_gid && setgid (pw->pw_gid) < 0) { + nih_error_raise_system (); + job_process_error_abort (fds[1], JOB_PROCESS_ERROR_SETGID, 0); + } + + if (pw->pw_uid && setuid (pw->pw_uid) < 0) { + nih_error_raise_system (); + job_process_error_abort (fds[1], JOB_PROCESS_ERROR_SETUID, 0); + } + + + } + /* Set the standard file descriptors to an output of our chosing; * any other open descriptor must be intended for the child, or have * the FD_CLOEXEC flag so it's automatically closed when we exec() @@ -480,6 +566,7 @@ job_process_error_abort (fds[1], JOB_PROCESS_ERROR_CONSOLE, 0); } + /* Set resource limits for the process, skipping over any that * aren't set in the job class such that they inherit from * ourselves (and we inherit from kernel defaults). @@ -495,9 +582,6 @@ } } - /* Set the process environment from the function paramters. */ - environ = (char **)env; - /* Set the file mode creation mask; this is one of the few operations * that can never fail. */ @@ -565,12 +649,11 @@ * configured in the job, or to the root directory of the filesystem * (or at least relative to the chroot). */ - if (chdir (class->chdir ? class->chdir : "/") < 0) { + if (chdir (class->chdir ? class->chdir : user_job ? user_dir : "/") < 0) { nih_error_raise_system (); job_process_error_abort (fds[1], JOB_PROCESS_ERROR_CHDIR, 0); } - /* Reset all the signal handlers back to their default handling so * the child isn't unexpectedly ignoring any, and so we won't * surprisingly handle them before we've exec()d the new process. @@ -604,54 +687,6 @@ } } - /* Handle unprivileged user job by dropping privileges to - * their level. - */ - if (class->session && class->session->user) { - uid_t uid = class->session->user; - struct passwd *pw = NULL; - - /* D-Bus does not expose a public API call to allow - * us to query a users primary group. - * _dbus_user_info_fill_uid () seems to exist for this - * purpose, but is a "secret" API. It is unclear why - * D-Bus neglects the gid when it allows the uid - * to be queried directly. - * - * Our only recourse is to disallow user sessions in a - * chroot and assume that all other user sessions - * originate from the local system. In this way, we can - * bypass D-Bus and use getpwuid (). - */ - - if (class->session->chroot) { - /* We cannot determine the group id of the user - * session in the chroot via D-Bus, so disallow - * all jobs in such an environment. - */ - _nih_error_raise (__FILE__, __LINE__, __FUNCTION__, - EPERM, strerror (EPERM)); - } - - pw = getpwuid (uid); - - if (!pw) - nih_return_system_error (-1); - - nih_assert (pw->pw_uid == uid); - - if (uid && setuid (uid) < 0) { - nih_error_raise_system (); - job_process_error_abort (fds[1], JOB_PROCESS_ERROR_SETUID, 0); - } - - if (pw->pw_gid && setgid (pw->pw_gid) < 0) { - nih_error_raise_system (); - job_process_error_abort (fds[1], JOB_PROCESS_ERROR_SETGID, 0); - } - } - - /* Execute the process, if we escape from here it failed */ if (execvp (argv[0], argv) < 0) { nih_error_raise_system (); @@ -845,6 +880,21 @@ err, _("unable to execute: %s"), strerror (err->errnum))); break; + case JOB_PROCESS_ERROR_SETUID: + err->error.message = NIH_MUST (nih_sprintf ( + err, _("unable to setuid: %s"), + strerror (err->errnum))); + break; + case JOB_PROCESS_ERROR_SETGID: + err->error.message = NIH_MUST (nih_sprintf ( + err, _("unable to setgid: %s"), + strerror (err->errnum))); + break; + case JOB_PROCESS_ERROR_CHOWN: + err->error.message = NIH_MUST (nih_sprintf ( + err, _("unable to chown: %s"), + strerror (err->errnum))); + break; default: nih_assert_not_reached (); } --- upstart-1.3.orig/init/job_process.h +++ upstart-1.3/init/job_process.h @@ -59,6 +59,7 @@ JOB_PROCESS_ERROR_EXEC, JOB_PROCESS_ERROR_SETUID, JOB_PROCESS_ERROR_SETGID, + JOB_PROCESS_ERROR_CHOWN } JobProcessErrorType; /** --- upstart-1.3.orig/init/main.c +++ upstart-1.3/init/main.c @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -63,6 +64,9 @@ #ifndef DEBUG static int logger_kmsg (NihLogLevel priority, const char *message); static void crash_handler (int signum); +#endif /* DEBUG */ +static void term_handler (void *data, NihSignal *signal); +#ifndef DEBUG static void cad_handler (void *data, NihSignal *signal); static void kbd_handler (void *data, NihSignal *signal); static void pwr_handler (void *data, NihSignal *signal); @@ -321,6 +325,13 @@ /* SIGUSR1 instructs us to reconnect to D-Bus */ nih_signal_set_handler (SIGUSR1, nih_signal_handler); NIH_MUST (nih_signal_add_handler (NULL, SIGUSR1, usr1_handler, NULL)); + + /* SIGTERM instructs us to re-exec ourselves; this should be the + * last in the list to ensure that all other signals are handled + * before a SIGTERM. + */ + nih_signal_set_handler (SIGTERM, nih_signal_handler); + NIH_MUST (nih_signal_add_handler (NULL, SIGTERM, term_handler, NULL)); } #endif /* DEBUG */ @@ -387,7 +398,17 @@ /* Generate and run the startup event or read the state from the * init daemon that exec'd us */ - if (! restart ) { + if (! restart) { + DIR *piddir; + + /* Look in well-known locations for pid files. + * + * Try /run (the newer) location first, but fall back to + * the original location for older systems. + */ + const char * const pid_paths[] = { "/run/initramfs/", "/dev/.initramfs/", NULL }; + const char * const *pid_path; + if (disable_startup_event) { nih_debug ("Startup event disabled"); } else { @@ -396,8 +417,69 @@ ? initial_event : STARTUP_EVENT, NULL)); - } + } + for (pid_path = pid_paths; pid_path && *pid_path; pid_path++) { + struct dirent *ent; + + /* Total hack, look for .pid files in known + * locations - if there's a job config for them pretend + * that we started it and it has that pid. + */ + piddir = opendir (*pid_path); + if (! piddir) + continue; + + while ((ent = readdir (piddir)) != NULL) { + char path[PATH_MAX]; + char * ptr; + FILE * pidfile; + pid_t pid; + JobClass *class; + Job * job; + + if (ent->d_name[0] == '.') + continue; + + strcpy (path, *pid_path); + strcat (path, ent->d_name); + + ptr = strrchr (ent->d_name, '.'); + if ((! ptr) || strcmp (ptr, ".pid")) + continue; + + *ptr = '\0'; + pidfile = fopen (path, "r"); + if (! pidfile) + continue; + + pid = -1; + if (fscanf (pidfile, "%d", &pid)) + ; + fclose (pidfile); + + if ((pid < 0) || (kill (pid, 0) < 0)) + continue; + + class = (JobClass *)nih_hash_lookup (job_classes, ent->d_name); + if (! class) + continue; + if (! class->process[PROCESS_MAIN]) + continue; + if (strlen (class->instance)) + continue; + + job = NIH_MUST (job_new (class, "")); + job->goal = JOB_START; + job->state = JOB_RUNNING; + job->pid[PROCESS_MAIN] = pid; + + nih_debug ("%s inherited from initramfs with pid %d", class->name, pid); + } + + closedir (piddir); + break; + } } else { sigset_t mask; @@ -406,6 +488,9 @@ sigprocmask (SIG_SETMASK, &mask, NULL); } + if (disable_sessions) + nih_debug ("Sessions disabled"); + /* Run through the loop at least once to deal with signals that were * delivered to the previous process while the mask was set or to * process the startup event we emitted. @@ -552,7 +637,60 @@ /* Goodbye, cruel world. */ exit (signum); } +#endif + +/** + * term_handler: + * @data: unused, + * @signal: signal caught. + * + * This is called when we receive the TERM signal, which instructs us + * to reexec ourselves. + **/ +static void +term_handler (void *data, + NihSignal *signal) +{ + NihError *err; + const char *loglevel; + sigset_t mask, oldmask; + + nih_assert (argv0 != NULL); + nih_assert (signal != NULL); + + nih_warn (_("Re-executing %s"), argv0); + + /* Block signals while we work. We're the last signal handler + * installed so this should mean that they're all handled now. + * + * The child must make sure that it unblocks these again when + * it's ready. + */ + sigfillset (&mask); + sigprocmask (SIG_BLOCK, &mask, &oldmask); + + /* Argument list */ + if (nih_log_priority <= NIH_LOG_DEBUG) { + loglevel = "--debug"; + } else if (nih_log_priority <= NIH_LOG_INFO) { + loglevel = "--verbose"; + } else if (nih_log_priority >= NIH_LOG_ERROR) { + loglevel = "--error"; + } else { + loglevel = NULL; + } + execl (argv0, argv0, "--restart", loglevel, NULL); + nih_error_raise_system (); + + err = nih_error_get (); + nih_error (_("Failed to re-execute %s: %s"), argv0, err->message); + nih_free (err); + + sigprocmask (SIG_SETMASK, &oldmask, NULL); +} + +#ifndef DEBUG /** * cad_handler: * @data: unused, --- upstart-1.3.orig/init/session.c +++ upstart-1.3/init/session.c @@ -124,12 +124,14 @@ session_from_dbus (const void *parent, NihDBusMessage *message) { - const char *sender; - DBusError dbus_error; - unsigned long unix_user; - unsigned long unix_process_id; - char root[PATH_MAX]; - Session *session; + const char *sender; + DBusError dbus_error; + unsigned long unix_user; + unsigned long unix_process_id; + char root[PATH_MAX]; + Session *session; + struct passwd *pwd; + nih_local char *conf_path = NULL; nih_assert (message != NULL); @@ -192,11 +194,25 @@ } else if (! unix_user) { /* No process id or user id found, return the NULL session */ return NULL; + } + + if (unix_user) { + pwd = getpwuid (unix_user); + + if (! pwd || ! pwd->pw_dir) { + nih_error ("%lu: %s: %s", unix_user, + _("Unable to lookup home directory"), + strerror (errno)); + return NULL; + } + NIH_MUST (nih_strcat_sprintf (&conf_path, NULL, "%s/%s", + pwd->pw_dir, USERCONFDIR)); } + /* Now find in the existing Sessions list */ - NIH_LIST_FOREACH (sessions, iter) { + NIH_LIST_FOREACH_SAFE (sessions, iter) { Session *session = (Session *)iter; if (unix_process_id) { @@ -212,6 +228,31 @@ if (unix_user != session->user) continue; + /* Found a user with the same uid but different + * conf_dir to the existing session user. Either the + * original user has been deleted and a new user created + * with the same uid, or the original users home + * directory has changed since they first started + * running jobs. Whatever the reason, we (can only) honour + * the new value. + * + * Since multiple users with the same uid are considered + * to be "the same user", invalidate the old path, + * allowing the correct new path to be set below. + * + * Note that there may be a possibility of trouble if + * the scenario relates to a deleted user and that original + * user still has jobs running. However, if that were the + * case, those jobs would likely fail anyway since they + * would have no working directory due to the original + * users home directory being deleted/changed/made inaccessible. + */ + if (unix_user && conf_path && session->conf_path && + strcmp (conf_path, session->conf_path)) { + nih_free (session->conf_path); + session->conf_path = NULL; + } + if (! session->conf_path) session_create_conf_source (session); --- upstart-1.3.orig/init/session.h +++ upstart-1.3/init/session.h @@ -33,23 +33,25 @@ * @entry: list header, * @chroot: path all jobs are chrooted to, * @user: uid all jobs are switched to, - * @conf_path: configuration path. + * @conf_path: configuration path (either full path to chroot root, or + * full path to users job directory (which may itself be prepended + * with a chroot path)). * * This structure is used to identify collections of jobs * that share either a common @chroot and/or common @user. * * Summary of Session values for different environments: * - * +-------------+---------------------------------------+ - * | D-Bus | Session | - * +------+------+--------+-----+------------------------+ - * | user | PID | chroot | uid | Object contents | - * +------+------+--------+-----+------------------------+ - * | 0 | >0 | no | 0 | NULL (*1) | - * | >0 | "0" | no | >0 | only uid set. | - * | 0 | >0 | yes | 0 | chroot + conf_path set | - * | >0 | ?? | yes | >0 | XXX: fails (*2) | - * +------+------+--------+-----+------------------------+ + * +-------------+--------------------------------------------------+ + * | D-Bus | Session | + * +------+------+--------+-----+-----------------------------------+ + * | user | PID | chroot | uid | Object contents | + * +------+------+--------+-----+-----------------------------------+ + * | 0 | >0 | no | 0 | NULL (*1) | + * | >0 | "0" | no | >0 | uid + conf_path set to "~/.init". | + * | 0 | >0 | yes | 0 | chroot + conf_path set | + * | >0 | ?? | yes | >0 | XXX: fails (*2) | + * +------+------+--------+-----+-----------------------------------+ * * Notes: * --- upstart-1.3.orig/init/tests/test_conf.c +++ upstart-1.3/init/tests/test_conf.c @@ -4593,7 +4593,6 @@ TEST_FUNCTION ("conf_file_destroy"); source = conf_source_new (NULL, "/path", CONF_JOB_DIR); - /* Check that when a ConfFile for a job is freed, the attached * job is also freed if it is not the current job. */ --- upstart-1.3.orig/init/man/init.5 +++ upstart-1.3/init/man/init.5 @@ -77,8 +77,12 @@ A User Job is a job configuration file created by a non\-privileged user in their .B $HOME/.init/ -directory. Job configuration files in this directory have -the same syntax as system job configuration files. +directory. Job configuration files in this directory have the same +syntax as system job configuration files. +Files in this directory will be read and an +.BR inotify (7) +watch created the first time a user runs +.BR initctl (8) "." Any user can create user jobs, but that user can control .I only @@ -88,6 +92,10 @@ .BR initctl (8) facility. +Note that stanzas which manipulate resources limits may cause a job to +fail to start should the value provided to such a stanza attempt to +exceed the maximum value the users privilege level allows. + Note that a user job configuration file cannot have the same name as a system job configuration file. .\" @@ -749,6 +757,12 @@ is unable to supervise forking processes and will believe them to have stopped as soon as they fork on startup. .\" +.SH RESTRICTIONS +The use of symbolic links in job configuration file directories is not +supported since it can lead to unpredicable behaviour resulting from +broken or inaccessible links (such as would be caused by a link crossing +a filesystem boundary to a filesystem that has not yet been mounted). +.\" .SH BUGS The .B and @@ -796,3 +810,4 @@ .BR init (8) .BR initctl (8) .BR sh (1) +.BR upstart-events (7) --- upstart-1.3.orig/init/man/init.8 +++ upstart-1.3/init/man/init.8 @@ -48,6 +48,10 @@ and .BR stopped (7) events emitted as jobs change state. + +See +.BR upstart-events (7) +for a summary of well-known events. .\" .SS System V compatibility The Upstart @@ -133,3 +137,4 @@ .BR stopping (7) .BR stopped (7) .BR telinit (8) +.BR upstart-events (7)