History log of /haiku/src/servers/launch/LaunchDaemon.cpp
Revision Date Author Comments
# 699bc536 24-Jul-2023 PulkoMandy <pulkomandy@pulkomandy.tk>

Launch daemon: fix some unused variables

Used for tracing only, so mark them as unused when tracing is disabled.

Change-Id: I76acb0f18ccab12512eaa4b2644e9d57c591b9ef
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6740
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com>


# 7d2a6f2d 16-Feb-2022 Augustin Cavalier <waddlesplash@gmail.com>

launch_daemon: Rework how user-session spawning functions.

* Instead of fork()ing, which leaks memory (and runs a second
BApplication inside the Run() of the original one, which was
the source of a TODO), use posix_spawn to start a second process
altogether.

* Move session initialization code to the new user_main(), invoked
from main() if we are starting a user session.

* Send event registration messages to the new session daemon
in _HandleRegisterSessionDaemon, as the child no longer has access
to the old events list from before fork()ing and must receive it.

The last of these fixes a race: previously, if an event was registered
or triggered between when the child (user) launch_daemon was fork()ed off
the parent and when it registered with the root launch_daemon, those
events were "lost" and would never be forwarded to the child.

That happened not altogether infrequently for some people (myself
included) especially in virtual machines for the "initial_volumes_mounted"
event, which was the most common remaining cause of "boot hangs on rocket"
or "boots to blue screen with only mouse cursor" problems.

So, in addition to being cleaner overall and resolving a number of TODOs,
this also fixes #17365.

Change-Id: I1ea28cba8938a38b3c27685d7f3943f596cfe7ec
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4968
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>


# 7f4c5a1f 30-Sep-2021 Augustin Cavalier <waddlesplash@gmail.com>

launch_daemon: Do not return errors from RegisterExternalEvent.

We will pick up events that have no match later on, and if we return
an error here, it will prevent the job from being initialized, which
we definitely do not want.

Fixes #17291.


# ce308ddc 29-Sep-2021 Augustin Cavalier <waddlesplash@gmail.com>

launch_daemon: Trigger sticky-already-triggered external events immediately.

If the external event is sticky and already triggered, then we want
to trigger any newly-added events immediately. This fixes "boot hangs
on rocket" regressions following 4f126f690c17de00f44135f46acf0664ede61ab1,
which seems to have exacerbated this already-existing race condition.

Fixes #17289.

Change-Id: Ie405826cc50255895c8831c34b8bdf902e584eb5
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4510
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# b19b3d9b 28-Sep-2021 Augustin Cavalier <waddlesplash@gmail.com>

launch_daemon: Refactor handling of ExternalEventSources.

* Refactor ResolveExternalEvent to actually return the resolved event,
not just whether or not one was found, and then skip resolution
in TriggerExternalEvent and ResetStickyExternalEvent, which now
should only be passed ExternalEvents.

* ExternalEventSources now store destination Events, not Jobs,
following on that refactor.

* The second variant of ResolveExternalEvents is dropped,
and instead the Register/Unregister functions are implemented.

* Trigger and ResetSticky are now done in ExternalEventSource,
which now keeps track of whether it has been sticky-triggered
or not, though it does not use this information yet.

These changes should not affect behavior, they largely constitute
a reorganization (though some TODOs are resolved.)

Change-Id: I46a51cac0edb90e90b154ef9c94791cb7a1aad94
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4509
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 07497347 21-Dec-2019 Jérôme Duval <jerome.duval@gmail.com>

launch_daemon: don't relaunch when a shutdown is in progress

Change-Id: Ice0dd504f65f592eb64ec0e2192ef42b88486daa
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2043
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# a77aa747 25-Apr-2018 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Added basic logging facility

* The daemon now stores many events in am internal log.
* You can use "launch_roster log" to retrieve it.


# 6d7b8a30 04-Dec-2017 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Renamed TeamRegistrator to TeamListener


# e96835a9 27-Nov-2017 Axel Dörfler <axeld@pinc-software.de>

Added simple test_launch_daemon.

* Expects its config files in /boot/home/test_launch.
* Uses standard I/O, and is always in user mode.
* Also added test_launch_roster command that is able to talk to the test
server like it does to the real thing.


# bc600adb 07-Apr-2017 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Don't allow restarting.

* Check if the port already exists on startup. This fixes #12901.


# 852e09d6 29-Nov-2016 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Added stop target ability.

* Before, you had to stop each job by itself.


# 4d99bf9a 29-Nov-2016 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Added missing reply for launch target.

* Caused BLaunchRoster::Target() to return B_NO_REPLY instead of B_OK.


# 90fd6af0 12-Jan-2016 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Added ability to enable/disable a job.

* Instead of just starting/stopping it.
* Also available via the launch_roster command.


# 59e6d9d2 27-Nov-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Maintain pending jobs for requirements.

* If a requirement cannot be launched, a job is now added to the
requirement as pending job.
* If the requirement enters the launch queue at a later time, the
pending job will be put there, too.


# 236e68ef 27-Nov-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Check requirements before launching a job.

* They were only launched, but we didn't check if we can actually
launch them.


# 70708ef9 10-Nov-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Retrieve default port from monitoring BRoster.

* Instead, we now maintain a default port for a job. For "legacy"
services, BRoster's B_SOME_APP_LAUNCHED will update it, too.
* This allows to quit Tracker using "launch_roster stop".
* Also, this fixes bug #12249, as we don't use the signature variant of
creating BMessenger anymore in Job::GetMessenger(). This would call
into the launch_daemon again, and deadlock.


# b0ecbc13 07-Nov-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Refactored some message handlers, more info.

* The info getters will now add a lot more info.


# 5860caae 07-Nov-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Added basic ability to stop/start jobs via API.

* Stopping a job is very simplistic right now, and will have to be
extended considerably, probably with its own job.


# e2f83cbd 06-Nov-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Monitor teams, and restart services.

* Services that end are now automatically restarted.
* However, this is very basic at the moment, there is no throttling,
and no support for shutting down the system.


# 3282b758 04-Nov-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Add API to get information on jobs.

* Ie. a listing of all targets/jobs, as well as specific (basic) info
on each.
* Also added a bit of optional debug output.
* Moved translating the path to launch time -- we should take the job's
environment into account here at some point.


# 2e17b650 21-Oct-2015 Axel Dörfler <axeld@pinc-software.de>

BLaunchRoster::ResetStickyEvent() added.

* Used to unflag sticky events that already have been triggered once.


# d9bb9513 19-Oct-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: "file_exists" now resolves $HOME, and '~'.


# 4ae4b3ff 18-Oct-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Fixed the remaining "operation not allowed" bug.

* This was the harmless part: a job was been requeued that already was
being launched.
* I was already aware of this one, and only accidentally stumbled over
the non-harmless case in the JobQueue code when I tried to fix that
little issue... (ie. never ignore warnings, even if you think you
know what's going on).


# 7cd19b7e 17-Oct-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Implemented sticky events, and registration.

* Sticky events are events that keep their signal raised, ie. even if
a job is initialized afterwards, it will still be triggered.
* Consolidated naming for external events.
* Events are now registered once they are actually being used. This
allows them to allocate the resources they need to do their thing.


# e96f5c33 15-Oct-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Renamed RegisteredEvent to ExternalEventSource.

* With events being registered, this proved to be confusing, and it also
helps to differentiate between event objects within the daemon, and
events coming from external sources.


# e048384d 13-Oct-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: launching on demand now actually works.

* Was broken in two ways: if only the shortcut "on_demand" was used,
the event didn't get created at all due to a bug in
Events::AddOnDemand().
* Furthermore, _LaunchJob() always triggered a demand, but it should
only do this when not called from a target.


# 16844b92 11-Sep-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Open stdin/out/err FDs.

* As with the boot script, point them to /dev/null.
* This should fix #12298.


# 14156a33 26-Aug-2015 Michael Lotz <mmlr@mlotz.ch>

launch_daemon: Delegate launch data replies to Job.

Previously the LaunchDaemon would send out its own team id when a given
job was not yet launched, leading to invalid BMessengers once the port
owner changed to the actually launched team.

The launch of the target team and the launch data replies were also not
synchronized, which could lead to the launched team getting a reply
pointing to the launch_daemon when requesting data for itself. This is
the case for the BRoster init of the registrar. The fix in hrev49561
therefore didn't always work, because the registrar would sometimes get
the launch_daemon team id instead of the id of itself. It would later
try talking to the launch_daemon, which obviously never replied, leading
to #12237.

The LaunchDaemon now delegates the launch data reply to the Job instead.
The Job either replies directly, in case it has already been launched,
or queues the reply for when the launch completes. This causes launch
data requesters to block until the launch attempt is completed, but
won't block the LaunchDaemon message loop.

This commit introduces the seperate fLaunchStatus to properly handle the
ambiguity of fTeam being < 0, which is the case for both, when no launch
was attempted and when the launch failed. This new field now determines
what IsLaunched() returns and how launch data replies are handled.

The new launch status is additionally protected by the launch status
lock, which will later probably be made broader in scope to protect
against race conditions once service monitoring is implemented.


# 8074f0b9 22-Aug-2015 Michael Lotz <mmlr@mlotz.ch>

launch_daemon: Replace the remaining putenv() calls by setenv().


# 0a02f8c2 12-Aug-2015 Adrien Destugues <pulkomandy@gmail.com>

LaunchDaemon: use setenv to set HOME env variable.

* The API is saner: no need to build a string with var=value
* It is safer: putenv requires the string passed to it to stay
allocated, although most implementations (Haiku, Linux, BSD, OSX) do not
follow POSIX on this,
* Fix a problem reported in #12298 comments because the variable was set
with extra quotes (putenv does not escape them), leading to Qupzilla not
finding the home dir.


# 6306a263 30-Jul-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Set working directory to user's directory.

* This fixes #12257.


# 5e541a60 24-Jul-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Added /system/data/user_launch directory.

* This directory is for services that are launched per user (in a user
context), but installed globally.
* This is now used for the default "user" configuration; before this was
put into ~/config/non-packaged/data/launch, which didn't really fit,
and has the huge disadvantage that it cannot be updated.
* Fixes part of #12227.


# 2fb7433b 23-Jul-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Fixed Alexander's logic mixup.

* The warning in GCC 4 is just that, a warning. It doesn't mean
the previous version was wrong :-)


# 739e7bdb 22-Jul-2015 Alexander von Gluck IV <kallisti5@unixzen.com>

launch_daemon: Fix missing logic parentheses

* These are not superfluous on gcc4+ :-)


# 2ca4f3f8 17-Jul-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Jobs were started before their target.

* A job must not be launched when its target hasn't been launched
yet. This fixes Tracker launching when the mount_server scanned
the initial disk, even though the FirstBootPrompt was showing.
* Jobs are no longer initialized when their target has not been launched
yet. This also means that you cannot talk to a service beforehand in
this case.
* Slight refactoring and clarifying, even added some documentation :-)
* _TriggerJob() is now called _LaunchJob(), and does all the checks for
jobs that _LaunchJobs() does now for targets.


# d94e9c97 16-Jul-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Added support for external events.

* Other apps can register events, and the launch_daemon can act on them
when they are triggered.


# 2c756e16 16-Jul-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Fixed job event trigger.

* Always check for events before launching a job unconditionally.
* Correctly check for demand before launching a job.


# f2afa733 16-Jul-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Divided MessageReceived() into several methods.

* Was getting huge.


# 5b6c827e 14-Jul-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Outlined basic event mechanism.


# abb7b710 10-Jul-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Fixed a race condition in Worker startup.

* When the thread is started during the construction of the base
class, the virtual method table may still point to the methods
of the base class when the thread actually starts to run.
* This caused the main worker to have a timeout, which could
eventually be reached which in turn caused all job processing
to stop.
* That's what you get when you do Java all day; whoever designed
C++ should be slapped (I'm talking to you, Bjarne).


# 19a4ba10 08-Jul-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Now blocks the CD tray on read-only /boot.


# 634aefe4 08-Jul-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Now supports getting the env from a script.

* Scripts from targets are evaluated once on first target launch,
scripts from jobs are evaluated on each start.
* The "desktop" target now sources SetupEnvironment as usual.


# ea19a80e 06-Jul-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Added support for setting env.

* We cannot "source" files through a shell yet, though.


# 1281fcd3 01-Jul-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Improved job overwriting.

* Certain things are set on job construction only.
* Now checks if the message has the field before updating it.
* Might not be final yet (it is confusing that 'requires' will add to
the requirements, but 'launch' will replace all arguments).


# bd1c9bf3 01-Jul-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Set some HOME/LC_TYPE defaults.


# a3211522 01-Jul-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Fixed registering session daemon.

* Still used the old protocol.
* Minor cleanup.


# 79879070 26-Jun-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: We can now talk to the authentication manager.

* When creating the port of the registrar's authentication manager, we
now set it manually, so that the user/group functions work.
* This allows LaunchDaemon::_StartSession() to set up the user, and
groups as needed.


# 560119c9 25-Jun-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Don't verify passwords.

* Instead, the caller should have done this already. This is really
outside of the scope of the launch_daemon.
* Fixed Login with empty passwords; removed the (unused) test login
feature along the way.


# e0fc09b4 25-Jun-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Conditions now know if they are constant.

* This allows to remove a job in the init phase already, if its
condition is not only constant, but also failing.
* Also removed the special Job::LaunchInSafeMode() method; this is now
done using the conditions (the config option no_safemode remains,
though).


# 004cd670 24-Jun-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Added run directive.

* Allows to conditionally (or unconditionally) launch targets.
* Including tests for the settings parser.
* FirstBootPrompt is now launched when deemed necessary (as in
the Bootscript).


# 17ac467a 24-Jun-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Actually set the conditions.


# 1e9c9871 22-Jun-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Added basic support for conditions.

* Admittedly not very well thought out, but it should be good
enough for now; it doesn't really make sense to initialize jobs
that is never run due to failed conditions.
* Job, and Target now have a common base class BaseJob that deals
with the conditions.


# 68a3c0f9 18-Jun-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Moved settings parsing into its own file.


# e51a20af 17-Jun-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Fixed operator precedence bug.

* Found by GCC 4.


# 78e39852 17-Jun-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Use BRoster::Launch() without registrar.

* BRoster now allows settings a "no-registrar" mode that is currently
only honored in _LaunchApp(), though.
* Job::Launch() is now using this, which also allows launching
applications by signature (ie. if the job name matches the
signature, you can omit the "launch" option).


# 8b8780bf 15-Jun-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Moved Job+Target into separate files.


# c086a183 15-Jun-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Improved target support.

* You can now put jobs/services into a target.
* Instead of having Login started as part of the normal boot process,
it's now in the "login" target.
* The app_server now launches the login target when a login becomes
available (ie. during startup, but that could be improved later on).


# ac0a462f 10-Jun-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Basic user session implementation.

* Instead of launching Tracker/Deskbar directly, we now launch the
Login application.
* This will now start a new session for the selected user (the password
is currently ignored).
* When a user session is started, the launch_daemon forks, and the
child then restarts the LaunchDaemon application in user mode.
* It then registers itself with its parent, in order to resolve user
dependent services.
* Added a user launch file that will cause Tracker, and Deskbar to
start in the new session.


# 9cc27f73 02-Jun-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Merged Job with LaunchJob, cyclic dependencies.

* Job is now a BJob, and includes the former LaunchJob functionality.
* Dependencies are now resolved on init, and jobs are removed early
when they are not met (or are cyclic, which is now also detected).


# 0337b4ad 01-Jun-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Moved (Main)Worker to its own file.


# f913a087 31-May-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Added basic dependency support.

* Untested, and even incomplete, though.


# f4e75e7c 31-May-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: use BJobs for everything, multi-threaded worker.

* Implemented a multi-threaded job queue, that launches as many as CPU
count jobs at once -- due to SSDs, this number could possibly even be
made much larger, though.
* Launching a job now happens within that worker queues as a LaunchJob.
* Put all init jobs into an init target, and make the launch jobs depend
on it.


# c16361c4 18-May-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Initialize /tmp & /var/shared_memory, clock.

* Added initializing /tmp & /var/shared_memory to the launch_daemon.
* Moved clockconfig.cpp code into the launch_daemon.
* This follows systemd design; since those jobs are fixed, it doesn't
matter where you maintain them.
* The init jobs are BJobs, but the JobQueue is only used for that
one use for now. At a later time, I intend to put the job launching
in there, as well. BJob allows to represent the dependencies already.


# 43aec2c7 21-Apr-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: added support for arbitrary ports.

* Dropped "create_port" -- this is now the default for services.
* Additionally (or alternatively, if you use the "legacy" mode), you can
now create named ports, and specify their capacity.
* Added convenience methods to BLaunchRoster that automatically use the
signature of the current be_app.


# d482c7ca 15-Apr-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: actually launch the jobs.

* BRoster::Launch() cannot be used (yet), as it pre-registers the
application we're launching, and that won't work for the registrar or
anything else until the registrar is up and running.
* Renamed B_GET_LAUNCH_CONNECTIONS to B_GET_LAUNCH_DATA.
* Add the team ID to the get-launch-data reply.
* Added BLaunchRoster::GetPort() for convenience.
* Removed some superfluous debug output, but temporarily dump all stdio
to /dev/dprintf (ie. the syslog).
* Made job matching case insensitive (as MIME types should be).


# 1480e5da 02-Apr-2015 Axel Dörfler <axeld@pinc-software.de>

The beginnings of a launch_daemon for Haiku.

* This will be heavily inspired by Apple's launchd, as well as
systemd -- for now it really doesn't do a whole lot, though.
* What works so far: the configuration files are read, parsed, and
the jobs created.
* The jobs are even initialized, and their message ports created.
* BApplication now retrieves a previously created port from the
launch_daemon for use with BServer.
* Only the registrar actually uses this for now.


# 16844b92fc2f3f6cec988f0bb873c7a5da436fd0 11-Sep-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Open stdin/out/err FDs.

* As with the boot script, point them to /dev/null.
* This should fix #12298.


# 14156a33ac0233f4233546080d6b975618b331fa 26-Aug-2015 Michael Lotz <mmlr@mlotz.ch>

launch_daemon: Delegate launch data replies to Job.

Previously the LaunchDaemon would send out its own team id when a given
job was not yet launched, leading to invalid BMessengers once the port
owner changed to the actually launched team.

The launch of the target team and the launch data replies were also not
synchronized, which could lead to the launched team getting a reply
pointing to the launch_daemon when requesting data for itself. This is
the case for the BRoster init of the registrar. The fix in hrev49561
therefore didn't always work, because the registrar would sometimes get
the launch_daemon team id instead of the id of itself. It would later
try talking to the launch_daemon, which obviously never replied, leading
to #12237.

The LaunchDaemon now delegates the launch data reply to the Job instead.
The Job either replies directly, in case it has already been launched,
or queues the reply for when the launch completes. This causes launch
data requesters to block until the launch attempt is completed, but
won't block the LaunchDaemon message loop.

This commit introduces the seperate fLaunchStatus to properly handle the
ambiguity of fTeam being < 0, which is the case for both, when no launch
was attempted and when the launch failed. This new field now determines
what IsLaunched() returns and how launch data replies are handled.

The new launch status is additionally protected by the launch status
lock, which will later probably be made broader in scope to protect
against race conditions once service monitoring is implemented.


# 8074f0b94b25c8a255b4c5bdb579bd0e5d8c09f8 22-Aug-2015 Michael Lotz <mmlr@mlotz.ch>

launch_daemon: Replace the remaining putenv() calls by setenv().


# 0a02f8c287980b82a2ea49cdb28ea586d1667ccc 12-Aug-2015 Adrien Destugues <pulkomandy@gmail.com>

LaunchDaemon: use setenv to set HOME env variable.

* The API is saner: no need to build a string with var=value
* It is safer: putenv requires the string passed to it to stay
allocated, although most implementations (Haiku, Linux, BSD, OSX) do not
follow POSIX on this,
* Fix a problem reported in #12298 comments because the variable was set
with extra quotes (putenv does not escape them), leading to Qupzilla not
finding the home dir.


# 6306a2634bf096c2ebbe4a772538703350234d28 30-Jul-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Set working directory to user's directory.

* This fixes #12257.


# 5e541a6042c1eb93bf0518c0e404bc90aefdb382 24-Jul-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Added /system/data/user_launch directory.

* This directory is for services that are launched per user (in a user
context), but installed globally.
* This is now used for the default "user" configuration; before this was
put into ~/config/non-packaged/data/launch, which didn't really fit,
and has the huge disadvantage that it cannot be updated.
* Fixes part of #12227.


# 2fb7433b583d6b003336a46698f0be261f4bd475 23-Jul-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Fixed Alexander's logic mixup.

* The warning in GCC 4 is just that, a warning. It doesn't mean
the previous version was wrong :-)


# 739e7bdb661214969652d066af00e16b10d96ddb 22-Jul-2015 Alexander von Gluck IV <kallisti5@unixzen.com>

launch_daemon: Fix missing logic parentheses

* These are not superfluous on gcc4+ :-)


# 2ca4f3f81d28b528d479f95e29cf6f936e2c7dc7 17-Jul-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Jobs were started before their target.

* A job must not be launched when its target hasn't been launched
yet. This fixes Tracker launching when the mount_server scanned
the initial disk, even though the FirstBootPrompt was showing.
* Jobs are no longer initialized when their target has not been launched
yet. This also means that you cannot talk to a service beforehand in
this case.
* Slight refactoring and clarifying, even added some documentation :-)
* _TriggerJob() is now called _LaunchJob(), and does all the checks for
jobs that _LaunchJobs() does now for targets.


# d94e9c97d269f47313d5134d0d90a62dd9428dae 16-Jul-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Added support for external events.

* Other apps can register events, and the launch_daemon can act on them
when they are triggered.


# 2c756e16e0b34223176755f8cb38ebab0c4db89a 16-Jul-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Fixed job event trigger.

* Always check for events before launching a job unconditionally.
* Correctly check for demand before launching a job.


# f2afa73344247e8a5417524838e1da7c9e02324d 16-Jul-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Divided MessageReceived() into several methods.

* Was getting huge.


# 5b6c827e828a20bb9d7bb357bdcac799fa51d7df 14-Jul-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Outlined basic event mechanism.


# abb7b710044a2ac8c1b3d3266585f5e183d02c99 10-Jul-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Fixed a race condition in Worker startup.

* When the thread is started during the construction of the base
class, the virtual method table may still point to the methods
of the base class when the thread actually starts to run.
* This caused the main worker to have a timeout, which could
eventually be reached which in turn caused all job processing
to stop.
* That's what you get when you do Java all day; whoever designed
C++ should be slapped (I'm talking to you, Bjarne).


# 19a4ba101569d33ae87589fc07ccfe59a86be573 08-Jul-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Now blocks the CD tray on read-only /boot.


# 634aefe4fdaa245ad977dd7e8eff1744f380a02d 08-Jul-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Now supports getting the env from a script.

* Scripts from targets are evaluated once on first target launch,
scripts from jobs are evaluated on each start.
* The "desktop" target now sources SetupEnvironment as usual.


# ea19a80ed6ba3f34abb2e4d138ddc666580b8d82 06-Jul-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Added support for setting env.

* We cannot "source" files through a shell yet, though.


# 1281fcd3cbf8c621f4193344944c4833fa5ef8d3 01-Jul-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Improved job overwriting.

* Certain things are set on job construction only.
* Now checks if the message has the field before updating it.
* Might not be final yet (it is confusing that 'requires' will add to
the requirements, but 'launch' will replace all arguments).


# bd1c9bf338fdae8456577c557faf36aba7b87cd5 01-Jul-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Set some HOME/LC_TYPE defaults.


# a3211522d9b14eff7ef955dd642392b45694dc12 01-Jul-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Fixed registering session daemon.

* Still used the old protocol.
* Minor cleanup.


# 798790700871873f6d9da860567ff951005d7fbe 26-Jun-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: We can now talk to the authentication manager.

* When creating the port of the registrar's authentication manager, we
now set it manually, so that the user/group functions work.
* This allows LaunchDaemon::_StartSession() to set up the user, and
groups as needed.


# 560119c9a46601b0051520c3c77be5a0e8dd874a 25-Jun-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Don't verify passwords.

* Instead, the caller should have done this already. This is really
outside of the scope of the launch_daemon.
* Fixed Login with empty passwords; removed the (unused) test login
feature along the way.


# e0fc09b439b66df0e35c159d0b5b055cde7d2792 25-Jun-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Conditions now know if they are constant.

* This allows to remove a job in the init phase already, if its
condition is not only constant, but also failing.
* Also removed the special Job::LaunchInSafeMode() method; this is now
done using the conditions (the config option no_safemode remains,
though).


# 004cd6709d7b26a37f7a7c037bb48ec7d985d7cc 24-Jun-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Added run directive.

* Allows to conditionally (or unconditionally) launch targets.
* Including tests for the settings parser.
* FirstBootPrompt is now launched when deemed necessary (as in
the Bootscript).


# 17ac467a6eb1a40210768790a5dd735a2a30faf7 24-Jun-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Actually set the conditions.


# 1e9c98710286129c9161f29787742b1ea2bff449 22-Jun-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Added basic support for conditions.

* Admittedly not very well thought out, but it should be good
enough for now; it doesn't really make sense to initialize jobs
that is never run due to failed conditions.
* Job, and Target now have a common base class BaseJob that deals
with the conditions.


# 68a3c0f919a80a8d2a346462fe5f3b92b6f91aa9 18-Jun-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Moved settings parsing into its own file.


# e51a20af4f59f029df31fe7e82a167a6daa423f5 17-Jun-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Fixed operator precedence bug.

* Found by GCC 4.


# 78e39852fad37b7ce43c29d0f22c41405513c119 17-Jun-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Use BRoster::Launch() without registrar.

* BRoster now allows settings a "no-registrar" mode that is currently
only honored in _LaunchApp(), though.
* Job::Launch() is now using this, which also allows launching
applications by signature (ie. if the job name matches the
signature, you can omit the "launch" option).


# 8b8780bfe399a2a8058f4620e5f33f74db097ca2 15-Jun-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Moved Job+Target into separate files.


# c086a1834bb7041ca9f64abfee7a3b3bb9f06aa9 15-Jun-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Improved target support.

* You can now put jobs/services into a target.
* Instead of having Login started as part of the normal boot process,
it's now in the "login" target.
* The app_server now launches the login target when a login becomes
available (ie. during startup, but that could be improved later on).


# ac0a462fba6a1337e6659ebf0ffd69fd64030786 10-Jun-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Basic user session implementation.

* Instead of launching Tracker/Deskbar directly, we now launch the
Login application.
* This will now start a new session for the selected user (the password
is currently ignored).
* When a user session is started, the launch_daemon forks, and the
child then restarts the LaunchDaemon application in user mode.
* It then registers itself with its parent, in order to resolve user
dependent services.
* Added a user launch file that will cause Tracker, and Deskbar to
start in the new session.


# 9cc27f7369a16f598734e076a513143c901d7542 02-Jun-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Merged Job with LaunchJob, cyclic dependencies.

* Job is now a BJob, and includes the former LaunchJob functionality.
* Dependencies are now resolved on init, and jobs are removed early
when they are not met (or are cyclic, which is now also detected).


# 0337b4adfdc34e53370f6fe95b4c55db5f13fe53 01-Jun-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Moved (Main)Worker to its own file.


# f913a08780a3685898c776bab93289ac4a0c434c 31-May-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Added basic dependency support.

* Untested, and even incomplete, though.


# f4e75e7c3772adb0844a8e38f1ed22addd2c2def 31-May-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: use BJobs for everything, multi-threaded worker.

* Implemented a multi-threaded job queue, that launches as many as CPU
count jobs at once -- due to SSDs, this number could possibly even be
made much larger, though.
* Launching a job now happens within that worker queues as a LaunchJob.
* Put all init jobs into an init target, and make the launch jobs depend
on it.


# c16361c49ce8db183df0a9c7abea0b5f1bc30581 18-May-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: Initialize /tmp & /var/shared_memory, clock.

* Added initializing /tmp & /var/shared_memory to the launch_daemon.
* Moved clockconfig.cpp code into the launch_daemon.
* This follows systemd design; since those jobs are fixed, it doesn't
matter where you maintain them.
* The init jobs are BJobs, but the JobQueue is only used for that
one use for now. At a later time, I intend to put the job launching
in there, as well. BJob allows to represent the dependencies already.


# 43aec2c726cc9522f961f87771f1ea712d54c0b7 21-Apr-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: added support for arbitrary ports.

* Dropped "create_port" -- this is now the default for services.
* Additionally (or alternatively, if you use the "legacy" mode), you can
now create named ports, and specify their capacity.
* Added convenience methods to BLaunchRoster that automatically use the
signature of the current be_app.


# d482c7ca5ba4f9041dfd5db328bd9703ea57d2ae 15-Apr-2015 Axel Dörfler <axeld@pinc-software.de>

launch_daemon: actually launch the jobs.

* BRoster::Launch() cannot be used (yet), as it pre-registers the
application we're launching, and that won't work for the registrar or
anything else until the registrar is up and running.
* Renamed B_GET_LAUNCH_CONNECTIONS to B_GET_LAUNCH_DATA.
* Add the team ID to the get-launch-data reply.
* Added BLaunchRoster::GetPort() for convenience.
* Removed some superfluous debug output, but temporarily dump all stdio
to /dev/dprintf (ie. the syslog).
* Made job matching case insensitive (as MIME types should be).


# 1480e5da6fc4a2926c3da1a973e39927ac2171ae 02-Apr-2015 Axel Dörfler <axeld@pinc-software.de>

The beginnings of a launch_daemon for Haiku.

* This will be heavily inspired by Apple's launchd, as well as
systemd -- for now it really doesn't do a whole lot, though.
* What works so far: the configuration files are read, parsed, and
the jobs created.
* The jobs are even initialized, and their message ports created.
* BApplication now retrieves a previously created port from the
launch_daemon for use with BServer.
* Only the registrar actually uses this for now.