Skip to content

Commit

Permalink
user/group-information should return #f for unknown users
Browse files Browse the repository at this point in the history
  • Loading branch information
ashinn committed Feb 23, 2024
1 parent 56ef426 commit 19c7d4f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions lib/chibi/system.sld
Original file line number Diff line number Diff line change
Expand Up @@ -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)
(getpwnam_r user (make-string 1024))
(getpwuid_r user (make-string 1024)))))
(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)
(getgrnam_r group (make-string 1024))
(getgrgid_r group (make-string 1024)))))))))
(safe-car (if (string? group)
(getgrnam_r group (make-string 1024))
(getgrgid_r group (make-string 1024)))))))))
4 changes: 2 additions & 2 deletions lib/chibi/tar.scm
Original file line number Diff line number Diff line change
Expand Up @@ -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) ""))
Expand Down

0 comments on commit 19c7d4f

Please sign in to comment.