tmp
parent
749889aad8
commit
516ccf1e58
|
@ -3,3 +3,4 @@ bin
|
||||||
drop
|
drop
|
||||||
lib
|
lib
|
||||||
templates/
|
templates/
|
||||||
|
docs/
|
||||||
|
|
35
Makefile
35
Makefile
|
@ -104,36 +104,13 @@ print-response-message-numbers:
|
||||||
print-response-messages-without-comments:
|
print-response-messages-without-comments:
|
||||||
make -s print-response-messages | grep -vE '^[[:blank:]]+#'
|
make -s print-response-messages | grep -vE '^[[:blank:]]+#'
|
||||||
|
|
||||||
MIGRATION_FILE_INIT ?= /tmp/dnsmanager-migration-init.txt
|
# format: nb-domains <TAB> login <TAB> domain1 <TAB> domain2 <TAB> domain3
|
||||||
MIGRATION_FILE_INTERMEDIARY ?= /tmp/dnsmanager-migration-intermediary.txt
|
MIGRATION_FILE_TARGET = /tmp/dnsmanagerd-migration
|
||||||
MIGRATION_FILE_TARGET ?= /tmp/dnsmanager-migration-target.txt
|
SQLDB = /tmp/usrdb
|
||||||
$(MIGRATION_FILE_TARGET):
|
$(MIGRATION_FILE_TARGET):; ./bin/sql-to-migration-format.awk < $(SQLDB) > $(MIGRATION_FILE_TARGET)
|
||||||
# Format entries: one per line.
|
|
||||||
./bin/format.awk < $(MIGRATION_FILE_INIT) |\
|
|
||||||
./bin/fix-last-element.awk |\
|
|
||||||
# Remove 'activated' attribute. No longer relevant (never, actually). \
|
|
||||||
sed 's/ \+activated \+=> \+0, \+//' |\
|
|
||||||
sed 's/domain \+=> \+/"domain": /' |\
|
|
||||||
sed 's/ \+login \+=> \+/"login": /' |\
|
|
||||||
# Put double-quotes around logins composed of digits. \
|
|
||||||
sed 's/"login": \([0-9]\+\)/"login": "\1"/' |\
|
|
||||||
sed 's/", \+}/" }/' |\
|
|
||||||
# Fix @ in logins. \
|
|
||||||
sed 's/\\@/@/' |\
|
|
||||||
# Remove obvious SQL hacks. \
|
|
||||||
sed '/))))/d' |\
|
|
||||||
sed '/: \+[0-9]\+,/d' |\
|
|
||||||
# Remove all entries with accents. \
|
|
||||||
grep -v '\\' > $(MIGRATION_FILE_INTERMEDIARY)
|
|
||||||
./bin/migration-final.awk < $(MIGRATION_FILE_INTERMEDIARY) | sort -n > $(MIGRATION_FILE_TARGET)
|
|
||||||
|
|
||||||
MIGRATION_FILE_AUTHD ?= /tmp/authd-migration-user-db.txt
|
|
||||||
$(MIGRATION_FILE_AUTHD):; cat $(MIGRATION_FILE_TARGET) | awk '{ print $$2 }' > $(MIGRATION_FILE_AUTHD)
|
|
||||||
migration-file-authd: $(MIGRATION_FILE_AUTHD)
|
|
||||||
|
|
||||||
run-migration-client:; ./bin/dnsmanager-client admin migration-script $(MIGRATION_FILE_TARGET) $(LOGIN)
|
run-migration-client:; ./bin/dnsmanager-client admin migration-script $(MIGRATION_FILE_TARGET) $(LOGIN)
|
||||||
migration-files: $(MIGRATION_FILE_TARGET) $(MIGRATION_FILE_AUTHD)
|
migration-file: $(MIGRATION_FILE_TARGET)
|
||||||
migration: migration-files run-migration-client
|
migration: migration-file run-migration-client
|
||||||
|
|
||||||
doc:
|
doc:
|
||||||
crystal docs src/main.cr src/client.cr lib/authd/src/client.cr
|
crystal docs src/main.cr src/client.cr lib/authd/src/client.cr
|
||||||
|
|
|
@ -98,14 +98,19 @@ class Actions
|
||||||
data = line.split "\t"
|
data = line.split "\t"
|
||||||
_ = data.shift
|
_ = data.shift
|
||||||
login = data.shift
|
login = data.shift
|
||||||
|
data.select! { |x| x != "" }
|
||||||
nb_domains = data.size
|
nb_domains = data.size
|
||||||
begin
|
begin
|
||||||
str = data.join(", ").to_s
|
|
||||||
i = 0
|
i = 0
|
||||||
data.each do |domain|
|
data.each do |domain|
|
||||||
STDOUT.write "migrating '#{i}/#{nb_domains}' domains for '#{login}': #{ "%.50s" % domain }\r".to_slice
|
STDOUT.write "migrating '#{i}/#{nb_domains}' domains for '#{login}': #{ "%.100s" % domain }".to_slice
|
||||||
STDOUT.write ((" " * 100) + "\r").to_slice
|
STDOUT.write ((" " * 80) + "\r").to_slice
|
||||||
i += 1
|
i += 1
|
||||||
|
if (login == "Régis")
|
||||||
|
req = DNSManager::Request::Migration.new login, domain
|
||||||
|
puts ""
|
||||||
|
Baguette::Log.info "#{req.to_json.to_s}"
|
||||||
|
end
|
||||||
response = @dnsmanagerd.migration login, domain
|
response = @dnsmanagerd.migration login, domain
|
||||||
case response
|
case response
|
||||||
when DNSManager::Response::DomainAdded
|
when DNSManager::Response::DomainAdded
|
||||||
|
@ -113,15 +118,19 @@ class Actions
|
||||||
else
|
else
|
||||||
case response
|
case response
|
||||||
when DNSManager::Response::DomainAlreadyExists
|
when DNSManager::Response::DomainAlreadyExists
|
||||||
Baguette::Log.error "error: domain name '#{domain}' already exists"
|
#Baguette::Log.error "error: domain name '#{domain}' already exists"
|
||||||
when DNSManager::Response::InvalidDomainName
|
when DNSManager::Response::InvalidDomainName
|
||||||
Baguette::Log.error "error: invalid domain name #{domain}"
|
puts ""
|
||||||
|
Baguette::Log.error "error: invalid domain name '#{domain}'"
|
||||||
when DNSManager::Response::UnacceptableDomain
|
when DNSManager::Response::UnacceptableDomain
|
||||||
Baguette::Log.error "error: unacceptable domain name '#{domain}'"
|
puts ""
|
||||||
|
Baguette::Log.error "error: unacceptable domain name '#{domain}' (login: '#{login}')"
|
||||||
when DNSManager::Response::UnknownUser
|
when DNSManager::Response::UnknownUser
|
||||||
|
puts ""
|
||||||
Baguette::Log.error "error: unknown user #{login}"
|
Baguette::Log.error "error: unknown user #{login}"
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
|
puts ""
|
||||||
Baguette::Log.error "error: unknown error"
|
Baguette::Log.error "error: unknown error"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -124,14 +124,14 @@ class DNSManager::Storage
|
||||||
# Verify if the domain is acceptable.
|
# Verify if the domain is acceptable.
|
||||||
matching_domains = accepted_domains.select { |adomain| domain.ends_with? adomain }
|
matching_domains = accepted_domains.select { |adomain| domain.ends_with? adomain }
|
||||||
unless matching_domains.size > 0
|
unless matching_domains.size > 0
|
||||||
Baguette::Log.warning "trying to add an unacceptable domain: #{domain}"
|
Baguette::Log.warning "trying to add an unacceptable domain: '#{domain}'"
|
||||||
return Response::UnacceptableDomain.new
|
return Response::UnacceptableDomain.new
|
||||||
end
|
end
|
||||||
|
|
||||||
matching_domains.each do |md|
|
matching_domains.each do |md|
|
||||||
# Prevent empty domains (from crafted requests) to be accepted.
|
# Prevent empty domains (from crafted requests) to be accepted.
|
||||||
return Response::InvalidDomainName.new unless (domain.chomp md).size > 1
|
return Response::InvalidDomainName.new unless (domain.chomp md).size > 1
|
||||||
Baguette::Log.info "Add new domain #{domain} (matching domain #{md})"
|
#Baguette::Log.info "Add new domain #{domain} (matching domain #{md})"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Verify the domain name validity.
|
# Verify the domain name validity.
|
||||||
|
|
Loading…
Reference in New Issue