change password file directly

This commit is contained in:
josh 2024-05-07 07:55:22 -04:00
parent 18be67f363
commit 07385a6a89
1 changed files with 3 additions and 3 deletions

View File

@ -154,12 +154,12 @@ func modifyPasswordFile(email, password string) bool {
// find the entry with the given email // find the entry with the given email
// replace the password with the new password // replace the password with the new password
// write the file back // write the file back
in, err := os.ReadFile("/root/docker/mail/config/postfix-accounts") in, err := os.ReadFile("/root/docker/mail/config/postfix-accounts.cf")
if err != nil { if err != nil {
log.Println(err) log.Println(err)
return false return false
} }
out, err := os.Create("/root/docker/mail/config/postfix-accounts.tmp") out, err := os.Create("/root/docker/mail/config/postfix-accounts.cf.tmp")
if err != nil { if err != nil {
log.Println(err) log.Println(err)
return false return false
@ -174,7 +174,7 @@ func modifyPasswordFile(email, password string) bool {
out.WriteString("\n") out.WriteString("\n")
} }
out.Close() out.Close()
os.Rename("/root/docker/mail/config/postfix-accounts.tmp", "/root/docker/mail/config/postfix-accounts") os.Rename("/root/docker/mail/config/postfix-accounts.cf.tmp", "/root/docker/mail/config/postfix-accounts.cf")
return true return true
} }