Skip to main content
Topic: tinydm service [SOLVED] (Read 948 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

tinydm service [SOLVED]

How can I make a tinydm service?
There is an openrc one only.
https://gitlab.com/postmarketOS/tinydm

Code: [Select]
#!/sbin/openrc-run
# Copyright 2020 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later
supervisor=supervise-daemon

name="tinydm"
description="tinydm"

command="/usr/bin/autologin"
command_args="tinydm-run-session"

depend() {
        provide display-manager
        need localmount
        want dbus elogind
}

start_pre() {
        # default to 1000 if none set in config
        [ -z "$AUTOLOGIN_UID" ] && AUTOLOGIN_UID=1000

        user=$(getent passwd ${AUTOLOGIN_UID} | cut -d: -f1)
        if [ -z "$user" ]; then
                eerror "ERROR: unable to find user with uid $AUTOLOGIN_UID"
                return 1
        fi

        command_args="$user $command_args"
}

I made this for dinit, in /etc/dinit.d/tinydm:
Code: [Select]
type            = process
command         = "/usr/bin/autologin tinydm-runsession"
smooth-recovery = true
logfile         = /var/log/dinit/tinydm.log
depends-on      = dbus logind
waits-for       = loginready
waits-for.d     = live.d
It is not working:
Code: [Select]
dinitctl start tinydm
dinitctl: failed to find service description.
dinitctl: check service description file exists / service name spelling.

I have autologin installed.


Re: tinydm service

Reply #1
My guess would be the following:

The dint service file: /etc/dinit.d/tinydm
Code: [Select]
type            = process
command         = /etc/dinit.d/scripts/tinydm
smooth-recovery = true
depends-on      = logind
waits-for       = loginready
waits-for.d     = live.d
The following starting script is based on sddm's dinit package.
Create a system user (a vacate <1000 entry) and group for tinydm daemon.
The starting script in /etc/dinit.d/scripts/tinydm.
Code: [Select]
#!/bin/sh
mkdir -p /var/lib/tinydm
mkdir -p /run/user/<tinydm user number>
chown -R tinydm:tinydm /var/lib/tinydm
chown -R tinydm:tinydm /run/user/<tinydm user number>
chmod 700 /run/user/<tinydm user number>
exec "/usr/bin/autologin tinydm-runsession"
Be sure to make the starting script executable.
Some tweaking most likely will be required and there is no guarantee that it will actually work.
Please see tinydm issue number 2.
Something about autologin being an issue that is not a bug in tinydm according to the developer.

Due to being an "interesting package" without an AUR listing I would think that no one else using "dinit" has ever heard of or even tried it out.

Re: tinydm service

Reply #2
Hi!

I think the problem is your `depends-on`. In Dinit syntax you need to use a new line for every depends. Example:
Code: [Select]
# Incorrect: depends-on = dbusd elogind
depends-on = dbusd
depends-on = elogind

Also `dinitcheck` is installed on artix to help you for debugging your service:
Code: [Select]
sudo dinitcheck tinydm

Regards

Re: tinydm service

Reply #3
The openrc service adds the username between the commands, after "autologin".
That is set in /etc/conf.d/tinydm.
Not sure to how add that to the dinit service, I se it manually.
No need to quote in exec.

In /etc/dinit.d/scripts/tinydm:
Code: [Select]
#!/bin/sh
mkdir -p /var/lib/tinydm
chown -R tinydm:tinydm /var/lib/tinydm
exec /usr/bin/autologin <user> tinydm-run-session

It seems that ~/.Xresources is ignored.

I packaged tinydm and tinydm-dinit.
Is there an example to how create the user/group for "chown -R tinydm:tinydm"?

I looked the sddm's dinit package for the script.

Re: tinydm service

Reply #4
Please see 5.2 Example adding a system user
Quote
Example adding a system user

System users can be used to run processes/daemons under a different user, protecting (e.g. with chown) files and/or directories and more examples of computer hardening.

With the following command a system user without shell access and without a home directory is created (optionally append the -U parameter to create a group with the same name as the user, and add the user to this group):
Code: [Select]
# useradd -r -s /usr/bin/nologin username
If the system user requires a specific user and group ID, specify them with the -u/--uid and -g/--gid options when creating the user:
Code: [Select]
# useradd -r -u 850* -g 850* -s /usr/bin/nologin tinydm
In this case the second example is the way to go. I edited the username to "tinydm".
(*) Check existing assigned numbers and elect a unused number which is not usually assign to common application daemons.
You can use any number you want that is free but usually system type daemon users are created with numbers below 1000.

One can also use one of GUI user and group desktop applications to create the user and group.
For daemons the shell should be "/usr/bin/nologin". One can edit the number as desired if required.


Re: tinydm service

Reply #6
The following line from the linked PKGBUILD:
Code: [Select]
install -m 644 ../lightdm.sysusers "${pkgdir}"/usr/lib/sysusers.d/lightdm.conf
Thus you would have to add a similar line to your new PKGBUILD's package section.
Code: [Select]
install -m 644 ../tinydm.sysusers "${pkgdir}"/usr/lib/sysusers.d/tinydm.conf
Note the path maybe different on your setup, adjust accordingly.

The actual "tinydm.sysusers" file would have to be created.

Re: tinydm service

Reply #7
Quote
~/.Xresources is ignored, it was not on lightdm.
Is this a tinydm bug?
Posting an issue on the project's code site is a good idea because it helps the devs gain knowledge of the issue and hopefully to create modifications to the project's code.
"Autologin" could be the source of the issue so you may want to check autologin's code site as well.

I am not sure if the lack of reading .Xresources when using Xorg is a bug or just a lack of feature which display manager applications should be able to do. It is "tiny" after all.

Re: tinydm service

Reply #8
I made the thing that make the tinydm user, thanks.

Is something like the openrc service doable on dinit?
Using something like "exec /usr/bin/autologin $user tinydm-runsession" on /etc/dinit.d/scripts/tinydm, to fetch the value set in the config.

I now found out that it is not supposed to load .Xresources.
I added it manually in the wrapper that I am using "xrdb -merge  "$HOME"/.Xresources".

Re: tinydm service

Reply #9
Based on the openrc stuff my best guess would be:
Code: [Select]
AUTOLOGIN_UID=1000
user=$(getent passwd ${AUTOLOGIN_UID} | cut -d: -f1)
I would place in the /etc/dinit.d/scripts/tinydm file at the beginning since it has to run before anything else.
This should be able to populate the user variable correctly.

The openrc configuration file showed AUTOLOGIN_UID as being a static variable.
The openrc script shows shows logic loop to ensure the configuration file information for the AUTOLOGIN_UID is able to be read.
Thus it seems to me that the simplest approach is to add the required static AUTOLOGIN_UID variable into the dinit script.
Since the AUTOLOGIN_UID variable is now defined inside the file, the step to check for a readable variable would be redundant.

Re: tinydm service

Reply #10
With this one you use the file in /etc, in case you want to use other init.
Code: [Select]
#!/bin/sh
source /etc/conf.d/tinydm
[ -z "$AUTOLOGIN_UID" ] && AUTOLOGIN_UID=1000
user=$(getent passwd ${AUTOLOGIN_UID} | cut -d: -f1)
if [ -z "$user" ]; then
eerror "ERROR: unable to find user with uid $AUTOLOGIN_UID"
return 1
fi
mkdir -p /var/lib/tinydm
chown -R tinydm:tinydm /var/lib/tinydm
exec /usr/bin/autologin $user tinydm-run-session