mirror of
https://github.com/drakkan/sftpgo.git
synced 2024-11-21 23:20:24 +00:00
fix misspells and ineffectual assignments
This commit is contained in:
parent
1019d74243
commit
22b8dc7f1d
7 changed files with 33 additions and 18 deletions
|
@ -153,7 +153,7 @@ func TestUpdateUserNoCredentials(t *testing.T) {
|
|||
}
|
||||
user.Password = ""
|
||||
user.PublicKey = ""
|
||||
// password and public key will be ommitted from json serialization if empty and so they will remain unchanged
|
||||
// password and public key will be omitted from json serialization if empty and so they will remain unchanged
|
||||
// and no validation error will be raised
|
||||
_, err = api.UpdateUser(user, http.StatusOK)
|
||||
if err != nil {
|
||||
|
@ -252,10 +252,16 @@ func TestGetUsers(t *testing.T) {
|
|||
t.Errorf("at least 2 users are expected")
|
||||
}
|
||||
users, err = api.GetUsers(1, 0, "", http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to get users: %v", err)
|
||||
}
|
||||
if len(users) != 1 {
|
||||
t.Errorf("1 user are expected")
|
||||
}
|
||||
users, err = api.GetUsers(1, 1, "", http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to get users: %v", err)
|
||||
}
|
||||
if len(users) != 1 {
|
||||
t.Errorf("1 user are expected")
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ func sqlCommonValidateUserAndPass(username string, password string) (User, error
|
|||
if err != nil {
|
||||
logger.Warn(logSender, "error authenticating user: %v, error: %v", username, err)
|
||||
} else {
|
||||
match := false
|
||||
var match bool
|
||||
if strings.HasPrefix(user.Password, argonPwdPrefix) {
|
||||
match, err = argon2id.ComparePasswordAndHash(password, user.Password)
|
||||
if err != nil {
|
||||
|
@ -63,19 +63,20 @@ func sqlCommonValidateUserAndPubKey(username string, pubKey string) (User, error
|
|||
user, err := getUserByUsername(username)
|
||||
if err != nil {
|
||||
logger.Warn(logSender, "error authenticating user: %v, error: %v", username, err)
|
||||
} else {
|
||||
if len(user.PublicKey) > 0 {
|
||||
storedPubKey, _, _, _, err := ssh.ParseAuthorizedKey([]byte(user.PublicKey))
|
||||
if err != nil {
|
||||
logger.Warn(logSender, "error parsing stored public key for user %v: %v", username, err)
|
||||
return user, err
|
||||
}
|
||||
if string(storedPubKey.Marshal()) != pubKey {
|
||||
err = errors.New("Invalid credentials")
|
||||
}
|
||||
} else {
|
||||
err = errors.New("Invalid credentials")
|
||||
return user, err
|
||||
}
|
||||
if len(user.PublicKey) > 0 {
|
||||
storedPubKey, _, _, _, err := ssh.ParseAuthorizedKey([]byte(user.PublicKey))
|
||||
if err != nil {
|
||||
logger.Warn(logSender, "error parsing stored public key for user %v: %v", username, err)
|
||||
return user, err
|
||||
}
|
||||
if string(storedPubKey.Marshal()) != pubKey {
|
||||
err = errors.New("Invalid credentials")
|
||||
return user, err
|
||||
}
|
||||
} else {
|
||||
err = errors.New("Invalid credentials")
|
||||
}
|
||||
return user, err
|
||||
}
|
||||
|
|
1
go.mod
1
go.mod
|
@ -12,6 +12,7 @@ require (
|
|||
github.com/mattn/go-sqlite3 v1.10.0
|
||||
github.com/pkg/sftp v1.10.0
|
||||
github.com/rs/zerolog v1.14.3
|
||||
github.com/stretchr/testify v1.3.0 // indirect
|
||||
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0
|
||||
)
|
||||
|
|
7
go.sum
7
go.sum
|
@ -1,6 +1,8 @@
|
|||
github.com/alexedwards/argon2id v0.0.0-20190612080829-01a59b2b8802 h1:RwMM1q/QSKYIGbHfOkf843hE8sSUJtf1dMwFPtEDmm0=
|
||||
github.com/alexedwards/argon2id v0.0.0-20190612080829-01a59b2b8802/go.mod h1:4dsm7ufQm1Gwl8S2ss57u+2J7KlxIL2QUmFGlGtWogY=
|
||||
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/go-chi/chi v4.0.2+incompatible h1:maB6vn6FqCxrpz4FqWdh4+lwpyZIQS7YEAUcHlgXVRs=
|
||||
github.com/go-chi/chi v4.0.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ=
|
||||
github.com/go-chi/render v1.0.1 h1:4/5tis2cKaNdnv9zFLfXzcquC9HbeZgCnxGnKrltBS8=
|
||||
|
@ -17,9 +19,14 @@ github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
|||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/sftp v1.10.0 h1:DGA1KlA9esU6WcicH+P8PxFZOl15O6GYtab1cIJdOlE=
|
||||
github.com/pkg/sftp v1.10.0/go.mod h1:NxmoDg/QLVWluQDUYG7XBZTLUpKeFa8e3aMf1BfjyHk=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
|
||||
github.com/rs/zerolog v1.14.3 h1:4EGfSkR2hJDB0s3oFfrlPqjU1e4WLncergLil3nEKW0=
|
||||
github.com/rs/zerolog v1.14.3/go.mod h1:3WXPzbXEEliJ+a6UFE4vhIxV8qR1EML6ngzP9ug4eYg=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
|
|
2
main.go
2
main.go
|
@ -58,7 +58,7 @@ func main() {
|
|||
|
||||
go func() {
|
||||
logger.Debug(logSender, "initializing SFTP server with config %+v", sftpdConf)
|
||||
if err := sftpdConf.Initalize(configDir); err != nil {
|
||||
if err := sftpdConf.Initialize(configDir); err != nil {
|
||||
logger.Error(logSender, "could not start SFTP server: %v", err)
|
||||
}
|
||||
shutdown <- true
|
||||
|
|
|
@ -394,7 +394,7 @@ func (c Connection) hasSpace(checkFiles bool) bool {
|
|||
numFile, size, err := dataprovider.GetUsedQuota(c.dataProvider, c.User.Username)
|
||||
if err != nil {
|
||||
if _, ok := err.(*dataprovider.MethodDisabledError); ok {
|
||||
logger.Warn(logSender, "quota enforcement not possibile for user %v: %v", c.User.Username, err)
|
||||
logger.Warn(logSender, "quota enforcement not possible for user %v: %v", c.User.Username, err)
|
||||
return true
|
||||
}
|
||||
logger.Warn(logSender, "error getting used quota for %v: %v", c.User.Username, err)
|
||||
|
|
|
@ -33,8 +33,8 @@ type Configuration struct {
|
|||
Umask string `json:"umask"`
|
||||
}
|
||||
|
||||
// Initalize the SFTP server and add a persistent listener to handle inbound SFTP connections.
|
||||
func (c Configuration) Initalize(configDir string) error {
|
||||
// Initialize the SFTP server and add a persistent listener to handle inbound SFTP connections.
|
||||
func (c Configuration) Initialize(configDir string) error {
|
||||
umask, err := strconv.ParseUint(c.Umask, 8, 8)
|
||||
if err == nil {
|
||||
utils.SetUmask(int(umask), c.Umask)
|
||||
|
|
Loading…
Reference in a new issue