Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
SlapOS Develop
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
Eric Zheng
SlapOS Develop
Commits
b3b7f065
Commit
b3b7f065
authored
Sep 25, 2012
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
only listen to ipv6 address, and unix socket
parent
8ab881ea
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
7 deletions
+14
-7
slapos/recipe/postgres/__init__.py
slapos/recipe/postgres/__init__.py
+14
-7
No files found.
slapos/recipe/postgres/__init__.py
View file @
b3b7f065
...
@@ -27,13 +27,11 @@
...
@@ -27,13 +27,11 @@
import
md5
import
md5
import
os
import
os
import
sys
import
subprocess
import
subprocess
import
textwrap
import
textwrap
from
zc.buildout
import
UserError
from
zc.buildout
import
UserError
from
slapos.recipe.librecipe
import
GenericBaseRecipe
from
slapos.recipe.librecipe
import
GenericBaseRecipe
from
slapos.recipe.librecipe
import
filehash
class
Recipe
(
GenericBaseRecipe
):
class
Recipe
(
GenericBaseRecipe
):
...
@@ -75,11 +73,13 @@ class Recipe(GenericBaseRecipe):
...
@@ -75,11 +73,13 @@ class Recipe(GenericBaseRecipe):
def
createConfig
(
self
):
def
createConfig
(
self
):
from
zc.buildout
import
buildout
pgdata
=
self
.
options
[
'pgdata-directory'
]
pgdata
=
self
.
options
[
'pgdata-directory'
]
host
=
buildout
.
loads
(
self
.
options
[
'ipv6_host'
]).
pop
()
# XXX ugly hack
with
open
(
os
.
path
.
join
(
pgdata
,
'postgresql.conf'
),
'wb'
)
as
cfg
:
with
open
(
os
.
path
.
join
(
pgdata
,
'postgresql.conf'
),
'wb'
)
as
cfg
:
# XXX TODO listen_addresses
cfg
.
write
(
textwrap
.
dedent
(
"""
\
cfg
.
write
(
textwrap
.
dedent
(
"""
\
listen_addresses = '%s'
logging_collector = on
logging_collector = on
log_rotation_size = 50MB
log_rotation_size = 50MB
max_connections = 100
max_connections = 100
...
@@ -90,7 +90,7 @@ class Recipe(GenericBaseRecipe):
...
@@ -90,7 +90,7 @@ class Recipe(GenericBaseRecipe):
lc_numeric = 'en_US.UTF-8'
lc_numeric = 'en_US.UTF-8'
lc_time = 'en_US.UTF-8'
lc_time = 'en_US.UTF-8'
default_text_search_config = 'pg_catalog.english'
default_text_search_config = 'pg_catalog.english'
"""
))
"""
%
host
))
with
open
(
os
.
path
.
join
(
pgdata
,
'pg_hba.conf'
),
'wb'
)
as
cfg
:
with
open
(
os
.
path
.
join
(
pgdata
,
'pg_hba.conf'
),
'wb'
)
as
cfg
:
...
@@ -103,7 +103,8 @@ class Recipe(GenericBaseRecipe):
...
@@ -103,7 +103,8 @@ class Recipe(GenericBaseRecipe):
local all all ident
local all all ident
host all all 127.0.0.1/32 md5
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
host all all ::1/128 md5
"""
))
host all all %s/128 md5
"""
%
host
))
def
createDatabase
(
self
):
def
createDatabase
(
self
):
...
@@ -114,9 +115,14 @@ class Recipe(GenericBaseRecipe):
...
@@ -114,9 +115,14 @@ class Recipe(GenericBaseRecipe):
"""
"""
Creates a Postgres superuser - other than "slapuser#" for use by the application.
Creates a Postgres superuser - other than "slapuser#" for use by the application.
"""
"""
user
=
self
.
options
[
'user'
]
password
=
'insecure'
password
=
'insecure'
enc_password
=
md5
.
md5
(
password
).
hexdigest
()
self
.
runPostgresCommand
(
cmd
=
"""CREATE USER "%s" PASSWORD '%s' SUPERUSER"""
%
(
self
.
options
[
'user'
],
enc_password
))
# XXX should send it encrypted, didn't work
# http://postgresql.1045698.n5.nabble.com/Algorithm-for-generating-md5-encrypted-password-not-found-in-documentation-td4919082.html
# enc_password = 'md5' + md5.md5(password+user).hexdigest()
self
.
runPostgresCommand
(
cmd
=
"""CREATE USER "%s" ENCRYPTED PASSWORD '%s' SUPERUSER"""
%
(
user
,
password
))
def
runPostgresCommand
(
self
,
cmd
):
def
runPostgresCommand
(
self
,
cmd
):
...
@@ -135,6 +141,7 @@ class Recipe(GenericBaseRecipe):
...
@@ -135,6 +141,7 @@ class Recipe(GenericBaseRecipe):
p
=
subprocess
.
Popen
([
postgres_binary
,
p
=
subprocess
.
Popen
([
postgres_binary
,
'--single'
,
'--single'
,
'-D'
,
pgdata
,
'-D'
,
pgdata
,
'-d'
,
'1'
,
# debug level, do not output commands
'postgres'
,
'postgres'
,
],
stdin
=
subprocess
.
PIPE
)
],
stdin
=
subprocess
.
PIPE
)
...
...
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