Compare commits

...
Sign in to create a new pull request.

9 commits

Author SHA1 Message Date
Petr Lautrbach
5cc7093c76 upstart-1.2-4.fc15 2011-05-26 11:17:31 +02:00
Petr Lautrbach
3c449f790a remove Obsoletes: upstart-sysvinit and clean spec file 2011-05-26 11:09:43 +02:00
Petr Lautrbach
9189b2e1cd /etc/init.conf, upstart-1.2-3.fc15 2011-05-13 10:44:00 +02:00
Petr Lautrbach
37dc1d3395 upstart-1.2-2.fc15 2011-05-05 13:02:20 +02:00
Petr Lautrbach
9b59ca86df move binaries to /lib/upstart, add /lib/upstart to default PATH, handle /run in tmpfiles.d 2011-05-05 13:01:20 +02:00
Petr Lautrbach
011ca1e5bb use only spaces in spec file 2011-05-05 13:00:06 +02:00
Petr Lautrbach
c144ab30b3 upstart-1.2-1.fc16 2011-03-23 09:48:10 +01:00
Petr Lautrbach
03a2a6176d upstart-1.1-1.fc15, enable .override files 2011-03-21 10:04:53 +01:00
Petr Lautrbach
4a7311a341 upstart-1.0-1.fc15 2011-03-04 16:38:10 +01:00
10 changed files with 5263 additions and 324 deletions

4
.gitignore vendored
View file

@ -1,3 +1,7 @@
upstart-0.6.6.tar.gz
/initjobs-20101206.tar.gz
/upstart-0.6.7.tar.gz
/upstart-1.0.tar.gz
/upstart-1.1.tar.gz
/upstart-1.2.tar.gz
/initjobs-20110502.tar.gz

8
fix-selinux-on-run.conf Normal file
View file

@ -0,0 +1,8 @@
# fix selinux context on /run created and mounted by dracut
# original context is tmpfs_t while we need var_run_t and others
start on starting rcS
task
exec /sbin/restorecon -R /run

0
init.conf Normal file
View file

View file

@ -1,2 +1,2 @@
37740f81b6d12a53072603fadee451c9 upstart-0.6.7.tar.gz
53aa2098362d482ce4058937b3bfd1fb initjobs-20101206.tar.gz
c1b1bab5c1c1ed2595081d8178542b37 upstart-1.2.tar.gz
dce904a3284fb76fa136c618b9e8a80c initjobs-20110502.tar.gz

View file

@ -26,8 +26,11 @@ script
# only directories
[ -n "$type" ] || continue
[ $type = "d" ] || [ $type = "D" ] || continue
# only /var/run and /var/lock
[ $path != ${path#/var/run/} ] || [ $path != ${path#/var/lock/} ] || continue
# only /run /var/run and /var/lock
[ $path != ${path#/run/} ] ||
[ $path != ${path#/var/run/} ] ||
[ $path != ${path#/var/lock/} ] ||
continue
if [ ! -d $path ]; then
mkdir -p $path || continue
SELINUX_RESTORE=1
@ -38,6 +41,6 @@ script
done
if [ -n "$SELINUX_STATE" ] && [ -n "$SELINUX_RESTORE" ]; then
/sbin/restorecon -R /var/lock /var/run 2> /dev/null
/sbin/restorecon -R /run /var/run /var/lock 2> /dev/null
fi
end script

13
upstart-lib-upstart.patch Normal file
View file

@ -0,0 +1,13 @@
diff --git a/init/paths.h b/init/paths.h
index c7ddec1..1402e9d 100644
--- a/init/paths.h
+++ b/init/paths.h
@@ -26,7 +26,7 @@
* This is the default PATH set by the init process itself.
**/
#ifndef PATH
-#define _PATH "/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin"
+#define _PATH "/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/lib/upstart:/sbin:/bin"
#ifdef EXTRA_PATH
#define PATH _PATH ":" EXTRA_PATH
#else

5145
upstart-override.patch Normal file

File diff suppressed because it is too large Load diff

View file

@ -24,19 +24,10 @@ index d40e750..e5b5190 100644
int deleted;
int debug;
diff --git a/init/job_process.c b/init/job_process.c
index 282bf17..996000b 100644
index 70fa2bf..544f5e3 100644
--- a/init/job_process.c
+++ b/init/job_process.c
@@ -38,6 +38,8 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <utmp.h>
+#include <utmpx.h>
#include <nih/macros.h>
#include <nih/alloc.h>
@@ -359,11 +361,13 @@ job_process_spawn (JobClass *class,
@@ -361,11 +361,13 @@ job_process_spawn (JobClass *class,
char * const *env,
int trace)
{
@ -55,7 +46,7 @@ index 282bf17..996000b 100644
nih_assert (class != NULL);
@@ -556,6 +560,20 @@ job_process_spawn (JobClass *class,
@@ -558,6 +560,20 @@ job_process_spawn (JobClass *class,
}
}
@ -76,242 +67,14 @@ index 282bf17..996000b 100644
/* Execute the process, if we escape from here it failed */
if (execvp (argv[0], argv) < 0) {
nih_error_raise_system ();
@@ -999,6 +1017,8 @@ job_process_terminated (Job *job,
int status)
{
int failed = FALSE, stop = FALSE, state = TRUE;
+ struct utmpx *utmptr;
+ struct timeval tv;
nih_assert (job != NULL);
@@ -1161,6 +1181,36 @@ job_process_terminated (Job *job,
job->kill_process = -1;
}
+ /* Find existing utmp entry for the process pid */
+ setutxent();
+ while ((utmptr = getutxent()) != NULL) {
+ if (utmptr->ut_pid == job->pid[process]) {
+ /* set type and clean ut_user, ut_host,
+ * ut_time as described in utmp(5)
+ */
+ utmptr->ut_type = DEAD_PROCESS;
+ memset(utmptr->ut_user, 0, UT_NAMESIZE);
+ memset(utmptr->ut_host, 0, UT_HOSTSIZE);
+ utmptr->ut_time = 0;
@@ -1176,6 +1192,10 @@ job_process_terminated (Job *job,
memset(utmptr->ut_user, 0, UT_NAMESIZE);
memset(utmptr->ut_host, 0, UT_HOSTSIZE);
utmptr->ut_time = 0;
+
+ /* Set class utmp_id for next spawn */
+ job->class->utmp_id = nih_strdup (job->class, utmptr->ut_id);
+
+ /* Update existing utmp file. */
+ pututxline(utmptr);
+
+ /* set ut_time for log */
+ gettimeofday(&tv, NULL);
+ utmptr->ut_tv.tv_sec = tv.tv_sec;
+ utmptr->ut_tv.tv_usec = tv.tv_usec;
+ /* Write wtmp entry */
+ updwtmpx (_PATH_WTMP, utmptr);
+
+ break;
+ }
+ }
+ endutxent();
+
/* Clear the process pid field */
job->pid[process] = 0;
diff --git a/init/tests/test_job_process.c b/init/tests/test_job_process.c
index 5946da8..1454afe 100644
--- a/init/tests/test_job_process.c
+++ b/init/tests/test_job_process.c
@@ -36,6 +36,8 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <utmp.h>
+#include <utmpx.h>
#include <nih/macros.h>
#include <nih/string.h>
@@ -4501,6 +4503,171 @@ test_find (void)
}
+void
+test_utmp (void)
+{
+ JobClass * class;
+ Job * job = NULL;
+ Blocked * blocked = NULL;
+ Event * event;
+ FILE * output;
+ char utmpname[PATH_MAX];
+ struct utmpx utmp, *utmptr;
+ struct timeval tv;
+
+ TEST_FUNCTION ("job_process_handler");
+ program_name = "test";
+
+ class = job_class_new (NULL, "test");
+ class->process[PROCESS_MAIN] = process_new (class);
+ class->process[PROCESS_MAIN]->command = "echo";
+
+ class->start_on = event_operator_new (class, EVENT_MATCH,
+ "foo", NULL);
+ class->stop_on = event_operator_new (class, EVENT_MATCH,
+ "foo", NULL);
+ nih_hash_add (job_classes, &class->entry);
+
+ event = event_new (NULL, "foo", NULL);
+
+ TEST_FILENAME(utmpname);
+
+ /* Check that utmp record for the running task of the job terminating
+ * is properly changed to DEAD_PROCESS
+ */
+ TEST_FEATURE ("with LOGIN_PROCESS utmp entry");
+ TEST_ALLOC_FAIL {
+ TEST_ALLOC_SAFE {
+ job = job_new (class, "");
+
+ blocked = blocked_new (job, BLOCKED_EVENT, event);
+ event_block (event);
+ nih_list_add (&job->blocking, &blocked->entry);
+ }
+
+ job->goal = JOB_START;
+ job->state = JOB_RUNNING;
+ job->pid[PROCESS_MAIN] = 1;
+
+ TEST_FREE_TAG (blocked);
+
+ job->blocker = NULL;
+ event->failed = FALSE;
+
+ job->failed = FALSE;
+ job->failed_process = -1;
+ job->exit_status = 0;
+
+ output = fopen (utmpname, "w");
+ fclose (output);
+
+ /* set utmp file */
+ utmpxname(utmpname);
+
+ /* set up utmp entries */
+ memset (&utmp, 0, sizeof utmp);
+
+ strcpy(utmp.ut_id, "2");
+ utmp.ut_type = LOGIN_PROCESS;
+ utmp.ut_pid = 2;
+
+ gettimeofday(&tv, NULL);
+ utmp.ut_tv.tv_sec = tv.tv_sec;
+ utmp.ut_tv.tv_usec = tv.tv_usec;
+
+ setutxent();
+ pututxline(&utmp);
+
+ strcpy(utmp.ut_id, "1");
+ utmp.ut_pid = 1;
+ pututxline(&utmp);
+
+ endutxent();
+
+ job_process_handler (NULL, 1, NIH_CHILD_EXITED, 0);
+
+ setutxent();
+
+ utmptr = getutxent();
+ TEST_NE_P(utmptr, NULL);
+ TEST_EQ(utmptr->ut_pid, 2);
+ TEST_EQ(utmptr->ut_type, LOGIN_PROCESS);
+
+ utmptr = getutxent();
+ TEST_NE_P(utmptr, NULL);
+ TEST_EQ(utmptr->ut_pid, 1);
+ TEST_EQ(utmptr->ut_type, DEAD_PROCESS);
+
+ nih_free (job);
+ }
+ TEST_FEATURE ("with USER_PROCESS utmp entry");
+ TEST_ALLOC_FAIL {
+ TEST_ALLOC_SAFE {
+ job = job_new (class, "");
+
+ blocked = blocked_new (job, BLOCKED_EVENT, event);
+ event_block (event);
+ nih_list_add (&job->blocking, &blocked->entry);
+ }
+
+ job->goal = JOB_START;
+ job->state = JOB_RUNNING;
+ job->pid[PROCESS_MAIN] = 1;
+
+ TEST_FREE_TAG (blocked);
+
+ job->blocker = NULL;
+ event->failed = FALSE;
+
+ job->failed = FALSE;
+ job->failed_process = -1;
+ job->exit_status = 0;
+
+ output = fopen (utmpname, "w");
+ fclose (output);
+
+ /* set utmp file */
+ utmpxname(utmpname);
+
+ /* set up utmp entries */
+ memset (&utmp, 0, sizeof utmp);
+
+ strcpy(utmp.ut_id, "2");
+ utmp.ut_type = USER_PROCESS;
+ utmp.ut_pid = 2;
+
+ gettimeofday(&tv, NULL);
+ utmp.ut_tv.tv_sec = tv.tv_sec;
+ utmp.ut_tv.tv_usec = tv.tv_usec;
+
+ setutxent();
+ pututxline(&utmp);
+
+ strcpy(utmp.ut_id, "1");
+ utmp.ut_pid = 1;
+ pututxline(&utmp);
+
+ endutxent();
+
+ job_process_handler (NULL, 1, NIH_CHILD_EXITED, 0);
+
+ setutxent();
+
+ utmptr = getutxent();
+ TEST_NE_P(utmptr, NULL);
+ TEST_EQ(utmptr->ut_pid, 2);
+ TEST_EQ(utmptr->ut_type, USER_PROCESS);
+
+ utmptr = getutxent();
+ TEST_NE_P(utmptr, NULL);
+ TEST_EQ(utmptr->ut_pid, 1);
+ TEST_EQ(utmptr->ut_type, DEAD_PROCESS);
+
+ nih_free (job);
+ }
+}
+
+
int
main (int argc,
char *argv[])
@@ -4532,6 +4699,7 @@ main (int argc,
test_spawn ();
test_kill ();
test_handler ();
+ test_utmp ();
test_find ();
/* Update existing utmp file. */
pututxline(utmptr);

4
upstart.sh Normal file
View file

@ -0,0 +1,4 @@
# check if upstart is running
if /lib/upstart/initctl list > /dev/null 2> /dev/null; then
export PATH=/lib/upstart:$PATH
fi

View file

@ -1,64 +1,56 @@
%define initscripts 20101206
%define initscripts 20110502
Name: upstart
Version: 0.6.7
Release: 2%{?dist}
Version: 1.2
Release: 4%{?dist}
Summary: An event-driven init system
Group: System Environment/Base
License: GPLv2 and LGPLv2+
URL: http://upstart.ubuntu.com
Source0: http://upstart.ubuntu.com/download/0.6/upstart-%{version}.tar.gz
URL: https://launchpad.net/upstart
Source0: http://launchpad.net/upstart/1.x/%{version}/+download/upstart-%{version}.tar.gz
Source1: init-system-dbus.conf
# These are taken from http://git.fedorahosted.org/git/?p=initscripts.git
Source2: initjobs-%{initscripts}.tar.gz
Source2: initjobs-%{initscripts}.tar.gz
# create missing files and directories according to /etc/tmpfiles.d/
Source3: tmpfiles.conf
# fix selinux context on /run created and mounted by dracut
Source4: fix-selinux-on-run.conf
# add /lib/upstart to shell PATH if upstart is running
Source5: upstart.sh
Source6: init.conf
Patch1: upstart-telinit.patch
Patch2: upstart-audit-events.patch
# set DEAD_PROCESS for dead process with pid in utmp table (#572199, #632568)
Patch3: upstart-utmp.patch
Patch4: upstart-reexec.patch
# shutdown exits with nonzero exitcode when fails
Patch5: upstart-shutdown-exitcode.patch
# send close fd command to shell first (#646894)
Patch6: upstart-close-fd.patch
# allow job override files
Patch7: upstart-override.patch
# add /lib/upstart to default PATH set by init process
Patch10: upstart-lib-upstart.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: autoconf, automake, gettext, audit-libs-devel, expat-devel
BuildRequires: dbus-devel >= 1:1.2.16, libnih-devel >= 1.0.1
Conflicts: initscripts < 9.12
Conflicts: initscripts < 9.12
Requires: sysvinit-userspace /etc/rc.d/rc.sysinit
Obsoletes: upstart-sysvinit
%description
Upstart is an event-based 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.
%package sysvinit
Group: System Environment/Base
Summary: Upstart System V init tools
Requires: %{name} = %{version}-%{release}
Obsoletes: SysVinit < 2.86-24, sysvinit < 2.86-24
Provides: SysVinit = 2.86-24, sysvinit = 2.86-24
Provides: sysvinit-userspace
Conflicts: systemd-sysvinit
%description sysvinit
Drop-in replacement for the System V init tools, provided by Upstart.
%prep
%setup -q -a 2
%patch1 -p1 -b .u
%patch2 -p1 -b .audit
%patch3 -p1 -b .utmp
%patch4 -p1 -b .reexec
%patch5 -p1 -b .exitcode
%patch6 -p1 -b .closefd
%patch7 -p1 -b .override
%patch10 -p1 -b .lib-upstart
%build
autoreconf
%configure --sbindir=/sbin --libdir=/%{_lib}
%configure --sbindir=/lib/upstart --libdir=/%{_lib}
make %{?_smp_mflags}
%install
@ -69,26 +61,16 @@ make install DESTDIR=%{buildroot}
# installation with systemd. We move the utility binaries into a
# subdirectory, so that program_name stays the same and Upstart still
# can check argv[0] properly in various places.
mv %{buildroot}/sbin/init %{buildroot}/sbin/upstart
rm %{buildroot}/sbin/halt
rm %{buildroot}/sbin/poweroff
mkdir -p -m 755 %{buildroot}/lib/upstart
mv %{buildroot}/sbin/reboot %{buildroot}/lib/upstart/reboot
mv %{buildroot}/sbin/runlevel %{buildroot}/lib/upstart/runlevel
mv %{buildroot}/sbin/shutdown %{buildroot}/lib/upstart/shutdown
mv %{buildroot}/sbin/telinit %{buildroot}/lib/upstart/telinit
mkdir -p %{buildroot}/sbin/
ln -sf ../lib/upstart/init %{buildroot}/sbin/upstart
ln -sf ../lib/upstart/initctl %{buildroot}/sbin/initctl
ln -sf ../lib/upstart/start %{buildroot}/sbin/start
ln -sf ../lib/upstart/status %{buildroot}/sbin/status
ln -sf ../lib/upstart/stop %{buildroot}/sbin/stop
ln -sf ../lib/upstart/restart %{buildroot}/sbin/restart
ln -sf ../lib/upstart/reload %{buildroot}/sbin/reload
ln -sf reboot %{buildroot}/lib/upstart/poweroff
ln -sf reboot %{buildroot}/lib/upstart/halt
%if 0
# disabled due the conflicts with systemd
ln -sf upstart %{buildroot}/sbin/init
ln -sf ../lib/upstart/reboot %{buildroot}/sbin/halt
ln -sf ../lib/upstart/reboot %{buildroot}/sbin/poweroff
ln -sf ../lib/upstart/reboot %{buildroot}/sbin/reboot
ln -sf ../lib/upstart/runlevel %{buildroot}/sbin/runlevel
ln -sf ../lib/upstart/shutdown %{buildroot}/sbin/shutdown
ln -sf ../lib/upstart/telinit %{buildroot}/sbin/telinit
%endif
# Rename init.8.gz to upstart.7.gz (#644249)
mv %{buildroot}/%{_mandir}/man8/init.8 %{buildroot}/%{_mandir}/man7/upstart.7
# Remove these files due the conflicts with systemd
@ -98,10 +80,15 @@ rm -f %{buildroot}/%{_mandir}/man8/{halt,init,poweroff,reboot,runlevel,shutdown,
rm -f %{buildroot}/%{_sysconfdir}/init/*
install -m 644 %{SOURCE1} %{buildroot}/%{_sysconfdir}/init/
install -m 644 %{SOURCE3} %{buildroot}/%{_sysconfdir}/init/
install -m 644 %{SOURCE4} %{buildroot}/%{_sysconfdir}/init/
for file in initjobs-%{initscripts}/*.conf ; do
install -m 644 $file %{buildroot}/%{_sysconfdir}/init/
install -m 644 $file %{buildroot}/%{_sysconfdir}/init/
done
mkdir -p -m 755 %{buildroot}/%{_sysconfdir}/profile.d/
install -m 644 %{SOURCE5} %{buildroot}/%{_sysconfdir}/profile.d/
install -m 644 %{SOURCE6} %{buildroot}/%{_sysconfdir}/init.conf
%find_lang %{name}
@ -127,21 +114,30 @@ rm -rf %{buildroot}
%doc TODO
%doc HACKING
%{_sysconfdir}/init/
%config(noreplace) %{_sysconfdir}/init.conf
%config(noreplace) %{_sysconfdir}/dbus-1/system.d/Upstart.conf
%dir /lib/upstart
/lib/upstart/halt
/sbin/upstart
/sbin/initctl
/lib/upstart/poweroff
/lib/upstart/reboot
/lib/upstart/runlevel
/lib/upstart/shutdown
/sbin/start
/sbin/status
/sbin/stop
/sbin/restart
/lib/upstart/telinit
/sbin/reload
%dir /lib/upstart
/lib/upstart/init
/lib/upstart/initctl
/lib/upstart/poweroff
/lib/upstart/reboot
/lib/upstart/runlevel
/lib/upstart/shutdown
/lib/upstart/halt
/lib/upstart/start
/lib/upstart/status
/lib/upstart/stop
/lib/upstart/restart
/lib/upstart/telinit
/lib/upstart/reload
/etc/profile.d/upstart.sh
%{_mandir}/man5/init.5.gz
%{_mandir}/man5/inittab.5.gz
%{_mandir}/man7/control-alt-delete.7.gz
@ -161,27 +157,30 @@ rm -rf %{buildroot}
%{_mandir}/man8/stop.8.gz
%{_mandir}/man8/reload.8.gz
%if 0
# disabled due the conflicts with systemd
%files sysvinit
%defattr(-,root,root,-)
/sbin/halt
/sbin/init
/sbin/poweroff
/sbin/reboot
/sbin/runlevel
/sbin/shutdown
/sbin/telinit
%{_mandir}/man8/halt.8.gz
%{_mandir}/man8/init.8.gz
%{_mandir}/man8/poweroff.8.gz
%{_mandir}/man8/reboot.8.gz
%{_mandir}/man8/runlevel.8.gz
%{_mandir}/man8/shutdown.8.gz
%{_mandir}/man8/telinit.8.gz
%endif
%changelog
* Wed May 25 2011 Petr Lautrbach <plautrba@redhat.com> 1.2-4
- drop Obsoletes: upstart-sysvinit (#707507)
- clean upstart-sysvinit stuff from spec file
* Fri May 13 2011 Petr Lautrbach <plautrba@redhat.com> 1.2-3
- add /etc/init.conf file
* Wed May 04 2011 Petr Lautrbach <plautrba@redhat.com> 1.2-2
- /run - fix selinux context and check for tmpfiles.d
- physically move binaries to /lib/upstart
- add /lib/upstart to default PATH
* Wed Mar 23 2011 Petr Lautrbach <plautrba@redhat.com> 1.2-1
- upgrade to 1.2
- update upstream URL
* Mon Mar 21 2011 Petr Lautrbach <plautrba@redhat.com> 1.1-1
- upgrade to 1.1 - https://launchpad.net/upstart/1.x/1.1
- allow job override files
* Thu Mar 03 2011 Petr Lautrbach <plautrba@redhat.com> 1.0-1
- upgrade to 1.0 - https://launchpad.net/upstart/1.x/1.0
* Mon Feb 07 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.6.7-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild