summaryrefslogtreecommitdiff
path: root/src/shim
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2024-06-21 21:55:47 -0500
committerMergify <37929162+mergify[bot]@users.noreply.github.com>2024-06-24 17:31:29 +0000
commitf1aa4c49b52e2be287a838560549689b9357a91d (patch)
treec1a3cd54debf74876c5c867a664e786ae5523685 /src/shim
parent340e44c59663d2b94e7b1fddb05c49a3ad737938 (diff)
downloadvyos-1x-f1aa4c49b52e2be287a838560549689b9357a91d.tar.gz
vyos-1x-f1aa4c49b52e2be287a838560549689b9357a91d.zip
configd: T6504: send sudo_user on session init and set env variable
The environment variable SUDO_USER is checked by system_login.py so as to prevent deleting the current user. Provide from config session and set within configd environment. (cherry picked from commit 7016f840f1193399f6ac59fab7faa721049229e8)
Diffstat (limited to 'src/shim')
-rw-r--r--src/shim/vyshim.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/shim/vyshim.c b/src/shim/vyshim.c
index 41723e7a4..4d836127d 100644
--- a/src/shim/vyshim.c
+++ b/src/shim/vyshim.c
@@ -178,6 +178,13 @@ int initialization(void* Requester)
strsep(&pid_val, "_");
debug_print("config session pid: %s\n", pid_val);
+ char *sudo_user = getenv("SUDO_USER");
+ if (!sudo_user) {
+ char nobody[] = "nobody";
+ sudo_user = nobody;
+ }
+ debug_print("sudo_user is %s\n", sudo_user);
+
debug_print("Sending init announcement\n");
char *init_announce = mkjson(MKJSON_OBJ, 1,
MKJSON_STRING, "type", "init");
@@ -240,6 +247,10 @@ int initialization(void* Requester)
zmq_recv(Requester, buffer, 16, 0);
debug_print("Received pid receipt\n");
+ debug_print("Sending config session sudo_user\n");
+ zmq_send(Requester, sudo_user, strlen(sudo_user), 0);
+ zmq_recv(Requester, buffer, 16, 0);
+ debug_print("Received sudo_user receipt\n");
return 0;
}