Ensure the cwd is not changed, whilst remaining a logon shell

This commit is contained in:
Matthew Winter
2023-12-30 05:40:07 +11:00
parent 9989436beb
commit 992888d4bd

View File

@ -841,6 +841,12 @@ const Subprocess = struct {
break :hush if (dir.access(".hushlogin", .{})) true else |_| false; break :hush if (dir.access(".hushlogin", .{})) true else |_| false;
} else false; } else false;
const cmd = try std.fmt.allocPrint(
alloc,
"exec -l {s}",
.{opts.full_config.command orelse default_path},
);
// The reason for executing login this way is unclear. This // The reason for executing login this way is unclear. This
// comment will attempt to explain but prepare for a truly // comment will attempt to explain but prepare for a truly
// unhinged reality. // unhinged reality.
@ -883,9 +889,11 @@ const Subprocess = struct {
// Awesome. // Awesome.
try args.append("/usr/bin/login"); try args.append("/usr/bin/login");
if (hush) try args.append("-q"); if (hush) try args.append("-q");
try args.append("-fp"); try args.append("-flp");
try args.append(username); try args.append(username);
try args.append(opts.full_config.command orelse default_path); try args.append("/bin/sh");
try args.append("-c");
try args.append(cmd);
break :args try args.toOwnedSlice(); break :args try args.toOwnedSlice();
} }