The unpac monorepo manager self-hosting as a monorepo using unpac
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #803 from patricoferris/process-users

Add setuid and setgid fork action

authored by

Thomas Leonard and committed by
GitHub
0c9b461b 481eb4b8

+84 -5
+38
vendor/opam/eio/lib_eio/unix/fork_action.c
··· 258 258 CAMLprim value eio_unix_fork_setpgid(value v_unit) { 259 259 return Val_fork_fn(action_setpgid); 260 260 } 261 + 262 + static void action_setuid(int errors, value v_config) { 263 + #ifdef _WIN32 264 + eio_unix_fork_error(errors, "action_setuid", "Unsupported operation on windows"); 265 + _exit(1); 266 + #else 267 + value v_uid = Field(v_config, 1); 268 + int r; 269 + r = setuid(Int_val(v_uid)); 270 + if (r != 0) { 271 + eio_unix_fork_error(errors, "setuid", strerror(errno)); 272 + _exit(1); 273 + } 274 + #endif 275 + } 276 + 277 + CAMLprim value eio_unix_fork_setuid(value v_unit) { 278 + return Val_fork_fn(action_setuid); 279 + } 280 + 281 + static void action_setgid(int errors, value v_config) { 282 + #ifdef _WIN32 283 + eio_unix_fork_error(errors, "action_setgid", "Unsupported operation on windows"); 284 + _exit(1); 285 + #else 286 + value v_gid = Field(v_config, 1); 287 + int r; 288 + r = setgid(Int_val(v_gid)); 289 + if (r != 0) { 290 + eio_unix_fork_error(errors, "setgid", strerror(errno)); 291 + _exit(1); 292 + } 293 + #endif 294 + } 295 + 296 + CAMLprim value eio_unix_fork_setgid(value v_unit) { 297 + return Val_fork_fn(action_setgid); 298 + }
+10 -1
vendor/opam/eio/lib_eio/unix/fork_action.ml
··· 71 71 72 72 external action_setpgid : unit -> fork_fn = "eio_unix_fork_setpgid" 73 73 let action_setpgid = action_setpgid () 74 - 75 74 let setpgid pgid = 76 75 { run = fun k -> k (Obj.repr (action_setpgid, 0, pgid)) } 76 + 77 + external action_setuid : unit -> fork_fn = "eio_unix_fork_setuid" 78 + let action_setuid = action_setuid () 79 + let setuid uid = { 80 + run = fun k -> k (Obj.repr (action_setuid, uid)) } 81 + 82 + external action_setgid : unit -> fork_fn = "eio_unix_fork_setgid" 83 + let action_setgid = action_setgid () 84 + let setgid gid = { 85 + run = fun k -> k (Obj.repr (action_setgid, gid)) }
+6
vendor/opam/eio/lib_eio/unix/fork_action.mli
··· 64 64 65 65 If [pgid] is [0] the child's process ID will be used as the PGID, placing 66 66 the child in a {e new} process group. *) 67 + 68 + val setuid : int -> t 69 + (** [setuid uid] sets the user ID to [uid]. *) 70 + 71 + val setgid : int -> t 72 + (** [setgid gid] sets the group ID to [gid]. *)
+6 -2
vendor/opam/eio/lib_eio/unix/process.ml
··· 84 84 sw:Switch.t -> 85 85 ?cwd:Eio.Fs.dir_ty Eio.Path.t -> 86 86 ?pgid:int -> 87 + ?uid:int -> 88 + ?gid:int -> 87 89 env:string array -> 88 90 fds:(int * Fd.t * Fork_action.blocking) list -> 89 91 executable:string -> ··· 109 111 sw:Switch.t -> 110 112 ?cwd:Eio.Fs.dir_ty Eio.Path.t -> 111 113 ?pgid:int -> 114 + ?uid:int -> 115 + ?gid:int -> 112 116 env:string array -> 113 117 fds:(int * Fd.t * Fork_action.blocking) list -> 114 118 executable:string -> ··· 140 144 let spawn_unix = X.spawn_unix 141 145 end 142 146 143 - let spawn_unix ~sw (Eio.Resource.T (v, ops)) ?cwd ?pgid ~fds ?env ?executable args = 147 + let spawn_unix ~sw (Eio.Resource.T (v, ops)) ?cwd ?pgid ?uid ?gid ~fds ?env ?executable args = 144 148 let module X = (val (Eio.Resource.get ops Pi.Mgr_unix)) in 145 149 let executable = get_executable executable ~args in 146 150 let env = get_env env in 147 - X.spawn_unix v ~sw ?cwd ?pgid ~fds ~env ~executable args 151 + X.spawn_unix v ~sw ?cwd ?pgid ?uid ?gid ~fds ~env ~executable args 148 152 149 153 let sigchld = Eio.Condition.create () 150 154
+6
vendor/opam/eio/lib_eio/unix/process.mli
··· 21 21 sw:Switch.t -> 22 22 ?cwd:Eio.Fs.dir_ty Eio.Path.t -> 23 23 ?pgid:int -> 24 + ?uid:int -> 25 + ?gid:int -> 24 26 env:string array -> 25 27 fds:(int * Fd.t * Fork_action.blocking) list -> 26 28 executable:string -> ··· 44 46 sw:Switch.t -> 45 47 ?cwd:Eio.Fs.dir_ty Eio.Path.t -> 46 48 ?pgid:int -> 49 + ?uid:int -> 50 + ?gid:int -> 47 51 env:string array -> 48 52 fds:(int * Fd.t * Fork_action.blocking) list -> 49 53 executable:string -> ··· 56 60 _ mgr -> 57 61 ?cwd:Eio.Fs.dir_ty Eio.Path.t -> 58 62 ?pgid:int -> 63 + ?uid:int -> 64 + ?gid:int -> 59 65 fds:(int * Fd.t * Fork_action.blocking) list -> 60 66 ?env:string array -> 61 67 ?executable:string ->
+9 -1
vendor/opam/eio/lib_eio_linux/eio_linux.ml
··· 219 219 module T = struct 220 220 type t = unit 221 221 222 - let spawn_unix () ~sw ?cwd ?pgid ~env ~fds ~executable args = 222 + let spawn_unix () ~sw ?cwd ?pgid ?uid ?gid ~env ~fds ~executable args = 223 223 let actions = Low_level.Process.Fork_action.[ 224 224 Eio_unix.Private.Fork_action.inherit_fds fds; 225 225 execve executable ~argv:(Array.of_list args) ~env ··· 227 227 let actions = match pgid with 228 228 | None -> actions 229 229 | Some pgid -> Eio_unix.Private.Fork_action.setpgid pgid :: actions 230 + in 231 + let actions = match uid with 232 + | None -> actions 233 + | Some uid -> Eio_unix.Private.Fork_action.setuid uid :: actions 234 + in 235 + let actions = match gid with 236 + | None -> actions 237 + | Some gid -> Eio_unix.Private.Fork_action.setgid gid :: actions 230 238 in 231 239 let with_actions cwd fn = match cwd with 232 240 | None -> fn actions
+9 -1
vendor/opam/eio/lib_eio_posix/process.ml
··· 23 23 module T = struct 24 24 type t = unit 25 25 26 - let spawn_unix () ~sw ?cwd ?pgid ~env ~fds ~executable args = 26 + let spawn_unix () ~sw ?cwd ?pgid ?uid ?gid ~env ~fds ~executable args = 27 27 let actions = Low_level.Process.Fork_action.[ 28 28 inherit_fds fds; 29 29 execve executable ~argv:(Array.of_list args) ~env ··· 31 31 let actions = match pgid with 32 32 | None -> actions 33 33 | Some pgid -> Low_level.Process.Fork_action.setpgid pgid :: actions 34 + in 35 + let actions = match uid with 36 + | None -> actions 37 + | Some uid -> Eio_unix.Private.Fork_action.setuid uid :: actions 38 + in 39 + let actions = match gid with 40 + | None -> actions 41 + | Some gid -> Eio_unix.Private.Fork_action.setgid gid :: actions 34 42 in 35 43 let with_actions cwd fn = match cwd with 36 44 | None -> fn actions