user_manager: Respect user umask and use less code
chmod(0o644) is no longer necessary after umask(0) removal in da4772c4e54467920d642e2a792c5d16d3b7bf33 ("tools: Remove umask 0")
as the default umask is 0o022, but if the umask is stricter (e.g.
0o027), then the user would expect the created files to be 0o640.
Creating the directory with the correct mode already also avoids
potential race conditions on systems with insufficient umask.
While at it, also use templating strings for .desktop file creation to
simplify the logic and split the template from the actual code a bit.
Alfred Neumayer [Tue, 29 Aug 2023 19:22:21 +0000 (21:22 +0200)]
container_manager: Keep schedtune cgroup around in case nesting is supported
Certain devices with Ubunutu Touch make use of the schedtune cgroup boosting mechanism,
allowing for better performance system-wide with very little tweaking.
Some devices have trouble using this cgroup in a regular GNU/Linux setting because
their kernels are not carrying the necessary kernel patch for enabling nesting. [1]
To please both those that want Waydroid to stop dropping their performance as well as
those having unpatched kernels, probe the capability to nest schedtune cgroups.
Jami Kettunen [Fri, 27 Jan 2023 12:34:27 +0000 (14:34 +0200)]
images: Cleanup Waydroid Updater zips after extracting
These will take up quite a bit of space over time in
~/.local/share/waydroid/data/lineageos_updates/ and should be cleaned up
during the update process.
It is used by WaydroidUpdater app for IHardware::upgrade
It defaults to /var/lib/waydroid/data but we are not bind mounting
xdg data over /var/lib/waydroid/data anymore
Jami Kettunen [Mon, 16 Jan 2023 13:08:45 +0000 (15:08 +0200)]
net: Don't fail start when already running
After 85843da (container: Make "waydroid-net.sh start" failure fatal)
this could result always failing to start unless you ran
"waydroid-net.sh stop" manually first; perhaps this should always be
stopped upon encountering errors?
Jami Kettunen [Sun, 15 Jan 2023 19:05:09 +0000 (21:05 +0200)]
container: Make "waydroid-net.sh start" failure fatal
Failing the network setup will in 99% of all cases cause the lxc-start
to fail due to the waydroid0 bridge not existing, so we might as well
fail fast instead of polluting the "waydroid log" and doing a futile
attempt at booting the LXC container.
Jami Kettunen [Tue, 3 Jan 2023 23:54:29 +0000 (01:54 +0200)]
lxc: Only add /dev/ashmem to config_nodes when it exists
This hasn't existed in mainline Linux kernels since v5.18 and trying to
always mount it regardless just adds to the noise in "waydroid log" in
most cases, so simply don't add it to config_nodes unless it actually
exists.
Silences the following:
lxc-start: waydroid: ../src/lxc/utils.c: safe_mount: 1221 No such file or directory - Failed to mount "/dev/ashmem" onto "/usr/lib/lxc/rootfs/dev/ashmem"
Enough with not checking we actually have a Wayland compositor around at
all: start requiring the WAYLAND_DISPLAY socket actually exists as an
absolute path or relatively under XDG_RUNTIME_DIR.
Additionally if WAYLAND_DISPLAY isn't an absolute path to the socket
(most setups) ensure XDG_RUNTIME_DIR is set and error with a typically
appropriate message.
This allows the user to make modifications to the images that may persist
between image upgrades.
For both the system and vendor image there's a set of two overlays.
One, specified in config as "overlay", is a read-only persistent overlay
meant for stuff like installing privileged apps that should persist.
Second one, specified as "overlay-rw", is a read-write overlay that
stores the changes made by the user in case they remount the mount point
in read-write mode. This one is meant to be removed when performing
image upgrade to not carry on potentially incompatible changes between
images.
We were implicitly using proc:mixed to mount /proc/sys as read-only.
Without the automount the whole /proc was mounted as read-write which
we want to avoid.
I'm unable to replicate the proc:mixed logic with lxc.mount.entry
so revert this change until a solution is found.
Jami Kettunen [Tue, 13 Dec 2022 19:29:40 +0000 (21:29 +0200)]
session: warn about unset WAYLAND_DISPLAY instead of XDG_SESSION_TYPE
XDG_SESSION_TYPE isn't a reliable check for Wayland being present (e.g.
on Ubuntu Touch currently XDG_SESSION_TYPE is "mir" with WAYLAND_DISPLAY
set to "wayland-0" as it also provides Wayland windowing.
Also mention the behavior of defaulting WAYLAND_DISPLAY to "wayland-0"
in case it's not set.
Jami Kettunen [Wed, 7 Dec 2022 20:40:42 +0000 (22:40 +0200)]
net: Fix vnic name selection for LXC <=2
The "default to waydroid0" was broken as awk never returned a non-zero
exit code if the file exists but no match was found. Also account for
the key being named lxc.network.link on older LXC versions so one still
has the ability to have a flexible Waydroid network configuration.