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
6
Merge Requests
6
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
slapos.toolbox
Commits
ef27fd3f
Commit
ef27fd3f
authored
Dec 02, 2013
by
Nicolas Wavrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slaprunner: create a .htpasswd on first run if .users is defined yet
parent
c6007954
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
0 deletions
+16
-0
slapos/runner/__init__.py
slapos/runner/__init__.py
+16
-0
No files found.
slapos/runner/__init__.py
View file @
ef27fd3f
...
...
@@ -8,6 +8,7 @@ import logging
import
logging.handlers
from
optparse
import
OptionParser
,
Option
import
os
from
slapos.htpasswd
import
HtpasswdFile
from
slapos.runner.process
import
setHandler
import
sys
from
slapos.runner.utils
import
(
runInstanceWithLock
,
...
...
@@ -65,6 +66,20 @@ class Config:
self
.
logger
.
debug
(
"Verbose mode enabled."
)
def
checkHtpasswd
(
config
):
"""XXX:set for backward compatiblity
create a htpassword if etc/.users exist"""
user
=
os
.
path
.
join
(
config
[
'etc_dir'
],
'.users'
)
htpasswdfile
=
os
.
path
.
join
(
config
[
'etc_dir'
],
'.htpasswd'
)
if
os
.
path
.
exists
(
user
)
and
not
os
.
path
.
exists
(
htpasswdfile
):
data
=
open
(
user
).
read
().
strip
().
split
(
';'
)
htpasswd
=
HtpasswdFile
(
htpasswdfile
,
create
=
True
)
htpasswd
.
update
(
data
[
0
],
data
[
1
])
htpasswd
.
save
()
else
:
return
def
run
():
"Run default configuration."
usage
=
"usage: %s [options] CONFIGURATION_FILE"
%
sys
.
argv
[
0
]
...
...
@@ -94,6 +109,7 @@ def serve(config):
SECRET_KEY
=
os
.
urandom
(
24
),
PERMANENT_SESSION_LIFETIME
=
datetime
.
timedelta
(
days
=
31
),
)
checkHtpasswd
(
app
.
config
)
if
not
os
.
path
.
exists
(
workdir
):
os
.
mkdir
(
workdir
)
if
not
os
.
path
.
exists
(
software_link
):
...
...
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