DirectSlave - solution to add and remove zones on slave without DirectAdmin

roman_m

Verified User
Joined
May 5, 2005
Messages
130
Location
Ukraine, Kiev
For new DirectSlave/GO 3 public beta see this thread -- https://forum.directadmin.com/showthread.php?t=54992

All versions in one place -- https://directslave.com/

Web interface demo available -- https://directslave.com:2224 demo:demo123

Benefits:
+ listen to tcp 2222 and imitates DirectAdmin /CMD_API_DNS_ADMIN (port can be changed in config)
+ SSL to secure parameters transferred from your DirectAdmin servers to DirectSlave server
+ acts as daemon with given uid/gid (bind (53), for example) for security & access to named.conf reason (named.conf is not system named.conf, just include from it)
+ no need for rsh/rsync
+ configurable via single config file (uid gid logs and many other things)
+ can serve parallel requests from as many servers, as you want
+ acts as normal secondary mode (just write named.conf entry for zone)
+ multiuser access. One server - one user. Strict permission check - no adding existing domains, nor remove unowned domains.

Limitations:
- old good perl, needs for CPAN-installed modules

Tested on FreeBSD and Ubuntu 12.04.

Do not forget to read README and UPDATING.

Downloads:

http://regme.in/download/directslave-1.3.tar.gz - version 1.3 - stable single-account version
http://regme.in/download/directslave-2.1-beta.tar.gz - version 2.1 - new version with multiuser & SSL features

DirectSlave is uncommercial, distributed absolutely free of charge, open-source project. Try it, test it, enjoy it ;-)
 
Last edited:

SeLLeRoNe

Super Moderator
Joined
Oct 9, 2004
Messages
6,789
Location
A Coruña, Spain
Already tested and in testing, work perfectly.

Some hints ive alread told via email to Roman for some features like multiple accounts.

Regards
 

scsi

Verified User
Joined
Aug 19, 2008
Messages
4,695
Why would you need multiple accounts if its just slave dns?
 

SeLLeRoNe

Super Moderator
Joined
Oct 9, 2004
Messages
6,789
Location
A Coruña, Spain
Cause you can offer service to other and create a user for customer without share main password, or just for have different access for each server so if a single password/server got hacked there is no need to change to each server.

I hope ive well understand the meaning of this.

Regards
 

Arieh

Verified User
Joined
May 27, 2008
Messages
1,200
Location
The Netherlands
Looks good. It's quite the readme you got there, but it's good to have everything explained. I see the auth user:encryptedpassword format, can you list it like that for multiple users?
I'll give it all a try later.
 

roman_m

Verified User
Joined
May 5, 2005
Messages
130
Location
Ukraine, Kiev
Looks good. It's quite the readme you got there, but it's good to have everything explained. I see the auth user:encryptedpassword format, can you list it like that for multiple users?
I'll give it all a try later.
There is no way to set multiple user entries at this time, just one. I'll work on this later (thanx SeLLeRoNe :)
 

Terrorhawk

Verified User
Joined
Jan 29, 2007
Messages
32
wow this looks very cool.
I will going to test this later this year and if it works stable i will switch my powerdns server to this.
 

sHuKKo

Verified User
Joined
Jun 24, 2003
Messages
89
Location
on the net!
I tried this today,
Although your README file is quite explains everything I need to try and test myself on how things must done on my ubuntu testbed.
but at the end it works as expected!
Thank you very much for this nice code.
I will try to make my test setup die/crash now.
Let's see how it goes.
 

Isoka

Verified User
Joined
Sep 22, 2012
Messages
6
Hi all :)

First, thank's for directslave, it's perfect :D

But I have a little problem with named.conf write.

When I create a domain on my first server, the command is correctly received by the second server but I have an error when the directslave file is running.

There is my error.log:

Use of uninitialized value in length at /usr/local/directslave/bin/directslave line 108.
Use of uninitialized value in length at /usr/local/directslave/bin/directslave line 108.
flock() on closed filehandle SEC at /usr/local/directslave/bin/directslave line 177.
print() on closed filehandle SEC at /usr/local/directslave/bin/directslave line 178.
flock() on closed filehandle LOG at /usr/local/directslave/bin/directslave line 229.
printf() on closed filehandle LOG at /usr/local/directslave/bin/directslave line 230.

My systeme is on Debian Squeeze and it is updated.. I'm not a perl dev so I can't resolve this problem by myself.

I have search on google but I have'nt found anything.

Thank's ;)
 

roman_m

Verified User
Joined
May 5, 2005
Messages
130
Location
Ukraine, Kiev
This happens because CGI did not receive correct
Turn on debug in directslave.conf and restart the daemon, then look for the explanation of the error in /usr/local/directslave/log/error.log

Remember, you need my patched CGI.pm located in lib directory for correct data processing since directadmin generates plain-text POST request.

Can you post your config to this thread or message me locally.
 

Isoka

Verified User
Joined
Sep 22, 2012
Messages
6
Hello,

First, where do I put the CGI.pm file?

Code:
find / -name CGI.pm -print 2>/dev/null
says:

Code:
/root/.cpan/build/CGI.pm-3.60-EU0zgA/blib/lib/CGI.pm
/root/.cpan/build/CGI.pm-3.60-EU0zgA/lib/CGI.pm
/root/.cpan/build/CGI.pm-3.60-N5muZB/blib/lib/CGI.pm
/root/.cpan/build/CGI.pm-3.60-N5muZB/lib/CGI.pm
/root/.cpan/build/CGI.pm-3.60-DgEMNS/blib/lib/CGI.pm
/root/.cpan/build/CGI.pm-3.60-DgEMNS/lib/CGI.pm
/usr/local/share/perl/5.10.1/CGI.pm
/usr/local/lib/perl/5.10.1/CGI.pm
/usr/share/perl/5.10.1/CGI.pm
/usr/lib/perl/5.10.1/CGI.pm
/usr/lib/perl5/CGI.pm
it is good?

Then, there is my error log with "background 1" and "debug 1":

Code:
SERVER OPTIONS: $VAR1 = bless( {
                 'server' => {
                               'peername' => '',
                               'sockport' => 2222,
                               'conf_file' => undef,
                               'chown_files' => [
                                                  '/usr/local/directslave/log/error.log',
                                                  '/usr/local/directslave/log/access.log'
                                                ],
                               'timeout_header' => 15,
                               'reverse_lookups' => undef,
                               'setsid' => undef,
                               'peerport' => 33618,
                               'pid_file' => '/usr/local/directslave/run/directslave.pid',
                               'listen' => undef,
                               'access_log_file' => '/usr/local/directslave/log/access.log',
                               'access_log_format' => '%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"',
                               '_bind' => [
                                            {
                                              'proto' => 'tcp',
                                              'ipv' => 4,
                                              'port' => '2222',
                                              'host' => '0.0.0.0'
                                            }
                                          ],
                               'user' => 103,
                               'server_type' => [
                                                  'Fork'
                                                ],
                               'ipv' => [],
                               'proto' => [],
                               'chroot' => undef,
                               'deny' => [],
                               'tied_stdout_callback' => sub { "DUMMY" },
                               'port' => [
                                           '2222'
                                         ],
                               'no_client_stdout' => undef,
                               'check_for_dead' => 60,
                               'server_revision' => 'DirectSlave/1.2',
                               'cidr_deny' => [],
                               'access_log_function' => sub { "DUMMY" },
                               'pid_file_unlink' => 1,
                               'cidr_allow' => [
                                                 '0.0.0.0/0'
                                               ],
                               'enable_dispatch' => undef,
                               'check_for_dequeue' => undef,
                               'max_servers' => 256,
                               'group' => '107 107',
                               'leave_children_open_on_hup' => undef,
                               'log_level' => 2,
                               'tie_client_stdout' => 1,
                               'select' => bless( [
                                                    ' ',
                                                    1,
                                                    undef,
                                                    undef,
                                                    undef,
                                                    undef,
                                                    undef,
                                                    bless( \*Symbol::GEN0, 'Net::Server::Proto::TCP' )
                                                  ], 'IO::Select' ),
                               'sock' => [
                                           undef
                                         ],
                               '_run_args' => [
                                                'min_spare_servers',
                                                undef,
                                                'spare_servers',
                                                undef
                                              ],
                               'multi_port' => 1,
                               'requests' => 1,
                               'background' => 1,
                               'sig_passthrough' => [],
                               'peeraddr' => '37.bb.cc.dd',
                               'log_file' => '/usr/local/directslave/log/error.log',
                               'host' => [
                                           '*'
                                         ],
                               'client' => bless( \*Symbol::GEN5, 'Net::Server::Proto::TCP' ),
                               'sockaddr' => '37.bbb.ccc.ddd',
                               'ppid' => 2037,
                               'max_dequeue' => undef,
                               'timeout_idle' => 60,
                               'no_close_by_child' => undef,
                               'allow' => [],
                               'tied_stdin_callback' => undef,
                               'commandline' => [
                                                  '/usr/bin/perl',
                                                  '/usr/local/directslave/bin/directslave'
                                                ],
                               'max_header_size' => 100000
                             },
                 'request_info' => {
                                     'request_headers' => [
                                                            [
                                                              'Authorization',
                                                              'Basic ****************************************'
                                                            ],
                                                            [
                                                              'Host',
                                                              '37.bbb.ccc.ddd'
                                                            ]
                                                          ],
                                     'request' => 'GET /CMD_API_DNS_ADMIN?action=exists&domain=bistocraft.fr HTTP/1.0',
                                     'sockport' => 2222,
                                     'query_string' => '?action=exists&domain=bistocraft.fr',
                                     'request_method' => 'GET',
                                     'peerport' => 33618,
                                     'peeraddr' => '37.bb.cc.dd',
                                     'remote_user' => '-',
                                     'request_size' => 0,
                                     'sockaddr' => '37.bbb.ccc.ddd',
                                     'peerhost' => '37.bb.cc.dd',
                                     'request_header_size' => 146,
                                     'begin' => '1349913140.03209',
                                     'request_path' => '/CMD_API_DNS_ADMIN',
                                     'request_protocol' => 'http'
                                   }
               }, 'main' );
CGI QUERY: $VAR1 = bless( {
                 '.parameters' => [
                                    'action',
                                    'domain'
                                  ],
                 'use_tempfile' => 1,
                 '.charset' => 'ISO-8859-1',
                 '.fieldnames' => {},
                 'param' => {
                              'domain' => [
                                            'bistocraft.fr'
                                          ],
                              'action' => [
                                            'exists'
                                          ]
                            },
                 'escape' => 1
               }, 'CGI' );
Checking credentials: received admin:$1$************************** vs admin:$1$**************************
Use of uninitialized value in length at /usr/local/directslave/bin/directslave line 109.
SERVER OPTIONS: $VAR1 = bless( {
                 'server' => {
                               'peername' => '',
                               'sockport' => 2222,
                               'conf_file' => undef,
                               'chown_files' => [
                                                  '/usr/local/directslave/log/error.log',
                                                  '/usr/local/directslave/log/access.log'
                                                ],
                               'timeout_header' => 15,
                               'reverse_lookups' => undef,
                               'setsid' => undef,
                               'peerport' => 43692,
                               'pid_file' => '/usr/local/directslave/run/directslave.pid',
                               'listen' => undef,
                               'access_log_file' => '/usr/local/directslave/log/access.log',
                               'access_log_format' => '%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"',
                               '_bind' => [
                                            {
                                              'proto' => 'tcp',
                                              'ipv' => 4,
                                              'port' => '2222',
                                              'host' => '0.0.0.0'
                                            }
                                          ],
                               'user' => 103,
                               'server_type' => [
                                                  'Fork'
                                                ],
                               'ipv' => [],
                               'proto' => [],
                               'chroot' => undef,
                               'deny' => [],
                               'tied_stdout_callback' => sub { "DUMMY" },
                               'port' => [
                                           '2222'
                                         ],
                               'no_client_stdout' => undef,
                               'check_for_dead' => 60,
                               'server_revision' => 'DirectSlave/1.2',
                               'cidr_deny' => [],
                               'access_log_function' => sub { "DUMMY" },
                               'pid_file_unlink' => 1,
                               'cidr_allow' => [
                                                 '0.0.0.0/0'
                                               ],
                               'enable_dispatch' => undef,
                               'check_for_dequeue' => undef,
                               'max_servers' => 256,
                               'group' => '107 107',
                               'leave_children_open_on_hup' => undef,
                               'log_level' => 2,
                               'tie_client_stdout' => 1,
                               'select' => bless( [
                                                    ' ',
                                                    1,
                                                    undef,
                                                    undef,
                                                    undef,
                                                    undef,
                                                    undef,
                                                    bless( \*Symbol::GEN0, 'Net::Server::Proto::TCP' )
                                                  ], 'IO::Select' ),
                               'sock' => [
                                           undef
                                         ],
                               '_run_args' => [
                                                'min_spare_servers',
                                                undef,
                                                'spare_servers',
                                                undef
                                              ],
                               'multi_port' => 1,
                               'requests' => 1,
                               'background' => 1,
                               'sig_passthrough' => [],
                               'peeraddr' => '37.bb.cc.dd',
                               'log_file' => '/usr/local/directslave/log/error.log',
                               'host' => [
                                           '*'
                                         ],
                               'client' => bless( \*Symbol::GEN6, 'Net::Server::Proto::TCP' ),
                               'sockaddr' => '37.bbb.ccc.ddd',
                               'ppid' => 2037,
                               'max_dequeue' => undef,
                               'timeout_idle' => 60,
                               'no_close_by_child' => undef,
                               'allow' => [],
                               'tied_stdin_callback' => undef,
                               'commandline' => [
                                                  '/usr/bin/perl',
                                                  '/usr/local/directslave/bin/directslave'
                                                ],
                               'max_header_size' => 100000
                             },
                 'request_info' => {
                                     'request_headers' => [
                                                            [
                                                              'Authorization',
                                                              'Basic **************************'
                                                            ],
                                                            [
                                                              'Content-Length',
                                                              '807'
                                                            ],
                                                            [
                                                              'Host',
                                                              '37.bbb.ccc.ddd'
                                                            ]
                                                          ],
                                     'request' => 'POST /CMD_API_DNS_ADMIN?action=rawsave&domain=bistocraft.fr HTTP/1.0',
                                     'sockport' => 2222,
                                     'query_string' => '?action=rawsave&domain=bistocraft.fr',
                                     'request_method' => 'POST',
                                     'peerport' => 43692,
                                     'peeraddr' => '37.bb.cc.dd',
                                     'remote_user' => '-',
                                     'request_size' => '807',
                                     'sockaddr' => '37.bbb.ccc.ddd',
                                     'peerhost' => '37.bb.cc.dd',
                                     'request_header_size' => 169,
                                     'begin' => '1349913140.43324',
                                     'request_path' => '/CMD_API_DNS_ADMIN',
                                     'request_protocol' => 'http'
                                   }
               }, 'main' );
CGI QUERY: $VAR1 = bless( {
                 '.parameters' => [
                                    '







$TTL 14400
@       IN      SOA     ns1.bistofly.in.      hostmaster.bistocraft.fr. (
                                                2012101100
                                                14400
                                                3600
                                                1209600
                                                86400 )

bistocraft.fr.	14400	IN	NS	ns1.bistofly.in.
bistocraft.fr.	14400	IN	NS	ns2.bistofly.in.

bistocraft.fr.	14400	IN	A	37.bb.cc.dd
ftp	14400	IN	A	37.bb.cc.dd
localhost	14400	IN	A	127.0.0.1
mail	14400	IN	A	37.bb.cc.dd
pop	14400	IN	A	37.bb.cc.dd
smtp	14400	IN	A	37.bb.cc.dd
www	14400	IN	A	37.bb.cc.dd

bistocraft.fr.	14400	IN	MX	10 mail



bistocraft.fr.	14400	IN	TXT	"v'
                                  ],
                 'use_tempfile' => 1,
                 '.charset' => 'ISO-8859-1',
                 '.fieldnames' => {},
                 'param' => {
                              '







$TTL 14400
@       IN      SOA     ns1.bistofly.in.      hostmaster.bistocraft.fr. (
                                                2012101100
                                                14400
                                                3600
                                                1209600
                                                86400 )

bistocraft.fr.	14400	IN	NS	ns1.bistofly.in.
bistocraft.fr.	14400	IN	NS	ns2.bistofly.in.

bistocraft.fr.	14400	IN	A	37.bb.cc.dd
ftp	14400	IN	A	37.bb.cc.dd
localhost	14400	IN	A	127.0.0.1
mail	14400	IN	A	37.bb.cc.dd
pop	14400	IN	A	37.bb.cc.dd
smtp	14400	IN	A	37.bb.cc.dd
www	14400	IN	A	37.bb.cc.dd

bistocraft.fr.	14400	IN	MX	10 mail



bistocraft.fr.	14400	IN	TXT	"v' => [
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            'spf1 a mx ip4:37.bb.cc.dd ~all"

localhost	14400	IN	AAAA	::1


'
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ]
                            },
                 'escape' => 1
               }, 'CGI' );
Checking credentials: received admin:$1$************************** vs admin:$1$**************************
Use of uninitialized value in length at /usr/local/directslave/bin/directslave line 109.
flock() on closed filehandle SEC at /usr/local/directslave/bin/directslave line 178.
print() on closed filehandle SEC at /usr/local/directslave/bin/directslave line 179.
flock() on closed filehandle LOG at /usr/local/directslave/bin/directslave line 230.
printf() on closed filehandle LOG at /usr/local/directslave/bin/directslave line 231.
Note: "peername" contains strange characters so I delete it.

And finally, this is my config:

Code:
background 	1
server_type	Fork
host  		*
port  		2222
debug 		1

uid  		bind
gid 		bind

pid	  	/usr/local/directslave/run/directslave.pid
access_log	/usr/local/directslave/log/access.log
error_log	/usr/local/directslave/log/error.log
action_log	/usr/local/directslave/log/action.log

mode		slave
named_workdir	/etc/bind/secondary
named_conf	/etc/bind/secondary/named.conf
retry_time	1200
rndc_path	/usr/sbin/rndc

allow		0.0.0.0/0

auth		admin:(crypted)mystronglypassword
Thank you very much
 
Last edited by a moderator:

zEitEr

Super Moderator
Joined
Apr 11, 2005
Messages
13,893
Location
GMT +7.00
@Isoka,

You might need to change your Directadmin and DirectSlave passwords as they were posted in your debug output, and can be easily discovered.
 

Isoka

Verified User
Joined
Sep 22, 2012
Messages
6
@ zEitEr:

This is not my really password in debug file, it's just a test pass ;)
 

snk

Verified User
Joined
Dec 19, 2007
Messages
102
Use of uninitialized value in length at /usr/local/directslave/bin/directslave line 109.
I'm not good with perl but i think to fix this, just need replace string in line 109:
Code:
if(length($query->{param}{zone})) {
to this
Code:
if((defined $query->{param}{zone} && length($query->{param}{zone}))) {
 

roman_m

Verified User
Joined
May 5, 2005
Messages
130
Location
Ukraine, Kiev
Yep, he can do it, but $zone param initialized from my patched and bundled CGI.pm module.
I look at find / and there is no CGI.pm in /usr/local/directslave/lib/
Grab it from original directslave tarball, put into /usr/local/directslave/lib/ folder, then restart directslave and check all the things works right.

Without my patched CGI.pm directslave was unable to process plain http data sent by DirectAdmin, this feature is not available in standart CGI from cpan or any *nix installation.
 

snk

Verified User
Joined
Dec 19, 2007
Messages
102
About this error
Code:
flock() on closed filehandle SEC at /usr/local/directslave/bin/directslave line 178.
print() on closed filehandle SEC at /usr/local/directslave/bin/directslave line 179.
flock() on closed filehandle LOG at /usr/local/directslave/bin/directslave line 230.
printf() on closed filehandle LOG at /usr/local/directslave/bin/directslave line 231.
check permission and owner for your /etc/bind/secondary/named.conf
I have same error but after changing owner to bind (my named.conf owner was root:bind) error is gone.


Maybe will be good to change:
Code:
open(CONF, $config->{named_conf});
to
Code:
open(CONF, $config->{named_conf}) [b]or die ($!)[/b];
So it will print error why DirectSlave can't open named.conf file. Roman, what do you think ?
 

Isoka

Verified User
Joined
Sep 22, 2012
Messages
6
Okaaaay....!

Don't worry, I'm an idiot...

I had forgot permission of named.conf...

I modified the chmod to 775 and.. it works :p

named.conf zone was write and.. it's ok :D

Thank's a lot for help roman, snk and zEitEr! :)
 
Top