M agreety/src/main.rs => agreety/src/main.rs +1 -0
@@ 107,6 107,7 @@ 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 fakegreet/src/main.rs => fakegreet/src/main.rs +1 -1
@@ 137,7 137,7 @@ async fn client_handler(ctx: &Context, mut s: UnixStream) -> Result<(), Error> {
res => wrap_result(res),
}
}
- Request::StartSession { cmd } => wrap_result(ctx.start(cmd).await),
+ Request::StartSession { cmd, env: _ } => wrap_result(ctx.start(cmd).await),
Request::CancelSession => wrap_result(ctx.cancel().await),
};
M greetd/src/context.rs => greetd/src/context.rs +3 -3
@@ 103,7 103,7 @@ impl Context {
}
}
- scheduled_session.send_args(cmd).await?;
+ scheduled_session.send_args(cmd, vec![]).await?;
scheduled_session.start().await
}
@@ 253,14 253,14 @@ impl Context {
}
/// Schedule the session under configuration with the provided arguments.
- pub async fn start(&self, cmd: Vec<String>) -> Result<(), Error> {
+ pub async fn start(&self, cmd: Vec<String>, env: 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).await?;
+ s.session.send_args(cmd, env).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
@@ 85,7 85,7 @@ async fn client_handler(ctx: &Context, mut s: UnixStream) -> Result<(), Error> {
res => wrap_result(res),
}
}
- Request::StartSession { cmd } => wrap_result(ctx.start(cmd).await),
+ Request::StartSession { cmd, env } => wrap_result(ctx.start(cmd, env).await),
Request::CancelSession => wrap_result(ctx.cancel().await),
};
M greetd/src/session/interface.rs => greetd/src/session/interface.rs +2 -2
@@ 193,8 193,8 @@ impl Session {
///
/// Send the arguments that will be used to start the session.
///
- pub async fn send_args(&mut self, cmd: Vec<String>) -> Result<(), Error> {
- let msg = ParentToSessionChild::Args { cmd };
+ pub async fn send_args(&mut self, cmd: Vec<String>, env: Vec<String>) -> Result<(), Error> {
+ let msg = ParentToSessionChild::Args { env, 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 +4 -3
@@ 46,6 46,7 @@ pub enum ParentToSessionChild {
resp: Option<String>,
},
Args {
+ env: Vec<String>,
cmd: Vec<String>,
},
Start,
@@ 110,8 111,8 @@ fn worker(sock: &UnixDatagram) -> Result<(), Error> {
SessionChildToParent::Success.send(sock)?;
// Fetch our arguments from the parent.
- let cmd = match ParentToSessionChild::recv(sock)? {
- ParentToSessionChild::Args { cmd } => cmd,
+ let (env, cmd) = match ParentToSessionChild::recv(sock)? {
+ ParentToSessionChild::Args { env, cmd } => (env, cmd),
ParentToSessionChild::Cancel => return Err("cancelled".into()),
msg => return Err(format!("expected Args or Cancel, got: {:?}", msg).into()),
};
@@ 200,7 201,7 @@ fn worker(sock: &UnixDatagram) -> Result<(), Error> {
),
];
- for e in prepared_env.iter() {
+ for e in prepared_env.iter().chain(env.iter()) {
pam.putenv(e)?;
}
M greetd_ipc/src/lib.rs => greetd_ipc/src/lib.rs +1 -1
@@ 75,7 75,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> },
+ StartSession { cmd: Vec<String>, env: 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 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)
-: Requests for the session to be started using the provided command line. The session will start after the greeter process terminates.
+: 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.
| cancel_session
:
: Cancels the session that is currently under configuration.