dm

package
v0.0.0-...-19622d4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2026 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Do not preselect any last user
	False enSelectLastUser = iota

	// Preselect last successfully logged in user per tty
	PerTty

	// Preselect last successfully logged in user per system
	Global
)
View Source
const (

	// Never show selection
	SelectionFalse enSelection = iota

	// Always show selection
	SelectionTrue

	// Show selection only if necessary
	SelectionAuto
)
View Source
const (
	// Undefined represents no environment
	Undefined enEnvironment = iota

	// X11 represents Xorg/XLibre environment
	X11

	// Wayland represents Wayland environment
	Wayland

	// Custom represents custom desktops, only helper before real env is loaded
	Custom

	// UserCustom represents user's desktops, only helper before real env is loaded
	UserCustom
)
View Source
const (
	// Rotate represents saving into new file and backing up older with suffix
	Rotate enLogging = iota + 1

	// Appending represents saving all logs into same file
	Appending

	// Disabled represents disabled logging
	Disabled
)

Variables

View Source
var TEST_MODE bool

TEST_MODE Defines if logging is in test mode

Functions

func Authenticate

func Authenticate(conf *config, username, password string) (authHandle, error)

Authenticate validates credentials (PAM when built with PAM support).

func AuthenticatePAM

func AuthenticatePAM(conf *config, username, password string) (*pamHandle, error)

AuthenticatePAM validates credentials via PAM. On success the handle is ready for openAuthSession / session start. If the username is a :command (and AllowCommands), no PAM transaction is opened; getCommand is set instead.

func EffectiveUsername

func EffectiveUsername(conf *config, username string) string

EffectiveUsername applies DefaultUser and last-logged hint when input is empty.

func FinalizeDesktopSelection

func FinalizeDesktopSelection(auth authHandle, conf *config, ud *desktop, selected *desktop, desktops []*desktop) *desktop

FinalizeDesktopSelection merges user config, selection, and last-session persistence.

func FormatCommand

func FormatCommand(command string) string

FormatCommand strips ANSI and leading ':' from a login-buffer command.

func InitLogger

func InitLogger(conf *Config)

InitLogger configures process logging according to conf.

func LastUserHint

func LastUserHint(conf *Config) string

LastUserHint returns the cached last login name (per SELECT_LAST_USER), if any.

func LoadConfigPath

func LoadConfigPath(args []string) (configPath string)

LoadConfigPath resolves config file path from argv.

func MotdText

func MotdText(conf *config) string

MotdText returns MOTD content for TUI display without printing to the terminal.

func ProcessArgs

func ProcessArgs(args []string, conf *config)

ProcessArgs applies CLI flags to an already-allocated config.

func ProcessCommand

func ProcessCommand(command string, c *config, auth authHandle, continuable bool) error

ProcessCommand runs power/session-wide commands (poweroff, reboot, suspend, help).

func ProcessCoreArgs

func ProcessCoreArgs(args []string)

ProcessCoreArgs handles -h / -v before configuration is loaded.

func RunLoginSession

func RunLoginSession(conf *config, h *SessionHandle, auth authHandle, d *desktop) (cmd string, err error)

RunLoginSession starts the graphical session after auth and desktop resolution.

Returns:

  • cmd: a built-in :command extracted from the username field, if any
  • err: a short, user-facing error describing why the chosen environment could not start or terminated abnormally; the caller is expected to display it and offer the user to pick another session

On any return path the auth handle is closed; the caller must re-authenticate (the UI keeps the entered username/password for that purpose).

func ShouldProcessCommand

func ShouldProcessCommand(input string, conf *config) bool

ShouldProcessCommand reports whether the input is a built-in :command.

func StartDaemon

func StartDaemon(conf *Config) *os.File

StartDaemon switches stdin/stdout/stderr to the configured TTY when in daemon mode.

func StopDaemon

func StopDaemon(conf *Config, fTTY *os.File)

StopDaemon restores the terminal after daemon mode.

func TryAutoSelectDesktop

func TryAutoSelectDesktop(auth authHandle, conf *config, ud *desktop) (chosen *desktop, desktops []*desktop, lastIdx int, needUI bool)

TryAutoSelectDesktop returns a desktop without UI when autologin/default/single-session rules apply.

Types

type AuthHandle

type AuthHandle = authHandle

AuthHandle is implemented by PAM and nopam backends.

type Config

type Config = config

Config is the display manager configuration (loaded from /etc/adm/conf by default).

func LoadConfig

func LoadConfig(path string) *Config

LoadConfig loads configuration from a properties file (empty path skips the file).

type DefaultLoginRetryPathProvider

type DefaultLoginRetryPathProvider struct {
}

type Desktop

type Desktop = desktop

Desktop describes a display session (.desktop entry).

func LoadUserConfig

func LoadUserConfig(homeDir string) (ud *Desktop, usrLang string)

LoadUserConfig reads ~/.config/adm or ~/.adm and optional LANG for the user.

type LoginRetryPathProvider

type LoginRetryPathProvider interface {
	// contains filtered or unexported methods
}

type SessionHandle

type SessionHandle struct {
	// contains filtered or unexported fields
}

SessionHandle groups an active GUI session with auth for signal handling.

func InitSessionHandle

func InitSessionHandle() *SessionHandle

InitSessionHandle registers interrupt handling for the current login/session lifecycle.

type Sysuser

type Sysuser = sysuser

Sysuser is an alias for exchanging user info across packages.

func UserOf

func UserOf(a AuthHandle) *Sysuser

UserOf returns the authenticated account, or nil. It is safe when the interface holds a typed-nil concrete pointer (e.g. (*pamHandle)(nil)).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL