Proper sudoers user / session setup for xrdp and systemd-modules-load / auditd fails in a WSL2 openSUSE-Leap-15.2 environment - linux

I've managed it to successfully run xrdp in an openSUSE-Leap-15.2 WSL 2 Linux subsystem on my Windows 10 64 PC.
My Linux knowledge is not that great.
I use KDE (startplasma-x11) as desktop for xrdp.
On my first setup I had no systemd and only a dbus-daemon. As you know systemd and dbus are disabled / broken on WSL. Without systemd I had no issues with kdesu for e.g. yast2 in the KDE xrdp session. On the other hand, I couldn't use packages which require systemd to work properly.
My xrdp user is "marvin" as a default user group.
How ever I need openSUSE because I have an app which only run in suse well - not in Ubuntu.
So I started over again with this guide: Auto-start/services (systemd and snap support)
To get it working on leap 15.2 I did the following:
Downloaded & reinstalled dbus-1: dbus-1-1.12.2-lp152.5.27.x86_64.rpm
Yast install policykit-1
Grabbed daemonize-1.7.8-1-omv4000.x86_64.rpm and extracted bin daemonize to "/usr/sbin/"
Then I modified /usr/bin/bash and added also xrdp to autostart at the same time outside systemd:
#!/bin/bash
printf "\n"
echo "Starting init bash..."
# your WSL2 username
UNAME="marvin"
# fake run for dbus, just in case
if ! [ -d "/run/dbus" ]
then
mkdir /run/dbus
chmod 777 /run/dbus
fi
UUID=$(id -u "${UNAME}")
UGID=$(id -g "${UNAME}")
UHOME=$(getent passwd "${UNAME}" | cut -d: -f6)
USHELL=$(getent passwd "${UNAME}" | cut -d: -f7)
if [[ -p /dev/stdin || "${BASH_ARGC}" > 0 && "${BASH_ARGV[1]}" != "-c" ]]; then
USHELL=/bin/bash
fi
if [[ "${PWD}" = "/root" ]]; then
cd "${UHOME}"
fi
# get pid of systemd
SYSTEMD_PID=$(pgrep -xo systemd)
# if we're already in the systemd environment
if [[ "${SYSTEMD_PID}" -eq "1" ]]; then
exec "${USHELL}" "$#"
fi
# start systemd if not started
# wait for systemd to start
# add echo feedback and timeout to avoid infinite loop
sto=50 # 5 secs
if [[ "${SYSTEMD_PID}" = "" ]]; then
echo -e "Starting systemd PID ${SYSTEMD_PID} max timeout: $((sto/10))s"
/usr/sbin/daemonize -l "${HOME}/.systemd.lock" /usr/bin/unshare -fp --mount-proc /usr/lib/systemd/systemd --system-unit=basic.target
fi
while [[ "${SYSTEMD_PID}" = "" && $sto -gt 0 ]]; do
sleep 0.1
((sto--))
SYSTEMD_PID=$(pgrep -xo systemd)
done
if [ "$sto" -eq "0" ]; then
echo "Timeout while waiting for systemd PID. Exiting bash now...";
exit 1;
fi
printf "\n"
echo -e "Checking xrdp status..."
printf "\n"
if ! ps -C xrdp-sesman
then
sto=20
echo -e "Starting xrdp session manager... max timeout: $((sto/10))s"
[ -f /var/run/xrdp-sesman.pid ] && rm /var/run/xrdp-sesman.pid
xrdp-sesman
while ! ps -C xrdp-sesman > /dev/null && [ $sto -gt 0 ]; do
sleep 0.1
((sto--))
done
if [ "$sto" -eq "0" ]; then
echo "Timeout while waiting for xrdp-sesman PID.";
fi
fi
printf "\n"
if ! ps -C xrdp
then
sto=20
echo -e "Starting xrdp... max timeout: $((sto/10))s"
[ -f /var/run/xrdp.pid ] && rm /var/run/xrdp.pid
yes "" | openssl req -x509 -newkey rsa:2048 -nodes -keyout /etc/xrdp/key.pem -out /etc/xrdp/cert.pem -days 365 > /dev/null 2>&1
xrdp -f
while ! ps -C xrdp > /dev/null && [ $sto -gt 0 ]; do
sleep 0.1
((sto--))
done
if [ "$sto" -eq "0" ]; then
echo "Timeout while waiting for xrdp PID.";
fi
fi
printf "\n"
echo "Init bash done."
printf "\n"
# enter systemd namespace
exec /usr/bin/nsenter -t "${SYSTEMD_PID}" -m -p --wd="${PWD}" /usr/sbin/runuser -s "${USHELL}" "${UNAME}" -- "${#}"
After that I:
Installed some packages via yast like xorg, KDE patterns, yast2 patterns, and so on.
Successfully connected via rdp localhost:3390 Xorg session to KDE desktop from Windows with user "marvin".
So what's not working is yast2 kde su:
Where password is no typo for sure ;)
Permission denied
I've got no wheel user group so far. I don't know if I had one last time but I don't think so.
How ever, I followed this guide to create a wheel user:
id marvin
uid=1000(marvin) gid=100(users) groups=1000(wheel),100(users)
My /etc/sudoers
# Host_Alias WEBSERVERS = www1, www2, www3
# User_Alias ADMINS = millert, dowdy, mikef
# Cmnd_Alias PROCESSES = /usr/bin/nice, /bin/kill, /usr/bin/renice, \
# /usr/bin/pkill, /usr/bin/top
# Cmnd_Alias REBOOT = /sbin/halt, /sbin/reboot, /sbin/poweroff
Defaults always_set_home
## Path that will be used for every command run from sudo
Defaults secure_path="/usr/sbin:/usr/bin:/sbin:/bin"
Defaults env_reset
Defaults env_keep = "LANG LC_ADDRESS LC_CTYPE LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE LC_ATIME LC_ALL LANGUAGE LINGUAS XDG_SESSION_COOKIE"
#Defaults env_keep = "LANG LC_ADDRESS LC_CTYPE LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE LC_ATIME LC_ALL LANGUAGE LINGUAS XDG_SESSION_COOKIE"
## Do not insult users when they enter an incorrect password.
Defaults !insults
# Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# Defaults mail_badpass
# Defaults log_output
# Defaults!/usr/bin/sudoreplay !log_output
# Defaults!REBOOT !log_output
Defaults targetpw # ask for the password of the target user i.e. root
ALL ALL=(ALL) ALL # WARNING! Only use this together with 'Defaults targetpw'!
##
## Runas alias specification
##
##
## User privilege specification
##
root ALL=(ALL) ALL
## Uncomment to allow members of group wheel to execute any command
# %wheel ALL=(ALL) ALL
## Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL
## Read drop-in files from /etc/sudoers.d
## (the '#' here does not indicate a comment)
#includedir /etc/sudoers.d
And my /etc/sudoers.d/wheel-users
# allow members of group wheel to execute any command
%wheel ALL=(ALL) ALL
Well I'm out of my Linux knowledge at this point. I don't want to comment out things when I don't know if I break security rules if I do so. And also I don't know if the problem is caused by this. How ever adding wheel group didn't solve to problem. Maybe I missed something or did something wrong.?
I also noticed that some systemd services are not running and may affect this problem:
service -s
Output:
accounts-daemon.service loaded active running Accounts Service
auditd.service loaded failed failed Security Auditing Service
avahi-daemon.service loaded active running Avahi mDNS/DNS-SD Stack
colord.service loaded active running Manage, Install and Generate Color Profiles
cron.service loaded active running Command Scheduler
cups.service loaded active running CUPS Scheduler
dbus.service loaded active running D-Bus System Message Bus
detect-part-label-duplicates.service loaded active exited Detect if the system suffers from bsc#1089761
display-manager.service loaded failed failed X Display Manager
dracut-shutdown.service loaded active exited Restore /run/initramfs on shutdown
getty#tty1.service loaded active running Getty on tty1
irqbalance.service loaded active running irqbalance daemon
iscsi.service loaded active exited Login and scanning of iSCSI devices
kbdsettings.service loaded active exited Apply settings from /etc/sysconfig/keyboard
klog.service loaded active exited Early Kernel Boot Messages
lvm2-monitor.service loaded active exited Monitoring of LVM2 mirrors, snapshots etc. using dmeventd or progress polling
ModemManager.service loaded active running Modem Manager
nscd.service loaded active running Name Service Cache Daemon
polkit.service loaded active running Authorization Manager
postfix.service loaded active running Postfix Mail Transport Agent
rsyslog.service loaded active running System Logging Service
systemd-journal-flush.service loaded active exited Flush Journal to Persistent Storage
systemd-journald.service loaded active running Journal Service
systemd-logind.service loaded active running Login Service
systemd-modules-load.service loaded failed failed Load Kernel Modules
systemd-random-seed.service loaded active exited Load/Save Random Seed
systemd-remount-fs.service loaded active exited Remount Root and Kernel File Systems
systemd-sysctl.service loaded active exited Apply Kernel Variables
systemd-tmpfiles-setup-dev.service loaded active exited Create Static Device Nodes in /dev
systemd-tmpfiles-setup.service loaded active exited Create Volatile Files and Directories
systemd-udev-settle.service loaded active exited udev Wait for Complete Device Initialization
systemd-udev-trigger.service loaded active exited udev Coldplug all Devices
systemd-udevd.service loaded active running udev Kernel Device Manager
systemd-update-utmp.service loaded active exited Update UTMP about System Boot/Shutdown
systemd-user-sessions.service loaded active exited Permit User Sessions
udisks2.service loaded active running Disk Manager
upower.service loaded active running Daemon for power management
user-runtime-dir#0.service loaded active exited User Runtime Directory /run/user/0
user#0.service loaded active running User Manager for UID 0
wicked.service loaded active exited wicked managed network interfaces
wickedd-auto4.service loaded active running wicked AutoIPv4 supplicant service
wickedd-dhcp4.service loaded active running wicked DHCPv4 supplicant service
wickedd-dhcp6.service loaded active running wicked DHCPv6 supplicant service
wickedd-nanny.service loaded active running wicked network nanny service
wickedd.service loaded active running wicked network management service daemon
Where console outputs this relevant information:
auditctl -e1
Error - audit support not in kernel
Cannot open netlink audit socket
hostnamectl | grep Kernel
Kernel: Linux 4.19.128-microsoft-standard
systemctl -l status systemd-modules-load.service
● systemd-modules-load.service - Load Kernel Modules
Loaded: loaded (/usr/lib/systemd/system/systemd-modules-load.service; static; vendor preset: disabled)
Active: failed (Result: exit-code) since Thu 2020-11-26 13:57:11 CET; 12min ago
Docs: man:systemd-modules-load.service(8)
man:modules-load.d(5)
Process: 25 ExecStart=/usr/lib/systemd/systemd-modules-load (code=exited, status=1/FAILURE)
Main PID: 25 (code=exited, status=1/FAILURE)
Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.
Further /var/log:
audit.log is empty
xrdp-sesman.log running well somehow
[CORE ] waiting for window manager (pid 1304) to exit
[ERROR] bind_loopback(4, 3350) failed; IPv6 ::1 (errno=98), IPv4 127.0.0.1 (errno=22) and IPv6 ::FFFF:127.0.0.1 (errno=98).
[ERROR] Failed to start xrdp-sesman daemon, possibly address already in use.
[CORE ] window manager (pid 1304) did exit, cleaning up session
Warn looks crazy; I hope I can solve some of this errors sooner or later. I feel bad about this log since I never hacked all that in a way. ;/
systemd-modules-load[27]: Failed to lookup alias 'scsi_dh_alua': Function not implemented
systemd-modules-load[27]: Failed to lookup alias 'scsi_dh_emc': Function not implemented
systemd-modules-load[27]: Failed to lookup alias 'scsi_dh_rdac': Function not implemented
systemd-modules-load[27]: Failed to lookup alias 'dm-multipath': Function not implemented
systemd-modules-load[27]: Failed to lookup alias 'sg': Function not implemented
systemd-sysctl[52]: Failed to open file '/boot/sysctl.conf-4.19.128-microsoft-standard', ignoring: No such file or directory
systemd-udevd[83]: Could not generate persistent MAC address for dummy0: No such file or directory
systemd-udevd[68]: Could not generate persistent MAC address for bond0: No such file or directory
systemd[1]: Failed to start Security Auditing Service.
systemd[1]: auditd.service: Failed with result 'exit-code'.
kernel: [ 0.155516] MDS CPU bug present and SMT on, data leak possible. See https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/mds.html for more details.
kernel: [ 0.155516] TAA CPU bug present and SMT on, data leak possible. See https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/tsx_async_abort.html for more details.
kernel: [ 0.264873] PCI: Fatal: No config space access function found
kernel: [ 0.277895] PCI: System does not support PCI
kernel: [ 0.155516] #2 #3 #4 #5 #6 #7 #8 #9 #10 #11
kernel: [ 0.291373] kvm: no hardware support
kernel: [ 0.291374] kvm: no hardware support
kernel: [ 0.312696] hv_utils: cannot register PTP clock: 0
kernel: [ 0.312707] dxgk:err: dxg_drv_init Version: 1
kernel: [ 0.322371] Unstable clock detected, switching default tracing clock to "global"
kernel: [ 0.322371] If you want to keep using the local clock, then add:
kernel: [ 0.322371] "trace_clock=local"
kernel: [ 0.322371] on the kernel command line
kernel: [ 0.906590] FS-Cache: Duplicate cookie detected
kernel: [ 0.906592] FS-Cache: O-cookie c=00000000daf1a0fc [p=0000000032b95ae1 fl=222 nc=0 na=1]
kernel: [ 0.906592] FS-Cache: O-cookie d=00000000d9a94301 n=000000002cec00fb
kernel: [ 0.906593] FS-Cache: O-key=[10] '34323934393337333731'
kernel: [ 0.906594] FS-Cache: N-cookie c=0000000013092984 [p=0000000032b95ae1 fl=2 nc=0 na=1]
kernel: [ 0.906595] FS-Cache: N-cookie d=00000000d9a94301 n=00000000b63ed825
kernel: [ 0.906595] FS-Cache: N-key=[10] '34323934393337333731'
kernel: [ 0.908315] FS-Cache: Duplicate cookie detected
kernel: [ 0.908317] FS-Cache: O-cookie c=00000000daf1a0fc [p=0000000032b95ae1 fl=222 nc=0 na=1]
kernel: [ 0.908317] FS-Cache: O-cookie d=00000000d9a94301 n=000000002cec00fb
kernel: [ 0.908317] FS-Cache: O-key=[10] '34323934393337333731'
kernel: [ 0.908319] FS-Cache: N-cookie c=000000004100e019 [p=0000000032b95ae1 fl=2 nc=0 na=1]
kernel: [ 0.908319] FS-Cache: N-cookie d=00000000d9a94301 n=00000000074b6ae8
kernel: [ 0.908320] FS-Cache: N-key=[10] '34323934393337333731'
kernel: [ 0.910004] FS-Cache: Duplicate cookie detected
kernel: [ 0.910006] FS-Cache: O-cookie c=00000000daf1a0fc [p=0000000032b95ae1 fl=222 nc=0 na=1]
kernel: [ 0.910006] FS-Cache: O-cookie d=00000000d9a94301 n=000000002cec00fb
kernel: [ 0.910007] FS-Cache: O-key=[10] '34323934393337333731'
kernel: [ 0.910008] FS-Cache: N-cookie c=000000006fbd91eb [p=0000000032b95ae1 fl=2 nc=0 na=1]
kernel: [ 0.910009] FS-Cache: N-cookie d=00000000d9a94301 n=00000000ced73ef6
kernel: [ 0.910009] FS-Cache: N-key=[10] '34323934393337333731'
avahi-daemon[222]: Host name conflict, retrying with XXXX-XXXX-2
accounts-daemon[613]: g_dbus_interface_skeleton_get_object_path: assertion 'G_IS_DBUS_INTERFACE_SKELETON (interface_)' failed
startproc: startproc: exit status of parent of /usr/sbin/lightdm: 1
systemd[1]: Failed to start X Display Manager.
systemd[1]: display-manager.service: Failed with result 'exit-code'.
xrdp-sesman: pam_systemd(xrdp-sesman:session): Failed to connect to system bus: No such file or directory
kdeinit5[0]: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-marvin'
klauncher[0]: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-marvin'
klauncher[0]: message repeated 3 times: [ QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-marvin']
klauncher[0]: Connecting to deprecated signal QDBusConnectionInterface::serviceOwnerChanged(QString,QString,QString)
klauncher[0]: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-marvin'
kded5[0]: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-marvin'
kded5[0]: message repeated 3 times: [ QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-marvin']
kaccess[0]: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-marvin'
kded5[0]: QObject::connect: No such signal QDBusAbstractInterface::StateChanged(uint)
kglobalaccel5[0]: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-marvin'
kglobalaccel5[0]: message repeated 3 times: [ QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-marvin']
ksmserver[0]: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-marvin'
ksmserver[0]: message repeated 2 times: [ QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-marvin']
ksmserver[0]: Qt: Session management error: networkIdsList argument is NULL
ksmserver[0]: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-marvin'
kded5[0]: org.kde.bluez: Cannot open /dev/rfkill for reading!
baloo_file[0]: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-marvin'
xembedsniproxy[0]: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-marvin'
polkit-kde-authentication-agent-1[0]: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-marvin'
udisksd[692]: Can't load configuration file /etc/udisks2/udisks2.conf
kded5[0]: print-manager.kded: unable to register service to dbus
udisksd[692]: Error statting /swap/file: No such file or directory
plasmashell[0]: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-marvin'
polkit-kde-authentication-agent-1[0]: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-marvin'
plasmashell[0]: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-marvin'
kwin_x11[0]: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-marvin'
polkit-kde-authentication-agent-1[0]: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-marvin'
kded5[0]: org.kde.wacomtablet.common: d->name.isEmpty? true
plasmashell[0]: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-marvin'
kwin_x11[0]: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-marvin'
kded5[0]: kf5.kded: found kded module "colord" by prepending 'kded_' to the library path, please fix your metadata.
polkit-kde-authentication-agent-1[0]: "Cannot create unix session: No session for pid 925"
polkit-kde-authentication-agent-1[0]: "Cannot register authentication agent!"
polkit-kde-authentication-agent-1[0]: Couldn't register listener!
gmenudbusmenuproxy[0]: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-marvin'
kded5[0]: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-marvin'
kded5[0]: message repeated 2 times: [ QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-marvin']
kdeconnectd[0]: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-marvin'
kactivitymanagerd[0]: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-marvin'
kactivitymanagerd[0]: message repeated 2 times: [ QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-marvin']
kwin_x11[0]: kf5.kconfig.core: "\"fsrestore1\" - conversion of \"0,0,0,0\" to QRect failed"
drkonqi[0]: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-marvin'
kdeconnectd[0]: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-marvin'
kded5[0]: "/home/marvin/.local/share/icc/.." is not an ICC profile
kded5[0]: "/home/marvin/.local/share/icc/." is not an ICC profile
kdeconnectd[0]: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-marvin'
drkonqi[0]: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-marvin'
kded5[0]: Unable to get EDID for output "rdp0"
kded5[0]: Failed to register device: "failed to obtain org.freedesktop.color-manager.create-device auth"
kded5[0]: Failed to create ICC profile on cmsCreateRGBProfile
kscreen_backend_launcher[0]: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-marvin'
kded5[0]: "/home/marvin/.local/share/icc/.." is not an ICC profile
kded5[0]: "/home/marvin/.local/share/icc/." is not an ICC profile
kded5[0]: Unable to get EDID for output "rdp0"
vncmanager-controller[0]: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-marvin'
org_kde_powerdevil[0]: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-marvin'
baloo_file[0]: QDBusConnection: name 'org.freedesktop.UDisks2' had owner '' but we thought it was ':1.21'
drkonqi[0]: org.kde.drkonqi: Invalid pid specified
vncmanager-controller[0]: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-marvin'
org_kde_powerdevil[0]: powerdevil: No outputs have backlight property
org_kde_powerdevil[0]: powerdevil: Xrandr not supported, trying ddc, helper
backlighthelper[719]: powerdevil: no kernel backlight interface found
kded5[0]: Failed to register device: "failed to obtain org.freedesktop.color-manager.create-device auth"
....................................................................
kded5[0]: message repeated 2 times: [ QDBusAbstractAdaptor: Cannot relay signal KDEDModule::moduleDeleted(KDEDModule*): Pointers are not supported: KDEDModule*]
kdeconnectd[0]: The X11 connection broke (error 1). Did the X11 server die?
kscreen_backend_launcher[0]: The X11 connection broke (error 1). Did the X11 server die?
kglobalaccel5[0]: The X11 connection broke (error 1). Did the X11 server die?
kactivitymanagerd[0]: The X11 connection broke (error 1). Did the X11 server die?
kded5[0]: The X11 connection broke: I/O error (code 1)
I got also a lightdm.log indicating that my Linux starts a session without a reason.
It looks like I have messed up session system
Well if I would restart from beginning that same would happen again. So I want to go through it step by step.
Goals:
Get kdesu working with my user marvin would be nice for GUI and tracking other issus
Proper session / user setup for xrdp
So if you need additional infos I'll update the question. Even if I got better results.

The wsl2 needs to have absolute knowledge of linux. Otherwise you, I, have no chance to be successful.
So I stop this question because of: I have to learn more.

Related

Why is my Postgres database working for a while and then not able to "start server" once restarted?

Recently, I've started playing around with an old Raspberry Pi 3 b+, and I thought it would be good practice to host a Postgres database on my local network and use it for whatever I want to work through. I understand that running Postgres on a Raspberry Pi with 1GB of memory is not ideal and can take a toll on the SDcard, but I've updated the postgresql.conf file and specified that the data directory path is to utilize a 1TB SSD. Additionally, I've installed zram and log2ram to try and curb some of the overhead on SDcard.
Overview of tech I'm working with:
Raspberry Pi 3 B+
Postgres 12
Ubuntu server 20.04 (no gui, only working from terminal)
1TB SSD
Yesterday, I was writing to the Postgres db from a python notebook without any issue, but once I restarted the Raspberry Pi, I was unable to reach the db from DataGrip and would receive the following error from my terminal in Ubuntu:
psql: error: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
I checked the status of the postgres server and that seemed to be alright...:
● postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
Active: active (exited) since Thu 2021-01-28 13:34:41 UTC; 20min ago
Process: 1895 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
Main PID: 1895 (code=exited, status=0/SUCCESS)
Jan 28 13:34:41 ubuntu systemd[1]: Starting PostgreSQL RDBMS...
Jan 28 13:34:41 ubuntu systemd[1]: Finished PostgreSQL RDBMS.
This is what is provided in the postgresql-12-main.log:
2021-01-28 13:17:23.344 UTC [1889] LOG: starting PostgreSQL 12.5 (Ubuntu 12.5-0ubuntu0.20.04.1) on aarch64-unknown-linux-gnu, compiled by gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0, 64-bit
2021-01-28 13:17:23.362 UTC [1889] LOG: listening on IPv4 address "0.0.0.0", port 5432
2021-01-28 13:17:23.362 UTC [1889] LOG: listening on IPv6 address "::", port 5432
2021-01-28 13:17:23.365 UTC [1889] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2021-01-28 13:17:23.664 UTC [1899] LOG: database system was shut down at 2021-01-28 01:43:38 UTC
2021-01-28 13:17:24.619 UTC [1899] LOG: could not link file "pg_wal/xlogtemp.1899" to "pg_wal/000000010000000000000002": Operation not permitted
2021-01-28 13:17:24.670 UTC [1899] FATAL: could not open file "pg_wal/000000010000000000000002": No such file or directory
2021-01-28 13:17:24.685 UTC [1889] LOG: startup process (PID 1899) exited with exit code 1
2021-01-28 13:17:24.686 UTC [1889] LOG: aborting startup due to startup process failure
2021-01-28 13:17:24.708 UTC [1889] LOG: database system is shut down
pg_ctl: could not start server
Examine the log output.
Please let me know if you have any questions or if you would like for me to include any additional information. I appreciate any pointers you may have for head ahead of time.
This is what the /etc/init.d/postgres file looks like:::
#!/bin/sh
set -e
### BEGIN INIT INFO
# Provides: postgresql
# Required-Start: $local_fs $remote_fs $network $time
# Required-Stop: $local_fs $remote_fs $network $time
# Should-Start: $syslog
# Should-Stop: $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: PostgreSQL RDBMS server
### END INIT INFO
# Setting environment variables for the postmaster here does not work; please
# set them in /etc/postgresql/<version>/<cluster>/environment instead.
[ -r /usr/share/postgresql-common/init.d-functions ] || exit 0
. /usr/share/postgresql-common/init.d-functions
# versions can be specified explicitly
if [ -n "$2" ]; then
versions="$2 $3 $4 $5 $6 $7 $8 $9"
else
get_versions
fi
case "$1" in
start|stop|restart|reload)
if [ "$1" = "start" ]; then
create_socket_directory
fi
if [ -z "`pg_lsclusters -h`" ]; then
log_warning_msg 'No PostgreSQL clusters exist; see "man pg_createcluster"'
exit 0
fi
for v in $versions; do
$1 $v || EXIT=$?
done
exit ${EXIT:-0}
;;
status)
LS=`pg_lsclusters -h`
# no clusters -> unknown status
[ -n "$LS" ] || exit 4
echo "$LS" | awk 'BEGIN {rc=0} {if (match($4, "down")) rc=3; printf ("%s/%s (port %s): %s\n", $1, $2, $3, $4)}; END {exit rc}'
;;
force-reload)
for v in $versions; do
reload $v
done
;;
*)
echo "Usage: $0 {start|stop|restart|reload|force-reload|status} [version ..]"
exit 1
;;
esac
exit 0
config file (partly):
#------------------------------------------------------------------------------
# FILE LOCATIONS
#------------------------------------------------------------------------------
# The default values of these variables are driven from the -D command-line
# option or PGDATA environment variable, represented here as ConfigDir.
#data_directory = 'ConfigDir' # use data in another directory
# (change requires restart)
#hba_file = 'ConfigDir/pg_hba.conf' # host-based authentication file
# (change requires restart)
#ident_file = 'ConfigDir/pg_ident.conf' # ident configuration file
# (change requires restart)
# If external_pid_file is not explicitly set, no extra PID file is written.
#external_pid_file = '' # write an extra PID file
# (change requires restart)
/etc/init.d/postgresql (partly):
NOTE: this is from a non-standard installation. YMMV
# Data directory
#PGDATA="/data/db/postgres"
#PGDATA="/data/db/postgres/pgdata"
#PGDATA="/data/db/postgres-12/pgdata"
PGDATA="/data/db/postgres-11/pgdata"
(when upgrading, I tend to keep the commented-out older setting for reference)
Note: the config-file is not edited, every path refers to the ConfigDir (by default)
Additionally, for Postgres on a Pi, I set:
random_page_cost = 1.1
shared_buffers = 128MB
#work_mem = 4MB # keep the low default
effective_cache_size = 3GB # This is for a RaspberryPi-4
# for a Pi-3, I'd use ~700M
Okay, I think I've figured it out. Might be overkill but it works:
First thing I did was format and mount my 1TB SSD. Here is a good video for a walkthrough for formatting to ext4 and mounting. The difference between the video is that I've updated the fstab file to check my SSD during bootup or "0 2" at the end of the SSD mount options instead of "0 0".
Secondly, I installed Postgres. Here is a good walkthrough for that. The directions provided in that blog were more than I needed, but a good walkthrough nonetheless. I simply installed Postgres with:
sudo apt install postgresql postgresql-contrib
Third, I followed this walkthrough until the end of step two, but before beginning step 2, I added a symbolic link from /var/lib/postgresql/12/main to /YOUR/MOUNT/POSITION/postgresql/12/main by executing:
ln -s /var/lib/postgresql/12/main /YOUR/MOUNT/POSITION/postgresql/12/main
Lastly, before restarting the postgres server, I used this website to help me better configure my server. Enter your specs and it should give you some useful configuration settings.
If I remember anything I've left out I'll try and come back and edit this post. Otherwise comment if anything doesn't make sense or is unclear.

How to disable serial console during bootup

I have stopped ttyS0 (initctl stop serial DEV=ttyS0). The ttyS0 process stops for the session but reappears post to reboot, I want to disable ttyS0 at boot as it throws errors like:
Feb 19 20:19:42 sdm2 init: serial (ttyS0) main process (608881) terminated with status 1
Feb 19 20:19:42 sdm2 init: serial (ttyS0) main process ended, respawning
Feb 19 20:19:42 sdm2 init: initLogger main process (608986) terminated with status 1
I couldnt find any /etc/init/ttyS0.conf but serial.conf exists.
I searched for 'respawn' in an attempt to turn it OFF, but I found 'respawn' in serial.conf.
instance $DEV
respawn
pre-start exec /sbin/securetty $DEV
./init/serial.conf-33-exec /sbin/agetty /dev/$DEV $SPEED vt100-nav
Though /etc/ttyS0.conf doesnt exists,but I used 'echo manual | sudo tee /etc/init/ttyS0.override' to stop the ttyS0 at boot time.
-Also I removed ttyS0 from securetty.
-There is no mention of ttyS0 in inittab file.
-In grub.conf I have two console entries tty0 and console=ttyS0,115200 as well.
-/dev/ttyS0 exists but /etc/init/ttyS0.conf does nt.
Could anyone assist in stopping ttyS0 after reboot.

Dnsmasq fails to start every time I reboot my VPS

Dnsmasq fails to start every time I reboot my VPS. Below is the log about it.
Aug 22 18:14:51 debian dnsmasq[776]: dnsmasq: syntax check OK.
Aug 22 18:14:51 debian dnsmasq[798]: chown: invalid user: ‘dnsmasq:nogroup’
Aug 22 18:14:51 debian systemd[1]: dnsmasq.service: Control process exited, code=exited status=2
Aug 22 18:14:51 debian systemd[1]: Failed to start dnsmasq - A lightweight DHCP and caching DNS server.
Aug 22 18:14:51 debian systemd[1]: dnsmasq.service: Unit entered failed state.
Aug 22 18:14:51 debian systemd[1]: dnsmasq.service: Failed with result 'exit-code'.
I'd set the user and group name correctly in /etc/dnsmasq.conf file. I tried to reinstall dnsmasq and then it worked. But after I reboot the VPS, it failed to start again. Then I have to reinstall again...
So, If I want to use dnsmasq, I have to not to reboot my VPS. But I want to know what causes this and how to fix it once and for all. My VPS's system is Debian 9, kernel is 4.9.0-7-amd64.
Finally, I've found the trouble and fixed it. As the system informed, chown: invalid user: ‘dnsmasq:nogroup’ is the bad code. I thought it should be dnsmasq failed to automatically add user or group that caused the error.
One solution might be manually adding a user named "dnsmasq". I didn't try it but I thought it would work. Another handling way is to looked up user "dnsmasq" in relative files and replace user "dnsmasq" with an existing user like "nobody".
There are 3 places in the /etc/init.d/dnsmasq file that need replace.
if [ ! "$DNSMASQ_USER" ]; then
DNSMASQ_USER="*dnsmasq*"
fi
# /run may be volatile, so we need to ensure that
# /run/dnsmasq exists here as well as in postinst
if [ ! -d /run/dnsmasq ]; then
mkdir /run/dnsmasq || return 2
chown *dnsmasq*:nogroup /run/dnsmasq || return 2
fi
# /run may be volatile, so we need to ensure that
# /run/dnsmasq exists here as well as in postinst
if [ ! -d /run/dnsmasq ]; then
mkdir /run/dnsmasq || return 2
chown *dnsmasq*:nogroup /run/dnsmasq || return 2
fi
Replace 3 empasized places above.
Although I'm not sure why dnsmasq failed to access account files.

Could not connect to wpa_supplicant: wlan0 - re-trying

I work on embedded device and I am configuring the WLAN module (QCA6174 - ath10k driver) with wpa_supplicant.
I load the driver modules (backports-20151120):
insmod /lib/modules/3.10.65-b2196-h301/wlan/compat.ko;
insmod lib/modules/3.10.65-b2196-h301/wlan/cfg80211.ko;
insmod /lib/modules/3.10.65-b2196-h301/wlan/mac80211.ko;
insmod /lib/modules/3.10.65-b2196-h301/wlan/ath.ko;
insmod /lib/modules/3.10.65-b2196-h301/wlan/ath10k_core.ko skip_otp=y;
insmod /lib/modules/3.10.65-b2196-h301/wlan/ath10k_pci.ko
I start the wpa_supplicant (default wpa_supplicant.conf):
wpa_supplicant -dd -Dwext -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf -B
[ 182.257304] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
everything seems to work fine. I see the wlan0 interface,I can scan with iwlist, /var/run/wpa_supplicant/wlan0 exist.
But I can not use wpa_cli interface:
#wpa_cli
wpa_cli v2.4
Copyright (c) 2004-2015, Jouni Malinen <j#w1.fi> and contributors
Selected interface 'wlan0'
Interactive mode
Could not connect to wpa_supplicant: wlan0 - re-trying
Do you have any hints how can I track down the problem ?
After issuing
strace wpa_cli -i wlan0
the problem with /tmp folder was reported:
bind(3, {sa_family=AF_FILE, path="/tmp/wpa_ctrl_1095-5"}, 110) = -1 EROFS (Read-only file system)
After mounting tmpfs:
mount -t tmpfs -o size=12m tmpfs /tmp/
everything works fine.
I solved this by running sudo wpa_cli -i wlan0 in response to the "Read-only file system" permissions error.
In contrast to the accepted answer, this does not carry the side-effect of altering the permissions of the directory mounted at /tmp/.
Thank you #BartlomiejGrzeskowiak. I did not know about strace.

Busybox SUID on NFS rootfs

I am building a Linux system from the bottom for a Beagle Bone board. I have compiled the vanilla kernel and built a basic root file system with busybox. The system is booted with U-boot, while the rootfs is located on a Linux PC and exported through NFS:
/path/to/rootfs 10.42.0.17(rw,wdelay,no_root_squash,no_subtree_check,sec=sys,rw,secure,no_root_squash,no_all_squash)
The U-boot bootargs are:
bootargs console=ttyO0,115200n8 root=/dev/nfs rw nfsroot=${serverip}:/path/to/rootfs,v3,tcp ip=dhcp
I've encountered a problem when trying to get su working for non-root users. In order to work around the problem people over internet are suggesting to set the suid bit for the busybox binary.
After doing so:
$ sudo chmod u+s busybox
and verifying:
$ ls -la
...
-rwsr-xr-x 1 myuser myuser 1882976 Jan 13 21:47 busybox
...
$ stat -c "%a %n" busybox
4755 busybox
Something went wrong. The kernel is booting and all of the usual messages are displayed, but it is getting stuck at the end, and no login line is displayed. Here are last few lines of the booting sequence:
[ 3.776185] IP-Config: Complete:
[ 3.779656] device=eth0, hwaddr=c8:a0:30:c5:80:e9, ipaddr=10.42.0.17, mask=255.255.255.0, gw=10.42.0.1
[ 3.789877] host=10.42.0.17, domain=, nis-domain=(none)
[ 3.795822] bootserver=10.42.0.1, rootserver=10.42.0.1, rootpath=
[ 3.802492] nameserver0=10.42.0.1
[ 3.871575] VFS: Mounted root (nfs filesystem) on device 0:15.
[ 3.879903] devtmpfs: mounted
[ 3.883713] Freeing unused kernel memory: 380K (c07ef000 - c084e000)
If removing the flag, the things are returning to normal:
....
[ 3.862291] Freeing unused kernel memory: 380K (c07ef000 - c084e000)
10.42.0.17 login:
If setting the flag from within the running shell on the Beagle Bone board itself, the shell is stopping responding right after the chmod is performed.
I suspect it is something to do with the way the NFS is exporting the rootfs, but it's only a guess, so qualified explanation and possible solution would be helpful.
After some research I will answer my question myself. The answer is very simple. In order the above to work, the busybox binary should be owned by root:root. The simplest solution is just to change the ownership.

Resources