Difference between revisions of "TDM"

From Trinity Desktop Project Wiki
Jump to navigation Jump to search
(Add page about TDM (Remote login via XDMCP + some technical info from the README file))
 
m (fix formatting)
 
Line 1: Line 1:
''TDM'' is the default graphical display manager of the Trinity Desktop Environment. It handles local and remote logins on a machine.
+
'''TDM''' is the default graphical display manager of the Trinity Desktop Environment. It handles local and remote logins on a machine.
   
 
__TOC__
 
__TOC__

Latest revision as of 11:27, 18 December 2023

TDM is the default graphical display manager of the Trinity Desktop Environment. It handles local and remote logins on a machine.

Remote login

Remote login can be performed via the XDMCP protocol. Due to security concerns, the XDMCP host component is disabled by default in TDM (but you can still connect to XDMCP hosts as a client).

Messagebox warning.png
Warning!
ArchWiki on the matter of XDMCP:

XDMCP is, similarly to telnet, doing unencrypted authentication. If snooping is possible, this leaves the system vulnerable to attack. It is disabled by default, using an ssh tunnel for X traffic is preferred.

As a matter of fact, you should only use it in a completely trusted and controlled environment.

To be able to login into a machine remotely you should edit the tdmrc file. Find the section titled [Xdmcp] and set the Enable key to true. Then, restart the tdm service.

On the remote side select "Remote login" from the options menu of the TDM login screen. You should be presented with a dialog of the remote machines to which you can connect via XDMCP. If you don't see the machine you want to connect to in the list, enter its IP address and press "Add". It should appear in the list.

By default a host might not allow remote connections despite being open for XDMCP requests. In XDMCP terminology, the host must be "Willing" to accept the remote connection. If you see "Display not authorized to connect" in the remote login dialog next to the address/hostname of the machine you want to connect to, you have to configure which hosts are allowed to connect to the machine. Follow the instructions in the Xaccess file (it should be in the same directory as tdmrc) to set up authorized hosts. After that, restart TDM and repeat the process.

When you select the desired host in the remote login menu and press "Connect", assuming the configuration is correct, you will be presented with the login screen of the host you are trying to connect to. If you see the local login screen again, then something has gone wrong. Ensure you have configured both instances of TDM according to the above instructions.

Technical details

TDM's file system layout

  • ${tde_confdir} is usually ${prefix}/share/config
  • ${tde_datadir} is usually ${prefix}/share/apps
  • ${tde_confdir}/tdm/{tdmrc,Xservers,Xaccess,Xwilling,...}
  • ${tde_datadir}/tdm/sessions/*.desktop
  • /etc/X11/sessions/,/usr/share/xsessions/
  • ${tde_datadir}/tdm/pics/users/
  • ${tde_datadir}/tdm/pics/
  • ${tde_datadir}/tdm/faces/*.face{,.icon}
  • /usr/share/faces/
  • /var/run/xauth/A*
  • /var/run/xdmctl/xdmctl*
  • /var/run/tdm.pid
  • /var/lib/tdm/tdmsts
  • <site-specific>/*.dmrc
  • $HOME/.face{,.icon}
  • $HOME/.dmrc


How to setup TDM

TDM's config files are all located in ${tde_confdir}/tdm. "make install" will create a probably working configuration, either by deriving it from an already present TDM/XDM installation or by using defaults if no previous installation is found.

You can change the configuration from the Trinity Control Center. You will find the "Login Manager" module in the "System Administration" group.

Have a look at README.pam in the tdebase top level directory if your system uses PAM.


Configuring session types

Session types are represented by .desktop files in appropriate locations. The format of the .desktop files is (not yet) defined in the FreeDesktop.org desktop entry spec. Differences to "standard" .desktop files are:

  • the Type is fixed to XSession and can be omitted.
  • the Encoding is fixed to UTF-8 and can be omitted.
  • the Exec field will be passed to "eval exec" in a bourne shell; no macro expansion is performed on it. "default", "custom" and "failsafe" are magic constants that cause special actions.
  • Name, Comment, TryExec and Hidden are supported.
  • the remaining keys have no meaning currently.

Session types are internally identified by filename (without extension); that's what will be saved to ~/.dmrc and what DESKTOP_SESSION will be set to. For every magic Exec constant a session type of the same name exists.

Unless your system is configured differently already, you should create a directory ${tde_confdir}/tdm/sessions and add this to tdmrc:

[X-*-Core]
SessionsDirs=${tde_confdir}/tdm/sessions,${tde_datadir}/tdm/sessions
Messagebox warning.png
Warning!
Always keep in mind the following:
  • You must use actual paths instead of variables, see the section about TDM's file system layout.
  • Do any changes only in the config directory - any changes in the data directory will be lost after the next TDE update.


To override a session type, copy the .desktop file from the data directory to the config directory and edit it at will. Removing the shipped session types can be accomplished by "shadowing" them with .desktop files containing Hidden=true.

For the magic session types no .desktop files exist by default, but TDM pretends they would, so you can override them like any other type.


The command sockets

This is a feature you can use to remote-control TDM. It's mostly intended for use by ksmserver and kdesktop from a running session, but other applications are possible as well.

The sockets are UNIX domain sockets which live in subdirectories of the directory specified by FifoDir=. The subdir is the key to addressing and security; the sockets all have the file name "socket" and file permissions rw-rw-rw- (0666). This is because some systems don't care for the file permissions of the socket files.

There are two types of sockets: the global one (dmctl) and the per-display ones (dmctl-<display>).

The global one's subdir is owned by root, the subdirs of the per-display ones' are owned by the user currently owning the session (root or the logged in user). Group ownership of the subdirs can be set via FifoGroup=, otherwise it's root. The file permissions of the subdirs are rwxr-x--- (0750).

The fields of a command are separated by tabs (\t), the fields of a list are separated by spaces, literal spaces in list fields are denoted by "\s". The command is terminated by a newline (\n). The same applies to replies. The reply on success is "ok", possibly followed by the requested information. The reply on error is an errno-style word (e.g., "perm", "noent", etc.) followed by a longer explanation.

Global commands

login {display} ("now"|"schedule") {user} {password} [session_arguments]
Login user at specified display. if "now" is specified, a possibly running session is killed, otherwise the login is done after the session exits.

session_arguments are printf-like escaped contents for .dmrc. Unlisted keys will default to previously saved values.

Per-display commands

lock
The display is marked as locked. If the X-Server crashes in this state, no auto-relogin will be performed even if the option is on.
unlock
Reverse the effect of "lock": re-enable auto-relogin.
suicide
The currently running session is forcibly terminated. No auto-relogin is attempted, but a scheduled "login" command will be executed.

Commands for all sockets

caps
Returns a list this socket's capabilities:
tdm identifies tdm, in case some other DM implements this protocol, too
list, activate, lock, suicide, login whether the respective command is supported
bootoptions whether the listbootoptions command and the "=" option to "shutdown" are supported
shutdown {list} whether "shutdown" is supported and allowed to the listed users (comma-separated), "*" means all authenticated users
shutdown whether "shutdown" is supported and allowed to everybody
nuke {list} whether forced shutdown is allowed to the listed users
nuke whether forced shutdown is allowed to everybody
reserve {number} whether reserve displays are configured and <number> are available at this time
list [all|alllocal]
Return a list of running sessions. By default all active sessions are listed.

If "all" is specified, passive sessions are listed as well.

If "alllocal" is specified, passive sessions are listed as well, but all incoming remote sessions are skipped.

Each session entry is a comma-separated tuple of:

  • Display or TTY name
  • VT name for local sessions
  • Logged in user's name, empty for passive sessions and outgoing remote sessions (local chooser mode)
  • Session type or remote host for outgoing remote sessions, empty for passive sessions
  • A flag field:
    • "t" for tty sessions
    • "*" for the display belonging to the requesting socket
    • "!" for sessions that cannot be killed by the requesting socket
reserve [timeout in seconds]
Start a reserve login screen. If nobody logs in within the specified amount of time (one minute by default), the display is removed again. When the session on the display exits, the display is removed, too.

Permitted only on sockets of local displays and the global socket.

activate (vt|display)
Switch to a particular VT (virtual terminal). The VT may be specified either directly (e.g., vt3) or by a display using it (e.g., :2).

Permitted only on sockets of local displays and the global socket.

listbootoptions
List available boot options.
=> "ok" list default current
  • default and current are indices into the list and are -1 if unset or undeterminable.
shutdown (reboot|halt)[={bootchoice}] (ask|trynow|forcenow|schedule|start (-1|end (force|forcemy|cancel)))
Request a system shutdown, either a reboot or a halt/poweroff.

An OS choice for the next boot may be specified from the list returned by "listbootoptions".

Shutdowns requested from per-display sockets are executed when the current session on that display exits. Such a request may pop up a dialog asking for confirmation and/or authentication.

  • start is the time for which the shutdown is scheduled. If it starts with a plus-sign, the current time is added. Zero means immediately.
  • end is the latest time at which the shutdown should be performed if active sessions are still running. If it starts with a plus-sign, the start time is added. Minus one means wait infinitely. If end is through and active sessions are still running, TDM can do one of the following:
    • cancel - give up the shutdown.
    • force - shut down nonetheless.
    • forcemy - shut down nonetheless if all active sessions belong to the requesting user. Only for per-display sockets.
  • trynow is a synonym for "0 0 cancel", forcenow for "0 0 force" and schedule for "0 -1".
  • ask attempts an immediate shutdown and interacts with the user if active sessions are still running. Only for per-display sockets.
  • start and end are specified in seconds since the UNIX epoch.
shutdown cancel [local|global]
Cancel a scheduled shutdown. The global socket always cancels the currently pending shutdown, while per-display sockets default to cancelling their queued request.
shutdown status
Return a list with information about shutdowns.

The entries are comma-separated tuples of:

  • ("global"|"local") - pending vs. queued shutdown. A local entry can be returned only by a per-display socket.
  • ("halt"|"reboot")
  • start
  • end
  • ("ask"|"force"|"forcemy"|"cancel")
  • Numeric user ID of the requesting user, -1 for the global socket.
  • The next boot OS choice or "-" for none.

There are two ways of using the sockets:

  • Connecting them directly. FifoDir is exported as $DM_CONTROL; the name of per-display sockets can be derived from $DISPLAY.
  • By using the tdmctl command (e.g., from within a shell script). Try "tdmctl -h" to find out more.

Here is an example bash script "reboot into FreeBSD":

if tdmctl | grep -q shutdown; then
  IFS=$'\t'
  set -- `tdmctl listbootoptions`
  if [ "$1" = ok ]; then
    fbsd=$(echo "$2" | tr ' ' '\n' | sed -ne 's,\\s, ,g;/freebsd/I{p;q}')
    if [ -n "$fbsd" ]; then
      tdmctl shutdown reboot "=$fbsd" ask > /dev/null
    else
      echo "FreeBSD boot unavailable."
    fi
  else
    echo "Boot options unavailable."
  fi
else
  echo "Cannot reboot system."
fi

Troubleshooting

TDM accepts two command line options related to logging:

 -debug <n>
   <n> is a decimal or hexadecimal (prefix 0x) number.
   The number is a bitfield, i.e., it is formed by summing up the
   required values from this table:
   1 (0x1) - core debugging. Probably the most useful one.
   2 (0x2) - config reader debugging.
   4 (0x4) - greeter debugging.
   8 (0x8) - IPC debugging. This logs _all_ communication between the

core, the config reader and the greeter - including the passwords you type, so edit the log before showing it to somebody. This attempts to synchronize the processes to interleave the log messages optimally, but will probably fail unless you use -debug 0x80 as well.

   16 (0x10) - wait after forking session sub-daemon.
   32 (0x20) - wait after starting config reader.
   64 (0x40) - wait after starting greeter.

The wait options are only useful if you need to attach a debugger to a process, but it crashes before you are able to do so without the delay. See below.

   128 (0x80) - don't use syslog for internally generated messages.
   256 (0x100) - core Xauth debugging.
   1024 (0x400) - run config reader and greeter through valgrind.
   2048 (0x800) - run config reader and greeter through strace.

Logs from "-debug 7" are usually a good start.

 -error <file>, -logfile <file>
   <file> is the file to log various messages to. The default log file is
   /var/log/tdm.log. For internal reasons there is no option in tdmrc to
   permanently specify the log file location. If you redirect TDM's
   standard error output to a file, TDM will log there.
   If TDM is configured to use syslog (and it _very_ probably is on any
   modern system), all internally generated messages are logged to the
   "daemon" facility. The log usually can be found in /var/log/debug.log
   and /var/log/daemon.log; make sure that daemon.* is logged (look at
   /etc/syslog.conf).
   If you have problems logging in and your system uses PAM (also quite
   probable on modern systems), the "auth" and "authpriv" syslog facilities
   are interesting, too.

When reporting bugs, send all the logs together with a detailed description of what you did and what happened. If your problem is related to a specific configuration, you should also attach a tar.gz archive of your TDM config directory.

Producing a backtrace

If a backtrace is requested from you and TDM didn't create one yet via the usual drkonqi procedure, you'll have to do that yourself. The keyphrase is "attaching gdb". How exactly this is done depends on the part that crashes:

Attaching gdb to the process

Master daemon

Actually you should never need to attach to it, as you can start it within the debugger already:

# gdb --args tdm -nodaemon -debug 7
(gdb) run
Display subdaemon

Find (using ps) the process with a name like "-:0" (where :0 is actually the display this process is for). This process' PPID is the master daemon. Attach to it this way:

# gdb tdm <the PID you found>
(gdb) cont

If the subdaemon crashes before you can attach, add 16 to the debug flags when you start TDM.

Config reader

You will have to add 32 to the debug flags almost certainly. The PPID will be the master daemon as well.

# gdb tdm_config $(pidof tdm_config)
(gdb) cont
Greeter

If it's too fast, add 64 to -debug. The PPID will be the subdaemon.

# gdb tdm_greet $(pidof tdm_greet)
(gdb) cont

The simplification with "pidof" works only if you have only one display, otherwise you have to find the PID manually (by using ps -fx).

Reproduce crash and create backtrace

Once you got gdb attached to the offending process, do whatever is needed to make it crash (probably nothing, if you had to use a delay parameter).

Once it crashed, gdb will tell you a signal name, like SIGSEGV - that's the first interesting part. Then you have to create the actual backtrace:

(gdb) bt

The output of this command is interesting for the developer, so a backtrace might be useful even if nothing crashes, but instead hangs. In this case don't use "cont" after attaching, but use "bt" right away. If the process is already running, interrupt it with ctrl-c.

For obvious reasons you have to run gdb on a different virtual terminal than the X server. To get there, press alt-ctrl-f1 and log in as root. To switch to the X server's vt, press alt-ctrl-f7 (the exact function key may be different on your system). You may also use a remote login from a second machine. In any case it is advantageous to have mouse support on the debugging console for copying the backtrace.

Note that a backtrace is usually much more useful if the binary contains debugging info.