Obsolete
/
dnsmanagerv1
Archived
3
0
Fork 0

Net::OpenSSH + readme + script pour les libs et modules nécessaires

master
Philippe Pittoli 2014-03-04 00:45:33 +01:00
parent 0d6d8db6dd
commit 1c00314b33
8 changed files with 96 additions and 55 deletions

View File

@ -17,7 +17,7 @@ use Moose;
has dbh => ( is => 'rw', builder => '_void');
has dnsi => ( is => 'rw', builder => '_void');
has um => ( is => 'rw', builder => '_void');
has [ qw/zdir dbname dbhost dbport dbuser dbpass sgbd dnsapp sshhost sshuser/ ] => qw/is ro required 1/;
has [ qw/zdir dbname dbhost dbport dbuser dbpass sgbd dnsapp sshhost sshuser sshport/ ] => qw/is ro required 1/;
sub _void { my $x = ''; \$x; }
### users
@ -94,7 +94,8 @@ sub add_domain {
my $ze = app::zone::edit->new(zname => $domain
, zdir => $self->zdir
, host => $self->sshhost
, user => $self->sshuser );
, user => $self->sshuser
, port => $self->sshport );
$ze->addzone();
}
@ -109,7 +110,8 @@ sub delete_domain {
my $ze = app::zone::edit->new(zname => $domain
, zdir => $self->zdir
, host => $self->sshhost
, user => $self->sshuser );
, user => $self->sshuser
, port => $self->sshport );
$ze->del();
1;
@ -121,7 +123,8 @@ sub update_domain_raw {
my $ze = app::zone::edit->new(zname => $domain
, zdir => $self->zdir
, host => $self->sshhost
, user => $self->sshuser );
, user => $self->sshuser
, port => $self->sshport );
$ze->update_raw($zone);
}
@ -130,7 +133,8 @@ sub update_domain {
my $ze = app::zone::edit->new(zname => $domain
, zdir => $self->zdir
, host => $self->sshhost
, user => $self->sshuser );
, user => $self->sshuser
, port => $self->sshport );
$ze->update($zone);
}
@ -139,7 +143,8 @@ sub get_domain {
my $ze = app::zone::edit->new(zname => $domain
, zdir => $self->zdir
, host => $self->sshhost
, user => $self->sshuser );
, user => $self->sshuser
, port => $self->sshport );
$ze->get();
}
@ -165,7 +170,8 @@ sub new_tmp {
my $ze = app::zone::edit->new(zname => $domain
, zdir => $self->zdir
, host => $self->sshhost
, user => $self->sshuser );
, user => $self->sshuser
, port => $self->sshport );
$ze->new_tmp();
}

View File

@ -2,7 +2,7 @@ use Modern::Perl;
use Data::Dump "dump";
use DNS::ZoneParse;
use File::Copy;
use Net::SCP;
use Net::OpenSSH;
use Net::SSH q<sshopen2>;
use v5.14;
@ -11,7 +11,7 @@ use app::zone::rndc_interface;
package app::zone::edit;
use Moose;
has [ qw/zname zdir host user/ ] => qw/is ro required 1/;
has [ qw/zname zdir host user port/ ] => qw/is ro required 1/;
sub get {
my ($self) = @_;
@ -140,15 +140,17 @@ sub _cp {
sub _scp_put {
my ($self, $src, $dest) = @_;
my $scp = Net::SCP->new( { host => $self->host, user => $self->user } );
$scp->put($src, $dest) or die $scp->{errstr};
my $co = $self->user . '@' . $self->host . ':' . $self->port;
my $ssh = Net::OpenSSH->new($co);
$ssh->scp_put($src, $dest) or die "scp failed: " . $ssh->error;
}
sub _scp_get {
my ($self, $src, $dest) = @_;
my $scp = Net::SCP->new( { host => $self->host, user => $self->user } );
$scp->get($src, $dest) or die $scp->{errstr};
my $co = $self->user . '@' . $self->host . ':' . $self->port;
my $ssh = Net::OpenSSH->new($co);
$ssh->scp_get($src, $dest) or die "scp failed: " . $ssh->error;
}
sub _sed {

32
get_libs.sh Executable file
View File

@ -0,0 +1,32 @@
#!/bin/bash
sudo apt-get update
sudo apt-get install libssl1.0.0 libssl-dev cpanminus make gcc
## En attendant de faire de vrais paquets pour l'application
cpanm YAML
cpanm Data::Dump
cpanm File::Basename
cpanm Find::Lib
cpanm Test::More
cpanm String::ShellQuote
cpanm Data::Structure::Util
cpanm Modern::Perl
cpanm Config::Simple
cpanm Crypt::Digest::SHA256
cpanm Dancer::Session::Storable
cpanm Moose
cpanm Template
cpanm Template::Toolkit
cpanm Dancer
cpanm Dancer::Test
cpanm ExtUtils::MakeMaker
cpanm Storable
cpanm Plack::Handler::FCGI
cpanm Plack::Runner
cpanm DNS::ZoneParse
cpanm Net::OpenSSH

View File

@ -1,31 +1,21 @@
## FR trame du projet / TODO / brainstorming / brouillon
### page d'inscription
* login
* captcha -- todo
### utilisateurs
* un login
* des domaines
* un mdp chiffré -- todo
* peuvent modifier leurs zones -- todo
* leur compte doit être activé par un admin -- todo
* réservation d'un ou plusieurs ndd en X.DOMAIN.TLD -- todo
* vérifier qu'ils ne sont pas déjà réservés ou attribués -- todo
### admins
* Valident les comptes des utilisateurs. -- todo
* en activant une zone d'un utilisateur. -- todo
* Doit être automatisé. -- todo
* Créent et suppriment d'autres administrateurs. -- todo
* Possèdent une page pour voir les comptes non activés. -- todo
Gérer la création de zones par des utilisateurs.
Les utilisateurs s'enregistrent, crééent des zones et les modifient comme ils le souhaitent.
Des administrateurs peuvent supprimer des utilisateurs avec leurs zones.
## outils
* [Dancer](http://perldancer.org/)
* [DNS::ZoneParse](http://search.cpan.org/~mschilli/DNS-ZoneParse-1.10/lib/DNS/ZoneParse.pm)
* [Bootstrap](http://twitter.github.io/bootstrap/) -- todo
* [DBD::mysql](https://metacpan.org/module/DBD::mysql)
* [Net::HTTPS::Any](https://metacpan.org/module/IVAN/Net-HTTPS-Any-0.10/lib/Net/HTTPS/Any.pm) -- todo
* [Moose](https://metacpan.org/module/ETHER/Moose-2.0802/lib/Moose.pm)
* voir pour le chiffrement
* [Dancer](http://perldancer.org/)
* [DNS::ZoneParse](http://search.cpan.org/~mschilli/DNS-ZoneParse-1.10/lib/DNS/ZoneParse.pm)
* [Bootstrap](http://twitter.github.io/bootstrap/) -- todo
* [DBD::mysql](https://metacpan.org/module/DBD::mysql)
* [Moose](https://metacpan.org/module/ETHER/Moose-2.0802/lib/Moose.pm)
* [Crypt::Digest::SHA256](http://search.cpan.org/~mik/CryptX-0.021/lib/Crypt/Digest/SHA256.pm)
## TODO
* captcha
* demander confirmation avant suppression d'une zone
Si on souhaite faire un client pour mettre à jour automatiquement une zone avec son IP:
* [Net::HTTPS::Any](https://metacpan.org/module/IVAN/Net-HTTPS-Any-0.10/lib/Net/HTTPS/Any.pm)

View File

@ -4,13 +4,19 @@ use warnings;
use v5.14;
use autodie;
use Modern::Perl;
use Net::SCP;
use Net::OpenSSH;
my $hostname = "pizza";
my $username = "karchnu";
my $hostname = "ns0.arn-fai.net";
my $username = "dnsmanager";
my $scp = Net::SCP->new( { host => $hostname, user => $username } );
$scp->get("/etc/resolv.conf", "kikoo") or die $scp->{errstr};
$scp->put("kikoo", "lolwat") or die $scp->{errstr};
my $co = "$username\@$hostname:2222";
say $co;
my $ssh = Net::OpenSSH->new($co);
$ssh->scp_put("tpl.zone", "/home/$username/") or die "scp failed: " . $ssh->error;
#use Net::SCP; # ne fonctionne pas avec des ports :/
#my $scp = Net::SCP->new( { host => $hostname, user => $username, port => 2222} );
#$scp->put("tpl.zone", "lolwat") or die $scp->{errstr};
# $scp->put("filename") or die $scp->{errstr};

View File

@ -1,6 +1,6 @@
;
; Database file tpl.zone for tpl.zone. zone.
; Zone version: 2014011815
; Zone version: 2014030200
;
$ORIGIN CHANGEMEORIGIN.
@ -8,7 +8,7 @@ $ORIGIN CHANGEMEORIGIN.
$TTL 3600
@ 3600 IN SOA ns0.netlib.re. postmaster.netlib.re. (
2014011815 ; serial number
2014030200 ; serial number
3600 ; refresh
600 ; retry
86400 ; expire
@ -16,3 +16,5 @@ $TTL 3600
)
;
; Zone NS Records
@ IN NS ns0.arn-fai.net.

View File

@ -9,13 +9,15 @@ host = localhost
# default port for mysql
port = 3306
user = bla
passwd = HardPass4bla
user = monutilisateur
passwd = motdepasse
# other options : see DBI module
# possible options for dnsserver : bind rndc
dnsapp = rndc
zones_path = "/etc/bind/named/"
zones_path = "/var/named/rndczones/"
sshhost = localhost
sshuser = karchnu
# to access zones on the server
sshhost = host
sshuser = dnsmanager
sshport = 2222

View File

@ -41,6 +41,7 @@ sub initco {
, sgbd => $cfg->param('sgbd')
, sshhost => $cfg->param('sshhost')
, sshuser => $cfg->param('sshuser')
, sshport => $cfg->param('sshport')
, dnsapp => $cfg->param('dnsapp') );
$app->init();