check for --privhelper_path when deciding whether to use sudo

Summary:
When running the Eden tests using buck2, this flag is used because the
privhelper is not immediately next to the EdenFS binary.

This diff updates the approximation of the privhelper path introduced in
D31870880 (710f03501d) accordingly so that it also works in this case.

Reviewed By: xavierd

Differential Revision: D32070038

fbshipit-source-id: c111cc533bb9e9d111bfe9bad71e817655b3d613
This commit is contained in:
Thomas Orozco 2021-11-01 13:39:44 -07:00 committed by Facebook GitHub Bot
parent a7e55e597a
commit f3839fc2f8

View File

@ -210,6 +210,16 @@ def prepare_edenfs_privileges(
return (cmd, env)
privhelper = os.path.join(os.path.dirname(daemon_binary), "edenfs_privhelper")
# EdenFS accepts a privhelper_path argument to locate the privhelper, so if
# we are about to pass that we should extract it.
next_arg_is_privhelper = False
for arg in cmd:
if next_arg_is_privhelper:
privhelper = arg
break
next_arg_is_privhelper = arg == "--privhelper_path"
# If the EdenFS privhelper is installed as setuid root we don't need to use
# sudo.
try: