{"size": 2256, "ext": "scrbl", "max_stars_repo_path": "pkgs/racket-doc/scribblings/foreign/file.scrbl", "max_stars_repo_name": "lkh01/racket", "max_stars_repo_stars_event_min_datetime": "2018-07-05T21:18:24.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-04T14:48:37.000Z", "max_issues_repo_path": "pkgs/racket-doc/scribblings/foreign/file.scrbl", "max_issues_repo_name": "lkh01/racket", "max_issues_repo_issues_event_min_datetime": "2017-05-10T07:33:20.000Z", "max_issues_repo_issues_event_max_datetime": "2018-07-19T15:49:46.000Z", "max_forks_repo_path": "pkgs/racket-doc/scribblings/foreign/file.scrbl", "max_forks_repo_name": "lkh01/racket", "max_forks_repo_forks_event_min_datetime": "2016-04-25T11:47:57.000Z", "max_forks_repo_forks_event_max_datetime": "2017-05-09T14:52:48.000Z"}
{"max_stars_count": 4, "max_issues_count": 9, "max_forks_count": 3, "avg_line_length": 32.2285714286, "max_line_length": 83, "alphanum_fraction": 0.6817375887}
#lang scribble/doc
@(require "utils.rkt" (for-label ffi/file))

@title[#:tag "file-security-guard-checks"]{File Security-Guard Checks}

@defmodule[ffi/file]

@defproc[(security-guard-check-file
           [who symbol?]
           [path path-string?]
           [perms (listof (or/c 'read 'write 'execute 'delete 'exists))])
         void?]{

Checks whether @racket[(current-security-guard)] permits access to the
file specified by @racket[path] with the permissions
@racket[perms]. See @racket[make-security-guard] for more information
on @racket[perms].

The symbol @racket[who] should be the name of the function on whose
behalf the security check is performed; it is passed to the security
guard to use in access-denied errors.
}


@defproc[(_file/guard [perms (listof (or/c 'read 'write 'execute 'delete 'exists))]
                      [who symbol? '_file/guard])
         ctype?]{

Like @racket[_file] and @racket[_path], but conversion from Racket to
C first completes the path using @racket[path->complete-path] then
cleanses it using @racket[cleanse-path], then checks that the current
security guard grants access on the resulting complete path with
@racket[perms]. As an output value, identical to @racket[_path].
}

@deftogether[[
@defthing[_file/r ctype?]
@defthing[_file/rw ctype?]]]{

Equivalent to @racket[(_file/guard '(read) '_file/r)] and
@racket[(_file/guard '(read write) '_file/rw)], respectively.}


@defproc[(security-guard-check-file-link
           [who symbol?]
           [path path-string?]
           [dest path-string?])
         void?]{

Checks whether @racket[(current-security-guard)] permits link creation
of @racket[path] as a link @racket[dest]. The symbol @racket[who] is
the same as for @racket[security-guard-check-file].

@history[#:added "6.9.0.5"]}


@defproc[(security-guard-check-network
           [who symbol?]
           [host string?]
           [port (integer-in 1 65535)]
           [mode (or/c 'client 'server)])
         void?]{

Checks whether @racket[(current-security-guard)] permits network
accesst at @racket[host] and @racket[port] in server or client
mode as specified by @racket[mode]. The symbol @racket[who] is the
same as for @racket[security-guard-check-file].

@history[#:added "6.9.0.5"]}
