Repository: lima-vm/lima
Pull request #2830 (2024-11-01 16:04:39)

Copy the GECOS information for user
Normally this is the display name.

Mostly unused, these days. (finger?)

```yaml
users:
  - name: "anders"
    uid: "1000"
    gecos: "Anders"
    homedir: "/home/anders.linux"
    ....
```


Patch:
diff --git a/pkg/cidata/cidata.TEMPLATE.d/boot/02-wsl2-setup.sh b/pkg/cidata/cidata.TEMPLATE.d/boot/02-wsl2-setup.sh
index 0b6e9578..ab942215 100755
--- a/pkg/cidata/cidata.TEMPLATE.d/boot/02-wsl2-setup.sh
+++ b/pkg/cidata/cidata.TEMPLATE.d/boot/02-wsl2-setup.sh
@@ -4,7 +4,7 @@
 [ "$LIMA_CIDATA_VMTYPE" = "wsl2" ] || exit 0
 
 # create user
-sudo useradd -u "${LIMA_CIDATA_UID}" "${LIMA_CIDATA_USER}" -d "${LIMA_CIDATA_HOME}"
+sudo useradd -u "${LIMA_CIDATA_UID}" "${LIMA_CIDATA_USER}" -c "${LIMA_CIDATA_GECOS}" -d "${LIMA_CIDATA_HOME}"
 sudo mkdir "${LIMA_CIDATA_HOME}"/.ssh/
 sudo cp "${LIMA_CIDATA_MNT}"/ssh_authorized_keys "${LIMA_CIDATA_HOME}"/.ssh/authorized_keys
 sudo chown "${LIMA_CIDATA_USER}" "${LIMA_CIDATA_HOME}"/.ssh/authorized_keys
diff --git a/pkg/cidata/cidata.TEMPLATE.d/lima.env b/pkg/cidata/cidata.TEMPLATE.d/lima.env
index 0b5737fd..6666b245 100644
--- a/pkg/cidata/cidata.TEMPLATE.d/lima.env
+++ b/pkg/cidata/cidata.TEMPLATE.d/lima.env
@@ -2,6 +2,7 @@ LIMA_CIDATA_DEBUG={{ .Debug }}
 LIMA_CIDATA_NAME={{ .Name }}
 LIMA_CIDATA_USER={{ .User }}
 LIMA_CIDATA_UID={{ .UID }}
+LIMA_CIDATA_GECOS={{ .GECOS }}
 LIMA_CIDATA_HOME={{ .Home}}
 LIMA_CIDATA_HOSTHOME_MOUNTPOINT={{ .HostHomeMountPoint }}
 LIMA_CIDATA_MOUNTS={{ len .Mounts }}
diff --git a/pkg/cidata/cidata.TEMPLATE.d/user-data b/pkg/cidata/cidata.TEMPLATE.d/user-data
index d98d0359..d8ea69e8 100644
--- a/pkg/cidata/cidata.TEMPLATE.d/user-data
+++ b/pkg/cidata/cidata.TEMPLATE.d/user-data
@@ -30,6 +30,9 @@ timezone: {{.TimeZone}}
 users:
   - name: "{{.User}}"
     uid: "{{.UID}}"
+{{- if .GECOS }}
+    gecos: {{ printf "%q" .GECOS }}
+{{- end }}
     homedir: "{{.Home}}"
     shell: /bin/bash
     sudo: ALL=(ALL) NOPASSWD:ALL
diff --git a/pkg/cidata/cidata.go b/pkg/cidata/cidata.go
index 633581d5..b0e60db8 100644
--- a/pkg/cidata/cidata.go
+++ b/pkg/cidata/cidata.go
@@ -132,6 +132,7 @@ func templateArgs(bootScripts bool, instDir, name string, instConfig *limayaml.L
 		Hostname:           identifierutil.HostnameFromInstName(name), // TODO: support customization
 		User:               u.Username,
 		UID:                uid,
+		GECOS:              u.Name,
 		Home:               fmt.Sprintf("/home/%s.linux", u.Username),
 		GuestInstallPrefix: *instConfig.GuestInstallPrefix,
 		UpgradePackages:    *instConfig.UpgradePackages,
diff --git a/pkg/cidata/template.go b/pkg/cidata/template.go
index ff83386d..a927f839 100644
--- a/pkg/cidata/template.go
+++ b/pkg/cidata/template.go
@@ -59,6 +59,7 @@ type TemplateArgs struct {
 	Hostname                        string // instance hostname
 	IID                             string // instance id
 	User                            string // user name
+	GECOS                           string // user information
 	Home                            string // home directory
 	UID                             int
 	SSHPubKeys                      []string
diff --git a/pkg/osutil/user.go b/pkg/osutil/user.go
index 7896d5e4..45b2b7e1 100644
--- a/pkg/osutil/user.go
+++ b/pkg/osutil/user.go
@@ -19,6 +19,7 @@ type User struct {
 	Uid   uint32
 	Group string
 	Gid   uint32
+	Name  string // or Comment
 	Home  string
 }
 
@@ -65,7 +66,7 @@ func LookupUser(name string) (User, error) {
 		if err != nil {
 			return User{}, err
 		}
-		users[name] = User{User: u.Username, Uid: uid, Group: g.Name, Gid: gid, Home: u.HomeDir}
+		users[name] = User{User: u.Username, Uid: uid, Group: g.Name, Gid: gid, Name: u.Name, Home: u.HomeDir}
 	}
 	return users[name], nil
 }
diff --git a/templates/README.md b/templates/README.md
index 8cdd2b0c..d72a0e5b 100644
--- a/templates/README.md
+++ b/templates/README.md
@@ -15,7 +15,7 @@ Distro:
 - [`almalinux-9`](./almalinux-9.yaml), `almalinux.yaml`: AlmaLinux 9
 - [`alpine`](./alpine.yaml): ☆Alpine Linux
 - [`alpine-iso`](./alpine-iso.yaml): ☆Alpine Linux (ISO9660 image). Compatible with the `alpine` template used in Lima prior to v1.0.
-- [`archlinux`](./archlinux.yaml): ☆Arch Linux
+- [`archlinux`](./archlinux.yaml): Arch Linux
 - [`centos-stream-9`](./centos-stream-9.yaml), `centos-stream.yaml`: CentOS Stream 9
 - [`debian-11`](./debian-11.yaml): Debian GNU/Linux 11(bullseye)
 - [`debian-12`](./debian-12.yaml), `debian.yaml`: ⭐Debian GNU/Linux 12(bookworm)
diff --git a/templates/archlinux.yaml b/templates/archlinux.yaml
index 812291d3..34c782f2 100644
--- a/templates/archlinux.yaml
+++ b/templates/archlinux.yaml
@@ -2,9 +2,9 @@
 images:
 # Try to use yyyyMMdd.REV image if available. Note that yyyyMMdd.REV will be removed after several months.
 
-- location: "https://geo.mirror.pkgbuild.com/images/v20241101.275802/Arch-Linux-x86_64-cloudimg-20241101.275802.qcow2"
+- location: "https://geo.mirror.pkgbuild.com/images/v20241001.267073/Arch-Linux-x86_64-cloudimg-20241001.267073.qcow2"
   arch: "x86_64"
-  digest: "sha256:9917535108a7b63811e1eef52d0d66452379a7848227c3b1afd6526900850c6d"
+  digest: "sha256:9e29f8aa543096af97579b6d3f7de627cd5f93dfa1f3f230b8a5ca4fbc3469be"
 - location: "https://github.com/mcginty/arch-boxes-arm/releases/download/v20220323/Arch-Linux-aarch64-cloudimg-20220323.0.qcow2"
   arch: "aarch64"
   digest: "sha512:27524910bf41cb9b3223c8749c6e67fd2f2fdb8b70d40648708e64d6b03c0b4a01b3c5e72d51fefd3e0c3f58487dbb400a79ca378cde2da341a3a19873612be8"
diff --git a/website/content/en/docs/dev/internals/_index.md b/website/content/en/docs/dev/internals/_index.md
index c0c2456e..0d8d6ebb 100644
--- a/website/content/en/docs/dev/internals/_index.md
+++ b/website/content/en/docs/dev/internals/_index.md
@@ -179,6 +179,7 @@ The volume label is "cidata", as defined by [cloud-init NoCloud](https://docs.cl
 - `LIMA_CIDATA_MNT`: the mount point of the disk. `/mnt/lima-cidata`.
 - `LIMA_CIDATA_USER`: the username string
 - `LIMA_CIDATA_UID`: the numeric UID
+- `LIMA_CIDATA_GECOS`: the name or comment string
 - `LIMA_CIDATA_HOME`: the guest home directory
 - `LIMA_CIDATA_HOSTHOME_MOUNTPOINT`: the mount point of the host home directory, or empty if not mounted
 - `LIMA_CIDATA_MOUNTS`: the number of the Lima mounts


Test patch:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 72b87574..c4093c4a 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -243,7 +243,8 @@ jobs:
         - alpine.yaml
         - debian.yaml  # reverse-sshfs
         - fedora.yaml
-        - archlinux.yaml
+        # cloud-init 24.3.1-1 package has a regression: https://github.com/lima-vm/lima/issues/2714
+        # - archlinux.yaml
         - opensuse.yaml
         - docker.yaml
         - ../hack/test-templates/alpine-iso-9p-writable.yaml  # Covers alpine-iso.yaml
@@ -277,6 +278,15 @@ jobs:
       if: matrix.template == '../hack/test-templates/test-misc.yaml'
     - name: "Show cache"
       run: ./hack/debug-cache.sh
+    - name: "Adjust LIMACTL_CREATE_ARGS"
+      # Change the mount type from 9p to reverse-sshfs, as a workaround for:
+      #
+      # > level=fatal msg="failed to get unprivileged mount flags for \"/home/runner/lima-container-engine-test-tmp/random\": stat /home/runner/lima-container-engine-test-tmp/random: no such file or directory"
+      #
+      # The issue is not reproducible on a local MacBook.
+      # https://github.com/lima-vm/lima/issues/2701
+      run: echo "LIMACTL_CREATE_ARGS=${LIMACTL_CREATE_ARGS} --mount-type=reverse-sshfs" >>$GITHUB_ENV
+      if: matrix.template == 'archlinux.yaml'
     - name: "Test"
       uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e  # v3.0.0
       with:
diff --git a/pkg/cidata/template_test.go b/pkg/cidata/template_test.go
index 35c3623e..dbe848ac 100644
--- a/pkg/cidata/template_test.go
+++ b/pkg/cidata/template_test.go
@@ -12,10 +12,11 @@ var defaultRemoveDefaults = false
 
 func TestConfig(t *testing.T) {
 	args := &TemplateArgs{
-		Name: "default",
-		User: "foo",
-		UID:  501,
-		Home: "/home/foo.linux",
+		Name:  "default",
+		User:  "foo",
+		UID:   501,
+		GECOS: "Foo",
+		Home:  "/home/foo.linux",
 		SSHPubKeys: []string{
 			"ssh-rsa dummy foo@example.com",
 		},
@@ -29,10 +30,11 @@ func TestConfig(t *testing.T) {
 
 func TestConfigCACerts(t *testing.T) {
 	args := &TemplateArgs{
-		Name: "default",
-		User: "foo",
-		UID:  501,
-		Home: "/home/foo.linux",
+		Name:  "default",
+		User:  "foo",
+		UID:   501,
+		GECOS: "Foo",
+		Home:  "/home/foo.linux",
 		SSHPubKeys: []string{
 			"ssh-rsa dummy foo@example.com",
 		},