Upgrading to Version 4.6.0¶
Warning: In development. 4.6.0 is the
masterbranch and has no tag yet. This guide is prepared in advance and the steps below will only work once v4.6.0 is tagged and published. The latest release is v4.5.1; 4.4.x remains the stable line recommended for production.
Overview¶
Version 4.6.0 adds an opt-in change approval workflow: users with a change request permission file their zone edits for review instead of writing them, and reviewers approve or reject from a new Change requests page or through the API. Alongside it, secondary zones can be retrieved from their primary on demand, the SOA serial bump on unchanged saves can be turned off, and every setting is reachable from a Docker environment variable.
Nothing changes unless you turn the workflow on. See What's New in 4.6.0 for the full list.
Database Schema Update¶
The 4.6.0 migration adds two tables, four permissions, two columns and one index, and changes one column:
| Change | Purpose |
|---|---|
Table zone_change_requests |
Stores filed change requests: the zone, requester, reason, the JSON action list with before/after rows, the reviewer, decision, the error when applying failed, and the zone file kept before an approved deletion |
Table zone_templ_groups |
The user groups each zone template is shared with. See Sharing Templates with Groups |
Permissions zone_change_request_own, zone_change_request_others |
Request changes to owned zones, or to any zone |
Permissions zone_change_approve_own, zone_change_approve_others |
Review change requests for owned zones, or for any zone |
Columns users.max_zones, user_groups.max_zones |
The zone limit of a user or group; NULL uses the dns.default_max_zones_* setting (unlimited by default). See Zone Limits |
Unique index idx_users_username on users.username |
Two accounts can no longer share a username. See Duplicate usernames |
Column password_reset_tokens.expires_at becomes DATETIME (MySQL/MariaDB only) |
Reset link expiry is stored in UTC, which a TIMESTAMP column would shift by the session time zone. All three scripts also mark unused reset links as used (#1850) |
The permissions are not granted to any permission template automatically. Grant them in the template editor once approval.enabled is on - see Change Requests.
The scripts also repair databases that earlier updates left incomplete. Each step does nothing on a database that is already correct:
- PostgreSQL: the 4.1.0 update added permissions with fixed ids without moving the id sequence on, so later updates failed to add
user_enforce_mfa,zone_logs_view_own,zone_logs_view_othersand, on databases installed before 4.0.5, more of the 4.5.0 permissions. The 4.6.0 script resyncs the sequences and adds any of them that are missing, with the metadata and ownership view grants 4.5.0 gave alongside them. Grant the restored permissions in the template editor as needed. - PostgreSQL: the same lagging sequences made the 4.1.0 update drop the Zone Manager user template and the Editor grants (#1673). The script recreates the Zone Manager template if it is missing, and gives Zone Manager and Editor their default permissions when the template has none.
- Databases upgraded from 4.0.0-4.0.4 straight to 4.1.0 or later never ran the 4.0.5 update:
records_zone_templgets itsidprimary key now. - MySQL/MariaDB and PostgreSQL: fresh installs have had the
idx_zones_domain_idandidx_zones_ownerindexes onzonessince 4.1.0, but no update added them, so every database installed before 4.1.0 lacks them. The script creates each one unless the column is already indexed under that name or under the 3.x name (zones_domain_id_idx,zones_owner_idx). - MySQL/MariaDB:
zone_change_requestsis created with theutf8mb4_unicode_cicollation fresh installs use, instead of the server default. - SQL backend: zones last changed by an older version can have no row in
zonesthat carries the zone name, and a later switch to the API backend would bring them back as new zones without their owners. The scripts name those rows from the PowerDNSdomainstable, as the "Zones Without A Stored Name" fix on the database consistency page does. A row that holds an outdated name is still corrected only from that page. A database that was switched to the API backend before 4.6.0 can also hold a second, ownerless row per zone that the API zone sync added; the scripts remove it when nothing uses it, so the zone's own row takes the name and keeps its owners. Log entries written under that row while the API backend was active move to the zone. The SQL backend refuses a database the API backend has written zone rows to; when the removed rows were the only ones, the scripts clear that refusal too, so reload the page after running them (see Migrating from SQL to API Backend). On SQLite this step is a separate script, see Step 3.
The SQLite 4.1.0, 4.2.0 and 4.3.0 update scripts rebuild tables. Run them once only: a second run drops the columns later updates added, and on an API backend database can empty the zones table.
The migration scripts are:
sql/poweradmin-mysql-update-to-4.6.0.sqlsql/poweradmin-pgsql-update-to-4.6.0.sqlsql/poweradmin-sqlite-update-to-4.6.0.sqlsql/poweradmin-sqlite-update-to-4.6.0-backfill.sql(SQLite with the PowerDNS tables in the same database only)
Run the script even if you do not plan to use the workflow, so the schema matches the release.
Duplicate usernames¶
The new unique index can't be created while two accounts share a username. Check before upgrading:
Rename or remove the extra accounts first. If duplicates are still there when the script runs:
- MySQL/MariaDB and PostgreSQL: the script skips the index and prints a warning. Clean up, then run the script again.
- SQLite: the last statement fails with
UNIQUE constraint failed. Everything before it has already been applied, so clean up and run only the finalCREATE UNIQUE INDEXstatement again.
Upgrade Instructions¶
Prerequisites¶
- Poweradmin v4.5.x
- PHP 8.2 or later
- Database backup
If you are upgrading from an older release, run the intermediate migration scripts first (4.3.0, then 4.4.0, then 4.5.0, then 4.6.0). Do not skip versions.
Step 1: Backup Your Data¶
# MySQL/MariaDB
mysqldump -u username -p poweradmin_db > poweradmin_backup_$(date +%Y%m%d).sql
# PostgreSQL
pg_dump -h localhost -U username poweradmin_db > poweradmin_backup_$(date +%Y%m%d).sql
# SQLite
sqlite3 /path/to/poweradmin.db ".backup '/path/to/poweradmin_backup_$(date +%Y%m%d).db'"
Use .backup rather than cp for SQLite: in WAL mode the latest changes may still sit in the -wal file next to the database, and copying the database file alone misses them.
Step 2: Download and Extract¶
cd /tmp
wget https://github.com/poweradmin/poweradmin/archive/refs/tags/v4.6.0.tar.gz
tar -xzf v4.6.0.tar.gz
rsync -av poweradmin-4.6.0/ /var/www/poweradmin/ --exclude=config/settings.php
Step 3: Run Database Update¶
MySQL/MariaDB:
If you have pdns_db_name set (PowerDNS tables in a separate database), first open the script and set @pdns_db near the end to that database name:
Your MySQL user needs SELECT on that database. If the domains table is not found there, the script prints notices starting with PowerDNS domains table not found and skips that whole block: the zone name backfill, the removal of the ownerless rows the API zone sync added before 4.6.0, and clearing the mark the API backend left. Everything else is applied. On a database that once ran the API backend, 4.6.0 then refuses the SQL backend until you set @pdns_db and run the script again.
PostgreSQL:
psql -h localhost -U username -d poweradmin_db -f /var/www/poweradmin/sql/poweradmin-pgsql-update-to-4.6.0.sql
The zone names are read from the domains table on the search path. When it is not there (API backend), psql shows NOTICE: PowerDNS domains table not found, zone name backfill skipped, and everything else is applied.
SQLite:
When the database also holds the PowerDNS tables (SQL backend), run the zone name backfill as well. It is safe to run again; on a database without them it stops at no such table: domains and changes nothing:
sqlite3 /path/to/poweradmin.db < /var/www/poweradmin/sql/poweradmin-sqlite-update-to-4.6.0-backfill.sql
Step 4: Clear Cache and Restart¶
Behaviour Changes¶
These changes apply as soon as 4.6.0 runs, with no setting to turn on. Check them before upgrading.
Permissions and refusals¶
- One permission rule for zone actions. A zone action is granted when any permission template the user holds, directly or through a group, grants it and the user owns the zone. The stricter hybrid rule, which required the grant to come from a group that owns the zone, is gone. This can give users more access than before, so review the permission templates of your groups.
- Changing a zone's type needs the add permission for the new type:
zone_slave_addfor Secondary and Consumer,zone_master_addfor the others. 4.5.2 makes the same change. - Applying a zone template to an existing zone needs the content edit permission for the zone (
zone_content_edit_ownorzone_content_edit_others); meta edit rights alone are refused. 4.5.2 makes the same change. - Deleting a group that is the last owner of a zone is refused. The message names the zone, and API v2 answers
409. - Super admin granted through a group counts as super admin. Removing a group member, deleting a group, changing a group's template or removing
user_is_ueberuserfrom a template is refused when it would leave no active super admin, with409in API v2. OIDC, SAML and LDAP sign-in skip such a change and log a warning. See Users and Roles. - Disable MFA and Regenerate Recovery Codes ask for a current code from the authenticator app, an email code or a recovery code. 4.5.2 makes the same change.
- A super admin who edits another user's private zone template without ticking Global template no longer becomes its owner; the owner stays. Before, the edit moved the template to the super admin.
DELETE /api/v2/zones/{id}/rrsets/{name}/{type}with an unknown record type answers400 Invalid record type.instead of404.- SAML sign-in now needs HTTPS (or
localhost) and refuses responses that do not answer a sign-in started from the same browser, including IdP-initiated SSO. Set'allow_idp_initiated' => trueon a provider (PA_SAML_<PROVIDER>_ALLOW_IDP_INITIATED=truein Docker) to keep the old behaviour for it. See SAML Authentication. POST /zones/{id}/records/bulkrefuses more than 1000 operations per request with400 Too many operations: at most 1000 per request. Raise or remove the limit withapi.bulk_max_operations(0= no limit).- Switching from the API backend back to the SQL backend is refused once the API backend has written zones to the database: zone ids written in API mode would point at other zones. The web pages show the error, the API answers
503, and the command line and dynamic DNS updates stop. If a database that never used the API backend is refused, set thebackend.zone_idsrow inapp_settingstosql; a zone deleted outside Poweradmin and created again under the same name can look like API use. See Migrating from SQL to API Backend.
Defaults¶
- SQL backend with
pdns_apiconfigured: zone create and delete and record changes call the PowerDNS cache flush API, so a new zone is served at once. A failed flush is logged as a warning and does not stop the save. See PowerDNS API. - PHP session strict mode is on, so a session id the server never issued is refused and replaced with a new one.
- Password reset links are checked in UTC. Links sent before the upgrade stop working; users who were mid-reset request a new link (#1850).
- SQLite: Poweradmin opens the database in WAL mode. The database gains
-waland-shmfiles next to it, must stay on local storage (not NFS or SMB), and needs the.backupcommand from Step 1 for backups. See Write-ahead logging. - Every page sends
X-Frame-Options: DENYandContent-Security-Policy: frame-ancestors 'none', so Poweradmin can no longer be shown in a frame on another site. List the sites that may frame it ininterface.frame_ancestors(PA_FRAME_ANCESTORSin Docker). See Framing and Response Headers. - API v2
500responses carry only the message for the failed action, for exampleFailed to replace RRSet. The underlying error is written to the log instead of the response. - The zone file export built from the database (SQL backend without
pdns_api, or with Include comments ticked) leaves out disabled records. Before, it wrote them as active records. - Docker image: PHP runs with
php.ini-production, and OPcache does not re-check files, so restart the container after editing bind-mounted PHP files. The web server caps request bodies at20MiB(REQUEST_BODY_MAX_SIZE). See Docker.
Custom themes¶
If you run a theme forked from the 4.5 templates, header.html should test nav.batch_ptr instead of can_batch_ptr for the Batch PTR link. can_batch_ptr is no longer passed, so the link disappears, and with misc.display_errors on the page fails in Twig strict mode. See Themes.
The rest of the changes are listed in What's New in 4.6.0.
New Features¶
Change Approval Workflow¶
Off by default. To turn it on:
return [
'approval' => [
'enabled' => true,
'require_review_for_all' => false,
],
'notifications' => [
'change_request_enabled' => false, // mail reviewers and requesters; needs mail.enabled
],
];
Then grant zone_change_request_* to the users who should file requests and zone_change_approve_* to the reviewers. Reviewers also need the edit permission for the zone; superusers review everything. With require_review_for_all, every change goes through review, editors and administrators included.
In Docker the variables are PA_APPROVAL_ENABLED, PA_APPROVAL_REQUIRE_REVIEW_FOR_ALL, PA_APPROVAL_ALLOW_SELF_APPROVAL and PA_NOTIFICATION_CHANGE_REQUEST. Set approval.allow_self_approval to false if a requester must not approve their own request.
Two things to check before enabling it on a live installation:
- Dynamic DNS clients cannot file requests. An update from a user whose changes to the zone need review is refused (
!yoursfromdynamic_update.php,403from the API endpoint). Keep an edit permission on DDNS accounts. - API clients whose changes need review get
403on the record write endpoints and have to use the change request endpoints instead.
See Change Requests.
Other changes¶
dns.bump_serial_on_unchanged_save(defaulttrue) lets an installation stop bumping the SOA serial on saves that change nothing. See DNS Settings.- API v2 DNSSEC key changes (add, import, update, delete) now need view access to the zone as well as
zone_dnssec_manage_own, as the web pages do. An API key whose user holds the DNSSEC permission without view access to the zone now gets403. See API Endpoints. - API backend mode: the API v2 zone list and
GET /zones/{id}now also returncanonical_id, equal toid. The zone id change, the one-time move of API key zone restrictions and the new-zone id rule shipped in 4.5.0; when upgrading from 4.4.x or earlier, read Zone ids in API backend mode first. - Group assignments made through the API before 4.5.0 hold the zone list's row id. The database consistency check lists those whose id now names no zone, so they can be assigned again.
- The database consistency check's Fix for zones without an SOA now writes the same SOA a new zone gets, from
dns.ns1,dns.hostmaster, the SOA timers anddns.ttl; before it wrotens1.<zone> hostmaster.<zone>with fixed timers and a TTL of 86400. - The SQL backend now stores the zone name whenever it writes a zone row, and the Database Consistency Check lists zones that still lack one, so a later switch to the API backend keeps every zone's owners.
- In API backend mode the automatic zone sync changes nothing when PowerDNS no longer lists more than half of the known zones, which usually means
pdns_api.urlpoints at the wrong server; the manual sync on the Forward Zones page still applies the changes. - With
approval.enabledon before the 4.6.0 update script has run, the Change requests entry and the pending counts are hidden and an error is logged, instead of every page failing. Filing a request still fails until the script has run. - SAML responses are checked against the advertised ACS URL and logout requests against the SLS URL, so a port mapping in front of PHP no longer refuses every response (also in 4.5.2). See SAML Authentication.
interface.session_max_lifetimeis new and off by default.
Rollback¶
To roll back to v4.5.0:
- Restore your database backup. For SQLite, stop the web server and PowerDNS first and delete any
poweradmin.db-walandpoweradmin.db-shmfiles next to the database. A leftover-walfile belongs to the newer database, and SQLite would apply it to the restored copy. - Restore your file backup.
- Restart the web server.
The zone_change_requests and zone_templ_groups tables and the four permissions are harmless in 4.5.0 - they are simply unused, and shared templates go back to being visible to their owner only. Pending change requests are not applied by the older version; decide them before rolling back or file them again afterwards.