diff -ruN smeserver-ddclient-1.3.0.old/root/usr/share/smanager/lib/SrvMngr/Controller/Ddclient.pm smeserver-ddclient-1.3.0/root/usr/share/smanager/lib/SrvMngr/Controller/Ddclient.pm --- smeserver-ddclient-1.3.0.old/root/usr/share/smanager/lib/SrvMngr/Controller/Ddclient.pm 2021-08-31 13:48:19.475463250 +0200 +++ smeserver-ddclient-1.3.0/root/usr/share/smanager/lib/SrvMngr/Controller/Ddclient.pm 2021-08-31 15:44:36.773106124 +0200 @@ -68,51 +68,50 @@ our $adb = esmith::AccountsDB->open(); our $domaindb = esmith::ConfigDB->open('/home/e-smith/db/domains') - or die "Unable to open domains db"; + or die "Unable to open domains db"; our $edb; $edb = esmith::ConfigDB->open('/home/e-smith/db/ddclient') - or $edb = esmith::ConfigDB->create('/home/e-smith/db/ddclient'); + or $edb = esmith::ConfigDB->create('/home/e-smith/db/ddclient'); my %ddc_datas = (); sub get_dns_labels { - # - # dns service names - # + # + # dns service names + # my $c = shift; my $Labels = ( - [ - [ $c->l('ddc_CUSTOMDNS'), 'CUSTOMDNS' ], - [ $c->l('ddc_DYNDNS1'), 'DYNDNS1' ], - [ $c->l('ddc_DYNDNS2'), 'DYNDNS2' ], - [ $c->l('ddc_DYNDNS3'), 'DYNDNS3' ], - [ $c->l('ddc_ZONEDIT'), 'ZONEDIT' ], - [ $c->l('ddc_EASYDNS'), 'EASYDNS' ], - [ $c->l('ddc_HAMMER'), 'HAMMER' ], - [ $c->l('ddc_DSLREPORTS'), 'DSLREPORTS' ], - [ $c->l('ddc_EURODYNDNS'), 'EURODYNDNS' ], - [ $c->l('ddc_DTDNS'), 'DTDNS' ], - [ $c->l('ddc_LOOPIA'), 'LOOPIA' ], - [ $c->l('ddc_DNSPARK'), 'DNSPARK' ], - [ $c->l('ddc_DYNHOST'), 'DYNHOST' ], - [ $c->l('ddc_NOIP'), 'NOIP' ], - [ $c->l('ddc_CHANGEIP'), 'CHANGEIP' ], - [ $c->l('ddc_NAMECHEAP'), 'NAMECHEAP' ], - [ $c->l('ddc_SPDNS'), 'SPDNS' ], - [ $c->l('ddc_SITELUTIONS'), 'SITELUTIONS'], - [ $c->l('ddc_FREEDNS'), 'FREEDNS'], - [ $c->l('ddc_NSUPDATE'), 'NSUPDATE'], - [ $c->l('ddc_CLOUDFLARE'), 'CLOUDFLARE'], - [ $c->l('ddc_GOOGLEDOMAINS'), 'GOOGLEDOMAINS'], - [ $c->l('ddc_DUCKDNS'), 'DUCKDNS'], - [ $c->l('ddc_FREEMYIP'), 'FREEMYIP'], - [ $c->l('ddc_WOIMA'), 'WOIMA'], - [ $c->l('ddc_YANDEX'), 'YANDEX'], - [ $c->l('ddc_DNSMADEEASY'), 'DNSMADEEASY'], - [ $c->l('ddc_DONDOMINIO'), 'DONDOMINIO'], - [ $c->l('ddc_NEARLYFREESPEECH'),'NFSN'], - [ $c->l('ddc_OVH'), 'OVH'], - [ $c->l('ddc_CLOUDNS'), 'CLOUDNS'] + [ [ $c->l('ddc_CUSTOMDNS'), 'CUSTOMDNS' ], + [ $c->l('ddc_DYNDNS1'), 'DYNDNS1' ], + [ $c->l('ddc_DYNDNS2'), 'DYNDNS2' ], + [ $c->l('ddc_DYNDNS3'), 'DYNDNS3' ], + [ $c->l('ddc_ZONEDIT'), 'ZONEDIT' ], + [ $c->l('ddc_EASYDNS'), 'EASYDNS' ], + [ $c->l('ddc_HAMMER'), 'HAMMER' ], + [ $c->l('ddc_DSLREPORTS'), 'DSLREPORTS' ], + [ $c->l('ddc_EURODYNDNS'), 'EURODYNDNS' ], + [ $c->l('ddc_DTDNS'), 'DTDNS' ], + [ $c->l('ddc_LOOPIA'), 'LOOPIA' ], + [ $c->l('ddc_DNSPARK'), 'DNSPARK' ], + [ $c->l('ddc_DYNHOST'), 'DYNHOST' ], + [ $c->l('ddc_NOIP'), 'NOIP' ], + [ $c->l('ddc_CHANGEIP'), 'CHANGEIP' ], + [ $c->l('ddc_NAMECHEAP'), 'NAMECHEAP' ], + [ $c->l('ddc_SPDNS'), 'SPDNS' ], + [ $c->l('ddc_SITELUTIONS'), 'SITELUTIONS' ], + [ $c->l('ddc_FREEDNS'), 'FREEDNS' ], + [ $c->l('ddc_NSUPDATE'), 'NSUPDATE' ], + [ $c->l('ddc_CLOUDFLARE'), 'CLOUDFLARE' ], + [ $c->l('ddc_GOOGLEDOMAINS'), 'GOOGLEDOMAINS' ], + [ $c->l('ddc_DUCKDNS'), 'DUCKDNS' ], + [ $c->l('ddc_FREEMYIP'), 'FREEMYIP' ], + [ $c->l('ddc_WOIMA'), 'WOIMA' ], + [ $c->l('ddc_YANDEX'), 'YANDEX' ], + [ $c->l('ddc_DNSMADEEASY'), 'DNSMADEEASY' ], + [ $c->l('ddc_DONDOMINIO'), 'DONDOMINIO' ], + [ $c->l('ddc_NEARLYFREESPEECH'), 'NFSN' ], + [ $c->l('ddc_OVH'), 'OVH' ], + [ $c->l('ddc_CLOUDNS'), 'CLOUDNS' ] ] ); return $Labels; @@ -148,8 +147,7 @@ my $emptycust = ( scalar @FreeDomains == 0 ); my $Labels = ( - [ - [ $c->l('ddc_SME external Interface'), "smeIF" ], + [ [ $c->l('ddc_SME external Interface'), "smeIF" ], [ $c->l('ddc_SME configuration DB'), "smeCMD" ], [ $c->l('ddc_web'), "web" ], [ $c->l('ddc_Interface'), "if" ], @@ -198,8 +196,8 @@ if ( $retmsg eq "ok" ) { my $dns = $c->param('dns'); my $domain = $c->param('domainname'); - $ddc_datas{"success"} = - $c->l( "ddc_SUCCESSFULLY_MODIFIED", $domain, $c->l( 'ddc_' . $dns ) ); + $ddc_datas{"success"} = $c->l( "ddc_SUCCESSFULLY_MODIFIED", $domain, + $c->l( 'ddc_' . $dns ) ); do_display( $c, %ddc_datas ); } else { @@ -235,12 +233,13 @@ if ( $retmsg eq "ok" ) { my $dns = $c->param('dns'); my $domain = $c->param('domainname'); - $ddc_datas{"success"} = - $c->l( "ddc_SUCCESSFULLY_DELETED", $domain, $c->l( 'ddc_' . $dns ) ); + $ddc_datas{"success"} = $c->l( "ddc_SUCCESSFULLY_DELETED", $domain, + $c->l( 'ddc_' . $dns ) ); do_display( $c, %ddc_datas ); } else { $ddc_datas{"error"} = $retmsg; + #Back to input panel to correct error do_create_custom($c); } @@ -257,8 +256,8 @@ my $trt = $c->param("trt"); #Extract domain stuff from DB - my @results = - get_custom_table( $c, $c->param("Domain") ); #Returns just one row + my @results + = get_custom_table( $c, $c->param("Domain") ); #Returns just one row $ddc_datas{"Domain_details"} = $results[0]; @@ -283,8 +282,8 @@ my $trt = $c->param("trt"); #Extract domain stuff from DB - my @results = - get_domain_table( $c, $c->param("Domain") ); #Returns just one row + my @results + = get_domain_table( $c, $c->param("Domain") ); #Returns just one row $ddc_datas{"Domain_details"} = $results[0]; $ddc_datas{'trt'} = $trt; @@ -309,7 +308,7 @@ my $retmsg = ""; my $domain = $c->param("Domain"); - #Delete it and return to front summary panel - depends on route domain or custom + #Delete it and return to front summary panel - depends on route domain or custom if ( $c->param("Route") eq "ddclient2" ) { #Route is hidden field $retmsg = performDeleteCustom( $c, $domain ); } @@ -338,7 +337,7 @@ my $retmsg = ""; my $domain = $c->param("Domain"); - #Delete it and return to front summary panel - depends on route domain or custom + #Delete it and return to front summary panel - depends on route domain or custom $retmsg = performDeleteCustom( $c, $domain ); if ( $retmsg eq "ok" ) { $ddc_datas{"success"} = $c->l( "ddc_SUCCESSFULLY_DELETED", $domain ); @@ -348,80 +347,6 @@ } -sub performDeleteDomain { - my ( $c, $domain ) = @_; - - #------------------------------------------------------------ - # Attempt to delete domain - #------------------------------------------------------------ - - if ( $domain =~ /^([a-zA-Z0-9\-\.]+)$/ ) { - $domain = $1; - } - else { - return $c->l( 'ddc_ERROR_WHILE_REMOVING_DOMAIN', $domain ); - } - - my $value = $domaindb->get($domain); - unless ($value) { - return $c->l( 'ddc_NONEXISTENT_DOMAIN_ERROR', $domain ); - } - - my %properties = $value->props; - my $type = $properties{'type'}; - if ( $type ne 'domain' ) { - return $c->l( 'ddc_NONEXISTENT_DOMAIN_ERROR', $domain ); - } - - my $evalue = $domaindb->get($domain); - - $evalue->set_prop( 'dns' => '' ); - $evalue->set_prop( 'login' => '' ); - $evalue->set_prop( 'password' => '' ); - $evalue->set_prop( 'customdns' => '' ); - $evalue->set_prop( 'customprotocol' => '' ); - - $domaindb->reload(); - - system( "/sbin/e-smith/signal-event", "ddclient" ); - - return "ok"; -} - -sub performDeleteCustom { - my ( $c, $domain ) = @_; - - #------------------------------------------------------------ - # Attempt to delete domain - #------------------------------------------------------------ - - if ( $domain =~ /^([a-zA-Z0-9\-\.]+)$/ ) { - $domain = $1; - } - else { - return $c->l( 'ddc_ERROR_WHILE_REMOVING_DOMAIN', $domain ); - } - - my $evalue = $edb->get($domain); - unless ($evalue) { - return $c->l( 'ddc_NONEXISTENT_DOMAIN_ERROR', $domain ); - } - - my %properties = $evalue->props; - my $type = $properties{'type'}; - - if ( $type ne 'ddhost' ) { - return $c->l( 'ddc_NONEXISTENT_DOMAIN_ERROR', $domain ); - - } - - $evalue->delete; - $edb->reload(); - - system( "/sbin/e-smith/signal-event", "ddclient" ); - return "ok"; -} - sub get_domain_table { # # Return full table of all domains OR just the details for the specified one @@ -442,15 +367,19 @@ foreach $domain ( sort @virtualDomains ) { my %properties = $domaindb->get($domain)->props; - my $test = $domaindb->get_prop( $domain, "dns" ) || ''; + my $test = $domaindb->get_prop( $domain, "dns" ) || ''; my %extraprops; - if ( $test ne '' ) { %extraprops = $domaindb->get($domain)->props; } + if ( $test ne '' ) { + %extraprops = $domaindb->get($domain)->props; + } my $content; if ( $properties{'Content'} eq 'wwwpublic' ) { $content = $c->l('ddc_PRIMARY_SITE'); } - else { $content = $c->l( 'ddc_CONTENT', $properties{'Content'} ); } + else { + $content = $c->l( 'ddc_CONTENT', $properties{'Content'} ); + } my $public; my %thisrow; @@ -520,20 +449,20 @@ 'Domain' => $domain, "Description" => $content, "dns" => $publish, - "Publication" => - $c->l( 'ddc_' . $publish ), #msg ddc prefix for ddclient - "customprotocol" => $vals->prop("customprotocol"), - "customdns" => $vals->prop("customdns"), - "login" => $vals->prop("login"), - "password" => $vals->prop("password"), - "mx" => $vals->prop("mx"), + "Publication" => $c->l( 'ddc_' . $publish ) + , #msg ddc prefix for ddclient + "customprotocol" => $vals->prop("customprotocol"), + "customdns" => $vals->prop("customdns"), + "login" => $vals->prop("login"), + "password" => $vals->prop("password"), + "mx" => $vals->prop("mx"), ); push( @freedomains2d, \%thisrow ); if ($findDomain) { if ( $domain eq $findDomain ) { - @freedomains2d = (); #Just return matching one + @freedomains2d = (); #Just return matching one push( @freedomains2d, \%thisrow ); last; } @@ -549,9 +478,9 @@ my $ddretrieve = $db->get('ddclient'); my $ExtIF = $db->get('ExternalInterface'); my $DeamonUpdate = $ddretrieve->prop('DeamonUpdate') || '300'; - my $urlcheckip = $ddretrieve->prop('urlcheckip') || 'checkip.dyndns.org'; - my $ssl = $ddretrieve->prop('SSL') || 'yes'; - my $method = $ddretrieve->prop('method') || 'web'; + my $urlcheckip = $ddretrieve->prop('urlcheckip') || 'checkip.dyndns.org'; + my $ssl = $ddretrieve->prop('SSL') || 'yes'; + my $method = $ddretrieve->prop('method') || 'web'; my $Extinterface = $ddretrieve->prop('Extinterface') || ''; my $cmd = $ddretrieve->prop('cmd') || ''; my $forceIP = $ddretrieve->prop('ForceIP') || ''; @@ -588,13 +517,16 @@ $domaindb->reload(); - system( "/sbin/e-smith/signal-event", "ddclient" ); + system( "/sbin/e-smith/signal-event", "smeserver-ddclient-update" ); return $c->l('ddc_SUCCESSFULLY_MODIFIED_RETRIEVE_IP'); } -sub performCreateCustom { - my ($c) = shift; +# We seem to be missing a Create Domain here +# sub performCreateDomain + +sub performModifyDomain { + my $c = shift; #------------------------------------------------------------ # Validate parameters and untaint them @@ -608,21 +540,6 @@ return $c->l( 'ddc_DOMAIN_NAME_VALIDATION_ERROR', $domainName ); } - foreach my $domain ( $edb->get_all_by_prop( type => 'domain' ) ) { - my $key = $domain->key; - if ( $key eq $domainName ) { - return $c->l( 'ddc_DOMAIN_NAME_ALREADY_EXIST', $domainName ); - } - } - - foreach my $domain ( $domaindb->get_all_by_prop( type => 'ddhost' ) ) { - my $key = $domain->key; - if ( $key eq $domainName ) { - return $c->l( 'ddc_DOMAIN_NAME_ALREADY_EXIST', $domainName ); - } - } - - my $domainDesc = $c->param('desc'); my $domainLogin = $c->param('login'); if ( $domainLogin =~ /^([\-\'\w][\-\'\w\s\.\@]*)$/ ) { $domainLogin = $1; @@ -636,7 +553,8 @@ $domainPassword = $1; } else { - return $c->l( 'ddc_DOMAIN_PASSWORD_VALIDATION_ERROR', $domainPassword ); + return $c->l( 'ddc_DOMAIN_PASSWORD_VALIDATION_ERROR', + $domainPassword ); } my $domainMX = $c->param('mx'); @@ -648,7 +566,9 @@ if ( $customDNS =~ /^([a-zA-Z0-9\-\.]+)$/ ) { $customDNS = $1; } - else { + else + + { return $c->l( 'ddc_CUSTOMDNS_VALIDATION_ERROR', $domainName ); } } @@ -658,25 +578,65 @@ # or if the domain is a reserved to provide a secured webserver # for a previous domain #------------------------------------------------------------ + # my $dns = $c->param ('dns'); - my %properties = (); - $properties{'type'} = 'ddhost'; - $properties{'dns'} = $dns; - $properties{'login'} = $domainLogin; - $properties{'password'} = $domainPassword; - $properties{'mx'} = $domainMX; - $properties{'desc'} = $domainDesc; - $properties{'customdns'} = $customDNS; - $properties{'customprotocol'} = $customPROTOCOL; - $edb->new_record( $domainName, \%properties ); + my $dom = $domaindb->get($domainName); + + $dom->set_prop( 'dns' => $dns ); + $dom->set_prop( 'login' => $domainLogin ); + $dom->set_prop( 'password' => $domainPassword ); + $dom->set_prop( 'mx' => $domainMX ); + $dom->set_prop( 'customdns' => $customDNS ); + $dom->set_prop( 'customprotocol' => $customPROTOCOL ); + + $domaindb->reload(); system( "/sbin/e-smith/signal-event", "ddclient" ); return "ok"; +} + +sub performDeleteDomain { + my ( $c, $domain ) = @_; + #------------------------------------------------------------ + # Attempt to delete domain + #------------------------------------------------------------ + + if ( $domain =~ /^([a-zA-Z0-9\-\.]+)$/ ) { + $domain = $1; + } + else { + return $c->l( 'ddc_ERROR_WHILE_REMOVING_DOMAIN', $domain ); + } + + my $value = $domaindb->get($domain); + unless ($value) { + return $c->l( 'ddc_NONEXISTENT_DOMAIN_ERROR', $domain ); + } + + my %properties = $value->props; + my $type = $properties{'type'}; + if ( $type ne 'domain' ) { + return $c->l( 'ddc_NONEXISTENT_DOMAIN_ERROR', $domain ); + } + + my $evalue = $domaindb->get($domain); + + $evalue->set_prop( 'dns' => '' ); + $evalue->set_prop( 'login' => '' ); + $evalue->set_prop( 'password' => '' ); + $evalue->set_prop( 'customdns' => '' ); + $evalue->set_prop( 'customprotocol' => '' ); + + $domaindb->reload(); + + system( "/sbin/e-smith/signal-event", "domain-modify" ); + + return "ok"; } -sub performModifyDomain { - my $c = shift; +sub performCreateCustom { + my ($c) = shift; #------------------------------------------------------------ # Validate parameters and untaint them @@ -690,6 +650,21 @@ return $c->l( 'ddc_DOMAIN_NAME_VALIDATION_ERROR', $domainName ); } + foreach my $domain ( $edb->get_all_by_prop( type => 'domain' ) ) { + my $key = $domain->key; + if ( $key eq $domainName ) { + return $c->l( 'ddc_DOMAIN_NAME_ALREADY_EXIST', $domainName ); + } + } + + foreach my $domain ( $domaindb->get_all_by_prop( type => 'ddhost' ) ) { + my $key = $domain->key; + if ( $key eq $domainName ) { + return $c->l( 'ddc_DOMAIN_NAME_ALREADY_EXIST', $domainName ); + } + } + + my $domainDesc = $c->param('desc'); my $domainLogin = $c->param('login'); if ( $domainLogin =~ /^([\-\'\w][\-\'\w\s\.\@]*)$/ ) { $domainLogin = $1; @@ -703,7 +678,8 @@ $domainPassword = $1; } else { - return $c->l( 'ddc_DOMAIN_PASSWORD_VALIDATION_ERROR', $domainPassword ); + return $c->l( 'ddc_DOMAIN_PASSWORD_VALIDATION_ERROR', + $domainPassword ); } my $domainMX = $c->param('mx'); @@ -715,9 +691,7 @@ if ( $customDNS =~ /^([a-zA-Z0-9\-\.]+)$/ ) { $customDNS = $1; } - else - - { + else { return $c->l( 'ddc_CUSTOMDNS_VALIDATION_ERROR', $domainName ); } } @@ -727,21 +701,21 @@ # or if the domain is a reserved to provide a secured webserver # for a previous domain #------------------------------------------------------------ - # my $dns = $c->param ('dns'); - - my $dom = $domaindb->get($domainName); - - $dom->set_prop( 'dns' => $dns ); - $dom->set_prop( 'login' => $domainLogin ); - $dom->set_prop( 'password' => $domainPassword ); - $dom->set_prop( 'mx' => $domainMX ); - $dom->set_prop( 'customdns' => $customDNS ); - $dom->set_prop( 'customprotocol' => $customPROTOCOL ); - $domaindb->reload(); + my %properties = (); + $properties{'type'} = 'ddhost'; + $properties{'dns'} = $dns; + $properties{'login'} = $domainLogin; + $properties{'password'} = $domainPassword; + $properties{'mx'} = $domainMX; + $properties{'desc'} = $domainDesc; + $properties{'customdns'} = $customDNS; + $properties{'customprotocol'} = $customPROTOCOL; + $edb->new_record( $domainName, \%properties ); - system( "/sbin/e-smith/signal-event", "ddclient" ); + system( "/sbin/e-smith/signal-event", "domain-create" ); return "ok"; + } sub performModifyCustom { @@ -772,7 +746,8 @@ $domainPassword = $1; } else { - return $c->l( 'ddc_DOMAIN_PASSWORD_VALIDATION_ERROR', $domainPassword ); + return $c->l( 'ddc_DOMAIN_PASSWORD_VALIDATION_ERROR', + $domainPassword ); } my $domainMX = $c->param('mx'); @@ -809,7 +784,41 @@ $domaindb->reload(); - system( "/sbin/e-smith/signal-event", "ddclient" ); + system( "/sbin/e-smith/signal-event", "domain-modify" ); + return "ok"; +} + +sub performDeleteCustom { + my ( $c, $domain ) = @_; + + #------------------------------------------------------------ + # Attempt to delete domain + #------------------------------------------------------------ + + if ( $domain =~ /^([a-zA-Z0-9\-\.]+)$/ ) { + $domain = $1; + } + else { + return $c->l( 'ddc_ERROR_WHILE_REMOVING_DOMAIN', $domain ); + } + + my $evalue = $edb->get($domain); + unless ($evalue) { + return $c->l( 'ddc_NONEXISTENT_DOMAIN_ERROR', $domain ); + } + + my %properties = $evalue->props; + my $type = $properties{'type'}; + + if ( $type ne 'ddhost' ) { + return $c->l( 'ddc_NONEXISTENT_DOMAIN_ERROR', $domain ); + + } + + $evalue->delete; + $edb->reload(); + + system( "/sbin/e-smith/signal-event", "domain-delete" ); return "ok"; }