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 eg 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)
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:
So what's not working is yast2 kde su :
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.?
service -s
Output:
accounts-daemon.service loaded active running Accounts 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-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 output s 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 :
[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
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)
Goals:
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.