list-runtime-roots: Ignore PIDs we cannot access.

This allows running as non-root.
Fixes a regression introduced in b8f59cdc20.

* nix/scripts/list-runtime-roots.in (referenced-files): Handle EACCES in
addition to ENOENT.
master
Ludovic Courtès 2017-11-12 23:52:18 +01:00
parent d0b87779f0
commit 856b68bda9
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 5 additions and 4 deletions

View File

@ -119,10 +119,11 @@ or the empty list."
(proc-maps-roots proc)
(proc-environ-roots proc)))
(lambda args
;; There's a TOCTTOU race that we need to handle.
(if (= ENOENT (system-error-errno args))
'()
(apply throw args))))))
(let ((err (system-error-errno args)))
(if (or (= ENOENT err) ;TOCTTOU race
(= EACCES err)) ;not running as root
'()
(apply throw args)))))))
(scandir %proc-directory string->number
(lambda (a b)
(< (string->number a) (string->number b))))))