user/group-information should return #f for unknown users

This commit is contained in:
Alex Shinn 2024-02-23 15:16:22 +09:00
parent 56ef426dfa
commit 19c7d4fec2
2 changed files with 9 additions and 8 deletions

View file

@ -17,11 +17,12 @@
(else
(export user-information group-information)
(body
(define (safe-car x) (and (pair? x) (car x)))
(define (user-information user)
(car (if (string? user)
(safe-car (if (string? user)
(getpwnam_r user (make-string 1024))
(getpwuid_r user (make-string 1024)))))
(define (group-information group)
(car (if (string? group)
(safe-car (if (string? group)
(getgrnam_r group (make-string 1024))
(getgrgid_r group (make-string 1024)))))))))

View file

@ -24,9 +24,9 @@
#u8(0 0 0 0 0 0 0 0 0 0 0 0)))
(define (file-owner-or-nobody uid)
(or (user-name (user-information uid)) "nobody"))
(or (cond ((user-information uid) => user-name) (else #f)) "nobody"))
(define (file-group-or-nobody gid)
(or (group-name (group-information gid)) "nobody"))
(or (cond ((group-information gid) => group-name) (else #f)) "nobody"))
(define (make-tar file mode uid gid size mod-time type . o)
(let* ((link (if (pair? o) (car o) ""))