update from author
This commit is contained in:
17
contrib/sdb/README.zone2ldap
Normal file
17
contrib/sdb/README.zone2ldap
Normal file
@@ -0,0 +1,17 @@
|
||||
INSTALLATION
|
||||
|
||||
To Compile zone2ldap from contrib/sdb directory:
|
||||
|
||||
gcc -g `../../isc-config.sh --cflags isc dns` -c zone2ldap.c
|
||||
gcc -g -o zone2ldap zone2ldap.o `isc-config.sh --libs isc dns` -lldap -llber -lresolv
|
||||
|
||||
USAGE:
|
||||
|
||||
See zone2ldap.1
|
||||
|
||||
BUGS:
|
||||
|
||||
Jeff McNeil <jeff@snapcase.g-rock.net>
|
||||
|
||||
|
||||
|
||||
17
contrib/sdb/ldap/README.zone2ldap
Normal file
17
contrib/sdb/ldap/README.zone2ldap
Normal file
@@ -0,0 +1,17 @@
|
||||
INSTALLATION
|
||||
|
||||
To Compile zone2ldap from contrib/sdb directory:
|
||||
|
||||
gcc -g `../../isc-config.sh --cflags isc dns` -c zone2ldap.c
|
||||
gcc -g -o zone2ldap zone2ldap.o `isc-config.sh --libs isc dns` -lldap -llber -lresolv
|
||||
|
||||
USAGE:
|
||||
|
||||
See zone2ldap.1
|
||||
|
||||
BUGS:
|
||||
|
||||
Jeff McNeil <jeff@snapcase.g-rock.net>
|
||||
|
||||
|
||||
|
||||
@@ -39,7 +39,13 @@
|
||||
#define DNS_OBJECT 6
|
||||
#define DNS_TOP 2
|
||||
|
||||
#define VERSION "0.3-ALPHA"
|
||||
#define VERSION "0.4-ALPHA"
|
||||
|
||||
#define NO_SPEC 0
|
||||
#define WI_SPEC 1
|
||||
|
||||
/* Global Zone Pointer */
|
||||
char *gbl_zone = NULL;
|
||||
|
||||
typedef struct LDAP_INFO
|
||||
{
|
||||
@@ -69,7 +75,7 @@ char **hostname_to_dn_list (char *hostname, char *zone, unsigned int flags);
|
||||
int get_attr_list_size (char **tmp);
|
||||
|
||||
/* Get a DN */
|
||||
char *build_dn_from_dc_list (char **dc_list, unsigned int ttl);
|
||||
char *build_dn_from_dc_list (char **dc_list, unsigned int ttl, int flag);
|
||||
|
||||
/* Add to RR list */
|
||||
void add_to_rr_list (char *dn, char *name, char *type, char *data,
|
||||
@@ -154,6 +160,8 @@ main (int *argc, char **argv)
|
||||
break;
|
||||
case 'z':
|
||||
argzone = strdup (optarg);
|
||||
// We wipe argzone all to hell when we parse it for the DN */
|
||||
gbl_zone = strdup(argzone);
|
||||
break;
|
||||
case 'f':
|
||||
zonefile = strdup (optarg);
|
||||
@@ -257,7 +265,8 @@ main (int *argc, char **argv)
|
||||
printf ("Creating base zone DN %s\n", argzone);
|
||||
|
||||
dc_list = hostname_to_dn_list (argzone, argzone, DNS_TOP);
|
||||
basedn = build_dn_from_dc_list (dc_list, 0);
|
||||
basedn = build_dn_from_dc_list (dc_list, 0, NO_SPEC);
|
||||
|
||||
for (ctmp = &basedn[strlen (basedn)]; ctmp >= &basedn[0]; ctmp--)
|
||||
{
|
||||
if ((*ctmp == ',') || (ctmp == &basedn[0]))
|
||||
@@ -319,7 +328,7 @@ isc_result_check (isc_result_t res, char *errorstr)
|
||||
{
|
||||
if (res != ISC_R_SUCCESS)
|
||||
{
|
||||
fprintf (stderr, "%s: %s\n", errorstr, isc_result_totext (res));
|
||||
fprintf (stderr, " %s: %s\n", errorstr, isc_result_totext (res));
|
||||
exit (-1);
|
||||
}
|
||||
}
|
||||
@@ -357,7 +366,7 @@ generate_ldap (dns_name_t * dnsname, dns_rdata_t * rdata, unsigned int ttl)
|
||||
|
||||
dc_list = hostname_to_dn_list (name, argzone, DNS_OBJECT);
|
||||
len = (get_attr_list_size (dc_list) - 2);
|
||||
dn = build_dn_from_dc_list (dc_list, ttl);
|
||||
dn = build_dn_from_dc_list (dc_list, ttl, WI_SPEC);
|
||||
|
||||
if (debug)
|
||||
printf ("Adding %s (%s %s) to run queue list.\n", dn, type, data);
|
||||
@@ -487,7 +496,7 @@ add_to_rr_list (char *dn, char *name, char *type,
|
||||
tmp->attrs[4]->mod_op = LDAP_MOD_ADD;
|
||||
tmp->attrs[4]->mod_type = "zoneName";
|
||||
tmp->attrs[4]->mod_values = (char **)calloc(sizeof(char *), 2);
|
||||
tmp->attrs[4]->mod_values[0] = argzone;
|
||||
tmp->attrs[4]->mod_values[0] = gbl_zone;
|
||||
tmp->attrs[4]->mod_values[1] = NULL;
|
||||
|
||||
tmp->attrs[5] = NULL;
|
||||
@@ -612,7 +621,7 @@ hostname_to_dn_list (char *hostname, char *zone, unsigned int flags)
|
||||
* exception of "@"/SOA. */
|
||||
|
||||
char *
|
||||
build_dn_from_dc_list (char **dc_list, unsigned int ttl)
|
||||
build_dn_from_dc_list (char **dc_list, unsigned int ttl, int flag)
|
||||
{
|
||||
int size;
|
||||
int x;
|
||||
@@ -623,6 +632,8 @@ build_dn_from_dc_list (char **dc_list, unsigned int ttl)
|
||||
bzero (dn, sizeof (dn));
|
||||
size = get_attr_list_size (dc_list);
|
||||
for (x = size - 2; x > 0; x--)
|
||||
{
|
||||
if (flag == WI_SPEC)
|
||||
{
|
||||
if (x == (size - 2) && (strncmp (dc_list[x], "@", 1) == 0) && (ttl))
|
||||
sprintf (tmp, "relativeDomainName=%s + dNSTTL=%d,", dc_list[x], ttl);
|
||||
@@ -630,6 +641,11 @@ build_dn_from_dc_list (char **dc_list, unsigned int ttl)
|
||||
sprintf(tmp, "relativeDomainName=%s,",dc_list[x]);
|
||||
else
|
||||
sprintf(tmp,"dc=%s,", dc_list[x]);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(tmp, "dc=%s,", dc_list[x]);
|
||||
}
|
||||
|
||||
|
||||
strncat (dn, tmp, sizeof (dn) - strlen (dn));
|
||||
@@ -638,7 +654,7 @@ build_dn_from_dc_list (char **dc_list, unsigned int ttl)
|
||||
sprintf (tmp, "dc=%s", dc_list[0]);
|
||||
strncat (dn, tmp, sizeof (dn) - strlen (dn));
|
||||
|
||||
printf("dn = %s\n", dn);
|
||||
fflush(NULL);
|
||||
return dn;
|
||||
}
|
||||
|
||||
@@ -666,6 +682,8 @@ ldap_result_check (char *msg, char *dn, int err)
|
||||
{
|
||||
if ((err != LDAP_SUCCESS) && (err != LDAP_ALREADY_EXISTS))
|
||||
{
|
||||
fprintf(stderr, "Error while adding %s (%s):\n",
|
||||
dn, msg);
|
||||
ldap_perror (conn, dn);
|
||||
ldap_unbind_s (conn);
|
||||
exit (-1);
|
||||
|
||||
@@ -39,7 +39,13 @@
|
||||
#define DNS_OBJECT 6
|
||||
#define DNS_TOP 2
|
||||
|
||||
#define VERSION "0.3-ALPHA"
|
||||
#define VERSION "0.4-ALPHA"
|
||||
|
||||
#define NO_SPEC 0
|
||||
#define WI_SPEC 1
|
||||
|
||||
/* Global Zone Pointer */
|
||||
char *gbl_zone = NULL;
|
||||
|
||||
typedef struct LDAP_INFO
|
||||
{
|
||||
@@ -69,7 +75,7 @@ char **hostname_to_dn_list (char *hostname, char *zone, unsigned int flags);
|
||||
int get_attr_list_size (char **tmp);
|
||||
|
||||
/* Get a DN */
|
||||
char *build_dn_from_dc_list (char **dc_list, unsigned int ttl);
|
||||
char *build_dn_from_dc_list (char **dc_list, unsigned int ttl, int flag);
|
||||
|
||||
/* Add to RR list */
|
||||
void add_to_rr_list (char *dn, char *name, char *type, char *data,
|
||||
@@ -154,6 +160,8 @@ main (int *argc, char **argv)
|
||||
break;
|
||||
case 'z':
|
||||
argzone = strdup (optarg);
|
||||
// We wipe argzone all to hell when we parse it for the DN */
|
||||
gbl_zone = strdup(argzone);
|
||||
break;
|
||||
case 'f':
|
||||
zonefile = strdup (optarg);
|
||||
@@ -257,7 +265,8 @@ main (int *argc, char **argv)
|
||||
printf ("Creating base zone DN %s\n", argzone);
|
||||
|
||||
dc_list = hostname_to_dn_list (argzone, argzone, DNS_TOP);
|
||||
basedn = build_dn_from_dc_list (dc_list, 0);
|
||||
basedn = build_dn_from_dc_list (dc_list, 0, NO_SPEC);
|
||||
|
||||
for (ctmp = &basedn[strlen (basedn)]; ctmp >= &basedn[0]; ctmp--)
|
||||
{
|
||||
if ((*ctmp == ',') || (ctmp == &basedn[0]))
|
||||
@@ -319,7 +328,7 @@ isc_result_check (isc_result_t res, char *errorstr)
|
||||
{
|
||||
if (res != ISC_R_SUCCESS)
|
||||
{
|
||||
fprintf (stderr, "%s: %s\n", errorstr, isc_result_totext (res));
|
||||
fprintf (stderr, " %s: %s\n", errorstr, isc_result_totext (res));
|
||||
exit (-1);
|
||||
}
|
||||
}
|
||||
@@ -357,7 +366,7 @@ generate_ldap (dns_name_t * dnsname, dns_rdata_t * rdata, unsigned int ttl)
|
||||
|
||||
dc_list = hostname_to_dn_list (name, argzone, DNS_OBJECT);
|
||||
len = (get_attr_list_size (dc_list) - 2);
|
||||
dn = build_dn_from_dc_list (dc_list, ttl);
|
||||
dn = build_dn_from_dc_list (dc_list, ttl, WI_SPEC);
|
||||
|
||||
if (debug)
|
||||
printf ("Adding %s (%s %s) to run queue list.\n", dn, type, data);
|
||||
@@ -487,7 +496,7 @@ add_to_rr_list (char *dn, char *name, char *type,
|
||||
tmp->attrs[4]->mod_op = LDAP_MOD_ADD;
|
||||
tmp->attrs[4]->mod_type = "zoneName";
|
||||
tmp->attrs[4]->mod_values = (char **)calloc(sizeof(char *), 2);
|
||||
tmp->attrs[4]->mod_values[0] = argzone;
|
||||
tmp->attrs[4]->mod_values[0] = gbl_zone;
|
||||
tmp->attrs[4]->mod_values[1] = NULL;
|
||||
|
||||
tmp->attrs[5] = NULL;
|
||||
@@ -612,7 +621,7 @@ hostname_to_dn_list (char *hostname, char *zone, unsigned int flags)
|
||||
* exception of "@"/SOA. */
|
||||
|
||||
char *
|
||||
build_dn_from_dc_list (char **dc_list, unsigned int ttl)
|
||||
build_dn_from_dc_list (char **dc_list, unsigned int ttl, int flag)
|
||||
{
|
||||
int size;
|
||||
int x;
|
||||
@@ -623,6 +632,8 @@ build_dn_from_dc_list (char **dc_list, unsigned int ttl)
|
||||
bzero (dn, sizeof (dn));
|
||||
size = get_attr_list_size (dc_list);
|
||||
for (x = size - 2; x > 0; x--)
|
||||
{
|
||||
if (flag == WI_SPEC)
|
||||
{
|
||||
if (x == (size - 2) && (strncmp (dc_list[x], "@", 1) == 0) && (ttl))
|
||||
sprintf (tmp, "relativeDomainName=%s + dNSTTL=%d,", dc_list[x], ttl);
|
||||
@@ -630,6 +641,11 @@ build_dn_from_dc_list (char **dc_list, unsigned int ttl)
|
||||
sprintf(tmp, "relativeDomainName=%s,",dc_list[x]);
|
||||
else
|
||||
sprintf(tmp,"dc=%s,", dc_list[x]);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(tmp, "dc=%s,", dc_list[x]);
|
||||
}
|
||||
|
||||
|
||||
strncat (dn, tmp, sizeof (dn) - strlen (dn));
|
||||
@@ -638,7 +654,7 @@ build_dn_from_dc_list (char **dc_list, unsigned int ttl)
|
||||
sprintf (tmp, "dc=%s", dc_list[0]);
|
||||
strncat (dn, tmp, sizeof (dn) - strlen (dn));
|
||||
|
||||
printf("dn = %s\n", dn);
|
||||
fflush(NULL);
|
||||
return dn;
|
||||
}
|
||||
|
||||
@@ -666,6 +682,8 @@ ldap_result_check (char *msg, char *dn, int err)
|
||||
{
|
||||
if ((err != LDAP_SUCCESS) && (err != LDAP_ALREADY_EXISTS))
|
||||
{
|
||||
fprintf(stderr, "Error while adding %s (%s):\n",
|
||||
dn, msg);
|
||||
ldap_perror (conn, dn);
|
||||
ldap_unbind_s (conn);
|
||||
exit (-1);
|
||||
|
||||
Reference in New Issue
Block a user