cs & io: fix security-guard call in current-directory

This commit is contained in:
Matthew Flatt 2019-07-07 08:27:33 -06:00
parent 79d6b9bc18
commit 839fb84eec

View File

@ -37,30 +37,34 @@
;; ---------------------------------------- ;; ----------------------------------------
(define (make-guard-paths who normalize?) (define (make-guard-paths who normalize?)
(case-lambda (lambda (path)
[() (cond
(security-guard-check-file who #f '(exists)) [(path-string? path)
(values)] (->host path who '(exists))
[(path) (if normalize?
(cond (path->directory-path (simplify-path path))
[(path-string? path) path)]
(->host path who '(exists)) [else path])))
(if normalize?
(path->directory-path (simplify-path path)) (define (make-wrap-paths who)
path)] (lambda (path)
[else path])])) (security-guard-check-file who #f '(exists))
path))
(define/who current-directory (define/who current-directory
(let ([guard (make-guard-paths who #t)]) (make-derived-parameter raw:current-directory
(make-derived-parameter raw:current-directory guard guard))) (make-guard-paths who #t)
(make-wrap-paths who)))
(define/who current-directory-for-path->complete-path (define current-directory-for-path->complete-path
(let ([guard (make-guard-paths 'path->complete-path #f)]) (make-derived-parameter raw:current-directory
(make-derived-parameter raw:current-directory guard guard))) (make-guard-paths 'path->complete-path #f)
(make-wrap-paths 'path->complete-path)))
(define/who current-directory-for-user (define/who current-directory-for-user
(let ([guard (make-guard-paths who #t)]) (make-derived-parameter raw:current-directory-for-user
(make-derived-parameter raw:current-directory-for-user guard guard))) (make-guard-paths who #t)
(make-wrap-paths who)))
(define/who current-load-relative-directory (define/who current-load-relative-directory
(let ([guard (make-guard-paths who #f)]) (let ([guard (make-guard-paths who #f)])