
Raymond Toy pushed to branch issue-393-os-common-getpwuid at cmucl / cmucl Commits: af84aebc by Raymond Toy at 2025-03-26T12:47:09-07:00 Handle unicode in the GECOS and home dir fields The GECOS field can contain Unicode characters so we need to decode these to create a Lisp string. Likewise the home directory could contain Unicode characters so we need to decode it too. - - - - - c94bf57a by Raymond Toy at 2025-03-26T12:51:06-07:00 Add a simple test for getpwuid I think the only guaranteed UID that is the same for every OS is 0. Check that we get something reasonably sensible for the root user. - - - - - 2 changed files: - src/code/unix.lisp - tests/unix.lisp Changes: ===================================== src/code/unix.lisp ===================================== @@ -2553,8 +2553,11 @@ :password (string (cast (slot passwd 'pw-passwd) c-call:c-string)) :uid (slot passwd 'pw-uid) :gid (slot passwd 'pw-gid) - :gecos (string (cast (slot passwd 'pw-gecos) c-call:c-string)) - :dir (string (cast (slot passwd 'pw-dir) c-call:c-string)) + ;; The GECOS field could be unicode + :gecos (string-decode (cast (slot passwd 'pw-gecos) c-call:c-string) + :default) + ;; The home directory could be unicode + :dir (%file->name (cast (slot passwd 'pw-dir) c-call:c-string)) :shell (string (cast (slot passwd 'pw-shell) c-call:c-string)))))) (unless (null-alien result) (let ((passwd (deref result))) ===================================== tests/unix.lisp ===================================== @@ -89,3 +89,10 @@ (assert-true (and (integerp errno) (plusp errno))))) +(define-test getpwuid + (:tag :issues) + ;; Check that we get something sensible from unix-getpwuid. + (let ((info (unix:unix-getpwuid 0))) + (assert-true info) + (assert-equal (unix:user-info-name info) + "root"))) View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/2117ed00193d7a44083a2af... -- View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/2117ed00193d7a44083a2af... You're receiving this email because of your account on gitlab.common-lisp.net.
participants (1)
-
Raymond Toy (@rtoy)