Slight protocol change, docs
This commit is contained in:
73
README.md
73
README.md
@@ -4,21 +4,26 @@ Generic display manager. Composed of a daemon which:
|
||||
|
||||
1. Launches a greeter of your choice.
|
||||
2. Listens on a socket for a login message.
|
||||
3. If the credentials are valid, terminates the greeter and starts the requested session application.
|
||||
3. If the credentials are valid, terminates the greeter (if it didn't do so itself) and starts the requested session application.
|
||||
4. When the session application terminates, the greeter is started once again.
|
||||
|
||||
All the greeter of choice needs to do is to be able to write a message to a socket. It could be anything from a simple terminal application to a fully-fledged desktop environment in which one of the applications present a user prompt.
|
||||
|
||||
The greeter runs as a configured user, which is supposed to be one with no interesting privileges except for what the greeter itself needs to run.
|
||||
|
||||
Future plans involve adding lock-screen support.
|
||||
|
||||
Protocol subject to change soon.
|
||||
|
||||
## Included in the box:
|
||||
|
||||
1. greetd, the daemon itself
|
||||
2. greetctl, a sample application to issue the login message.
|
||||
### Binaries
|
||||
|
||||
- greetd, the daemon itself
|
||||
- greetctl, a sample application to issue the login message.
|
||||
- greet_proto, a protocol library in Rust. Don't worry if you don't use Rust, the protocol is very simple.
|
||||
|
||||
### Configuration files
|
||||
|
||||
- greeter.pam, a PAM service file that should be put as `/etc/pam.d/greeter`
|
||||
- config.toml, a configuration file example
|
||||
- greetd.service, a systemd service file example.
|
||||
|
||||
## Dumb demo
|
||||
|
||||
@@ -27,6 +32,56 @@ Protocol subject to change soon.
|
||||
3. (In the new terminal): greetctl
|
||||
4. Answer the questions, and the sway greeter will be replaced by whatever you typed if your login is successful.
|
||||
|
||||
## It doesn't work yet!
|
||||
## Other greeters
|
||||
|
||||
Why are you using this? I haven't even tested it myself!
|
||||
- dlm - Dumb Login Manager
|
||||
- wlgreet - Wayland greeter
|
||||
|
||||
# Protocol
|
||||
|
||||
```
|
||||
________________________________________________________
|
||||
| | | | |
|
||||
| magic u32 | version u32 | payload_length u32 | payload |
|
||||
|___________|_____________|____________________|_________|
|
||||
```
|
||||
|
||||
Magic is always `0xAFBFCFDF`, version is `1`, payload is JSON.
|
||||
|
||||
Requests and responses are encoded the same.
|
||||
|
||||
## Requests
|
||||
|
||||
### Login
|
||||
|
||||
```
|
||||
{
|
||||
"type": "login",
|
||||
"username": "user",
|
||||
"password": "password",
|
||||
"command": ["sway"],
|
||||
"env": {
|
||||
"XDG_SESSION_TYPE": "wayland",
|
||||
"XDG_SESSION_DESKTOP": "sway",
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Response
|
||||
|
||||
### Success
|
||||
|
||||
```
|
||||
{
|
||||
"type": "success",
|
||||
}
|
||||
```
|
||||
|
||||
### Login error
|
||||
|
||||
```
|
||||
{
|
||||
"type": "loginError",
|
||||
"description": "..."
|
||||
}
|
||||
```
|
3
config.toml
Normal file
3
config.toml
Normal file
@@ -0,0 +1,3 @@
|
||||
vt = 2
|
||||
greeter = "dlm"
|
||||
greeter_user = "greeter"
|
@@ -74,8 +74,10 @@ impl Request {
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
pub enum Response {
|
||||
LoginSuccess,
|
||||
LoginFailure,
|
||||
Success,
|
||||
LoginError {
|
||||
description: String
|
||||
},
|
||||
}
|
||||
|
||||
impl Response {
|
||||
|
@@ -44,9 +44,9 @@ fn login() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let resp = Response::from_slice(&resp_buf)?;
|
||||
|
||||
match resp {
|
||||
Response::LoginSuccess => Ok(()),
|
||||
Response::LoginFailure => {
|
||||
Err(std::io::Error::new(io::ErrorKind::Other, "authentication failed").into())
|
||||
Response::Success => Ok(()),
|
||||
Response::LoginError { description } => {
|
||||
Err(std::io::Error::new(io::ErrorKind::Other, format!("login error: {}", description)).into())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -4,13 +4,8 @@ After=systemd-user-sessions.service plymouth-quit-wait.service
|
||||
After=getty@tty2.service
|
||||
|
||||
[Service]
|
||||
Type=idle
|
||||
ExecStart=/usr/local/bin/greetd --vt=2 --greeter=dlm --greeteruser=greeter
|
||||
StandardInput=tty
|
||||
StandardError=syslog
|
||||
TTYPath=/dev/tty2
|
||||
TTYReset=yes
|
||||
TTYVHangup=yes
|
||||
Type=simple
|
||||
ExecStart=greetd
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
|
@@ -102,8 +102,8 @@ impl Pollable for Client {
|
||||
self.buf.scramble();
|
||||
|
||||
let resp = match ctx.login(username, password, command, env) {
|
||||
Ok(_) => Response::LoginSuccess,
|
||||
Err(_) => Response::LoginFailure,
|
||||
Ok(_) => Response::Success,
|
||||
Err(e) => Response::LoginError{ description: format!("{}", e) },
|
||||
};
|
||||
|
||||
let resp_bytes =
|
||||
|
Reference in New Issue
Block a user