1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00

Add session(5).

This commit is contained in:
Jonas 'Sortie' Termansen 2022-09-18 21:54:21 +02:00
parent 050ba71ca0
commit 875030f3f3
3 changed files with 75 additions and 4 deletions

View file

@ -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

View file

@ -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);

51
share/man/man5/session.5 Normal file
View file

@ -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