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
Aug 10, 2015
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
from
os
import
mkdir
from
os
import
mkdir
,
remove
,
chown
from
pwd
import
getpwnam
import
platform
import
platform
from
shutil
import
rmtree
,
move
from
shutil
import
rmtree
,
move
import
subprocess
import
subprocess
...
@@ -147,7 +148,6 @@ class Context(BaseContext):
...
@@ -147,7 +148,6 @@ class Context(BaseContext):
@staticmethod
@staticmethod
def
_save_keys
(
keys
):
def
_save_keys
(
keys
):
print
keys
try
:
try
:
mkdir
(
SSH_DIR
)
mkdir
(
SSH_DIR
)
except
OSError
:
except
OSError
:
...
@@ -156,6 +156,10 @@ class Context(BaseContext):
...
@@ -156,6 +156,10 @@ class Context(BaseContext):
for
key
in
keys
:
for
key
in
keys
:
f
.
write
(
unicode
(
key
)
+
'
\n
'
)
f
.
write
(
unicode
(
key
)
+
'
\n
'
)
uid
=
getpwnam
(
"cloud"
)
.
pw_uid
chown
(
SSH_DIR
,
uid
,
-
1
)
chown
(
AUTHORIZED_KEYS
,
uid
,
-
1
)
@staticmethod
@staticmethod
def
add_keys
(
keys
):
def
add_keys
(
keys
):
new_keys
=
Context
.
get_keys
()
new_keys
=
Context
.
get_keys
()
...
@@ -185,13 +189,16 @@ class Context(BaseContext):
...
@@ -185,13 +189,16 @@ class Context(BaseContext):
@staticmethod
@staticmethod
def
cleanup
():
def
cleanup
():
filelist
=
([
filelist
=
([
'/root/.bash_history'
'/root/.bash_history'
,
'/home/cloud/.bash_history'
,
'/home/cloud/.bash_history'
]
+
glob
(
'/etc/ssh/ssh_host_*'
))
'/root/.ssh'
dirlist
=
(
'/root/.ssh'
,
'/home/cloud/.ssh'
)
'/home/cloud/.ssh'
]
+
glob
(
'/etc/ssh/ssh_host_*'
))
for
d
in
dirlist
:
rmtree
(
d
,
ignore_errors
=
True
)
for
f
in
filelist
:
for
f
in
filelist
:
rmtree
(
f
,
ignore_errors
=
True
)
if
exists
(
f
):
remove
(
f
)
subprocess
.
call
((
'/usr/bin/ssh-keygen'
,
'-A'
))
subprocess
.
call
((
'/usr/bin/ssh-keygen'
,
'-A'
))
...
...
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