diff options
| author | Damien Doligez <damien.doligez@inria.fr> | 2017-06-23 17:32:50 +0200 |
|---|---|---|
| committer | Damien Doligez <damien.doligez@inria.fr> | 2017-06-23 17:55:46 +0200 |
| commit | 15966dbeaacc4051ecfbf9c5ac0407b805b211b4 (patch) | |
| tree | 260f10816594ef7b2f6ad404560b3af8a6a67009 /otherlibs | |
| parent | ac6dbd49ace4e0caf6a63507b6947ab67e4b1b78 (diff) | |
| download | ocaml-15966dbeaacc4051ecfbf9c5ac0407b805b211b4.tar.gz | |
cherry-pick the fix for MPR#7557 from 4.04
Diffstat (limited to 'otherlibs')
| -rw-r--r-- | otherlibs/unix/unix.ml | 1 | ||||
| -rw-r--r-- | otherlibs/unix/unix.mli | 19 | ||||
| -rw-r--r-- | otherlibs/unix/unixLabels.mli | 14 | ||||
| -rw-r--r-- | otherlibs/win32unix/unix.ml | 1 |
4 files changed, 33 insertions, 2 deletions
diff --git a/otherlibs/unix/unix.ml b/otherlibs/unix/unix.ml index de379c9639..b760bc144c 100644 --- a/otherlibs/unix/unix.ml +++ b/otherlibs/unix/unix.ml @@ -187,6 +187,7 @@ let handle_unix_error f arg = external environment : unit -> string array = "unix_environment" external getenv: string -> string = "caml_sys_getenv" +(* external unsafe_getenv: string -> string = "caml_sys_unsafe_getenv" *) external putenv: string -> string -> unit = "unix_putenv" type process_status = diff --git a/otherlibs/unix/unix.mli b/otherlibs/unix/unix.mli index 2c69433852..0d7db1ea72 100644 --- a/otherlibs/unix/unix.mli +++ b/otherlibs/unix/unix.mli @@ -125,10 +125,25 @@ val environment : unit -> string array val getenv : string -> string (** Return the value associated to a variable in the process + environment, unless the process has special privileges. + @raise Not_found if the variable is unbound or the process has + special privileges. + + (This function is identical to {!Sys.getenv}. *) + +(* +val unsafe_getenv : string -> string +(** Return the value associated to a variable in the process environment. - @raise Not_found if the variable is unbound. - (This function is identical to {!Sys.getenv}.) *) + Unlike {!getenv}, this function returns the value even if the + process has special privileges. It is considered unsafe because the + programmer of a setuid program must be careful to prevent execution + of arbitrary commands through manipulation of the environment + variables. + + @raise Not_found if the variable is unbound. *) +*) val putenv : string -> string -> unit (** [Unix.putenv name value] sets the value associated to a diff --git a/otherlibs/unix/unixLabels.mli b/otherlibs/unix/unixLabels.mli index b65e8b12dc..c6289cab80 100644 --- a/otherlibs/unix/unixLabels.mli +++ b/otherlibs/unix/unixLabels.mli @@ -126,6 +126,20 @@ val getenv : string -> string environment. Raise [Not_found] if the variable is unbound. (This function is identical to [Sys.getenv].) *) +(* +val unsafe_getenv : string -> string +(** Return the value associated to a variable in the process + environment. + + Unlike {!getenv}, this function returns the value even if the + process has special privileges. It is considered unsafe because the + programmer of a setuid program must be careful to prevent execution + of arbitrary commands through manipulation of the environment + variables. + + @raise Not_found if the variable is unbound. *) +*) + val putenv : string -> string -> unit (** [Unix.putenv name value] sets the value associated to a variable in the process environment. diff --git a/otherlibs/win32unix/unix.ml b/otherlibs/win32unix/unix.ml index 8adc319b42..5a0e315940 100644 --- a/otherlibs/win32unix/unix.ml +++ b/otherlibs/win32unix/unix.ml @@ -122,6 +122,7 @@ let handle_unix_error f arg = external environment : unit -> string array = "unix_environment" external getenv: string -> string = "caml_sys_getenv" +(* external unsafe_getenv: string -> string = "caml_sys_unsafe_getenv" *) external putenv: string -> string -> unit = "unix_putenv" type process_status = |
