Package Details: systemd-guest-user 19.014ada1-1

Git Clone URL: https://aur.archlinux.org/systemd-guest-user.git (read-only)
Package Base: systemd-guest-user
Description: A simple systemd configurations for guest user support
Upstream URL: https://github.com/Akrai/systemd-guest-user
Keywords: guest systemd user
Licenses: GPL3
Submitter: pavelshuvalov
Maintainer: Akrai
Last Packager: Akrai
Votes: 3
Popularity: 0.169885
First Submitted: 2016-10-14 12:39
Last Updated: 2018-07-31 14:17

Required by (0)

Sources (1)

Pinned Comments

Akrai commented on 2018-08-01 14:49

Installing the package gets your system ready to use the guest user, which is basically a normal user with a tmpfs home folder (which gets erased after every reboot, not after a logout), but please notice two things:

  1. You probably want to add the guest user to some system groups you may consider in order to be able to use some resources of your computer, the same way as any other human user

  2. The script copies any file placed in the /usr/share/guest-configuration/ folder to the guest home after every reboot, intended mainly for copying config files you may consider useful to copy in every new guest session, for example if you need special graphical or network config files placed in order to get a properly working guest user. Any suggestion is welcomed

Latest Comments

1 2 3 Next › Last »

Akrai commented on 2018-08-01 14:49

Installing the package gets your system ready to use the guest user, which is basically a normal user with a tmpfs home folder (which gets erased after every reboot, not after a logout), but please notice two things:

  1. You probably want to add the guest user to some system groups you may consider in order to be able to use some resources of your computer, the same way as any other human user

  2. The script copies any file placed in the /usr/share/guest-configuration/ folder to the guest home after every reboot, intended mainly for copying config files you may consider useful to copy in every new guest session, for example if you need special graphical or network config files placed in order to get a properly working guest user. Any suggestion is welcomed

Akrai commented on 2018-07-31 14:28

All done, thanks for your contribution

azurata commented on 2018-07-31 14:15

Yes, it's not necessary rm -rf to remove de /home/guest mounting point, but just a precaution if the directory isn't empty.

I copy how it's done in the user creation. Only delete the user if the user exists. :)

Akrai commented on 2018-07-31 13:48

your approach is nice and clean, im not very sure about the need of rm -rf in the uninstall when the folder is mounted as tmpfs, but whatever, won't do any harm

i will write it

by the way, why write bash -c 'id guest >& /dev/null && userdel guest' in the uninstall when you could simply delete the user directly? bash -c 'userdel guest'

azurata commented on 2018-07-31 11:45

Yes, this would be better. I would use pre_install() to create the user before the install. Something like this:

pre_install() {
    /usr/sbin/bash -c 'id guest >& /dev/null || useradd -c Guest guest'
    /usr/sbin/usermod -d /home/guest/ guest >& /dev/null
    /usr/sbin/chsh -s /bin/sh guest >& /dev/null
    /usr/sbin/passwd -d guest >& /dev/null
}

post_install() {
    /usr/sbin/bash -c 'cp -a /usr/share/guest-configuration/. /home/guest'
    /usr/sbin/chown -R guest:users /home/guest
}

post_remove() {
    /usr/bin/pkill -9 -u guest >& /dev/null
    /usr/bin/sleep 1
    /usr/sbin/bash -c 'id guest >& /dev/null && userdel guest'
    /usr/bin/umount /home/guest >& /dev/null
    /usr/bin/rm -rf /home/guest
}

systemd-guest-user.service

[Unit]
DefaultDependencies=no
Before=systemd-tmpfiles-setup.service

RefuseManualStart=yes
RefuseManualStop=yes

[Service]
Type=oneshot
ExecStart=/usr/sbin/bash -c 'id guest >& /dev/null || useradd -c Guest guest'
ExecStart=/usr/sbin/usermod -d /home/guest/ guest
ExecStart=/usr/sbin/chsh -s /bin/sh guest
ExecStart=/usr/sbin/passwd -d guest
ExecStart=/usr/sbin/bash -c 'cp -a /usr/share/guest-configuration/. /home/guest'
ExecStart=/usr/sbin/chown -R guest:users /home/guest

home-guest.mount

[Unit]
Conflicts=umount.target
After=systemd-tmpfiles-setup.service
Before=umount.target

RefuseManualStart=yes
RefuseManualStop=yes

[Mount]
What=tmpfs
Type=tmpfs
Options=mode=0750,uid=guest,gid=users,strictatime,nosuid,nodev

Akrai commented on 2018-07-30 22:12

yeah i know it, i meant we could erase the sysusers.d config file and create the user using an execstart command

azurata commented on 2018-07-30 22:01

It is being created with sysusers.d as the package is now

u guest - - /home/guest


Because sysusers.d/guest.conf runs first, it will create the user guest before ExecStart=/usr/sbin/bash -c 'id guest >& /dev/null || useradd guest'

Akrai commented on 2018-07-30 21:52

https://www.freedesktop.org/software/systemd/man/sysusers.d.html no, it seems it is not the best idea to create the user using sysusers.d, maybe using an execstart in the service should do it safer, but i don't know enough bash to write it, it should be an easy if guest doesn't exist, create it

by the way, what does id guest >& /dev/null || useradd guest do then?

azurata commented on 2018-07-30 21:33

The guest user is not created with the command: ExecStart=/usr/sbin/bash -c 'id guest >& /dev/null || useradd guest'

It is created at sysusers.d/guest.conf

I don't know if it's safe or the best option, but adding a line to sysusers.d/guest.conf will solve this:

r - 1000-60000

u guest - Guest /home/guest

Akrai commented on 2018-07-30 16:53

i see, what do you suggest? the man page of useradd mentions an option to create a system account, but i can't find one for creating an user account