fix write files and deprecated calls
This commit is contained in:
@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user