fix write files and deprecated calls

This commit is contained in:
Mikaël Cluseau
2023-11-27 14:08:44 +01:00
parent 69cc01db9b
commit 86d85f014c
6 changed files with 21 additions and 18 deletions

View File

@ -4,7 +4,6 @@ import (
"bytes"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"os"
@ -121,7 +120,7 @@ func bootstrap(cfg *config.Config) {
func setUserPass(user, passwordHash string) {
const fpath = "/system/etc/shadow"
ba, err := ioutil.ReadFile(fpath)
ba, err := os.ReadFile(fpath)
if err != nil {
fatalf("failed to read shadow: %v", err)
}
@ -144,7 +143,7 @@ func setUserPass(user, passwordHash string) {
buf.WriteByte('\n')
}
err = ioutil.WriteFile(fpath, buf.Bytes(), 0600)
err = os.WriteFile(fpath, buf.Bytes(), 0600)
if err != nil {
fatalf("failed to write shadow: %v", err)
}
@ -163,7 +162,7 @@ func setAuthorizedKeys(ak []string) {
fatalf("failed to create %s: %v", sshDir, err)
}
err = ioutil.WriteFile(filepath.Join(sshDir, "authorized_keys"), buf.Bytes(), 0600)
err = os.WriteFile(filepath.Join(sshDir, "authorized_keys"), buf.Bytes(), 0600)
if err != nil {
fatalf("failed to write authorized keys: %v", err)
}