Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
coco
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
coco
Commits
e60bfffa
Commit
e60bfffa
authored
Apr 06, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' into test
parents
4d45b64d
b9394717
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
4 deletions
+19
-4
sftp.py
coco/sftp.py
+19
-4
No files found.
coco/sftp.py
View file @
e60bfffa
...
@@ -19,8 +19,9 @@ class SFTPServer(paramiko.SFTPServerInterface):
...
@@ -19,8 +19,9 @@ class SFTPServer(paramiko.SFTPServerInterface):
def
get_host_sftp
(
self
,
host
,
su
):
def
get_host_sftp
(
self
,
host
,
su
):
asset
=
self
.
hosts
.
get
(
host
)
asset
=
self
.
hosts
.
get
(
host
)
system_user
=
None
system_user
=
None
for
system_user
in
self
.
get_asset_system_users
(
host
):
for
s
in
self
.
get_asset_system_users
(
host
):
if
system_user
.
name
==
su
:
if
s
.
name
==
su
:
system_user
=
s
break
break
if
not
asset
or
not
system_user
:
if
not
asset
or
not
system_user
:
...
@@ -67,6 +68,13 @@ class SFTPServer(paramiko.SFTPServerInterface):
...
@@ -67,6 +68,13 @@ class SFTPServer(paramiko.SFTPServerInterface):
return
[]
return
[]
return
[
su
for
su
in
asset
.
system_users_granted
if
su
.
protocol
==
"ssh"
]
return
[
su
for
su
in
asset
.
system_users_granted
if
su
.
protocol
==
"ssh"
]
def
su_in_asset
(
self
,
su
,
host
):
system_users
=
self
.
get_asset_system_users
(
host
)
if
su
in
[
s
.
name
for
s
in
system_users
]:
return
True
else
:
return
False
def
create_ftp_log
(
self
,
path
,
operate
,
is_success
=
True
,
filename
=
None
):
def
create_ftp_log
(
self
,
path
,
operate
,
is_success
=
True
,
filename
=
None
):
host
,
su
,
rpath
=
self
.
parse_path
(
path
)
host
,
su
,
rpath
=
self
.
parse_path
(
path
)
date_start
=
datetime
.
utcnow
()
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
+
" +0000"
,
date_start
=
datetime
.
utcnow
()
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
+
" +0000"
,
...
@@ -119,6 +127,13 @@ class SFTPServer(paramiko.SFTPServerInterface):
...
@@ -119,6 +127,13 @@ class SFTPServer(paramiko.SFTPServerInterface):
def
stat
(
self
,
path
):
def
stat
(
self
,
path
):
host
,
su
,
rpath
=
self
.
parse_path
(
path
)
host
,
su
,
rpath
=
self
.
parse_path
(
path
)
e
=
OSError
(
"Not that dir"
)
if
host
and
host
not
in
self
.
hosts
:
return
paramiko
.
SFTPServer
.
convert_errno
(
e
.
errno
)
if
su
and
not
self
.
su_in_asset
(
su
,
host
):
return
paramiko
.
SFTPServer
.
convert_errno
(
e
.
errno
)
if
not
rpath
or
rpath
==
"/"
:
if
not
rpath
or
rpath
==
"/"
:
attr
=
self
.
stat_host_dir
()
attr
=
self
.
stat_host_dir
()
attr
.
filename
=
su
or
host
attr
.
filename
=
su
or
host
...
@@ -229,7 +244,7 @@ class SFTPServer(paramiko.SFTPServerInterface):
...
@@ -229,7 +244,7 @@ class SFTPServer(paramiko.SFTPServerInterface):
result
=
paramiko
.
SFTP_OK
result
=
paramiko
.
SFTP_OK
else
:
else
:
result
=
paramiko
.
SFTP_FAILURE
result
=
paramiko
.
SFTP_FAILURE
self
.
create_ftp_log
(
path
,
"M
akeD
ir"
,
success
)
self
.
create_ftp_log
(
path
,
"M
kd
ir"
,
success
)
return
result
return
result
def
rmdir
(
self
,
path
):
def
rmdir
(
self
,
path
):
...
@@ -246,7 +261,7 @@ class SFTPServer(paramiko.SFTPServerInterface):
...
@@ -246,7 +261,7 @@ class SFTPServer(paramiko.SFTPServerInterface):
result
=
paramiko
.
SFTP_OK
result
=
paramiko
.
SFTP_OK
else
:
else
:
result
=
paramiko
.
SFTP_FAILURE
result
=
paramiko
.
SFTP_FAILURE
self
.
create_ftp_log
(
path
,
"Rm
D
ir"
,
success
)
self
.
create_ftp_log
(
path
,
"Rm
d
ir"
,
success
)
return
result
return
result
# def chattr(self, path, attr):
# def chattr(self, path, attr):
...
...
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