Slight protocol change, docs

This commit is contained in:
Kenny Levinsen
2019-09-16 22:57:06 +02:00
parent 8138301a7a
commit eea19d52de
6 changed files with 78 additions and 23 deletions

View File

@@ -4,21 +4,26 @@ Generic display manager. Composed of a daemon which:
1. Launches a greeter of your choice. 1. Launches a greeter of your choice.
2. Listens on a socket for a login message. 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. 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. 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. 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: ## Included in the box:
1. greetd, the daemon itself ### Binaries
2. greetctl, a sample application to issue the login message.
- 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 ## Dumb demo
@@ -27,6 +32,56 @@ Protocol subject to change soon.
3. (In the new terminal): greetctl 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. 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
View File

@@ -0,0 +1,3 @@
vt = 2
greeter = "dlm"
greeter_user = "greeter"

View File

@@ -74,8 +74,10 @@ impl Request {
#[derive(Debug, Deserialize, Serialize)] #[derive(Debug, Deserialize, Serialize)]
#[serde(tag = "type")] #[serde(tag = "type")]
pub enum Response { pub enum Response {
LoginSuccess, Success,
LoginFailure, LoginError {
description: String
},
} }
impl Response { impl Response {

View File

@@ -44,9 +44,9 @@ fn login() -> Result<(), Box<dyn std::error::Error>> {
let resp = Response::from_slice(&resp_buf)?; let resp = Response::from_slice(&resp_buf)?;
match resp { match resp {
Response::LoginSuccess => Ok(()), Response::Success => Ok(()),
Response::LoginFailure => { Response::LoginError { description } => {
Err(std::io::Error::new(io::ErrorKind::Other, "authentication failed").into()) Err(std::io::Error::new(io::ErrorKind::Other, format!("login error: {}", description)).into())
} }
} }
} }

View File

@@ -4,13 +4,8 @@ After=systemd-user-sessions.service plymouth-quit-wait.service
After=getty@tty2.service After=getty@tty2.service
[Service] [Service]
Type=idle Type=simple
ExecStart=/usr/local/bin/greetd --vt=2 --greeter=dlm --greeteruser=greeter ExecStart=greetd
StandardInput=tty
StandardError=syslog
TTYPath=/dev/tty2
TTYReset=yes
TTYVHangup=yes
Restart=always Restart=always
[Install] [Install]

View File

@@ -102,8 +102,8 @@ impl Pollable for Client {
self.buf.scramble(); self.buf.scramble();
let resp = match ctx.login(username, password, command, env) { let resp = match ctx.login(username, password, command, env) {
Ok(_) => Response::LoginSuccess, Ok(_) => Response::Success,
Err(_) => Response::LoginFailure, Err(e) => Response::LoginError{ description: format!("{}", e) },
}; };
let resp_bytes = let resp_bytes =