@@ -163,7 +163,7 @@ void loadMainConfig(const std::string& configdir)
163
163
164
164
// irritatingly enough, rectifyZone needs its own ueberbackend and can't therefore benefit from transactions outside its scope
165
165
// I think this has to do with interlocking transactions between B and DK, but unsure.
166
- void rectifyZone (DNSSECKeeper& dk, const std::string& zone)
166
+ bool rectifyZone (DNSSECKeeper& dk, const std::string& zone)
167
167
{
168
168
UeberBackend B (" default" );
169
169
bool doTransaction=true ; // but see above
@@ -172,7 +172,7 @@ void rectifyZone(DNSSECKeeper& dk, const std::string& zone)
172
172
173
173
if (!B.getSOA (zone, sd)) {
174
174
cerr<<" No SOA known for '" <<zone<<" ', is such a zone in the database?" <<endl;
175
- return ;
175
+ return false ;
176
176
}
177
177
sd.db ->list (zone, sd.domain_id );
178
178
@@ -305,6 +305,8 @@ void rectifyZone(DNSSECKeeper& dk, const std::string& zone)
305
305
306
306
if (doTransaction)
307
307
sd.db ->commitTransaction ();
308
+
309
+ return true ;
308
310
}
309
311
310
312
void rectifyAllZones (DNSSECKeeper &dk)
@@ -557,11 +559,19 @@ void verifyCrypto(const string& zone)
557
559
#endif
558
560
559
561
}
560
- void disableDNSSECOnZone (DNSSECKeeper& dk, const string& zone)
562
+ bool disableDNSSECOnZone (DNSSECKeeper& dk, const string& zone)
561
563
{
564
+ UeberBackend B (" default" );
565
+ DomainInfo di;
566
+
567
+ if (!B.getDomainInfo (zone, di)){
568
+ cerr << " No such zone in the database" << endl;
569
+ return false ;
570
+ }
571
+
562
572
if (!dk.isSecuredZone (zone)) {
563
573
cerr<<" Zone is not secured\n " ;
564
- return ;
574
+ return false ;
565
575
}
566
576
DNSSECKeeper::keyset_t keyset=dk.getKeys (zone);
567
577
@@ -576,9 +586,18 @@ void disableDNSSECOnZone(DNSSECKeeper& dk, const string& zone)
576
586
}
577
587
dk.unsetNSEC3PARAM (zone);
578
588
dk.unsetPresigned (zone);
589
+ return true ;
579
590
}
580
- void showZone (DNSSECKeeper& dk, const std::string& zone)
591
+ bool showZone (DNSSECKeeper& dk, const std::string& zone)
581
592
{
593
+ UeberBackend B (" default" );
594
+ DomainInfo di;
595
+
596
+ if (!B.getDomainInfo (zone, di)){
597
+ cerr << " No such zone in the database" << endl;
598
+ return false ;
599
+ }
600
+
582
601
if (!dk.isSecuredZone (zone)) {
583
602
cerr<<" Zone is not actively secured\n " ;
584
603
}
@@ -628,6 +647,7 @@ void showZone(DNSSECKeeper& dk, const std::string& zone)
628
647
}
629
648
}
630
649
}
650
+ return true ;
631
651
}
632
652
633
653
bool secureZone (DNSSECKeeper& dk, const std::string& zone)
928
948
cerr << " Syntax: pdnssec rectify-zone ZONE [ZONE..]" <<endl;
929
949
return 0 ;
930
950
}
951
+ unsigned int exitCode = 0 ;
931
952
for (unsigned int n = 1 ; n < cmds.size (); ++n)
932
- rectifyZone (dk, cmds[n]);
953
+ if (!rectifyZone (dk, cmds[n])) exitCode = 1 ;
954
+ return exitCode;
933
955
}
934
956
else if (cmds[0 ] == " rectify-all-zones" ) {
935
957
rectifyAllZones (dk);
@@ -984,15 +1006,16 @@ try
984
1006
return 0 ;
985
1007
}
986
1008
const string& zone=cmds[1 ];
987
- showZone (dk, zone);
1009
+ if (! showZone (dk, zone)) return 1 ;
988
1010
}
989
1011
else if (cmds[0 ] == " disable-dnssec" ) {
990
1012
if (cmds.size () != 2 ) {
991
1013
cerr << " Syntax: pdnssec disable-dnssec ZONE" <<endl;
992
1014
return 0 ;
993
1015
}
994
1016
const string& zone=cmds[1 ];
995
- disableDNSSECOnZone (dk, zone);
1017
+ if (!disableDNSSECOnZone (dk, zone))
1018
+ return 1 ;
996
1019
}
997
1020
else if (cmds[0 ] == " activate-zone-key" ) {
998
1021
if (cmds.size () != 3 ) {
@@ -1036,6 +1059,15 @@ try
1036
1059
return 0 ;
1037
1060
}
1038
1061
const string& zone=cmds[1 ];
1062
+
1063
+ UeberBackend B (" default" );
1064
+ DomainInfo di;
1065
+
1066
+ if (!B.getDomainInfo (zone, di)){
1067
+ cerr << " No such zone in the database" << endl;
1068
+ return 0 ;
1069
+ }
1070
+
1039
1071
// need to get algorithm, bits & ksk or zsk from commandline
1040
1072
bool keyOrZone=false ;
1041
1073
int tmp_algo=0 ;
0 commit comments