Increase uid:gid limits (#362)

Fixes #361
This commit is contained in:
Mike Unitskyi 2021-03-25 18:11:42 +02:00 committed by GitHub
parent db274f1093
commit 5939ac4801
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 6 deletions

View file

@ -4,6 +4,7 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"math"
"net" "net"
"os" "os"
"path" "path"
@ -821,7 +822,7 @@ func (u *User) GetFsConfigAsJSON() ([]byte, error) {
// GetUID returns a validate uid, suitable for use with os.Chown // GetUID returns a validate uid, suitable for use with os.Chown
func (u *User) GetUID() int { func (u *User) GetUID() int {
if u.UID <= 0 || u.UID > 65535 { if u.UID <= 0 || u.UID > int(math.Pow(2, 31))-1 {
return -1 return -1
} }
return u.UID return u.UID
@ -829,7 +830,7 @@ func (u *User) GetUID() int {
// GetGID returns a validate gid, suitable for use with os.Chown // GetGID returns a validate gid, suitable for use with os.Chown
func (u *User) GetGID() int { func (u *User) GetGID() int {
if u.GID <= 0 || u.GID > 65535 { if u.GID <= 0 || u.GID > int(math.Pow(2, 31))-1 {
return -1 return -1
} }
return u.GID return u.GID

View file

@ -1742,13 +1742,13 @@ components:
type: integer type: integer
format: int32 format: int32
minimum: 0 minimum: 0
maximum: 65535 maximum: 2147483647
description: 'if you run SFTPGo as root user, the created files and directories will be assigned to this uid. 0 means no change, the owner will be the user that runs SFTPGo. Ignored on windows' description: 'if you run SFTPGo as root user, the created files and directories will be assigned to this uid. 0 means no change, the owner will be the user that runs SFTPGo. Ignored on windows'
gid: gid:
type: integer type: integer
format: int32 format: int32
minimum: 0 minimum: 0
maximum: 65535 maximum: 2147483647
description: 'if you run SFTPGo as root user, the created files and directories will be assigned to this gid. 0 means no change, the group will be the one of the user that runs SFTPGo. Ignored on windows' description: 'if you run SFTPGo as root user, the created files and directories will be assigned to this gid. 0 means no change, the group will be the one of the user that runs SFTPGo. Ignored on windows'
max_sessions: max_sessions:
type: integer type: integer

View file

@ -264,13 +264,13 @@
<label for="idUID" class="col-sm-2 col-form-label">UID</label> <label for="idUID" class="col-sm-2 col-form-label">UID</label>
<div class="col-sm-3"> <div class="col-sm-3">
<input type="number" class="form-control" id="idUID" name="uid" placeholder="" value="{{.User.UID}}" <input type="number" class="form-control" id="idUID" name="uid" placeholder="" value="{{.User.UID}}"
min="0" max="65535"> min="0" max="2147483647">
</div> </div>
<div class="col-sm-2"></div> <div class="col-sm-2"></div>
<label for="idGID" class="col-sm-2 col-form-label">GID</label> <label for="idGID" class="col-sm-2 col-form-label">GID</label>
<div class="col-sm-3"> <div class="col-sm-3">
<input type="number" class="form-control" id="idGID" name="gid" placeholder="" value="{{.User.GID}}" <input type="number" class="form-control" id="idGID" name="gid" placeholder="" value="{{.User.GID}}"
min="0" max="65535"> min="0" max="2147483647">
</div> </div>
</div> </div>