change password file directly
This commit is contained in:
parent
18be67f363
commit
07385a6a89
6
main.go
6
main.go
|
@ -154,12 +154,12 @@ func modifyPasswordFile(email, password string) bool {
|
|||
// find the entry with the given email
|
||||
// replace the password with the new password
|
||||
// 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 {
|
||||
log.Println(err)
|
||||
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 {
|
||||
log.Println(err)
|
||||
return false
|
||||
|
@ -174,7 +174,7 @@ func modifyPasswordFile(email, password string) bool {
|
|||
out.WriteString("\n")
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue