...
 
Commits (12)
v0.13.0
- [dns] Adds differentiation between domains and hostnames, allowing to use
additional valid custom dns entries.
- Adds option field to several more tables
- Adds some basic tests for development
- Changes to only allow a more limited set of login names
- Changes to a better structure in docs
- Fixes performance issue
- Fixes many static code anlaysis warnings
- Fixes missing consitency checks
v0.12.0
- Changes uids to centralized sequence
- Fixes srv_record cannot serve if "domain_prefix" contains underscore (#21)
......
dev-gen-docs:
SHELL=/bin/bash
dev-gen-html-docs:
mkdir -p docs/schemas
mkdir -p docs/schemas_system
rm -f docs/schemas/*.rst
rm -f docs/schemas_system/*.rst
./dev/all-schemas-hamsql-setup.py | hamsql doc -s - -o docs/schemas
mv docs/schemas/{backend,commons,system,user}.rst docs/schemas_system
rm -r docs/_build
make -C docs html
dev-gen-docs: dev-gen-html-docs
make -C docs man
make -C docs latex
make -C docs/_build/latex
services:
- service: domain_reseller
subservices:
- domain
- handle
entity_name: reseller.invalid
machines:
- server.example
dns: []
- service: domain_registered
subservices:
- managed
entity_name: nameserver.invalid
machines:
- server.example
dns: []
- service: dns
subservices:
- managed
entity_name: dns.invalid
machines:
- server.example
dns: []
services:
- service: email
subservices:
- mailbox
- alias
- list
- redirection
- dns_activatable
entity_name: mail.my-org.example
machines:
- server.example
dns:
# MX
- type: MX
rdata:
exchange: mail.example.org.
priority: 20
# SPF
- type: TXT
rdata:
txtdata:
- "v=spf1 +mx ~all"
# Auto-configuration for email clients
# <https://tools.ietf.org/html/rfc6186>
- type: SRV
rdata:
service: imap
proto: tcp
port: 143
target: mail.example.org.
weight: 1
priority: 0
- type: SRV
rdata:
service: submission
proto: tcp
port: 587
target: mail.example.org.
weight: 1
priority: 0
# Thunderbird autoconfig
# <https://developer.mozilla.org/docs/Mozilla/Thunderbird/Autoconfiguration>
- type: A
domain_prefix: autoconfig.
rdata:
address: 127.0.0.1
services:
- service: jabber
subservices:
- account
entity_name: jabber.my-org.example
machines:
- server.example
dns:
- type: A
domain_prefix: jabber-server
rdata:
address: 127.0.0.1
- type: SRV
rdata:
port: 5222
proto: tcp
target: jabber-server
weight: 5
service: xmpp-client
priority: 0
- type: SRV
domain_prefix: conference.
rdata:
port: 5222
proto: tcp
target: jabber-server
weight: 5
service: xmpp-client
priority: 0
- type: SRV
rdata:
port: 5269
proto: tcp
target: jabber-server
weight: 5
service: xmpp-server
priority: 0
- type: SRV
rdata:
port: 5269
proto: tcp
target: jabber-server
weight: 5
service: xmpp-server
priority: 0
machines:
- name: server.example
auth_roles: [postgres]
services:
- service: server_access
subservices:
- ssh
entity_name: web.my-org.example
machines:
- server.example
dns: []
- service: web
subservices:
- site
entity_name: web.my-org.example
machines:
- server.example
dns:
- type: A
rdata:
address: 127.0.0.1
- type: AAAA
rdata:
address: ::1
#!/bin/bash
#!/bin/bash -e
log=/tmp/carnivora-dev-deploy.log
yamsql=/tmp/yamsql-out
setup=../examples/setup.yml
db=postgresql://postgres@/carnivora
echo "" > $log
chmod go= $log
if [ ! "$2" ] || [ "$2" == "1" ]; then
hamsql install \
--delete-existing-database \
--delete-residual-roles \
......@@ -14,6 +16,16 @@ hamsql install \
--sql-log $log \
--setup $setup \
--connection $db
fi
if [ ! "$2" ] || [ "$2" == "2" ]; then
echo "LISTEN \"carnivora/server.example\"; SELECT pg_sleep(2); SELECT 1;" | psql carnivora postgres &
psql $db --file $1 --set ON_ERROR_STOP=on
echo "CREATE EXTENSION plpgsql_check;" | psql $db
sleep 2
echo "---"
fi
#hamsql yamsql --connection $db "${yamsql}"
This diff is collapsed.
#!/bin/bash
log=/tmp/carnivora-dev-upgrade.log
setup=../examples/setup.yml
db=postgresql://postgres@/carnivora
echo "" > $log
chmod go= $log
hamsql upgrade \
--sql-log $log \
--setup $setup \
--connection $db
......@@ -60,9 +60,9 @@ author = 'Sophie Herold'
# built documents.
#
# The short X.Y version.
version = '0.12'
version = '0.13'
# The full version, including alpha/beta/rc tags.
release = '0.12.2'
release = '0.13.1'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
......
......@@ -4,17 +4,32 @@ PostgreSQL
Types
-----
.. _DOMAIN-anyarray:
``anyarray``
~~~~~~~~~~~~
.. _DOMAIN-bigint:
.. _DOMAIN-bigint[]:
``bigint``
~~~~~~~~~~~
.. _DOMAIN-bool:
.. _DOMAIN-boolean:
``boolean``
~~~~~~~~~~~
.. _DOMAIN-integer:
.. _DOMAIN-int:
.. _DOMAIN-integer[]:
.. _DOMAIN-int[]:
``integer``
~~~~~~~~~~~
.. _DOMAIN-int:
- int
.. _DOMAIN-jsonb:
......@@ -37,6 +52,8 @@ Types
- https://www.postgresql.org/docs/current/static/uuid-ossp.html
.. _DOMAIN-varchar:
.. _DOMAIN-varchar[]:
``varchar``
~~~~~~~~~~~
......
This diff is collapsed.
......@@ -66,7 +66,7 @@ Foreign keys
Columns
- .. _COLUMN-domain_reseller.handle.service_entity_name:
``service_entity_name`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
``service_entity_name`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
Service entity name
......@@ -266,7 +266,7 @@ Primary key
Columns
- .. _COLUMN-domain_reseller.registered.domain:
``domain`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
``domain`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
Domain
......@@ -384,15 +384,12 @@ Parameters
Variables defined for body
- ``v_service_entity_name`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
- ``v_service_entity_name`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
- ``v_owner`` :ref:`user.t_user <DOMAIN-user.t_user>`
- ``v_login`` :ref:`user.t_user <DOMAIN-user.t_user>`
Returns
void
......@@ -404,7 +401,6 @@ Execute privilege
.. code-block:: plpgsql
-- begin userlogin prelude
v_login := (SELECT t.owner FROM "user"._get_login() AS t);
v_owner := (SELECT t.act_as FROM "user"._get_login() AS t);
-- end userlogin prelude
......@@ -453,10 +449,6 @@ Parameters
Variables defined for body
- ``v_machine`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
Returns
void
......@@ -467,7 +459,7 @@ Execute privilege
.. code-block:: plpgsql
v_machine := (SELECT "machine" FROM "backend"._get_login());
PERFORM backend._get_login();
UPDATE domain_reseller.handle
......@@ -484,7 +476,7 @@ Execute privilege
Update status
Parameters
- ``p_domain`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
- ``p_domain`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
- ``p_payable`` :ref:`timestamp <DOMAIN-timestamp>`
......@@ -507,10 +499,6 @@ Parameters
Variables defined for body
- ``v_machine`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
Returns
void
......@@ -521,7 +509,7 @@ Execute privilege
.. code-block:: plpgsql
v_machine := (SELECT "machine" FROM "backend"._get_login());
PERFORM backend._get_login();
UPDATE domain_reseller.registered
......@@ -546,7 +534,7 @@ Parameters
- ``p_alias`` :ref:`varchar <DOMAIN-varchar>`
- ``p_service_entity_name`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
- ``p_service_entity_name`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
- ``p_fname`` :ref:`varchar <DOMAIN-varchar>`
......@@ -591,9 +579,6 @@ Variables defined for body
- ``v_owner`` :ref:`user.t_user <DOMAIN-user.t_user>`
- ``v_login`` :ref:`user.t_user <DOMAIN-user.t_user>`
Returns
void
......@@ -605,7 +590,6 @@ Execute privilege
.. code-block:: plpgsql
-- begin userlogin prelude
v_login := (SELECT t.owner FROM "user"._get_login() AS t);
v_owner := (SELECT t.act_as FROM "user"._get_login() AS t);
-- end userlogin prelude
......@@ -663,7 +647,7 @@ Execute privilege
Inserts details for registered domain
Parameters
- ``p_domain`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
- ``p_domain`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
- ``p_registrant`` :ref:`varchar <DOMAIN-varchar>`
......@@ -678,9 +662,6 @@ Variables defined for body
- ``v_owner`` :ref:`user.t_user <DOMAIN-user.t_user>`
- ``v_login`` :ref:`user.t_user <DOMAIN-user.t_user>`
Returns
void
......@@ -692,7 +673,6 @@ Execute privilege
.. code-block:: plpgsql
-- begin userlogin prelude
v_login := (SELECT t.owner FROM "user"._get_login() AS t);
v_owner := (SELECT t.act_as FROM "user"._get_login() AS t);
-- end userlogin prelude
......@@ -721,9 +701,6 @@ Variables defined for body
- ``v_owner`` :ref:`user.t_user <DOMAIN-user.t_user>`
- ``v_login`` :ref:`user.t_user <DOMAIN-user.t_user>`
Returns
SETOF domain_reseller."handle"
......@@ -735,7 +712,6 @@ Execute privilege
.. code-block:: plpgsql
-- begin userlogin prelude
v_login := (SELECT t.owner FROM "user"._get_login() AS t);
v_owner := (SELECT t.act_as FROM "user"._get_login() AS t);
-- end userlogin prelude
......@@ -743,7 +719,7 @@ Execute privilege
RETURN QUERY
SELECT * FROM domain_reseller.handle
WHERE
owner=v_owner OR (owner=v_login AND NOT p_hide_foreign)
owner=v_owner OR (owner="user"._login_user() AND NOT p_hide_foreign)
ORDER BY backend_status, fname, lname, alias;
......@@ -763,15 +739,12 @@ Variables defined for body
- ``v_owner`` :ref:`user.t_user <DOMAIN-user.t_user>`
- ``v_login`` :ref:`user.t_user <DOMAIN-user.t_user>`
Returns
TABLE
Returned columns
- ``domain`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
- ``domain`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
- ``registrant`` :ref:`varchar <DOMAIN-varchar>`
......@@ -800,7 +773,6 @@ Execute privilege
.. code-block:: plpgsql
-- begin userlogin prelude
v_login := (SELECT t.owner FROM "user"._get_login() AS t);
v_owner := (SELECT t.act_as FROM "user"._get_login() AS t);
-- end userlogin prelude
......@@ -843,9 +815,6 @@ Variables defined for body
- ``v_owner`` :ref:`user.t_user <DOMAIN-user.t_user>`
- ``v_login`` :ref:`user.t_user <DOMAIN-user.t_user>`
Returns
TABLE
......@@ -853,7 +822,7 @@ Returns
Returned columns
- ``subservice`` :ref:`commons.t_key <DOMAIN-commons.t_key>`
- ``service_entity_name`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
- ``service_entity_name`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
Execute privilege
......@@ -862,7 +831,6 @@ Execute privilege
.. code-block:: plpgsql
-- begin userlogin prelude
v_login := (SELECT t.owner FROM "user"._get_login() AS t);
v_owner := (SELECT t.act_as FROM "user"._get_login() AS t);
-- end userlogin prelude
......@@ -896,10 +864,6 @@ Parameters
Variables defined for body
- ``v_machine`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
Returns
SETOF domain_reseller."handle"
......@@ -910,7 +874,7 @@ Execute privilege
.. code-block:: plpgsql
v_machine := (SELECT "machine" FROM "backend"._get_login());
PERFORM backend._get_login();
RETURN QUERY
......@@ -953,16 +917,12 @@ Parameters
Variables defined for body
- ``v_machine`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
Returns
TABLE
Returned columns
- ``domain`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
- ``domain`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
- ``registrant`` :ref:`varchar <DOMAIN-varchar>`
......@@ -988,7 +948,7 @@ Execute privilege
.. code-block:: plpgsql
v_machine := (SELECT "machine" FROM "backend"._get_login());
PERFORM backend._get_login();
RETURN QUERY
......@@ -1055,15 +1015,12 @@ Parameters
Variables defined for body
- ``v_service_entity_name`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
- ``v_service_entity_name`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
- ``v_owner`` :ref:`user.t_user <DOMAIN-user.t_user>`
- ``v_login`` :ref:`user.t_user <DOMAIN-user.t_user>`
Returns
void
......@@ -1075,7 +1032,6 @@ Execute privilege
.. code-block:: plpgsql
-- begin userlogin prelude
v_login := (SELECT t.owner FROM "user"._get_login() AS t);
v_owner := (SELECT t.act_as FROM "user"._get_login() AS t);
-- end userlogin prelude
......@@ -1113,7 +1069,7 @@ Execute privilege
Updates details for registered domain
Parameters
- ``p_domain`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
- ``p_domain`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
- ``p_admin_c`` :ref:`varchar <DOMAIN-varchar>`
......@@ -1122,7 +1078,7 @@ Parameters
Variables defined for body
- ``v_nameserver`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
- ``v_nameserver`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
- ``v_managed`` :ref:`commons.t_key <DOMAIN-commons.t_key>`
......@@ -1131,9 +1087,6 @@ Variables defined for body
- ``v_owner`` :ref:`user.t_user <DOMAIN-user.t_user>`
- ``v_login`` :ref:`user.t_user <DOMAIN-user.t_user>`
Returns
void
......@@ -1145,7 +1098,6 @@ Execute privilege
.. code-block:: plpgsql
-- begin userlogin prelude
v_login := (SELECT t.owner FROM "user"._get_login() AS t);
v_owner := (SELECT t.act_as FROM "user"._get_login() AS t);
-- end userlogin prelude
......
This diff is collapsed.
......@@ -62,7 +62,7 @@ Foreign keys
Columns
- .. _COLUMN-jabber.account.domain:
``domain`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
``domain`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
Domain name
......@@ -80,7 +80,7 @@ Columns
- .. _COLUMN-jabber.account.service_entity_name:
``service_entity_name`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
``service_entity_name`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
ent. name
......@@ -162,7 +162,7 @@ Parameters
- ``p_node`` :ref:`email.t_localpart <DOMAIN-email.t_localpart>`
- ``p_domain`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
- ``p_domain`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
......@@ -171,9 +171,6 @@ Variables defined for body
- ``v_owner`` :ref:`user.t_user <DOMAIN-user.t_user>`
- ``v_login`` :ref:`user.t_user <DOMAIN-user.t_user>`
Returns
void
......@@ -185,7 +182,6 @@ Execute privilege
.. code-block:: plpgsql
-- begin userlogin prelude
v_login := (SELECT t.owner FROM "user"._get_login() AS t);
v_owner := (SELECT t.act_as FROM "user"._get_login() AS t);
-- end userlogin prelude
......@@ -212,7 +208,7 @@ Parameters
- ``p_node`` :ref:`email.t_localpart <DOMAIN-email.t_localpart>`
- ``p_domain`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
- ``p_domain`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
- ``p_password`` :ref:`commons.t_password_plaintext <DOMAIN-commons.t_password_plaintext>`
......@@ -230,9 +226,6 @@ Variables defined for body
- ``v_owner`` :ref:`user.t_user <DOMAIN-user.t_user>`
- ``v_login`` :ref:`user.t_user <DOMAIN-user.t_user>`
Returns
void
......@@ -244,7 +237,6 @@ Execute privilege
.. code-block:: plpgsql
-- begin userlogin prelude
v_login := (SELECT t.owner FROM "user"._get_login() AS t);
v_owner := (SELECT t.act_as FROM "user"._get_login() AS t);
-- end userlogin prelude
......@@ -284,9 +276,6 @@ Variables defined for body
- ``v_owner`` :ref:`user.t_user <DOMAIN-user.t_user>`
- ``v_login`` :ref:`user.t_user <DOMAIN-user.t_user>`
Returns
TABLE
......@@ -294,7 +283,7 @@ Returns
Returned columns
- ``node`` :ref:`email.t_localpart <DOMAIN-email.t_localpart>`
- ``domain`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
- ``domain`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
- ``backend_status`` :ref:`backend.t_status <DOMAIN-backend.t_status>`
......@@ -305,7 +294,6 @@ Execute privilege
.. code-block:: plpgsql
-- begin userlogin prelude
v_login := (SELECT t.owner FROM "user"._get_login() AS t);
v_owner := (SELECT t.act_as FROM "user"._get_login() AS t);
-- end userlogin prelude
......@@ -335,10 +323,6 @@ Parameters
Variables defined for body
- ``v_machine`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
Returns
TABLE
......@@ -346,7 +330,7 @@ Returns
Returned columns
- ``node`` :ref:`email.t_localpart <DOMAIN-email.t_localpart>`
- ``domain`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
- ``domain`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
- ``password`` :ref:`commons.t_password <DOMAIN-commons.t_password>`
......@@ -358,7 +342,7 @@ Execute privilege
.. code-block:: plpgsql
v_machine := (SELECT "machine" FROM "backend"._get_login());
PERFORM backend._get_login();
RETURN QUERY
......@@ -406,7 +390,7 @@ Parameters
- ``p_node`` :ref:`email.t_localpart <DOMAIN-email.t_localpart>`
- ``p_domain`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
- ``p_domain`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
- ``p_password`` :ref:`commons.t_password_plaintext <DOMAIN-commons.t_password_plaintext>`
......@@ -418,9 +402,6 @@ Variables defined for body
- ``v_owner`` :ref:`user.t_user <DOMAIN-user.t_user>`
- ``v_login`` :ref:`user.t_user <DOMAIN-user.t_user>`
Returns
void
......@@ -432,7 +413,6 @@ Execute privilege
.. code-block:: plpgsql
-- begin userlogin prelude
v_login := (SELECT t.owner FROM "user"._get_login() AS t);
v_owner := (SELECT t.act_as FROM "user"._get_login() AS t);
-- end userlogin prelude
......
......@@ -62,7 +62,7 @@ Foreign keys
Columns
- .. _COLUMN-server_access.user.service_entity_name:
``service_entity_name`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
``service_entity_name`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
Service entity name
......@@ -166,7 +166,7 @@ Parameters
- ``p_user`` :ref:`server_access.t_user <DOMAIN-server_access.t_user>`
- ``p_service_entity_name`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
- ``p_service_entity_name`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
......@@ -178,9 +178,6 @@ Variables defined for body
- ``v_owner`` :ref:`user.t_user <DOMAIN-user.t_user>`
- ``v_login`` :ref:`user.t_user <DOMAIN-user.t_user>`
Returns
void
......@@ -192,7 +189,6 @@ Execute privilege
.. code-block:: plpgsql
-- begin userlogin prelude
v_login := (SELECT t.owner FROM "user"._get_login() AS t);
v_owner := (SELECT t.act_as FROM "user"._get_login() AS t);
-- end userlogin prelude
......@@ -235,7 +231,7 @@ Parameters
- ``p_user`` :ref:`server_access.t_user <DOMAIN-server_access.t_user>`
- ``p_service_entity_name`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
- ``p_service_entity_name`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
- ``p_subservice`` :ref:`commons.t_key <DOMAIN-commons.t_key>`
......@@ -253,9 +249,6 @@ Variables defined for body
- ``v_owner`` :ref:`user.t_user <DOMAIN-user.t_user>`
- ``v_login`` :ref:`user.t_user <DOMAIN-user.t_user>`
Returns
void
......@@ -267,7 +260,6 @@ Execute privilege
.. code-block:: plpgsql
-- begin userlogin prelude
v_login := (SELECT t.owner FROM "user"._get_login() AS t);
v_owner := (SELECT t.act_as FROM "user"._get_login() AS t);
-- end userlogin prelude
......@@ -302,9 +294,6 @@ Variables defined for body
- ``v_owner`` :ref:`user.t_user <DOMAIN-user.t_user>`
- ``v_login`` :ref:`user.t_user <DOMAIN-user.t_user>`
Returns
TABLE
......@@ -318,7 +307,7 @@ Returned columns
- ``subservice`` :ref:`commons.t_key <DOMAIN-commons.t_key>`
- ``service_entity_name`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
- ``service_entity_name`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
- ``backend_status`` :ref:`backend.t_status <DOMAIN-backend.t_status>`
......@@ -329,7 +318,6 @@ Execute privilege
.. code-block:: plpgsql
-- begin userlogin prelude
v_login := (SELECT t.owner FROM "user"._get_login() AS t);
v_owner := (SELECT t.act_as FROM "user"._get_login() AS t);
-- end userlogin prelude
......@@ -364,10 +352,6 @@ Parameters
Variables defined for body
- ``v_machine`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
Returns
TABLE
......@@ -381,7 +365,7 @@ Returned columns
- ``subservice`` :ref:`commons.t_key <DOMAIN-commons.t_key>`
- ``service_entity_name`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
- ``service_entity_name`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
- ``backend_status`` :ref:`backend.t_status <DOMAIN-backend.t_status>`
......@@ -393,7 +377,7 @@ Execute privilege
.. code-block:: plpgsql
v_machine := (SELECT "machine" FROM "backend"._get_login());
PERFORM backend._get_login();
RETURN QUERY
......@@ -444,7 +428,7 @@ Parameters
- ``p_user`` :ref:`server_access.t_user <DOMAIN-server_access.t_user>`
- ``p_service_entity_name`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
- ``p_service_entity_name`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
- ``p_password`` :ref:`commons.t_password_plaintext <DOMAIN-commons.t_password_plaintext>`
......@@ -462,9 +446,6 @@ Variables defined for body
- ``v_owner`` :ref:`user.t_user <DOMAIN-user.t_user>`
- ``v_login`` :ref:`user.t_user <DOMAIN-user.t_user>`
Returns
void
......@@ -476,7 +457,6 @@ Execute privilege
.. code-block:: plpgsql
-- begin userlogin prelude
v_login := (SELECT t.owner FROM "user"._get_login() AS t);
v_owner := (SELECT t.act_as FROM "user"._get_login() AS t);
-- end userlogin prelude
......@@ -491,7 +471,8 @@ Execute privilege
backend_status = 'upd'
WHERE
"user" = p_user AND
service_entity_name = p_service_entity_name
service_entity_name = p_service_entity_name AND
owner = v_owner
RETURNING subservice INTO v_subservice;
PERFORM backend._conditional_notify_service_entity_name(
......@@ -520,7 +501,7 @@ Checks
.. code-block:: sql
VALUE ~ '^[a-z0-9_-]+$'
VALUE ~ '^[a-z0-9\-_]+$'
- ``no_repeated_hyphens``
Reserve double hyphens as a seperator for system generated users.
......
This diff is collapsed.
......@@ -35,6 +35,19 @@ Primary key
Columns
- .. _COLUMN-backend.auth.option:
``option`` :ref:`jsonb <DOMAIN-jsonb>`
Free options in JSON format
Default
.. code-block:: sql
'{}'
- .. _COLUMN-backend.auth.role:
``role`` :ref:`commons.t_key <DOMAIN-commons.t_key>`
......@@ -47,7 +60,7 @@ Columns
- .. _COLUMN-backend.auth.machine:
``machine`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
``machine`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
Machine for which the rights are granted.
......@@ -76,9 +89,22 @@ Primary key
Columns
- .. _COLUMN-backend.machine.option:
``option`` :ref:`jsonb <DOMAIN-jsonb>`
Free options in JSON format
Default
.. code-block:: sql
'{}'
- .. _COLUMN-backend.machine.name:
``name`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
``name`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
Machine name
......@@ -138,7 +164,7 @@ Parameters
- ``p_subservice`` :ref:`commons.t_key <DOMAIN-commons.t_key>`
- ``p_domain`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
- ``p_domain`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
......@@ -171,7 +197,7 @@ Parameters
- ``p_condition`` :ref:`boolean <DOMAIN-boolean>`
- ``p_service_entity_name`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
- ``p_service_entity_name`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
- ``p_service`` :ref:`commons.t_key <DOMAIN-commons.t_key>`
......@@ -243,7 +269,7 @@ Returns
TABLE
Returned columns
- ``machine`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
- ``machine`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
......@@ -261,6 +287,30 @@ Returned columns
.. _FUNCTION-backend._login_machine:
``backend._login_machine``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Shows machine for the current backend login.
Parameters
*None*
Returns
dns.t_hostname
.. code-block:: plpgsql
RETURN (SELECT machine FROM backend._get_login());
.. _FUNCTION-backend._machine_priviledged:
``backend._machine_priviledged``
......@@ -270,37 +320,27 @@ Checks if a currently connected machine is priviledged to obtain data for
a certain service for a certain domain name.
.. warning::
The parameter p_domain must be a domain, which means an entry in
the column dns.service.domain. It must not be confused with a service_entity_name.
The parameter ``p_domain`` must be a domain, which means an entry in
the column dns.service.domain. It must not be confused with a
``service_entity_name``.
Parameters
- ``p_service`` :ref:`commons.t_key <DOMAIN-commons.t_key>`
- ``p_domain`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
- ``p_include_inactive`` :ref:`boolean <DOMAIN-boolean>`
- ``p_domain`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
Variables defined for body
- ``v_machine`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
Returns
boolean
Execute privilege
- :ref:`backend <ROLE-backend>`
.. code-block:: plpgsql
v_machine := (SELECT "machine" FROM "backend"._get_login());
RETURN COALESCE(
(
......@@ -313,7 +353,7 @@ Execute privilege
WHERE
t.service = p_service AND
t.service_entity_name = s.service_entity_name AND
t.machine_name = v_machine
t.machine_name = backend._login_machine()
)
, FALSE);
......@@ -328,37 +368,26 @@ Checks if a currently connected machine is priviledged to obtain data for
a certain service for a certain servicee name.
.. warning::
The parameter p_server_name must be a service name. It must not be
confused with a domain.
The parameter ``p_service_entity_name`` must be the name of a service entity.
It must not be confused with a domain.
Parameters
- ``p_service`` :ref:`commons.t_key <DOMAIN-commons.t_key>`
- ``p_service_entity_name`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
- ``p_include_inactive`` :ref:`boolean <DOMAIN-boolean>`
- ``p_service_entity_name`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
Variables defined for body
- ``v_machine`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
Returns
boolean
Execute privilege
- :ref:`backend <ROLE-backend>`
.. code-block:: plpgsql
v_machine := (SELECT "machine" FROM "backend"._get_login());
RETURN COALESCE(
(
......@@ -366,7 +395,7 @@ Execute privilege
WHERE
t.service = p_service AND
t.service_entity_name = p_service_entity_name AND
t.machine_name = v_machine
t.machine_name = backend._login_machine()
)
, FALSE);
......@@ -377,16 +406,21 @@ Execute privilege
``backend._notify``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Informs all machines about changes.
Informs a machine about changes. To listen to signals use
.. code-block :: sql
LISTEN "carnivora/machine.name.example"
To listen to signals use LISTEN "carnivora/machine.name.example".
The payload has the form 'mail.domain.example/email/list'.
on the machine. The payload has the form
``<service_entity_name>/<service>/<subservice>``. For example
``mail.domain.example/email/mailbox`` for a mailbox related update.
Parameters
- ``p_machine`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
- ``p_machine`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
- ``p_service_entity_name`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
- ``p_service_entity_name`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
- ``p_service`` :ref:`commons.t_key <DOMAIN-commons.t_key>`
......@@ -432,7 +466,7 @@ Parameters
- ``p_subservice`` :ref:`commons.t_key <DOMAIN-commons.t_key>`
- ``p_domain`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
- ``p_domain`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
......@@ -474,7 +508,7 @@ Informs all machines about changes.
confused with a domain.
Parameters
- ``p_service_entity_name`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
- ``p_service_entity_name`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
- ``p_service`` :ref:`commons.t_key <DOMAIN-commons.t_key>`
......
......@@ -194,6 +194,8 @@ Parameters
Language
sql
Returns
......@@ -204,16 +206,13 @@ Execute privilege
- :ref:`userlogin <ROLE-userlogin>`
- :ref:`backend <ROLE-backend>`
.. code-block:: plpgsql
.. code-block:: guess
RETURN
SELECT
ARRAY(
SELECT p_array[i]
FROM generate_series(
array_lower(p_array,1),
array_upper(p_array,1)
) AS s(i)
SELECT $1[i]
FROM generate_subscripts($1,1) AS s(i)
ORDER BY i DESC
);
......@@ -239,7 +238,7 @@ Returns
.. code-block:: plpgsql
RETURN uuid_generate_v4();
RETURN public.uuid_generate_v4();
......
......@@ -93,6 +93,19 @@ Primary key
Columns
- .. _COLUMN-system.service.option:
``option`` :ref:`jsonb <DOMAIN-jsonb>`
Free options in JSON format
Default
.. code-block:: sql
'{}'
- .. _COLUMN-system.service.service:
``service`` :ref:`commons.t_key <DOMAIN-commons.t_key>`
......@@ -146,9 +159,22 @@ Primary key
Columns
- .. _COLUMN-system.service_entity.option:
``option`` :ref:`jsonb <DOMAIN-jsonb>`
Free options in JSON format
Default
.. code-block:: sql
'{}'
- .. _COLUMN-system.service_entity.service_entity_name:
``service_entity_name`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
``service_entity_name`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
Host name
......@@ -205,7 +231,7 @@ Foreign keys
Columns
- .. _COLUMN-system.service_entity_dns.service_entity_name:
``service_entity_name`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
``service_entity_name`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
Service entity name
......@@ -248,6 +274,19 @@ Columns
- .. _COLUMN-system.service_entity_dns.option:
``option`` :ref:`jsonb <DOMAIN-jsonb>`
Free options in JSON format
Default
.. code-block:: sql
'{}'
- .. _COLUMN-system.service_entity_dns.id:
``id`` :ref:`uuid <DOMAIN-uuid>`
......@@ -309,7 +348,7 @@ Foreign keys
Columns
- .. _COLUMN-system.service_entity_machine.service_entity_name:
``service_entity_name`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
``service_entity_name`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
Service entity name
......@@ -325,9 +364,22 @@ Columns
- .. _COLUMN-system.service_entity_machine.option:
``option`` :ref:`jsonb <DOMAIN-jsonb>`
Free options in JSON format
Default
.. code-block:: sql
'{}'
- .. _COLUMN-system.service_entity_machine.machine_name:
``machine_name`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
``machine_name`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
Assigns machine
......@@ -422,9 +474,22 @@ Foreign keys
Columns
- .. _COLUMN-system.subservice_entity.option:
``option`` :ref:`jsonb <DOMAIN-jsonb>`
Free options in JSON format
Default
.. code-block:: sql
'{}'
- .. _COLUMN-system.subservice_entity.service_entity_name:
``service_entity_name`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
``service_entity_name`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
Service entity name
......@@ -497,7 +562,7 @@ Foreign keys
Columns
- .. _COLUMN-system.subservice_entity_contingent.service_entity_name:
``service_entity_name`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
``service_entity_name`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
Service entity name
......@@ -601,7 +666,7 @@ Foreign keys
Columns
- .. _COLUMN-system.subservice_entity_domain_contingent.service_entity_name:
``service_entity_name`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
``service_entity_name`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
Service entity name
......@@ -640,7 +705,7 @@ Columns
- .. _COLUMN-system.subservice_entity_domain_contingent.domain:
``domain`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
``domain`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
Specific domain for which the access is granted
......@@ -683,7 +748,7 @@ Parameters
- ``p_subservice`` :ref:`commons.t_key <DOMAIN-commons.t_key>`
- ``p_domain`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
- ``p_domain`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
- ``p_current_quantity_total`` :ref:`integer <DOMAIN-integer>`
......@@ -695,9 +760,6 @@ Parameters
Variables defined for body
- ``v_remaining`` :ref:`integer <DOMAIN-integer>`
- ``v_total_contingent`` :ref:`integer <DOMAIN-integer>`
......@@ -710,7 +772,7 @@ Variables defined for body
- ``v_domain_contingent_specific`` :ref:`integer <DOMAIN-integer>`
- ``v_service_entity_name`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
- ``v_service_entity_name`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
- ``v_domain_owner`` :ref:`user.t_user <DOMAIN-user.t_user>`
......@@ -812,62 +874,6 @@ Returns
.. _FUNCTION-system._contingent_total:
``system._contingent_total``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Contingent
Parameters
- ``p_owner`` :ref:`user.t_user <DOMAIN-user.t_user>`
- ``p_service`` :ref:`commons.t_key <DOMAIN-commons.t_key>`
- ``p_service_entity_name`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
Variables defined for body
- ``v_user`` :ref:`integer <DOMAIN-integer>`
- ``v_default`` :ref:`integer <DOMAIN-integer>`
Returns
integer
.. code-block:: plpgsql
v_user := (
SELECT t.quantity
FROM system.contingent_total AS t
WHERE
t.owner = p_owner AND
t.service = p_service AND
t.service_entity_name = p_service_entity_name
);
v_default := (
SELECT t.quantity
FROM system.contingent_default_total AS t
WHERE
t.service = p_service AND
t.service_entity_name = p_service_entity_name
);
RETURN COALESCE(v_user, v_default);
.. _FUNCTION-system._effective_contingent:
``system._effective_contingent``
......@@ -888,7 +894,7 @@ Returned columns
- ``subservice`` :ref:`commons.t_key <DOMAIN-commons.t_key>`
- ``service_entity_name`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
- ``service_entity_name`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
- ``owner`` :ref:`user.t_user <DOMAIN-user.t_user>`
......@@ -947,9 +953,9 @@ Returned columns
- ``subservice`` :ref:`commons.t_key <DOMAIN-commons.t_key>`
- ``service_entity_name`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
- ``service_entity_name`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
- ``domain`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
- ``domain`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
- ``owner`` :ref:`user.t_user <DOMAIN-user.t_user>`
......@@ -1130,9 +1136,6 @@ Variables defined for body
- ``v_owner`` :ref:`user.t_user <DOMAIN-user.t_user>`
- ``v_login`` :ref:`user.t_user <DOMAIN-user.t_user>`
Returns
TABLE
......@@ -1151,7 +1154,6 @@ Execute privilege
.. code-block:: plpgsql
-- begin userlogin prelude
v_login := (SELECT t.owner FROM "user"._get_login() AS t);
v_owner := (SELECT t.act_as FROM "user"._get_login() AS t);
-- end userlogin prelude
......@@ -1180,9 +1182,6 @@ Variables defined for body
- ``v_owner`` :ref:`user.t_user <DOMAIN-user.t_user>`
- ``v_login`` :ref:`user.t_user <DOMAIN-user.t_user>`
Returns
TABLE
......@@ -1190,7 +1189,7 @@ Returns
Returned columns
- ``subservice`` :ref:`commons.t_key <DOMAIN-commons.t_key>`
- ``service_entity_name`` :ref:`dns.t_domain <DOMAIN-dns.t_domain>`
- ``service_entity_name`` :ref:`dns.t_hostname <DOMAIN-dns.t_hostname>`
Execute privilege
......@@ -1199,7 +1198,6 @@ Execute privilege
.. code-block:: plpgsql
-- begin userlogin prelude
v_login := (SELECT t.owner FROM "user"._get_login() AS t);
v_owner := (SELECT t.act_as FROM "user"._get_login() AS t);
-- end userlogin prelude
......
......@@ -230,11 +230,37 @@ Returned columns
WHERE "id"="user"._session_id();
ELSE
RAISE 'Database connection is not associated to a user login.'
USING HINT := 'Use user.login(...) first.';
USING HINT := 'Use user.ins_login(...) first.';
END IF;
.. _FUNCTION-user._login_user:
``user._login_user``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Shows informations for the current user login.
Throws an exception if no login is associated to the
current database connection.
Parameters
*None*
Returns
user.t_user
.. code-block:: plpgsql
RETURN (SELECT owner FROM "user"._get_login());
.. _FUNCTION-user._session_id:
``user._session_id``
......@@ -259,13 +285,43 @@ Returns
RETURN
session_user || '.' ||
pg_backend_pid() || '.' ||
COALESCE((SELECT backend_start FROM pg_stat_get_activity(pg_backend_pid()))::varchar, 'xxx') || '.' ||
pg_conf_load_time();
.. _FUNCTION-user.del_login:
``user.del_login``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Try to logout
Parameters
*None*
Returns
void
Execute privilege
- :ref:`userlogin <ROLE-userlogin>`
.. code-block:: plpgsql
DELETE FROM "user".session WHERE id = "user"._session_id();
IF NOT FOUND THEN
RAISE 'Carnivora: user logout failed, not logged in'
USING DETAIL = '$carnivora:user:logout_failed$';
END IF;
.. _FUNCTION-user.ins_deputy:
``user.ins_deputy``
......@@ -283,9 +339,6 @@ Variables defined for body
- ``v_owner`` :ref:`user.t_user <DOMAIN-user.t_user>`
- ``v_login`` :ref:`user.t_user <DOMAIN-user.t_user>`
Returns
void
......@@ -297,7 +350,6 @@ Execute privilege
.. code-block:: plpgsql
-- begin userlogin prelude
v_login := (SELECT t.owner FROM "user"._get_login() AS t);
v_owner := (SELECT t.act_as FROM "user"._get_login() AS t);
-- end userlogin prelude