Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logname(1) returns root on macOS, instead of current user #6196

Open
dennisse opened this issue Sep 25, 2024 · 0 comments
Open

logname(1) returns root on macOS, instead of current user #6196

dennisse opened this issue Sep 25, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@dennisse
Copy link

dennisse commented Sep 25, 2024

What Operating System(s) are you seeing this problem on?

macOS 15.0 Sequoia

Which Wayland compositor or X11 Window manager(s) are you using?

N/A

WezTerm version

20240922-151228-2b76c63b

Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?

Yes, and I updated the version box above to show the version of the nightly that I tried

Describe the bug

When running logname(1) on macOS, it returns root, not the name of the current user.

In Terminal.app and Kitty, the command returns the current user.

To Reproduce

Just run logname(1)

(zsh) % logname
root

(bash) $ logname
root

Configuration

None

Expected Behavior

logname(1) should return the username of the current user.

Logs

N/A

Anything else?

The discussion at kovidgoyal/kitty#6511 seems be related. This is the solution they landed on.

logname(1) calls getlogin(2), and getlogin(2) should return the correct username under a login-shell, but it doesn't.

Launching the shell with login(1) make logname(1) behave as expected, so here is my workaround:

if wezterm.target_triple:find("darwin") ~= nil then
  local USER = os.getenv("USER")
  local SHELL = os.getenv("SHELL")
  config.default_prog = { '/usr/bin/login', '-fpq', USER, SHELL, '-li' }
end
@dennisse dennisse added the bug Something isn't working label Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant