Commit Graph

260 Commits

Author SHA1 Message Date
Colin 208cd4a687 call pam_end from within the child session, not the parent
this allows modules like pam_cap to configure the capability bits of the
session process, particularly the ambient capability set.

further details/precedent can be found here:
- <https://github.com/shadow-maint/shadow/pull/408>
- <https://bugzilla.kernel.org/show_bug.cgi?id=214377>
2024-01-30 09:17:13 +00:00
Hugo Osvaldo Barrera 67eaa39b93 Derive VtSelection::default 2023-06-23 22:10:09 +02:00
Hugo Osvaldo Barrera 195a811177 Use strip_prefix to strip prefix
No need to do it manually.
2023-06-23 22:10:09 +02:00
Hugo Osvaldo Barrera 4b402a5753 Remove pointless copying of string before copying it 2023-06-23 22:10:09 +02:00
Hugo Osvaldo Barrera 755c42b8d8 Remove references that are implicitly dereferenced
This are implicitly dereferenced by the compiler and a no-op.
2023-06-23 22:10:09 +02:00
Hugo Osvaldo Barrera 9c97b6aa2c Remove no-op question mark and Ok() 2023-06-23 22:10:09 +02:00
Kenny Levinsen 7525628028 cargo update 2023-06-23 22:07:29 +02:00
Hugo Osvaldo Barrera 7ebc50ea7a Drop unmaintained `users` crate
Its functionality is provided by the `nix` crate which is already a
dependency anyway.

See: https://rustsec.org/advisories/RUSTSEC-2023-0040.html
2023-06-23 22:05:18 +02:00
Aleksei Bavshin 7d0f74dfbe Update deprecated SPDX identifier for GPL-3.0-only
Link the LICENSE file into the greetd_ipc crate to ensure that it
appears in the crates.io archive.
2023-06-19 16:01:14 +02:00
Kenny Levinsen 68fff8d3d2 Minimize user-exposed environment variables
PAM requires a number of environment variables set, and greeters need to
know the greetd socket path. All these environment variables were set
for all sessions started by greetd.

Only set the greetd socket path for greeter sessions, and remove some
environment variables only need for PAM before starting a session.
2023-06-19 15:51:13 +02:00
Kenny Levinsen 3608fc9494 server: cargo fmt 2023-05-12 09:41:53 +02:00
Kenny Levinsen 1b6c93cb2d config: Fix tests for service config 2023-05-12 09:41:18 +02:00
Jonathan Sköld a7c8ac89cf agreety: Return error if no input when prompted
If EOF is provided when the user is prompted agreety would panic. This
commit fixes that by returning an error instead causing graceful exit(1)
instead.
2023-04-05 00:36:23 +02:00
Arnaud Ferraris 95ab9cdc3f config: allow using custom PAM configs
In the event several greeters are installed, each needing a specific PAM
config, it could be useful to have each greeter having its own config
file (which is already possible), each one indicating the PAM config to
be used with this greeter (which is not possible for now).

This commit adds a new (optional) "service" key to the "general",
"default_session" and "initial_session" sections so users and/or
distributions can have more flexibility regarding PAM config management.

In case this option is missing from the config file, we fall back to the
default "greetd" and "greetd-greeter" config names.

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
2023-03-27 11:08:22 +02:00
Harish Rajagopal c597e82b1e Add ReGreet to list of known greetd greeters 2023-02-13 12:13:01 +01:00
Kenny Levinsen f3f3249885 Bump version to 0.9.0 2023-01-06 00:25:45 +01:00
Kenny Levinsen 23fadf16d4 cargo: Update dependencies 2023-01-06 00:24:20 +01:00
Kenny Levinsen dd96c93b98 readme: Add ddlm, note list updates welcome 2022-12-07 23:00:08 +01:00
Kenny Levinsen ccf50fe46e cargo: Update tokio 2022-12-07 22:58:58 +01:00
Felix Lechner 9c8297e4cb For FUSE-based home folders, chdir into them as the user instead of root.
By default, filesystems user-mounted via FUSE are not accessible to
root. [1] Such user mounts have been common for encrypted home folders
since 2003. [2][3][4] This change accommodates users with those home
folders.

Greetd previously sent affected users into the root directory ("/")
because their home folders were inaccessible to root.

Now the directory operation occurs after a user's privileges were
assumed. Users find themselves in their home folders after logging in.

Since the call to PAM's open_session now takes place before any change
of folders, the value of the current directory is no longer being
exposed to the modules via the environment variable $PWD, but the PAM
environment is distinct from the process environment.

This commit was tested on Guix without commit 424ecac4 since the Rust
crate for nix 0.20 was not immediately available there.

[1] https://unix.stackexchange.com/a/17423
[2] https://en.wikipedia.org/wiki/Comparison_of_disk_encryption_software
[3] https://en.wikipedia.org/wiki/EncFS
[4] https://nuetzlich.net/gocryptfs/
2022-11-30 18:53:13 +01:00
Aleksei Bavshin c5c2f64679 fakegreet: reset state on errors
Some greeters were sending CancelSession in response to Error, likely
because it was necessary for a consistent internal state of fakegreet.

Change fakegreet to comply with the protocol doc, which states that the
sessions are automatically cancelled on error, and remove the need for
the redundant CancelSession.
2022-09-13 11:14:55 +02:00
Aleksei Bavshin bc7e369225 Change order of setting pam environment variables.
Set the variables coming from a greeter first to ensure that the
duplicates will be overwritten by the values from greetd worker.
2022-08-13 21:48:55 +02:00
Aleksei Bavshin 3a32863bc7 ipc: ensure backward compatibility of the protocol
If the client was compiled with the previous version of the protocol,
initialize StartSession.env with the default value instead of failing to
deserialize the message.
2022-08-13 21:48:55 +02:00
Aleksei Bavshin 2f1810d1a2 Revert "Remove 'env' from start_session"
This reverts commit 1bc6ddbf67.
2022-08-13 21:48:55 +02:00
Kenny Levinsen 3b7229bacd Minor doc adjustments 2022-08-01 00:47:19 +02:00
Kenny Levinsen d700309623 readme: Add reference to QtGreet 2022-03-09 00:05:38 +01:00
Matěj Cepl 399c30826f Use /bin/sh instead of $SHELL
$SHELL variable is not set yet at this moment, so it is hardly a good
idea to use it. /bin/sh is completely generally available shell on all
UNIX platforms.
2022-02-15 14:55:16 +01:00
Kenny Levinsen 424ecac439 compat: Upgrade nix to 0.20 for x32 support
Closes: https://todo.sr.ht/~kennylevinsen/greetd/29
2022-01-04 17:16:45 +01:00
Kenny Levinsen d2477a8f9c Bump version to 0.8.0 2021-09-05 21:15:06 +02:00
muradm 87e9277654 greetd: add terminal switch flag configuration option
This adds "switch" true/false flag in "terminal" section of
configuration file.

Flag controls whether terminal under control should be switched to
when greetd starts. If "switch" set to true, greetd behaves as it
did before, on start vt_setactivate will be called. If "switch" set
to false, and terminal under control by greetd is not currently
active VT, greetd will wait for terminal to become active with
vt_waitactive, which translates to VT_WAITACTIVE ioctl call.

* greetd/src/config/mod.rs: add "switch" flag
* greetd/src/server.rs: add using "switch" flag and waiting for active
* greetd/src/terminal/mod.rs: add vt_waitactive method
* man/greetd-5.scd: mention "switch" configuration option
2021-08-17 00:33:11 +02:00
Kenny Levinsen fba10c1316 ipc: Fix tokio codec 2021-08-17 00:32:12 +02:00
Kenny Levinsen b42e4714b0 rustfmt: Change merge_imports to imports_granularity 2021-08-02 22:01:13 +02:00
Kenny Levinsen d5b7d81342 docs: Fix scdoc syntax for greetd.5 2021-08-02 21:59:15 +02:00
Antoine POPINEAU 5201469e39 Ensure initial session is only run once.
Security concerns were raised regarding the initial session being
executed whenever greetd was restarted (when signing out of one's DE,
when greetd or a greeter restarted or crashed, ...).

This creates a runfile (by default at /run/greetd.run) either when the
initial session is executed or when a greeter is started. Whenever this
file exists, the initial session is ignored (and the configured greeter
is always run).
2021-07-29 19:25:51 +02:00
cinerea0 41c6b5f1d4 Add makefile for man pages 2021-07-29 19:20:32 +02:00
Eli Schwartz f89d80a2f6 recommend making config world readable rather than setting owner
There is no secret material that needs to be unreadable except to the
daemon, but if there were, the current instructions never recommended
setting a locked down mode.

The daemon doesn't need write access either.

Recommending chown rather than making the config world readable as is
typical for bog standard system configs, is confusing and inconsistent
with e.g. the in house AUR packaging. It also might be erroneously
interpreted as a requirement, which is challenging for packaging systems
that don't support distributing files/directories owned by non-root
users.
2021-07-06 22:20:39 +02:00
Kenny Levinsen e069f5ac4d readme: Add discuss section 2021-05-19 17:38:54 +02:00
Kenny Levinsen 47d0ee939e Update lock file 2021-01-18 20:14:17 +01:00
Aleksei Bavshin e5a598298a deps: update nix and other dependencies
`fork` is now marked as unsafe (nix-rust/nix#1030)
2021-01-18 20:10:02 +01:00
Aleksei Bavshin eef821c68b deps: update tokio to 1.0 2021-01-18 20:10:02 +01:00
Kenny Levinsen b25b72ae51 ci: Disable automatic github mirroring 2020-12-22 12:29:48 +01:00
Kenny Levinsen c0887255db docs: Document new general section 2020-11-16 14:38:30 +01:00
Kenny Levinsen ef33843492 config: Fix tests for general section 2020-11-16 14:37:49 +01:00
Kenny Levinsen 8fea33c476 config: Add general.source_profile
This adds a system-wide toggle for whether the system profile should be
sourced by /bin/sh before running the command. Note that the command
will still be run with /bin/sh, regardless of profile sourcing.

The option defaults to true for now.

Example usage:

	[general]
	source_profile = false
2020-11-15 17:43:29 +01:00
Aleksei Bavshin 4c2a2e89d4 Use additional pam service config for greeter
Check the existence and attempt to use `greetd-greeter` pam service file
for greeter sessions. The fallback is a standard greetd pam service,
i.e. `greetd` or `login`.

Rationale: proper configurations for different session types can vary in
acceptable modules. Certain modules like `pam_selinux` are actually
harmful for an unprivileged greeter session as it removes the SELinux
security label from the greeter processes.
2020-10-21 00:38:12 +02:00
Kenny Levinsen 0d8812c80b config: Skip reading config in session worker
The decision to start a session worker or main process is taken after
the config module has been queried. This means that the regular process
for loading config files is also run. This can lead to errors if the
config file is not in the default location, as the session worker does
not receive the config argument.

Skip reading config files if the session-worker flag is set.
2020-10-13 18:55:46 +02:00
Kenny Levinsen 3dccaa44c7 Use stdin as VT for current/none vt selections
The controlling tty will now be obtained from stdin if possible for
current/non, which is useful for inittab setups and shell test
use-cases.
2020-09-08 17:57:34 +02:00
Kenny Levinsen c71b83eca7 Terminate cleanly on SIGINT 2020-07-10 18:27:29 +02:00
Kenny Levinsen 1a263c94e6 Use per-pid socket paths
Use of per-pid socket paths allows multiple greetd instances to be
started without accidentally trampling on eachothers' socket paths.

This has the added benefit of rendering the socket-path configuration
unnecessary.

Delete the listener on Drop for cleanup.
2020-07-10 18:27:25 +02:00
Kirill Chibisov d4664b4061 Add installation instructions on Gentoo 2020-07-08 14:38:23 +02:00