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

Configuration option for specifying the username #1015

Open
panuhorsmalahti opened this issue Aug 11, 2022 · 6 comments
Open

Configuration option for specifying the username #1015

panuhorsmalahti opened this issue Aug 11, 2022 · 6 comments

Comments

@panuhorsmalahti
Copy link

Description

lima creates a default user as specified in https://github.com/lima-vm/lima/blob/master/pkg/cidata/cidata.TEMPLATE.d/user-data#L18, where the username is https://github.com/lima-vm/lima/blob/master/pkg/osutil/user.go#L102. In some cases the username and groups can't be created (example: username docker). While these errors could be handled better, it would be useful to support specifying the username of the created user with e.g. environmental variables.

I propose that env variable LIMA_DEFAULT_USERNAME would be used instead of the current user's username for the default user.

@kwlockwo
Copy link

+1 one for this, my mac username is firstname.lastname which doesn't work with the regex. I would really like to default to this and not lima.

Note I can't seem to find any logs for the warning either.

@maho
Copy link

maho commented Oct 11, 2022

👍

@jandubois
Copy link
Member

jandubois commented Oct 12, 2022

@panuhorsmalahti

I propose that env variable LIMA_DEFAULT_USERNAME would be used instead of the current user's username for the default user.

What is the use case for this? Why would you use a different username than the one on the host? Is the problem that the user already exists inside the OS image you are using?

@kwlockwo

my mac username is firstname.lastname which doesn't work with the regex. I would really like to default to this and not lima.

This would not work with the proposed mechanism; the alternate username would still be subject to the same validation.

The rule exist because many user names from macOS don't work with Linux commands:

$ limactl shell alpine sudo -i
lima-alpine:~# useradd me@example.com
useradd: invalid user name 'me@example.com': use --badname to ignore
lima-alpine:~# useradd firstname.lastname
lima-alpine:~# chown firstname.lastname $HOME
chown: unknown user/group firstname:lastname

As you can see, email addresses don't work with useradd, names with a . don't work with chown. These commands are executed by Lima, as part of cloud-init, to initialize the VM. When they fail, it is difficult to figure out why (because you don't have a working VM that you can ssh into).

I've personally spent multiple days helping users with these issues (and learning about all the wild things organizations use for user names). Yes, at least one person uses Five O'Clock as a macOS username...

Since I don't want to waste any more time of my life debugging these issues, I've added the validation found in upstream tools.

The easiest way to have the same user name inside the VM is to use a simple name for your account on the host (you still have a fullname field for the proper name).

@panuhorsmalahti
Copy link
Author

@jandubois we found out that using username "docker" creates some issues, but there is no way to override the username.

@swalkinshaw
Copy link

I have a Vagrant-like use case which could really benefit from a config option for setting the user. In the Vagrant case, it's always vagrant and the benefit is consistency. Makes it easier for docs and tooling since it's always the same. I have a CLI which basically abstracts limactl and I'd rather not try to match Lima's logic for the user.

The original proposal here was for LIMA_DEFAULT_USERNAME, but I assume it could be a config option as well? I'd be happy to try and contribute this if you're open to it.

@maho
Copy link

maho commented Nov 20, 2022

What is the use case for this? Why would you use a different username than the one on the host? Is the problem that the user already exists inside the OS image you are using?

I use lima to have ... linux in mac. My username in mac is lukasz.mach and I would like to have maho or lmach or at least lukaszmach as my username.

Otherwise when I do git commit the default commiter is some lima not maho. The same with many other tools.

It's quite important for me to have my own username, not default lima.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants