Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
agent
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
7
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
34d5248f
authored
9 years ago
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix cleanup and .ssh permissions
parent
c70e6bc5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
8 deletions
+15
-8
linux/_linuxcontext.py
+15
-8
No files found.
linux/_linuxcontext.py
View file @
34d5248f
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from
os
import
mkdir
from
os
import
mkdir
,
remove
,
chown
from
pwd
import
getpwnam
import
platform
from
shutil
import
rmtree
,
move
import
subprocess
...
...
@@ -147,7 +148,6 @@ class Context(BaseContext):
@staticmethod
def
_save_keys
(
keys
):
print
keys
try
:
mkdir
(
SSH_DIR
)
except
OSError
:
...
...
@@ -156,6 +156,10 @@ class Context(BaseContext):
for
key
in
keys
:
f
.
write
(
unicode
(
key
)
+
'
\n
'
)
uid
=
getpwnam
(
"cloud"
)
.
pw_uid
chown
(
SSH_DIR
,
uid
,
-
1
)
chown
(
AUTHORIZED_KEYS
,
uid
,
-
1
)
@staticmethod
def
add_keys
(
keys
):
new_keys
=
Context
.
get_keys
()
...
...
@@ -185,13 +189,16 @@ class Context(BaseContext):
@staticmethod
def
cleanup
():
filelist
=
([
'/root/.bash_history'
'/home/cloud/.bash_history'
'/root/.ssh'
'/home/cloud/.ssh'
]
+
glob
(
'/etc/ssh/ssh_host_*'
))
'/root/.bash_history'
,
'/home/cloud/.bash_history'
,
]
+
glob
(
'/etc/ssh/ssh_host_*'
))
dirlist
=
(
'/root/.ssh'
,
'/home/cloud/.ssh'
)
for
d
in
dirlist
:
rmtree
(
d
,
ignore_errors
=
True
)
for
f
in
filelist
:
rmtree
(
f
,
ignore_errors
=
True
)
if
exists
(
f
):
remove
(
f
)
subprocess
.
call
((
'/usr/bin/ssh-keygen'
,
'-A'
))
...
...
This diff is collapsed.
Click to expand it.
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