postgresql: Quote role names when creating database users

This commit is contained in:
Christian Kampka 2019-12-08 21:33:07 +01:00 committed by Austin Seipp
parent 6242cf6f7b
commit b85286fe66
1 changed files with 2 additions and 2 deletions

View File

@ -339,9 +339,9 @@ in
'') cfg.ensureDatabases} '') cfg.ensureDatabases}
'' + '' '' + ''
${concatMapStrings (user: '' ${concatMapStrings (user: ''
$PSQL -tAc "SELECT 1 FROM pg_roles WHERE rolname='${user.name}'" | grep -q 1 || $PSQL -tAc "CREATE USER ${user.name}" $PSQL -tAc "SELECT 1 FROM pg_roles WHERE rolname='${user.name}'" | grep -q 1 || $PSQL -tAc 'CREATE USER "${user.name}"'
${concatStringsSep "\n" (mapAttrsToList (database: permission: '' ${concatStringsSep "\n" (mapAttrsToList (database: permission: ''
$PSQL -tAc 'GRANT ${permission} ON ${database} TO ${user.name}' $PSQL -tAc 'GRANT ${permission} ON ${database} TO "${user.name}"'
'') user.ensurePermissions)} '') user.ensurePermissions)}
'') cfg.ensureUsers} '') cfg.ensureUsers}
''; '';