
Raymond Toy pushed to branch issue-393-os-common-getpwuid at cmucl / cmucl Commits: 99b585ab by Raymond Toy at 2025-03-28T12:26:46-07:00 Add unix_passwd strucc to define the result of os_getpwuid We don't want os_getpwuid returning the OS passwd structure because it's not necessarily the same everywhere. Define our own unix_passwd struct to hold the result of os_getpwuid. Add this definition to unix.lisp, replacing the old definition. - - - - - 2 changed files: - src/code/unix.lisp - src/lisp/os-common.c Changes: ===================================== src/code/unix.lisp ===================================== @@ -2417,9 +2417,12 @@ ;; ;; While each OS may contain additional fields, we only need the ones ;; that are used the user-info structure. +;; +;; NOTE: This may NOT be the actual OS-defined passwd structure. It +;; is the structure returned by os_getpwuid (in unix-getpwuid). (def-alien-type nil - (struct passwd + (struct unix-passwd (pw-name (* char)) ; user's login name (pw-passwd (* char)) ; no longer used (pw-uid uid-t) ; user id ===================================== src/lisp/os-common.c ===================================== @@ -946,7 +946,22 @@ os_get_user_homedir(const char* name, int *status) * The caller MUST call os_free_getpwuid() to free the space allocated * by os_getpwuid(). */ -struct passwd* + +/* + * This MUST match the definition in code/unix.lisp. + */ +struct unix_passwd +{ + char* pw_name; + char* pw_passwd; + uid_t pw_uid; + gid_t pw_gid; + char* pw_gecos; + char* pw_dir; + char* pw_shell; +}; + +struct unix_passwd* os_getpwuid(uid_t uid) { char initial[1024]; @@ -954,7 +969,7 @@ os_getpwuid(uid_t uid) size_t size; struct passwd pwd; struct passwd *ppwd; - struct passwd *result = NULL; + struct unix_passwd *result = NULL; buffer = initial; obuffer = NULL; @@ -973,7 +988,7 @@ again: * that. */ if (ppwd != NULL) { - result = (struct passwd*) malloc(sizeof(pwd)); + result = (struct unix_passwd*) malloc(sizeof(pwd)); result->pw_name = strdup(pwd.pw_name); result->pw_passwd = strdup(pwd.pw_passwd); result->pw_uid = pwd.pw_uid; View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/99b585abb401a2f2833d424c... -- View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/99b585abb401a2f2833d424c... You're receiving this email because of your account on gitlab.common-lisp.net.
participants (1)
-
Raymond Toy (@rtoy)