1
0
mirror of https://github.com/cmur2/dyndnsd.git synced 2025-06-26 02:30:22 +02:00

gem: allow config to contain users without any hosts

This commit is contained in:
cn
2022-09-20 19:30:02 +02:00
parent d066b3ecee
commit 3a5b1bcb27
3 changed files with 19 additions and 1 deletions

View File

@ -215,10 +215,11 @@ module Dyndnsd
invalid_hostnames = hostnames.select { |h| !Helper.fqdn_valid?(h, @domain) }
return [422, {'X-DynDNS-Response' => 'hostname_malformed'}, []] if invalid_hostnames.any?
# we can trust this information since user was authorized by middleware
user = env['REMOTE_USER']
# check for hostnames that the user does not own
forbidden_hostnames = hostnames - @users[user]['hosts']
forbidden_hostnames = hostnames - @users[user].fetch('hosts', [])
return [422, {'X-DynDNS-Response' => 'host_forbidden'}, []] if forbidden_hostnames.any?
if params['offline'] == 'YES'