revert: undo elevate env forwarding
Reverts971c8a9and0c6ea9c. The env wrapping approach polluted the superpowerd notification with all env vars, making it impossible to see what command was being approved.
This commit is contained in:
parent
0c6ea9cca2
commit
8e3e35da73
|
|
@ -44,7 +44,7 @@ def main():
|
|||
print("usage: elevate -- <cmd>", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
req = json.dumps({"cmd": sys.argv[2], "cwd": os.getcwd(), "env": dict(os.environ)}).encode() + b"\n"
|
||||
req = json.dumps({"cmd": sys.argv[2], "cwd": os.getcwd()}).encode() + b"\n"
|
||||
|
||||
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -345,28 +345,6 @@ def handle(conn):
|
|||
pass
|
||||
|
||||
|
||||
def _wrap_with_env(cmd, env):
|
||||
"""Wrap a command with env vars that differ from the adapter's own env.
|
||||
|
||||
Only exports the delta so the command string stays readable in
|
||||
superpowerd notifications. Vars that match the session env are
|
||||
already inherited.
|
||||
"""
|
||||
import shlex
|
||||
adapter_env = os.environ
|
||||
diff = {}
|
||||
for k, v in env.items():
|
||||
if adapter_env.get(k) != v:
|
||||
diff[k] = v
|
||||
if not diff:
|
||||
return cmd
|
||||
parts = ["env"]
|
||||
for k, v in sorted(diff.items()):
|
||||
parts.append(f"{k}={v}")
|
||||
parts.extend(["bash", "-c", cmd])
|
||||
return " ".join(shlex.quote(p) for p in parts)
|
||||
|
||||
|
||||
def _handle_inner(conn):
|
||||
data = b""
|
||||
while chunk := conn.recv(65536):
|
||||
|
|
@ -382,12 +360,6 @@ def _handle_inner(conn):
|
|||
|
||||
cmd = req.get("cmd", "")
|
||||
cwd = req.get("cwd", os.getcwd())
|
||||
env = req.get("env")
|
||||
|
||||
# If the client sent its environment, wrap the command to reproduce it.
|
||||
# This ensures the elevated command sees the agent's env, not the adapter's.
|
||||
if env and isinstance(env, dict):
|
||||
cmd = _wrap_with_env(cmd, env)
|
||||
|
||||
token = os.environ.get("SUPERPOWERD_SESSION_TOKEN", "")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue