put password in a file in user's home folder

This commit is contained in:
Arya Kiran 2023-01-08 15:55:26 +05:30
parent 5672b6a520
commit 44b5af735c
Signed by untrusted user who does not match committer: arya
GPG Key ID: 842D12BDA50DF120

View File

@ -39,9 +39,12 @@ func SignupPage(c *fiber.Ctx) error {
bashscript := "#!/bin/bash \n" +
"# Path: /var/publapi/users/" + username + ".sh\n" +
"# This file is generated by publapi. Do not edit this file.\n" +
"pass=\"$(tr -dc A-Za-z0-9 </dev/urandom | head -c 64)\"" +
"pass=\"$(tr -dc A-Za-z0-9 </dev/urandom | head -c 64)\"\n" +
"useradd -Um -s /bin/bash " + username + "\n" +
"printf \"%s\\n%s\" \"${pass}\" \"${pass}\" | passwd " + username + "\n" +
"echo \"${pass}\" > /home/" + username + "/pass\n" +
"chmod 600 /home/" + username + "/pass\n" +
"chown " + username + ":" + username + " /home/" + username + "/pass\n" +
"echo \"" + username + "'s account has been created!\""