mirror of
https://github.com/coalaura/up.git
synced 2025-07-17 21:44:35 +00:00
improve serverside errors
This commit is contained in:
@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"crypto/rand"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
@ -25,6 +26,16 @@ func LoadAuthorizedKeys() (map[string]ssh.PublicKey, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if _, err := os.Stat(path); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return nil, errors.New("authorized_keys file is missing")
|
||||
} else if os.IsPermission(err) {
|
||||
return nil, errors.New("no permissions to read authorized_keys file")
|
||||
}
|
||||
|
||||
return nil, err
|
||||
}
|
||||
|
||||
keys := make(map[string]ssh.PublicKey)
|
||||
|
||||
data, err := os.ReadFile(path)
|
||||
|
Reference in New Issue
Block a user