1162 Commits (4f57437ce1fc18c303710cd2e221c3e53fd8628e)
 

Author SHA1 Message Date
Bart Ribbers 4f57437ce1
Add pkgconfig file
Without it, -lapplauncherd is undefined and it can not be used to
compile other applications with it. I needed this to get
mapplauncherd-qt to compile
4 years ago
Raine Makelainen 51abc464b7 Bump version 4 years ago
Simo Piiroinen 402d9fde2f
Merge pull request #2 from sailfishos/jb53844_sandboxed_boosters
Sandboxed application boosters
4 years ago
Simo Piiroinen 833b551af1 [mapplauncerd] Sandboxed application boosters. JB#53844 OMP#JOLLA-43
When booster is executing in sandbox as an applicatiom booster, it
needs to verify that command line received from invoker matches
Exec line in application desktop file, application launch is allowed,
and permissions granted are as was expected at the time of booster
launch.

Provide booster-generic@.service that can be used for instantiating
sandboxed application boosters.

D-Bus ipc with sailjaild is modified version of similar code in
sailjailclient. The biggest difference is that this version uses
private connection via libdbus to avoid leaving stray dbus connections
or threads behind when transferring control to application code
without use of exec*() functions.

Remove cap_sys_ptrace from booster executable as makes it impossible
to run the booster within a no-new-privs sandbox.

Fix socket passing from booster instance to booster daemon so that it
works also when invoker is running in different namespace than booster
instance (invoker pid might be unresolvable).

Replace ad-hoc booster argument parsing with getopt_long().

Fix issues with argv handling: using const pointers for non-const
data, passing data by reference between objects that might have
different lifespans and never releasing the dynamically allocated
arrays.

Fix issues with env passing: duplicating invoker env at booster
side as-is can lead to problems like loss of customg session
bus socket address that has been set up by firejail.

If booster bumps into command read problems, bailout immediately
instead of relying on out-of sequence data possibly triggering
exit due to unknown commands.

As an enabler for sharing code between invoker (written in c) and
daemon (written in c++), modify Logger class used by c++ code so
that it is just a wrapper for logging functionality used by invoker.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jolla.com>
4 years ago
Simo Piiroinen f24871adb2 Revert "[launcherlib] Add checks for invoker"
This reverts commit 88bf4689e4.
4 years ago
Tomi Leppänen 254e3d1493 Merge branch 'cmake' into 'master'
Fix CMake issues

See merge request mer-core/mapplauncherd!17
5 years ago
Simo Piiroinen 15f235ff24 Version to 4.2.1
Signed-off-by: Simo Piiroinen <simo.piiroinen@jolla.com>
5 years ago
spiiroin 59ebf7cd70 Merge branch 'jb53845_peer_exit' into 'master'
Avoid using signals for peer termination

See merge request mer-core/mapplauncherd!32
5 years ago
Simo Piiroinen 1a3ec406de [mapplauncherd] Avoid using signals for peer termination. Fixes JB#53845 OMP#JOLLA-44
Invoker and booster instance make up a process pair that are meant to exit
at the same time. To arrange this a) when invoker is about to exit, it sends
a terminating signal to booster instance, and b) when booster instance
exits, booster daemon sends a terminating signal to invoker. Overall this
has worked well enough - save some hiccups from potential race conditions -
but it is not compatible with setup where invoker and booster daemon are
running in different namespaces and sending signals is not possible.

There is already an unix domain socket that is kept open for the lifetime of
boosted application - used for transferring application information from
invoker to booster daemon during startup and exit status from booster daemon
to invoker at exit time. This socket can be utilized also for detecting when
peer process exits.

Normally when application (booster instance) exits, booster daemon receives
SIGCHLD, collects application exit reason, forwards it to invoker via
booster socket, and invoker then makes exit with the same exit status as
what application used.

Augment this by having booster daemon watch over booster sockets and
terminate booster instance upon eof on socket. This accomplishes that
application gets killed if/when invoker dies.

Additionally all booster instances are terminated if booster daemon exits
due to SIGTERM.

In general, instead of simply closing booster socket at each end at exit
time, an orderly disconnect is done via: shutdown write end of the socket,
read data until eof is received, then close socket. If this is accomplished
successfully within reasonable time limit, there is no need to send signals
- both peers know that the other end is going to make an appropriate exit.

Previously booster daemon and invoker made an attempt to reproduce
application getting killed by some signal such as as SIGSEGV also at the
invoker side. As this produces false positive crash reports and complicates
things (some of the signals are terminal and can't be handled in
asynchronous manner) this is no longer done - only standard TERM and KILL
signals are used for terminating peers and even then it is done as a last
resort.

Invoker signal handler used non async signal safe functions, those
have been removed.

To ease ad-hoc debugging, logging is automatically switched from syslog to
stderr when booster/invoker is executed from interactive command line.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jolla.com>
5 years ago
Simo Piiroinen dbd90c880e Version to 4.2.0
Signed-off-by: Simo Piiroinen <simo.piiroinen@jolla.com>
5 years ago
spiiroin 1137a3ba4b Merge branch 'jb53864_socket_paths' into 'master'
Adjust booster socket paths

See merge request mer-core/mapplauncherd!31
5 years ago
Simo Piiroinen 23846d0db4 [mapplauncherd] Adjust booster socket paths. Fixes JB#53864 OMP#JOLLA-39
Having all booster sockets reside at the same level in /run/user
directory structure makes it difficult to limit what boosters
sandboxed applications have access to.

Move socket files to booster specific sub-directories. And as an enabler
for sandboxed boosters, add another sub-directory level that can be used
for identifying application specific boosters.

As an example, silica-qt booster socket file path changes from

  /run/user/UID/mapplauncherd/silica-qt5

to

  /run/user/UID/mapplauncherd/_default/silica-qt5/socket

and sandboxed silica-qt5 booster for application APP would use

  /run/user/UID/mapplauncherd/_APP/silica-qt5/socket

Signed-off-by: Simo Piiroinen <simo.piiroinen@jolla.com>
5 years ago
Simo Piiroinen 66db6e7063 [mapplauncherd] Cleanup compilation warnings
Comparing signed vs unsigned integers.

Unused static data.

Questionable variable declarations.

Const correctness issues.

Unchecked socket and pipe i/o.

Unchecked chdir() call.

String sender that silently skips null strings while protocol does
not make it possible for receiver to detect such omissions.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jolla.com>
5 years ago
Bart Ribbers 75aafafa6e
Respect GNUInstallDirs
This allows packagers to set the proper directories to install stuff
too using CMAKE_INSTALL_PREFIX, CMAKE_INSTALL_LIBDIR, etc.

Also make installing systemd unit files optional, for systemd without
systemd, but enable them by default
5 years ago
Bart Ribbers 87e8190d44
Make CMake respect current source dir when generating docs 5 years ago
Bart Ribbers be365526e7
Fix the install rules for executables 5 years ago
Bart Ribbers e5707b8f3f
Fix linking to systemd when elogind is used instead
This is mainly useful for non-glibc systems. Yes, systemd doesn't even run
on non-glibc systems, but elogind does and this way it links to both systemd
and elogind.

However due to switching the way we link to systemd, we now also make
sure systemd is actually installed on the system before we even try to
compile, thus preventing compiler errors when systemd isn't present.
5 years ago
Tomi Leppänen 9970c11190 Merge branch 'jb53620' into 'master'
Add checks for invoker, v2

See merge request mer-core/mapplauncherd!30
5 years ago
Tomi Leppänen 82acc16141 [mapplauncherd] Drop capabilities before launching process. Contributes to JB#53620
Signed-off-by: Tomi Leppänen <tomi.leppanen@jolla.com>
5 years ago
Tomi Leppänen 338e69d20f [mapplauncherd] Set CAP_SYS_PTRACE to allow reading /proc/pid/exe. Fixes JB#53620
All other boosters must be changed as well.

Signed-off-by: Tomi Leppänen <tomi.leppanen@jolla.com>
5 years ago
Tomi Leppänen 3cb9c45c41 [launcherlib] Add checks for invoker. Fixes JB#52956
Check that caller is from the same namespace as the booster and the
calling binary is /usr/bin/invoker.

Signed-off-by: Tomi Leppänen <tomi.leppanen@jolla.com>
5 years ago
Raine Makelainen 92d182de05 Merge branch 'jb53620' into 'master'
[launcherlib] Revert: Add checks for invoker. JB#53620

See merge request mer-core/mapplauncherd!29
5 years ago
Raine Makelainen 75c156112a [launcherlib] Revert: Add checks for invoker. JB#53620
This reverts commit 88bf4689e4.
5 years ago
Tomi Leppänen b7de66d551 Merge branch 'jb52956_plug_the_hole' into 'master'
[launcherlib] Add checks for invoker. Fixes JB#52956

See merge request mer-core/mapplauncherd!28
5 years ago
Tomi Leppänen 88bf4689e4 [launcherlib] Add checks for invoker. Fixes JB#52956
Check that caller is from the same namespace as the booster and the
calling binary is /usr/bin/invoker.

Signed-off-by: Tomi Leppänen <tomi.leppanen@jolla.com>
5 years ago
Tomi Leppänen 3c56c25256 Merge branch 'jb53097_simple_fix' into 'master'
[launcherlib] Correct single instance code for QML apps. Contributes to JB#53159

See merge request mer-core/mapplauncherd!27
5 years ago
Tomi Leppänen d2ee6f8617 [launcherlib] Correct single instance code for QML apps. Contributes to JB#53097
This makes sure that we retain the behaviour we had before for
non-sandboxed apps. This is done to ensure that locking uses appName()
when using for example QML based applications.

Signed-off-by: Tomi Leppänen <tomi.leppanen@jolla.com>
5 years ago
Tomi Leppänen 46a89c4705 Fix changelog date 5 years ago
pvuorela 4fd919ca0e Merge branch 'musl' into 'master'
Fix Musl incompabilities

See merge request mer-core/mapplauncherd!16
5 years ago
Bart Ribbers 6d31938929 Fix Musl incompabilities
Without including libgen.h, basename is not available on Musl.
sourceArgv[0] is a const char* which can not be converted to char*, so
cast it instead
RTLD_DEEPBIND is not available on Musl, only on glibc (since 2.3.4)
ARG_MAX is already defined so it has to be renamed
Even according to glibc itself, <bits/socket.h> should never be included
directly and <sys/socket.h> should, which is already done anyway
5 years ago
Tomi Leppänen c2324d1984 Merge branch 'jb52187_sandboxed_cgroups' into 'master'
[launcherlib] Set cgroups of sandboxed apps correctly. Fixes JB#52187

See merge request mer-core/mapplauncherd!25
5 years ago
Tomi Leppänen 26c5406e63 [launcherlib] Set cgroups of sandboxed apps correctly. Fixes JB#52187
Separate cgroups of sandboxed apps. Previously they were all put to the
same group with this change they are in separate groups.

Looking at invoker.c appName and fileName are the same and can be used
interchangeably.

Also change --desktop-file to have a bit more accurate description.

Signed-off-by: Tomi Leppänen <tomi.leppanen@jolla.com>
5 years ago
Tomi Leppänen 7091378e7d Merge branch 'jb52491_fix' into 'master'
[launcherlib] Use actual application name for sailjail'd apps. Fixes JB#52491

See merge request mer-core/mapplauncherd!24
5 years ago
Tomi Leppänen 5ae55df59e [launcherlib] Use actual application name for sailjail'd apps. Fixes JB#52491
Applications launched via sailjail have their appName set to
/usr/bin/sailjail and that is used to set single instance lock. That
results in not being able to launch multiple different applications
simultaneously via mapplauncher. Mitigate this by using actual
application name for single instance lock.

This implements a very simple way of deducing the application binary
path from sailjail's arguments. It works for most cases and the
remaining cases can be worked around.

Signed-off-by: Tomi Leppänen <tomi.leppanen@jolla.com>
5 years ago
Niels Breet 1b1d2c3798 Merge branch 'jb49681' into 'master'
[aarch64] Use macros, not hardcoded paths. Contributes to JB#49681

See merge request mer-core/mapplauncherd!21
6 years ago
Niels Breet e4cc3b8f79 [aarch64] Use macros, not hardcoded paths. Contributes to JB#49681 6 years ago
pvuorela 72f487f73a Merge branch 'master' into 'master'
[Packaging] Remove python2 requires

See merge request mer-core/mapplauncherd!20
6 years ago
Chupligin Sergey ef26653ca6 [Packaging] Remove python2 requires 6 years ago
Andrew Branson 3c78ac5d94 Merge branch 'jb49488' into 'master'
[priv] isPrivileged should return true if the file is listed with no privileges. JB#49488

See merge request mer-core/mapplauncherd!19
6 years ago
Andrew Branson e907e276f2 [priv] isPrivileged should return true if the file is listed with no privileges. JB#49488
Also remove leftover m_privileges member from Booster.
6 years ago
Andrew Branson 02bba3a3c6 Merge branch 'jb49488' into 'master'
[booster] Expose privilege values for use. JB#49488

See merge request mer-core/mapplauncherd!18
6 years ago
Andrew Branson a8dea6a958 [booster] Expose privilege values for use. JB#49488 6 years ago
Raine Makelainen 7e93b143a1 Merge branch 'jb49088' into 'master'
[booster] Always drop extra groups for non-privileged apps. Fixes JB#49088

See merge request mer-core/mapplauncherd!14
6 years ago
Igor Zhbanov 294cd4d37c [booster] Always drop extra groups for non-privileged apps. Fixes JB#49088
Don't trust to UID/GID received from untrusted invoker request when deciding
whether to drop extra groups for non-privileged apps. The application's
rights should depend only on the stated application's privileges and not
on the caller's process rights.

Drop setuid() because the boosters are launched under "nemo" user ID in
user session.

Signed-off-by: Igor Zhbanov <i.zhbanov@omprussia.ru>
6 years ago
Raine Makelainen f84e8e15e0 Bump version to 4.1.31 6 years ago
Raine Makelainen 16c9749dd6 Merge branch 'jb48847' into 'master'
[booster] Drop privileged SGID for non-privileged apps. Fixes JB#48847

See merge request mer-core/mapplauncherd!13
6 years ago
Igor Zhbanov b62ef0d2d4 [booster] Drop privileged SGID for non-privileged apps. Fixes JB#48847
Under Linux, setgid() is implemented like the POSIX version with the
_POSIX_SAVED_IDS feature. That means that after "setgid(nemo)" SGID
will be set to "privileged" instead of "nemo". So using "setresuid()"
instead.

Signed-off-by: Igor Zhbanov <i.zhbanov@omprussia.ru>
6 years ago
Andrew den Exter 6912348d5a Merge branch 'jb44214' into 'master'
[booster] Check for execute permissions before invoking a process. Fixes JB#44214

See merge request mer-core/mapplauncherd!12
7 years ago
Andrew den Exter a841302207 [booster] Check for execute permissions before invoking a process. Fixes JB#44214 7 years ago
Raine Makelainen db11a3a532 Merge branch 'jb42038' into 'master'
[mapplauncherd] Add booster cgroup mount service. Fixes MER#1916

See merge request mer-core/mapplauncherd!9
7 years ago