Skip to content

Commit

Permalink
Check os permissions as if acting as user
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Verraedt <[email protected]>
  • Loading branch information
peterverraedt committed Mar 14, 2023
1 parent dad346c commit dcf5537
Show file tree
Hide file tree
Showing 31 changed files with 180 additions and 157 deletions.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ require (
github.com/mhale/smtpd v0.8.0
github.com/minio/sio v0.3.1
github.com/otiai10/copy v1.9.0
github.com/peterverraedt/useros v0.1.5
github.com/pires/go-proxyproto v0.6.2
github.com/pkg/sftp v1.13.6-0.20230213180117-971c283182b6
github.com/pquerna/otp v1.4.0
Expand Down Expand Up @@ -121,6 +122,7 @@ require (
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/joshlf/go-acl v0.0.0-20200411065538-eae00ae38531 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/kr/fs v0.1.0 // indirect
github.com/lestrrat-go/blackmagic v1.0.1 // indirect
Expand Down
5 changes: 5 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1411,6 +1411,9 @@ github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqx
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/joshlf/go-acl v0.0.0-20200411065538-eae00ae38531 h1:hgVxRoDDPtQE68PT4LFvNlPz2nBKd3OMlGKIQ69OmR4=
github.com/joshlf/go-acl v0.0.0-20200411065538-eae00ae38531/go.mod h1:fqTUQpVYBvhCNIsMXGl2GE9q6z94DIP6NtFKXCSTVbg=
github.com/joshlf/testutil v0.0.0-20170608050642-b5d8aa79d93d h1:J8tJzRyiddAFF65YVgxli+TyWBi0f79Sld6rJP6CBcY=
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
Expand Down Expand Up @@ -1708,6 +1711,8 @@ github.com/pelletier/go-toml/v2 v2.0.7 h1:muncTPStnKRos5dpVKULv2FVd4bMOhNePj9Cjg
github.com/pelletier/go-toml/v2 v2.0.7/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek=
github.com/performancecopilot/speed/v4 v4.0.0/go.mod h1:qxrSyuDGrTOWfV+uKRFhfxw6h/4HXRGUiZiufxo49BM=
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
github.com/peterverraedt/useros v0.1.5 h1:zwt96Q/3vm89gAUlgFzyfq3aiTVpGsvapIQqnxEphXA=
github.com/peterverraedt/useros v0.1.5/go.mod h1:JJp7q3r6tvRHC0QcQ3BifCSvQGQeeBxShAjdUS/yg1I=
github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc=
github.com/pires/go-proxyproto v0.6.2 h1:KAZ7UteSOt6urjme6ZldyFm4wDe/z0ZUP0Yv0Dos0d8=
github.com/pires/go-proxyproto v0.6.2/go.mod h1:Odh9VFOZJCf9G8cLW5o435Xf1J95Jw9Gw5rnCjcwzAY=
Expand Down
2 changes: 1 addition & 1 deletion internal/common/actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ func TestPreDeleteAction(t *testing.T) {
}
user.Permissions = make(map[string][]string)
user.Permissions["/"] = []string{dataprovider.PermAny}
fs := vfs.NewOsFs("id", homeDir, "")
fs := vfs.NewOsFs("id", homeDir, "", 0, 0)
c := NewBaseConnection("id", ProtocolSFTP, "", "", user)

testfile := filepath.Join(user.HomeDir, "testfile")
Expand Down
2 changes: 1 addition & 1 deletion internal/common/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ func TestConnectionStatus(t *testing.T) {
Username: username,
},
}
fs := vfs.NewOsFs("", os.TempDir(), "")
fs := vfs.NewOsFs("", os.TempDir(), "", 0, 0)
c1 := NewBaseConnection("id1", ProtocolSFTP, "", "", user)
fakeConn1 := &fakeConnection{
BaseConnection: c1,
Expand Down
2 changes: 0 additions & 2 deletions internal/common/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,6 @@ func (c *BaseConnection) CreateDir(virtualPath string, checkFilePatterns bool) e
c.Log(logger.LevelError, "error creating dir: %q error: %+v", fsPath, err)
return c.GetFsError(fs, err)
}
vfs.SetPathPermissions(fs, fsPath, c.User.GetUID(), c.User.GetGID())
elapsed := time.Since(startTime).Nanoseconds() / 1000000

logger.CommandLog(mkdirLogSender, fsPath, "", c.User.Username, "", c.ID, c.protocol, -1, -1, "", "", "", -1,
Expand Down Expand Up @@ -764,7 +763,6 @@ func (c *BaseConnection) renameInternal(virtualSourcePath, virtualTargetPath str
c.Log(logger.LevelError, "failed to rename %q -> %q: %+v", fsSourcePath, fsTargetPath, err)
return c.GetFsError(fsSrc, err)
}
vfs.SetPathPermissions(fsDst, fsTargetPath, c.User.GetUID(), c.User.GetGID())
elapsed := time.Since(startTime).Nanoseconds() / 1000000
c.updateQuotaAfterRename(fsDst, virtualSourcePath, virtualTargetPath, fsTargetPath, initialSize, files, size) //nolint:errcheck
logger.CommandLog(renameLogSender, fsSourcePath, fsTargetPath, c.User.Username, "", c.ID, c.protocol, -1, -1,
Expand Down
12 changes: 6 additions & 6 deletions internal/common/connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (fs *MockOsFs) Walk(root string, walkFn filepath.WalkFunc) error {

func newMockOsFs(hasVirtualFolders bool, connectionID, rootDir, name string, err error) vfs.Fs {
return &MockOsFs{
Fs: vfs.NewOsFs(connectionID, rootDir, ""),
Fs: vfs.NewOsFs(connectionID, rootDir, "", 0, 0),
name: name,
hasVirtualFolders: hasVirtualFolders,
err: err,
Expand Down Expand Up @@ -114,7 +114,7 @@ func TestRemoveErrors(t *testing.T) {
}
user.Permissions = make(map[string][]string)
user.Permissions["/"] = []string{dataprovider.PermAny}
fs := vfs.NewOsFs("", os.TempDir(), "")
fs := vfs.NewOsFs("", os.TempDir(), "", 0, 0)
conn := NewBaseConnection("", ProtocolFTP, "", "", user)
err := conn.IsRemoveDirAllowed(fs, mappedPath, "/virtualpath1")
if assert.Error(t, err) {
Expand Down Expand Up @@ -159,7 +159,7 @@ func TestSetStatMode(t *testing.T) {
}

func TestRecursiveRenameWalkError(t *testing.T) {
fs := vfs.NewOsFs("", filepath.Clean(os.TempDir()), "")
fs := vfs.NewOsFs("", filepath.Clean(os.TempDir()), "", 0, 0)
conn := NewBaseConnection("", ProtocolWebDAV, "", "", dataprovider.User{
BaseUser: sdk.BaseUser{
Permissions: map[string][]string{
Expand Down Expand Up @@ -193,7 +193,7 @@ func TestRecursiveRenameWalkError(t *testing.T) {
}

func TestCrossRenameFsErrors(t *testing.T) {
fs := vfs.NewOsFs("", os.TempDir(), "")
fs := vfs.NewOsFs("", os.TempDir(), "", 0, 0)
conn := NewBaseConnection("", ProtocolWebDAV, "", "", dataprovider.User{})
res := conn.hasSpaceForCrossRename(fs, vfs.QuotaCheckResult{}, 1, "missingsource")
assert.False(t, res)
Expand Down Expand Up @@ -224,7 +224,7 @@ func TestRenameVirtualFolders(t *testing.T) {
},
VirtualPath: vdir,
})
fs := vfs.NewOsFs("", os.TempDir(), "")
fs := vfs.NewOsFs("", os.TempDir(), "", 0, 0)
conn := NewBaseConnection("", ProtocolFTP, "", "", u)
res := conn.isRenamePermitted(fs, fs, "source", "target", vdir, "vdirtarget", nil)
assert.False(t, res)
Expand Down Expand Up @@ -376,7 +376,7 @@ func TestUpdateQuotaAfterRename(t *testing.T) {
}

func TestErrorsMapping(t *testing.T) {
fs := vfs.NewOsFs("", os.TempDir(), "")
fs := vfs.NewOsFs("", os.TempDir(), "", 0, 0)
conn := NewBaseConnection("", ProtocolSFTP, "", "", dataprovider.User{BaseUser: sdk.BaseUser{HomeDir: os.TempDir()}})
osErrorsProtocols := []string{ProtocolWebDAV, ProtocolFTP, ProtocolHTTP, ProtocolHTTPShare,
ProtocolDataRetention, ProtocolOIDC, protocolEventAction}
Expand Down
3 changes: 1 addition & 2 deletions internal/common/eventmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,6 @@ func getFileWriter(conn *BaseConnection, virtualPath string, expectedSize int64)
if err != nil {
return nil, numFiles, truncatedSize, nil, conn.GetFsError(fs, err)
}
vfs.SetPathPermissions(fs, fsPath, conn.User.GetUID(), conn.User.GetGID())

if isFileOverwrite {
if vfs.HasTruncateSupport(fs) || vfs.IsCryptOsFs(fs) {
Expand Down Expand Up @@ -1927,7 +1926,7 @@ func executeFoldersQuotaResetRuleAction(conditions dataprovider.ConditionOptions
BaseVirtualFolder: folder,
VirtualPath: "/",
}
numFiles, size, err := f.ScanQuota()
numFiles, size, err := f.ScanQuota(0, 0)
QuotaScans.RemoveVFolderQuotaScan(folder.Name)
if err != nil {
eventManagerLog(logger.LevelError, "error scanning quota for folder %q: %v", folder.Name, err)
Expand Down
16 changes: 8 additions & 8 deletions internal/common/transfer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestTransferUpdateQuota(t *testing.T) {
transfer := BaseTransfer{
Connection: conn,
transferType: TransferUpload,
Fs: vfs.NewOsFs("", os.TempDir(), ""),
Fs: vfs.NewOsFs("", os.TempDir(), "", 0, 0),
}
transfer.BytesReceived.Store(123)
errFake := errors.New("fake error")
Expand Down Expand Up @@ -74,7 +74,7 @@ func TestTransferThrottling(t *testing.T) {
DownloadBandwidth: 40,
},
}
fs := vfs.NewOsFs("", os.TempDir(), "")
fs := vfs.NewOsFs("", os.TempDir(), "", 0, 0)
testFileSize := int64(131072)
wantedUploadElapsed := 1000 * (testFileSize / 1024) / u.UploadBandwidth
wantedDownloadElapsed := 1000 * (testFileSize / 1024) / u.DownloadBandwidth
Expand Down Expand Up @@ -106,7 +106,7 @@ func TestTransferThrottling(t *testing.T) {

func TestRealPath(t *testing.T) {
testFile := filepath.Join(os.TempDir(), "afile.txt")
fs := vfs.NewOsFs("123", os.TempDir(), "")
fs := vfs.NewOsFs("123", os.TempDir(), "", 0, 0)
u := dataprovider.User{
BaseUser: sdk.BaseUser{
Username: "user",
Expand Down Expand Up @@ -140,7 +140,7 @@ func TestRealPath(t *testing.T) {

func TestTruncate(t *testing.T) {
testFile := filepath.Join(os.TempDir(), "transfer_test_file")
fs := vfs.NewOsFs("123", os.TempDir(), "")
fs := vfs.NewOsFs("123", os.TempDir(), "", 0, 0)
u := dataprovider.User{
BaseUser: sdk.BaseUser{
Username: "user",
Expand Down Expand Up @@ -209,7 +209,7 @@ func TestTransferErrors(t *testing.T) {
isCancelled = true
}
testFile := filepath.Join(os.TempDir(), "transfer_test_file")
fs := vfs.NewOsFs("id", os.TempDir(), "")
fs := vfs.NewOsFs("id", os.TempDir(), "", 0, 0)
u := dataprovider.User{
BaseUser: sdk.BaseUser{
Username: "test",
Expand Down Expand Up @@ -316,7 +316,7 @@ func TestFTPMode(t *testing.T) {
transfer := BaseTransfer{
Connection: conn,
transferType: TransferUpload,
Fs: vfs.NewOsFs("", os.TempDir(), ""),
Fs: vfs.NewOsFs("", os.TempDir(), "", 0, 0),
}
transfer.BytesReceived.Store(123)
assert.Empty(t, transfer.ftpMode)
Expand Down Expand Up @@ -394,7 +394,7 @@ func TestTransferQuota(t *testing.T) {

conn := NewBaseConnection("", ProtocolSFTP, "", "", user)
transfer := NewBaseTransfer(nil, conn, nil, "file.txt", "file.txt", "/transfer_test_file", TransferUpload,
0, 0, 0, 0, true, vfs.NewOsFs("", os.TempDir(), ""), dataprovider.TransferQuota{})
0, 0, 0, 0, true, vfs.NewOsFs("", os.TempDir(), "", 0, 0), dataprovider.TransferQuota{})
err := transfer.CheckRead()
assert.NoError(t, err)
err = transfer.CheckWrite()
Expand Down Expand Up @@ -448,7 +448,7 @@ func TestUploadOutsideHomeRenameError(t *testing.T) {
transfer := BaseTransfer{
Connection: conn,
transferType: TransferUpload,
Fs: vfs.NewOsFs("", filepath.Join(os.TempDir(), "home"), ""),
Fs: vfs.NewOsFs("", filepath.Join(os.TempDir(), "home"), "", 0, 0),
}
transfer.BytesReceived.Store(123)

Expand Down
11 changes: 5 additions & 6 deletions internal/dataprovider/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func (u *User) getRootFs(connectionID string) (fs vfs.Fs, err error) {
case sdk.HTTPFilesystemProvider:
return vfs.NewHTTPFs(connectionID, u.GetHomeDir(), "", u.FsConfig.HTTPConfig)
default:
return vfs.NewOsFs(connectionID, u.GetHomeDir(), ""), nil
return vfs.NewOsFs(connectionID, u.GetHomeDir(), "", u.UID, u.GID), nil
}
}

Expand Down Expand Up @@ -204,7 +204,6 @@ func (u *User) checkDirWithParents(virtualDirPath, connectionID string) error {
if err != nil {
return err
}
vfs.SetPathPermissions(fs, fsPath, u.GetUID(), u.GetGID())
} else {
return fmt.Errorf("unable to stat path %q: %w", vPath, err)
}
Expand All @@ -218,7 +217,7 @@ func (u *User) checkLocalHomeDir(connectionID string) {
case sdk.LocalFilesystemProvider, sdk.CryptedFilesystemProvider:
return
default:
osFs := vfs.NewOsFs(connectionID, u.GetHomeDir(), "")
osFs := vfs.NewOsFs(connectionID, u.GetHomeDir(), "", u.UID, u.GID)
osFs.CheckRootPath(u.Username, u.GetUID(), u.GetGID())
}
}
Expand Down Expand Up @@ -565,7 +564,7 @@ func (u *User) GetFilesystemForPath(virtualPath, connectionID string) (vfs.Fs, e
}
forbiddenSelfUsers = append(forbiddenSelfUsers, forbiddens...)
}
fs, err := folder.GetFilesystem(connectionID, forbiddenSelfUsers)
fs, err := folder.GetFilesystem(connectionID, u.UID, u.GID, forbiddenSelfUsers)
if err == nil {
u.fsCache[folder.VirtualPath] = fs
}
Expand Down Expand Up @@ -617,7 +616,7 @@ func (u *User) CheckMetadataConsistency() error {
}
for idx := range u.VirtualFolders {
v := &u.VirtualFolders[idx]
if err = v.CheckMetadataConsistency(); err != nil {
if err = v.CheckMetadataConsistency(u.UID, u.GID); err != nil {
return err
}
}
Expand All @@ -642,7 +641,7 @@ func (u *User) ScanQuota() (int, int64, error) {
if !v.IsIncludedInUserQuota() {
continue
}
num, s, err := v.ScanQuota()
num, s, err := v.ScanQuota(u.UID, u.GID)
if err != nil {
return numFiles, size, err
}
Expand Down
4 changes: 0 additions & 4 deletions internal/ftpd/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,6 @@ func (c *Connection) handleFTPUploadToNewFile(fs vfs.Fs, flags int, resolvedPath
return nil, c.GetFsError(fs, err)
}

vfs.SetPathPermissions(fs, filePath, c.User.GetUID(), c.User.GetGID())

// we can get an error only for resume
maxWriteSize, _ := c.GetMaxWriteSize(diskQuota, false, 0, fs.IsUploadResumeSupported())

Expand Down Expand Up @@ -496,8 +494,6 @@ func (c *Connection) handleFTPUploadToExistingFile(fs vfs.Fs, flags int, resolve
}
}

vfs.SetPathPermissions(fs, filePath, c.User.GetUID(), c.User.GetGID())

baseTransfer := common.NewBaseTransfer(file, c.BaseConnection, cancelFn, resolvedPath, filePath, requestPath,
common.TransferUpload, minWriteOffset, initialSize, maxWriteSize, truncatedSize, false, fs, transferQuota)
baseTransfer.SetFtpMode(c.getFTPMode())
Expand Down
6 changes: 3 additions & 3 deletions internal/ftpd/internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ func (fs MockOsFs) Rename(source, target string) (int, int64, error) {

func newMockOsFs(err, statErr error, atomicUpload bool, connectionID, rootDir string) vfs.Fs {
return &MockOsFs{
Fs: vfs.NewOsFs(connectionID, rootDir, ""),
Fs: vfs.NewOsFs(connectionID, rootDir, "", 0, 0),
err: err,
statErr: statErr,
isAtomicUploadSupported: atomicUpload,
Expand Down Expand Up @@ -723,7 +723,7 @@ func TestUploadFileStatError(t *testing.T) {
user.Permissions["/"] = []string{dataprovider.PermAny}
mockCC := mockFTPClientContext{}
connID := fmt.Sprintf("%v", mockCC.ID())
fs := vfs.NewOsFs(connID, user.HomeDir, "")
fs := vfs.NewOsFs(connID, user.HomeDir, "", 0, 0)
connection := &Connection{
BaseConnection: common.NewBaseConnection(connID, common.ProtocolFTP, "", "", user),
clientContext: mockCC,
Expand Down Expand Up @@ -813,7 +813,7 @@ func TestUploadOverwriteErrors(t *testing.T) {
_, err = connection.handleFTPUploadToExistingFile(fs, os.O_TRUNC, filepath.Join(os.TempDir(), "sub", "file"),
filepath.Join(os.TempDir(), "sub", "file1"), 0, "/sub/file1")
assert.Error(t, err)
fs = vfs.NewOsFs(connID, user.GetHomeDir(), "")
fs = vfs.NewOsFs(connID, user.GetHomeDir(), "", 0, 0)
_, err = connection.handleFTPUploadToExistingFile(fs, 0, "missing1", "missing2", 0, "missing")
assert.Error(t, err)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/httpd/api_quota.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func doFolderQuotaScan(folder vfs.BaseVirtualFolder) error {
BaseVirtualFolder: folder,
VirtualPath: "/",
}
numFiles, size, err := f.ScanQuota()
numFiles, size, err := f.ScanQuota(0, 0)
if err != nil {
logger.Warn(logSender, "", "error scanning folder %q: %v", folder.Name, err)
return err
Expand Down
2 changes: 0 additions & 2 deletions internal/httpd/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,6 @@ func (c *Connection) handleUploadFile(fs vfs.Fs, resolvedPath, filePath, request
}
}

vfs.SetPathPermissions(fs, filePath, c.User.GetUID(), c.User.GetGID())

baseTransfer := common.NewBaseTransfer(file, c.BaseConnection, cancelFn, resolvedPath, filePath, requestPath,
common.TransferUpload, 0, initialSize, maxWriteSize, truncatedSize, isNewFile, fs, transferQuota)
return newHTTPDFile(baseTransfer, w, nil), nil
Expand Down
6 changes: 3 additions & 3 deletions internal/httpd/httpd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12012,7 +12012,7 @@ func TestWebClientMaxConnections(t *testing.T) {
checkResponseCode(t, http.StatusOK, rr)

// now add a fake connection
fs := vfs.NewOsFs("id", os.TempDir(), "")
fs := vfs.NewOsFs("id", os.TempDir(), "", 0, 0)
connection := &httpd.Connection{
BaseConnection: common.NewBaseConnection(fs.ConnectionID(), common.ProtocolHTTP, "", "", user),
}
Expand Down Expand Up @@ -12203,7 +12203,7 @@ func TestMaxSessions(t *testing.T) {
apiToken, err := getJWTAPIUserTokenFromTestServer(defaultUsername, defaultPassword)
assert.NoError(t, err)
// now add a fake connection
fs := vfs.NewOsFs("id", os.TempDir(), "")
fs := vfs.NewOsFs("id", os.TempDir(), "", 0, 0)
connection := &httpd.Connection{
BaseConnection: common.NewBaseConnection(fs.ConnectionID(), common.ProtocolHTTP, "", "", user),
}
Expand Down Expand Up @@ -13312,7 +13312,7 @@ func TestShareMaxSessions(t *testing.T) {
rr = executeRequest(req)
checkResponseCode(t, http.StatusOK, rr)
// add a fake connection
fs := vfs.NewOsFs("id", os.TempDir(), "")
fs := vfs.NewOsFs("id", os.TempDir(), "", 0, 0)
connection := &httpd.Connection{
BaseConnection: common.NewBaseConnection(fs.ConnectionID(), common.ProtocolHTTP, "", "", user),
}
Expand Down
4 changes: 0 additions & 4 deletions internal/sftpd/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,6 @@ func (c *Connection) handleSFTPUploadToNewFile(fs vfs.Fs, pflags sftp.FileOpenFl
return nil, c.GetFsError(fs, err)
}

vfs.SetPathPermissions(fs, filePath, c.User.GetUID(), c.User.GetGID())

// we can get an error only for resume
maxWriteSize, _ := c.GetMaxWriteSize(diskQuota, false, 0, fs.IsUploadResumeSupported())

Expand Down Expand Up @@ -497,8 +495,6 @@ func (c *Connection) handleSFTPUploadToExistingFile(fs vfs.Fs, pflags sftp.FileO
}
}

vfs.SetPathPermissions(fs, filePath, c.User.GetUID(), c.User.GetGID())

baseTransfer := common.NewBaseTransfer(file, c.BaseConnection, cancelFn, resolvedPath, filePath, requestPath,
common.TransferUpload, minWriteOffset, initialSize, maxWriteSize, truncatedSize, false, fs, transferQuota)
t := newTransfer(baseTransfer, w, nil, errForRead)
Expand Down
Loading

0 comments on commit dcf5537

Please sign in to comment.