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

Make guest username, uid, home directory configurable #2827

Merged
merged 1 commit into from
Nov 2, 2024

Conversation

jandubois
Copy link
Member

@jandubois jandubois commented Nov 1, 2024

Also disallows the "admin" username by default (because it is a builtin user in Ubuntu), but can be overridden by setting it explicitly in lima.yaml.

user:
  name: john
  comment: John Doe
  uid: 1000
  home: "/home/{{.User}}"

Another change is that {{.User}} and {{.UID}} in host templates now expand to the host values and not the guest values. Note that on Windows the host user is something like runner\runneradmin and host uid something like S-1-5-21-2897396845-3571823323-1290545657-500 (on GitHub runner).

Setting home and comment does not work yet with alpine-iso because lima-init hardcodes the home directory to /home/$USER.linux and doesn't set the comment at all (implemented in lima-vm/alpine-lima#134).

Fixes #2117
Fixes #2037
Implements #2622

Replaces #2378

@jandubois jandubois force-pushed the username branch 7 times, most recently from bc70c89 to 6279d7a Compare November 1, 2024 04:04
@jandubois jandubois marked this pull request as ready for review November 1, 2024 04:45
@jandubois
Copy link
Member Author

I recommend using "Hide whitespace" for reviewing this PR, especially for osutil/user.go.

@jandubois jandubois requested a review from a team November 1, 2024 04:46
@jandubois jandubois added this to the v1.0 milestone Nov 1, 2024
@afbjorklund

This comment was marked as resolved.

templates/default.yaml Outdated Show resolved Hide resolved
@afbjorklund
Copy link
Member

  • The code also implements support for setting user.gid but doesn't document it because cloud-init has no way to set it. We'll have to implement this ourselves in our ci scripts (if we want it).

In terms of features, it probably would be more useful to have "groups" (extra groups) than "gid" (not used so much)

templates/default.yaml Outdated Show resolved Hide resolved
templates/default.yaml Outdated Show resolved Hide resolved
templates/default.yaml Outdated Show resolved Hide resolved
templates/default.yaml Outdated Show resolved Hide resolved
pkg/osutil/user.go Outdated Show resolved Hide resolved
@jandubois
Copy link
Member Author

Should there be an option to avoid "mirroring" the host values, and go with the default ones from the cloud.cfg?

I don't know how we would set up ssh without knowing the username. If we can figure this out, then I think we should support this.

@jandubois
Copy link
Member Author

In terms of features, it probably would be more useful to have "groups" (extra groups) than "gid" (not used so much)

I have removed all code related to gid, so we can figure out the correct schema in due time.

Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The go name and the yaml name are inconsistent.

@jandubois
Copy link
Member Author

I'm wondering if {{.Comment}} should be supported in host/guest templates. It would be easy to add, but I can't think of an actual use-case.

@jandubois
Copy link
Member Author

I believe I've addressed all feedback now, PTAL

There are 2 open issues that should probably be done "later":

  • Optionally don't add an additional user at all (but how do we set up ssh keys?)
  • Add {{.Comment}} to host and guest templates (but why?)

pkg/limayaml/defaults.go Fixed Show fixed Hide fixed
Also disallows the "admin" username by default (because it is a builtin
user in Ubuntu), but can be overridden by setting it explicitly in lima.yaml.

Signed-off-by: Jan Dubois <[email protected]>
Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@AkihiroSuda AkihiroSuda merged commit 9c21e15 into lima-vm:master Nov 2, 2024
29 checks passed
@afbjorklund
Copy link
Member

afbjorklund commented Nov 2, 2024

I'm wondering if {{.Comment}} should be supported in host/guest templates. It would be easy to add, but I can't think of an actual use-case.

I don't actually know the use case for GECOS (even finger has been removed, for "pinky") - it was just that all the cloud-config examples had gecos...

$ lima pinky $USER
Login    Name                 TTY      Idle   When             Where
anders   Anders               pts/0           2024-11-02 09:27 192.168.5.2

For the templates though, no idea.

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