Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
K
koko
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
koko
Commits
099cfe35
Commit
099cfe35
authored
Jun 20, 2019
by
Eric
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix sftp bugs
parent
74d4c5c2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
8 deletions
+62
-8
sftp.go
pkg/handler/sftp.go
+61
-7
koko.go
pkg/koko/koko.go
+1
-1
No files found.
pkg/handler/sftp.go
View file @
099cfe35
...
@@ -159,8 +159,26 @@ func (fs *sftpHandler) Filecmd(r *sftp.Request) (err error) {
...
@@ -159,8 +159,26 @@ func (fs *sftpHandler) Filecmd(r *sftp.Request) (err error) {
if
len
(
pathNames
)
<=
2
{
if
len
(
pathNames
)
<=
2
{
return
sftp
.
ErrSshFxPermissionDenied
return
sftp
.
ErrSshFxPermissionDenied
}
}
hostDir
:=
fs
.
hosts
[
pathNames
[
0
]]
hostDir
,
ok
:=
fs
.
hosts
[
pathNames
[
0
]]
suDir
:=
hostDir
.
suMaps
[
pathNames
[
1
]]
if
!
ok
{
return
sftp
.
ErrSshFxNoSuchFile
}
if
hostDir
.
suMaps
==
nil
{
hostDir
.
suMaps
=
make
(
map
[
string
]
*
SysUserDir
)
systemUsers
:=
hostDir
.
asset
.
SystemUsers
for
i
,
sysUser
:=
range
systemUsers
{
hostDir
.
suMaps
[
sysUser
.
Name
]
=
&
SysUserDir
{
time
:
time
.
Now
()
.
UTC
(),
rootPath
:
fs
.
rootPath
,
systemUser
:
&
systemUsers
[
i
],
prefix
:
fmt
.
Sprintf
(
"/%s/%s"
,
hostDir
.
asset
.
Hostname
,
sysUser
.
Name
),
}
}
}
suDir
,
ok
:=
hostDir
.
suMaps
[
pathNames
[
1
]]
if
!
ok
{
return
sftp
.
ErrSshFxNoSuchFile
}
if
!
fs
.
validatePermission
(
hostDir
.
asset
.
ID
,
suDir
.
systemUser
.
ID
,
model
.
ConnectAction
)
{
if
!
fs
.
validatePermission
(
hostDir
.
asset
.
ID
,
suDir
.
systemUser
.
ID
,
model
.
ConnectAction
)
{
return
sftp
.
ErrSshFxPermissionDenied
return
sftp
.
ErrSshFxPermissionDenied
...
@@ -219,8 +237,26 @@ func (fs *sftpHandler) Filewrite(r *sftp.Request) (io.WriterAt, error) {
...
@@ -219,8 +237,26 @@ func (fs *sftpHandler) Filewrite(r *sftp.Request) (io.WriterAt, error) {
if
len
(
pathNames
)
<=
2
{
if
len
(
pathNames
)
<=
2
{
return
nil
,
sftp
.
ErrSshFxPermissionDenied
return
nil
,
sftp
.
ErrSshFxPermissionDenied
}
}
hostDir
:=
fs
.
hosts
[
pathNames
[
0
]]
hostDir
,
ok
:=
fs
.
hosts
[
pathNames
[
0
]]
suDir
:=
hostDir
.
suMaps
[
pathNames
[
1
]]
if
!
ok
{
return
nil
,
sftp
.
ErrSshFxNoSuchFile
}
if
hostDir
.
suMaps
==
nil
{
hostDir
.
suMaps
=
make
(
map
[
string
]
*
SysUserDir
)
systemUsers
:=
hostDir
.
asset
.
SystemUsers
for
i
,
sysUser
:=
range
systemUsers
{
hostDir
.
suMaps
[
sysUser
.
Name
]
=
&
SysUserDir
{
time
:
time
.
Now
()
.
UTC
(),
rootPath
:
fs
.
rootPath
,
systemUser
:
&
systemUsers
[
i
],
prefix
:
fmt
.
Sprintf
(
"/%s/%s"
,
hostDir
.
asset
.
Hostname
,
sysUser
.
Name
),
}
}
}
suDir
,
ok
:=
hostDir
.
suMaps
[
pathNames
[
1
]]
if
!
ok
{
return
nil
,
sftp
.
ErrSshFxNoSuchFile
}
if
!
fs
.
validatePermission
(
hostDir
.
asset
.
ID
,
suDir
.
systemUser
.
ID
,
model
.
UploadAction
)
{
if
!
fs
.
validatePermission
(
hostDir
.
asset
.
ID
,
suDir
.
systemUser
.
ID
,
model
.
UploadAction
)
{
return
nil
,
sftp
.
ErrSshFxPermissionDenied
return
nil
,
sftp
.
ErrSshFxPermissionDenied
...
@@ -260,8 +296,26 @@ func (fs *sftpHandler) Fileread(r *sftp.Request) (io.ReaderAt, error) {
...
@@ -260,8 +296,26 @@ func (fs *sftpHandler) Fileread(r *sftp.Request) (io.ReaderAt, error) {
if
len
(
pathNames
)
<=
2
{
if
len
(
pathNames
)
<=
2
{
return
nil
,
sftp
.
ErrSshFxPermissionDenied
return
nil
,
sftp
.
ErrSshFxPermissionDenied
}
}
hostDir
:=
fs
.
hosts
[
pathNames
[
0
]]
hostDir
,
ok
:=
fs
.
hosts
[
pathNames
[
0
]]
suDir
:=
hostDir
.
suMaps
[
pathNames
[
1
]]
if
!
ok
{
return
nil
,
sftp
.
ErrSshFxNoSuchFile
}
if
hostDir
.
suMaps
==
nil
{
hostDir
.
suMaps
=
make
(
map
[
string
]
*
SysUserDir
)
systemUsers
:=
hostDir
.
asset
.
SystemUsers
for
i
,
sysUser
:=
range
systemUsers
{
hostDir
.
suMaps
[
sysUser
.
Name
]
=
&
SysUserDir
{
time
:
time
.
Now
()
.
UTC
(),
rootPath
:
fs
.
rootPath
,
systemUser
:
&
systemUsers
[
i
],
prefix
:
fmt
.
Sprintf
(
"/%s/%s"
,
hostDir
.
asset
.
Hostname
,
sysUser
.
Name
),
}
}
}
suDir
,
ok
:=
hostDir
.
suMaps
[
pathNames
[
1
]]
if
!
ok
{
return
nil
,
sftp
.
ErrSshFxNoSuchFile
}
if
!
fs
.
validatePermission
(
hostDir
.
asset
.
ID
,
suDir
.
systemUser
.
ID
,
model
.
DownloadAction
)
{
if
!
fs
.
validatePermission
(
hostDir
.
asset
.
ID
,
suDir
.
systemUser
.
ID
,
model
.
DownloadAction
)
{
return
nil
,
sftp
.
ErrSshFxPermissionDenied
return
nil
,
sftp
.
ErrSshFxPermissionDenied
}
}
...
@@ -303,7 +357,7 @@ func (fs *sftpHandler) GetSftpClient(asset *model.Asset, sysUser *model.SystemUs
...
@@ -303,7 +357,7 @@ func (fs *sftpHandler) GetSftpClient(asset *model.Asset, sysUser *model.SystemUs
if
err
!=
nil
{
if
err
!=
nil
{
return
return
}
}
return
sftpClient
,
sshClient
,
nil
return
sftpClient
,
sshClient
,
err
}
}
func
(
fs
*
sftpHandler
)
CreateFTPLog
(
data
*
model
.
FTPLog
)
{
func
(
fs
*
sftpHandler
)
CreateFTPLog
(
data
*
model
.
FTPLog
)
{
...
...
pkg/koko/koko.go
View file @
099cfe35
...
@@ -14,7 +14,7 @@ import (
...
@@ -14,7 +14,7 @@ import (
"github.com/jumpserver/koko/pkg/sshd"
"github.com/jumpserver/koko/pkg/sshd"
)
)
const
version
=
"1.
4
.0"
const
version
=
"1.
5
.0"
type
Coco
struct
{
type
Coco
struct
{
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment