summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2026-02-24 12:52:42 +0000
committerGitHub <noreply@github.com>2026-02-24 12:52:42 +0000
commitcced1dd8170d00abb8ded0c6a233c73c5596a4ca (patch)
treedf0ee25abff7fe2d5dc615db18ed06d986561d90 /src
parente70df7b80c3d80a33def819408a2fd4d4823d119 (diff)
parentffde10a863f4da905618139ad1ab03dcf613cfa2 (diff)
downloadvyos-1x-cced1dd8170d00abb8ded0c6a233c73c5596a4ca.tar.gz
vyos-1x-cced1dd8170d00abb8ded0c6a233c73c5596a4ca.zip
Merge pull request #49 from dmbaturin/T8301-fix-root-check
vyos-op-run: T8301: improve the security of UID check and setuid logic
Diffstat (limited to 'src')
-rw-r--r--src/vyos_op_run.ml4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/vyos_op_run.ml b/src/vyos_op_run.ml
index 6299a1d9c..7afa07111 100644
--- a/src/vyos_op_run.ml
+++ b/src/vyos_op_run.ml
@@ -218,7 +218,7 @@ let group_perms_match perms group cmd =
let is_admin () =
(* If executed by root, skip all permission checks *)
- if Unix.geteuid () = 0 then true else
+ if Unix.getuid () = 0 then true else
(* Otherwise, check if the user is a VyOS admin *)
let admin_group = Unix.getgrnam vyos_admin_group_name in
let user_groups = Unix.getgroups () in
@@ -487,10 +487,10 @@ let () =
let () = setup_logging debug in
let op_defs = read_command_definitions () in
let permissions = read_permissions () in
- let () = Unix.setuid 0 in
let () = Logs.debug @@ fun m -> m "Executing VyOS command [%s]" (String.concat " " args) in
try
check_command_permissions permissions args;
+ Unix.setuid 0;
run_vyos_command options ~env:[] ~parent:"" op_defs args
with
| Permission_error ->