~kennylevinsen/greetd

1bc6ddbf67397494b7097e92a901344782d394ae — Kenny Levinsen 4 years ago b709d2b
Remove 'env' from start_session

It was entirely unused, and was complicating a change. It is only
necessary if we need to pass arguments to PAM, as other environment
variables can be loaded by the started command.

This feature can be revisited in the future if it becomes necessary.
M agreety/src/main.rs => agreety/src/main.rs +0 -1
@@ 105,7 105,6 @@ fn login(node: &str, cmd: &mut Option<String>) -> Result<LoginResult, Box<dyn st
                        None => prompt_stderr("Command: ")?,
                    };
                    next_request = Request::StartSession {
                        env: vec![],
                        cmd: vec![command.to_string()],
                    }
                }

M greet_proto/src/lib.rs => greet_proto/src/lib.rs +1 -1
@@ 68,7 68,7 @@ pub enum Request {

    /// Start a successfully logged in session. This will fail if the session
    /// has pending messages or has encountered an error.
    StartSession { cmd: Vec<String>, env: Vec<String> },
    StartSession { cmd: Vec<String> },

    /// Cancel a session. This can only be done if the session has not been
    /// started. Cancel does not have to be called if an error has been

M greetd/src/context.rs => greetd/src/context.rs +3 -3
@@ 69,7 69,7 @@ impl Context {
        }

        scheduled_session
            .send_args(vec![self.greeter_bin.to_string()], vec![], self.vt)
            .send_args(vec![self.greeter_bin.to_string()], self.vt)
            .await?;
        scheduled_session.start().await
    }


@@ 168,14 168,14 @@ impl Context {
    }

    /// Schedule the session under configuration with the provided arguments.
    pub async fn start(&self, cmd: Vec<String>, env: Vec<String>) -> Result<(), Error> {
    pub async fn start(&self, cmd: Vec<String>) -> Result<(), Error> {
        let mut session = self.inner.write().await.configuring.take();

        match &mut session {
            Some(s) => match s.session.get_state().await? {
                SessionState::Ready => {
                    // Send our arguments to the session.
                    s.session.send_args(cmd, env, self.vt).await?;
                    s.session.send_args(cmd, self.vt).await?;

                    let mut inner = self.inner.write().await;
                    std::mem::swap(&mut session, &mut inner.scheduled);

M greetd/src/server.rs => greetd/src/server.rs +1 -1
@@ 68,7 68,7 @@ async fn client_handler(ctx: &Context, mut s: UnixStream) -> Result<(), Error> {
                    res => wrap_result(res),
                }
            }
            Request::StartSession { cmd, env } => wrap_result(ctx.start(cmd, env).await),
            Request::StartSession { cmd } => wrap_result(ctx.start(cmd).await),
            Request::CancelSession => wrap_result(ctx.cancel().await),
        };


M greetd/src/session/interface.rs => greetd/src/session/interface.rs +1 -2
@@ 191,10 191,9 @@ impl Session {
    pub async fn send_args(
        &mut self,
        cmd: Vec<String>,
        env: Vec<String>,
        vt: usize,
    ) -> Result<(), Error> {
        let msg = ParentToSessionChild::Args { vt, env, cmd };
        let msg = ParentToSessionChild::Args { vt, cmd };
        msg.send(&mut self.sock).await?;

        let msg = SessionChildToParent::recv(&mut self.sock).await?;

M greetd/src/session/worker.rs => greetd/src/session/worker.rs +3 -4
@@ 35,7 35,6 @@ pub enum ParentToSessionChild {
    },
    Args {
        vt: usize,
        env: Vec<String>,
        cmd: Vec<String>,
    },
    Start,


@@ 93,8 92,8 @@ fn worker(sock: &UnixDatagram) -> Result<(), Error> {
    SessionChildToParent::Success.send(sock)?;

    // Fetch our arguments from the parent.
    let (vt, env, cmd) = match ParentToSessionChild::recv(sock)? {
        ParentToSessionChild::Args { vt, env, cmd } => (vt, env, cmd),
    let (vt, cmd) = match ParentToSessionChild::recv(sock)? {
        ParentToSessionChild::Args { vt, cmd } => (vt, cmd),
        ParentToSessionChild::Cancel => return Err("cancelled".into()),
        _ => return Err("unexpected message".into()),
    };


@@ 185,7 184,7 @@ fn worker(sock: &UnixDatagram) -> Result<(), Error> {
        ),
    ];

    for e in prepared_env.iter().chain(env.iter()) {
    for e in prepared_env.iter() {
        pam.putenv(e)?;
    }


M man/greetd-ipc-7.scd => man/greetd-ipc-7.scd +2 -2
@@ 46,8 46,8 @@ following hexdump:
:  response (string, optional)
:  Answers an authentication message. If the message was informative (info, error), then a response does not need to be set in this message. The session is ready to be started if a success is returned.
|  start_session
:  cmd (array of strings), env (array of strings)
:  Requests for the session to be started using the provided command line, adding the supplied environment to that created by PAM. The session will start after the greeter process terminates.
:  cmd (array of strings)
:  Requests for the session to be started using the provided command line. The session will start after the greeter process terminates.
|  cancel_session
: 
:  Cancels the session that is currently under configuration.