From dac23225b3ba29749012a80aee77403b4286eb52 Mon Sep 17 00:00:00 2001 From: Eric Gu <69128383+skybound0@users.noreply.github.com> Date: Wed, 29 Apr 2026 15:11:24 -0700 Subject: [PATCH 1/2] change username retrieval to use ORIGINAL_USER env var pwd fetch would return mysql instead of user running the script --- makeservices/makemysql-real | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/makeservices/makemysql-real b/makeservices/makemysql-real index 038b9b9..3c993d2 100755 --- a/makeservices/makemysql-real +++ b/makeservices/makemysql-real @@ -80,10 +80,10 @@ def main(): # Without this quiet below will be local variable global quiet try: - username = pwd.getpwuid(os.getuid()).pw_name + username = os.environ.get('ORIGINAL_USER') if not username: - raise RuntimeError('Unable to read pwd.getpwuid(os.getuid()).pw_name.') + raise RuntimeError('Unable to read ORIGINAL_USER.') # Read config file. mysql_host, mysql_root_pw = read_config() From 478f84a96edbf3ec0627fd930c7308c6cf590e9f Mon Sep 17 00:00:00 2001 From: Eric Gu <69128383+skybound0@users.noreply.github.com> Date: Wed, 29 Apr 2026 15:12:23 -0700 Subject: [PATCH 2/2] add ORIGINAL_USER env variable pass pass the original user to makemysql-real --- makeservices/makemysql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makeservices/makemysql b/makeservices/makemysql index a1a324e..f21ea9b 100755 --- a/makeservices/makemysql +++ b/makeservices/makemysql @@ -30,7 +30,7 @@ done # makemysql-real will output the new password ONLY on the # last line. The --quiet will also make sure it only output the password... -if ! PASS=$(sudo -u mysql /run/current-system/sw/bin/makemysql-real --quiet) ; then +if ! PASS=$(sudo -u mysql ORIGINAL_USER=$USER /run/current-system/sw/bin/makemysql-real --quiet) ; then echo 'makemysql-real did not exit properly.' echo 'Run "sudo -u mysql /run/current-system/sw/bin/makemysql-real" for a more verbose output.' echo 'Additionally, you may contact staff members for help. This script will stop.'