Only print loccode header if we have actual records

Add whitespace to version banner in zone output


git-svn-id: https://svn.alkaloid.net/gpl/ldap2dns/trunk@332 06cd67b6-e706-0410-b29e-9de616bca6e9
This commit is contained in:
Ben Klang
2006-06-13 17:03:41 +00:00
parent f942b26f60
commit 304a172b2c

View File

@@ -780,7 +780,7 @@ static void write_zone(void)
zone.domainname, zone.class, zone.domainname); zone.domainname, zone.class, zone.domainname);
} }
if (namedzone) { if (namedzone) {
fprintf(namedzone, "; Automatically generated by ldap2dns v%s - DO NOT EDIT!\n", VERSION); fprintf(namedzone, ";\n; Automatically generated by ldap2dns v%s - DO NOT EDIT!\n;\n\n", VERSION);
if (zone.ttl[0]) if (zone.ttl[0])
fprintf(namedzone, "$TTL %s\n", zone.ttl); fprintf(namedzone, "$TTL %s\n", zone.ttl);
else else
@@ -839,9 +839,9 @@ static void read_dnszones(void)
int ldaperr; int ldaperr;
if (tinyfile) if (tinyfile)
fprintf(tinyfile, "# Automatically generated by ldap2dns v%s - DO NOT EDIT!\n", VERSION); fprintf(tinyfile, "#\n# Automatically generated by ldap2dns v%s - DO NOT EDIT!\n#\n\n", VERSION);
if (namedmaster) if (namedmaster)
fprintf(namedmaster, "# Automatically generated by ldap2dns v%s - DO NOT EDIT!\n", VERSION); fprintf(namedmaster, "#\n# Automatically generated by ldap2dns v%s - DO NOT EDIT!\n#\n\n", VERSION);
if ( (ldaperr = ldap_search_ext_s(ldap_con, options.searchbase[0] ? options.searchbase : NULL, LDAP_SCOPE_SUBTREE, "objectclass=DNSzone", NULL, 0, NULL, NULL, &options.searchtimeout, options.reclimit, &res))!=LDAP_SUCCESS ) if ( (ldaperr = ldap_search_ext_s(ldap_con, options.searchbase[0] ? options.searchbase : NULL, LDAP_SCOPE_SUBTREE, "objectclass=DNSzone", NULL, 0, NULL, NULL, &options.searchtimeout, options.reclimit, &res))!=LDAP_SUCCESS )
die_ldap(ldaperr); die_ldap(ldaperr);
if (ldap_count_entries(ldap_con, res) < 1) { if (ldap_count_entries(ldap_con, res) < 1) {
@@ -984,15 +984,18 @@ static void read_loccodes(void)
LDAPMessage* m; LDAPMessage* m;
int ldaperr; int ldaperr;
if (tinyfile)
fprintf(tinyfile, "# Location Codes (if any) - generated by ldap2dns v%s - DO NOT EDIT!\n", VERSION);
if ( (ldaperr = ldap_search_ext_s(ldap_con, options.searchbase[0] ? options.searchbase : NULL, LDAP_SCOPE_SUBTREE, "objectclass=DNSloccodes", NULL, 0, NULL, NULL, &options.searchtimeout, options.reclimit, &res))!=LDAP_SUCCESS ) if ( (ldaperr = ldap_search_ext_s(ldap_con, options.searchbase[0] ? options.searchbase : NULL, LDAP_SCOPE_SUBTREE, "objectclass=DNSloccodes", NULL, 0, NULL, NULL, &options.searchtimeout, options.reclimit, &res))!=LDAP_SUCCESS )
die_ldap(ldaperr); die_ldap(ldaperr);
if (ldap_count_entries(ldap_con, res) < 1) {
fprintf(stderr, "[**] Warning: No records returned from search. Check for correct credentials,\n[**] LDAP hostname, and search base DN.\n\n"); // We aren't going to warn for zero records here as many installs do
// not use location codes at all
if ((ldap_count_entries(ldap_con, res) > 0) && tinyfile) {
fprintf(tinyfile, "#\n# Location Codes (if any) - generated by ldap2dns v%s - DO NOT EDIT!\n#\n\n", VERSION);
} else {
return; return;
} }
for (m = ldap_first_entry(ldap_con, res); m; m = ldap_next_entry(ldap_con, m)) { for (m = ldap_first_entry(ldap_con, res); m; m = ldap_next_entry(ldap_con, m)) {
BerElement* ber = NULL; BerElement* ber = NULL;
char* attr; char* attr;