Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
96d01458
Commit
96d01458
authored
Apr 12, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2605 from b6d/postgresql_user-quote-pwd
Use psycopg2's string handling to escape password string
parents
2da03604
77068018
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
4 deletions
+8
-4
library/postgresql_user
+8
-4
No files found.
library/postgresql_user
View file @
96d01458
...
@@ -142,8 +142,10 @@ def user_exists(cursor, user):
...
@@ -142,8 +142,10 @@ def user_exists(cursor, user):
def
user_add
(
cursor
,
user
,
password
,
role_attr_flags
):
def
user_add
(
cursor
,
user
,
password
,
role_attr_flags
):
"""Create a new database user (role)."""
"""Create a new database user (role)."""
query
=
"CREATE USER
\"
%(user)
s
\"
with PASSWORD '
%(password)
s'
%(role_attr_flags)
s"
query
=
'CREATE USER "
%(user)
s" WITH PASSWORD
%%(password)
s
%(role_attr_flags)
s'
%
{
cursor
.
execute
(
query
%
{
"user"
:
user
,
"password"
:
password
,
"role_attr_flags"
:
role_attr_flags
})
"user"
:
user
,
"role_attr_flags"
:
role_attr_flags
}
cursor
.
execute
(
query
,
{
"password"
:
password
})
return
True
return
True
def
user_alter
(
cursor
,
user
,
password
,
role_attr_flags
):
def
user_alter
(
cursor
,
user
,
password
,
role_attr_flags
):
...
@@ -168,8 +170,10 @@ def user_alter(cursor, user, password, role_attr_flags):
...
@@ -168,8 +170,10 @@ def user_alter(cursor, user, password, role_attr_flags):
if
password
is
not
None
:
if
password
is
not
None
:
# Update the role attributes, including password.
# Update the role attributes, including password.
alter
=
"ALTER USER
\"
%(user)
s
\"
WITH PASSWORD '
%(password)
s'
%(role_attr_flags)
s"
alter
=
'ALTER USER "
%(user)
s" WITH PASSWORD
%%(password)
s
%(role_attr_flags)
s'
%
{
cursor
.
execute
(
alter
%
{
"user"
:
user
,
"password"
:
password
,
"role_attr_flags"
:
role_attr_flags
})
"user"
:
user
,
"role_attr_flags"
:
role_attr_flags
}
cursor
.
execute
(
alter
,
{
"password"
:
password
})
else
:
else
:
# Update the role attributes, excluding password.
# Update the role attributes, excluding password.
alter
=
"ALTER USER
\"
%(user)
s
\"
WITH
%(role_attr_flags)
s"
alter
=
"ALTER USER
\"
%(user)
s
\"
WITH
%(role_attr_flags)
s"
...
...
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