diff --git a/login/login.8 b/login/login.8 index c16d86e0..b52e871f 100644 --- a/login/login.8 +++ b/login/login.8 @@ -26,6 +26,15 @@ exists. The process remains running in the background and takes over again when the user session exits. .Pp +The user's +.Xr session 5 +is created upon login by running the user's +.Pa ~/.session +script if it exists and is executable, otherwise attempting +.Pa /etc/session , +and ultimately falling back on the user's shell from +.Xr passwd 5 . +.Pp Type a special username to perform special options: .Pp .Bl -tag -width "poweroff" -compact -offset indent @@ -57,12 +66,18 @@ shell username .El .Sh FILES -.Bl -tag -width "/etc/passwd" -compact +.Bl -tag -width "/etc/login.conf.textual" -compact +.It Pa ~/.session +user session script run upon login (see +.Xr session 5 ) +.It Pa /etc/login.conf.textual +textual interface is forced if this file exists .It Pa /etc/passwd user database (see .Xr passwd 5 ) -.It Pa /etc/login.conf.textual -textual interface is forced if this file exists +.It Pa /etc/session +fallback session script run upon login (see +.Xr session 5 ) .El .Sh EXIT STATUS .Nm login @@ -72,6 +87,7 @@ reboot, or exits 2 on fatal failure and the boot should halt. .Xr passwd 1 , .Xr crypt_checkpass 3 , .Xr passwd 5 , +.Xr session 5 , .Xr init 8 , .Xr login 8 .Sh BUGS diff --git a/login/login.c b/login/login.c index f3831280..0f085700 100644 --- a/login/login.c +++ b/login/login.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, 2018 Jonas 'Sortie' Termansen. + * Copyright (c) 2014, 2015, 2018, 2022 Jonas 'Sortie' Termansen. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -249,6 +249,10 @@ bool login(const char* username) tcsetpgrp(0, getpgid(0)) || sigprocmask(SIG_SETMASK, &oldset, NULL) < 0 || settermmode(0, TERMMODE_NORMAL) < 0 || + (execlp("./.session", "./.session", (const char*) NULL) < 0 && + errno != ENOENT && errno != EACCES) || + (execlp("/etc/session", "/etc/session", (const char*) NULL) < 0 && + errno != ENOENT && errno != EACCES) || execlp(pwd->pw_shell, pwd->pw_shell, (const char*) NULL)); write(pipe_fds[1], &errno, sizeof(errno)); _exit(127); diff --git a/share/man/man5/session.5 b/share/man/man5/session.5 new file mode 100644 index 00000000..249c4ff4 --- /dev/null +++ b/share/man/man5/session.5 @@ -0,0 +1,51 @@ +.Dd September 18, 2022 +.Dt SESSION 5 +.Os +.Sh NAME +.Nm session +.Nd user login ession +.Sh SYNOPSIS +.Nm ~/.session +.Nm /etc/session +.Sh DESCRIPTION +.Xr login 8 +creates the user's session by running the user's +.Nm +script, which normally +executes a command line or graphical user environment. +The session concludes once the session script exits and +.Xr login 8 +reclaims control. +.Pp +The session script is found by searching for an executable script in the +following paths: +.Bl -bullet -compact +.It +.Pa ~/.session +.It +.Pa /etc/session +.El +.Pp +The user's shell from +.Xr passwd 5 +is used as a fallback session. +.Sh EXAMPLES +The user's +.Pa ~/.session +file can be created in any text editor and then made executable: +.Bd -literal -offset indent +editor ~/.session +chmod +x ~/.session +.Ed +.Ss Trianglix +.Xr trianglix 1 +can be selected as the user's triangle environment with this executable +.Pa ~/.session +script: +.Bd -literal -offset indent +#!/bin/sh +exec trianglix +.Ed +.Sh SEE ALSO +.Xr passwd 5 , +.Xr login 8