diff --git a/README.md b/README.md index 71355d1..2e16644 100644 --- a/README.md +++ b/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! \ No newline at end of file +- 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": "..." +} +``` \ No newline at end of file diff --git a/config.toml b/config.toml new file mode 100644 index 0000000..98f14ae --- /dev/null +++ b/config.toml @@ -0,0 +1,3 @@ +vt = 2 +greeter = "dlm" +greeter_user = "greeter" diff --git a/greet_proto/src/lib.rs b/greet_proto/src/lib.rs index 09ddba3..888a8fa 100644 --- a/greet_proto/src/lib.rs +++ b/greet_proto/src/lib.rs @@ -74,8 +74,10 @@ impl Request { #[derive(Debug, Deserialize, Serialize)] #[serde(tag = "type")] pub enum Response { - LoginSuccess, - LoginFailure, + Success, + LoginError { + description: String + }, } impl Response { diff --git a/greetctl/src/main.rs b/greetctl/src/main.rs index cf57f86..e710afe 100644 --- a/greetctl/src/main.rs +++ b/greetctl/src/main.rs @@ -44,9 +44,9 @@ fn login() -> Result<(), Box> { 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()) } } } diff --git a/greetd.service b/greetd.service index 6127a75..0beb734 100755 --- a/greetd.service +++ b/greetd.service @@ -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] diff --git a/greetd/src/client.rs b/greetd/src/client.rs index ebb7fd8..46a0da4 100644 --- a/greetd/src/client.rs +++ b/greetd/src/client.rs @@ -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 =