Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Klaus Wölfel
slapos.toolbox
Commits
878e68ad
Commit
878e68ad
authored
Feb 24, 2014
by
Nicolas Wavrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
runner: reads recovery code from knowledge0 file
parent
d8e79b2b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
6 deletions
+14
-6
slapos/runner/utils.py
slapos/runner/utils.py
+10
-0
slapos/runner/views.py
slapos/runner/views.py
+4
-6
No files found.
slapos/runner/utils.py
View file @
878e68ad
...
...
@@ -2,6 +2,7 @@
# vim: set et sts=2:
# pylint: disable-msg=W0311,C0301,C0103,C0111,W0141,W0142
import
ConfigParser
import
json
import
logging
import
md5
...
...
@@ -112,6 +113,15 @@ def saveSession(config, account):
return
str
(
e
)
def
getRcode
(
config
):
parser
=
ConfigParser
.
ConfigParser
()
try
:
parser
.
read
(
config
[
'knowledge0_cfg'
])
return
parser
.
get
(
'private'
,
'recovery-code'
)
except
(
ConfigParser
.
NoSectionError
,
IOError
)
as
e
:
return
None
def
createNewUser
(
config
,
name
,
passwd
):
htpasswdfile
=
os
.
path
.
join
(
config
[
'etc_dir'
],
'.htpasswd'
)
if
os
.
path
.
exists
(
htpasswdfile
):
...
...
slapos/runner/views.py
View file @
878e68ad
...
...
@@ -16,7 +16,7 @@ from slapos.runner.process import killRunningProcess
from
slapos.runner.utils
import
(
checkSoftwareFolder
,
configNewSR
,
createNewUser
,
getProfilePath
,
listFolder
,
getBuildAndRunParams
,
getProjectTitle
,
getSession
,
getProjectTitle
,
get
Rcode
,
get
Session
,
getSlapStatus
,
getSvcStatus
,
getSvcTailProcess
,
isInstanceRunning
,
isSoftwareRunning
,
isSoftwareReleaseReady
,
isText
,
...
...
@@ -552,7 +552,7 @@ def updateBuildAndRunConfig():
#update user account data
def
updateAccount
():
code
=
request
.
form
[
'rcode'
].
strip
()
recovery_code
=
open
(
os
.
path
.
join
(
app
.
config
[
'etc_dir'
],
".rcode"
),
"r"
).
read
(
)
recovery_code
=
getRcode
(
app
.
config
)
if
code
!=
recovery_code
:
return
jsonify
(
code
=
0
,
result
=
"Your password recovery code is not valid!"
)
...
...
@@ -583,8 +583,7 @@ def configAccount():
account
.
append
(
request
.
form
[
'email'
].
strip
())
account
.
append
(
request
.
form
[
'name'
].
strip
())
code
=
request
.
form
[
'rcode'
].
strip
()
recovery_code
=
open
(
os
.
path
.
join
(
app
.
config
[
'etc_dir'
],
".rcode"
),
"r"
).
read
().
strip
()
recovery_code
=
getRcode
(
app
.
config
)
if
code
!=
recovery_code
:
return
jsonify
(
code
=
0
,
result
=
"Your password recovery code is not valid!"
)
result
=
saveSession
(
app
.
config
,
account
)
...
...
@@ -595,8 +594,7 @@ def configAccount():
def
addUser
():
code
=
request
.
form
[
'rcode'
].
strip
()
recovery_code
=
open
(
os
.
path
.
join
(
app
.
config
[
'etc_dir'
],
".rcode"
),
"r"
).
read
().
strip
()
recovery_code
=
getRcode
(
app
.
config
)
if
code
!=
recovery_code
:
return
jsonify
(
code
=
0
,
result
=
"Your password recovery code is not valid!"
)
if
createNewUser
(
app
.
config
,
request
.
form
[
'username'
],
...
...
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