summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2008-06-09 19:21:43 +0000
committerStef Walter <stef@memberwebs.com>2008-06-09 19:21:43 +0000
commit3f65ea3cb042826f7343d80a2a1c048fba16edfa (patch)
treef71ac23a5bf8a9dd2b4ab15ccc5758bb95ef3083
parentb9ecd6e5e5b87fe1c4dab960e92246772002dd6a (diff)
Bug fixes.
-rw-r--r--plugin/autoserial.c21
-rw-r--r--plugin/dnsnotify.c8
-rw-r--r--plugin/plugin.c6
-rw-r--r--tools/notify-dns-slaves.c31
4 files changed, 48 insertions, 18 deletions
diff --git a/plugin/autoserial.c b/plugin/autoserial.c
index d10f8a5..16af5d7 100644
--- a/plugin/autoserial.c
+++ b/plugin/autoserial.c
@@ -18,12 +18,12 @@
* DECLARATIONS
*/
-/* TODO: Fill these in from settings */
static const char *dnsserial_soa_attribute = "sOARecord";
static const char *dnsserial_soa_base = "";
static Slapi_Mutex *dnsserial_mutex = NULL;
static strset *dnsserial_soa_cache = NULL;
+static int dnsserial_enable = 0;
/* ---------------------------------------------------------------------------------
* MEMORY ALLOCATION
@@ -389,6 +389,9 @@ change_soa_attribute (const char *dn, const char *soa_old, const char *soa_new)
return -1;
}
+ /* Call the dns notify code, and note that we've changed a sOARecord */
+ dnsnotify_post_modify (dn, mods);
+
trace ("success");
return 0;
}
@@ -433,6 +436,9 @@ autoserial_post_delete (const char *dn)
return_if_fail (dn && dn[0]);
+ if (!dnsserial_enable)
+ return;
+
/* A DN that is an SOA? */
if (present_in_soa_cache (dn)) {
remove_from_soa_cache (dn);
@@ -455,6 +461,9 @@ autoserial_post_modify (const char *dn, LDAPMod **mods)
return_if_fail (dn && dn[0]);
+ if (!dnsserial_enable)
+ return;
+
/* Add or remove from cache as appropriate */
soa = load_soa_attribute(dn);
if (soa) {
@@ -484,6 +493,9 @@ autoserial_post_modrdn (const char *odn, const char *ndn)
return_if_fail (odn && odn[0]);
return_if_fail (ndn && ndn[0]);
+ if (!dnsserial_enable)
+ return;
+
/* A DN that is an SOA? */
if (present_in_soa_cache (odn)) {
@@ -507,6 +519,9 @@ autoserial_post_add (const char *dn)
return_if_fail (dn && dn[0]);
+ if (!dnsserial_enable)
+ return;
+
/* A DN that is an SOA? */
soa = load_soa_attribute (dn);
if (soa) {
@@ -536,6 +551,10 @@ autoserial_config (const char *name, const char *value)
} else if (strcmp ("base-dn", name) == 0 && value) {
dnsserial_soa_base = value;
return 1;
+
+ } else if (strcmp ("enable-auto-serial", name) == 0 && !value) {
+ dnsserial_enable = 1;
+ return 1;
}
return 0;
diff --git a/plugin/dnsnotify.c b/plugin/dnsnotify.c
index 132726f..d610414 100644
--- a/plugin/dnsnotify.c
+++ b/plugin/dnsnotify.c
@@ -41,7 +41,7 @@ load_soa_ns_attributes (const char *dn, char **soa_result, char ***ns_result)
Slapi_PBlock *pb;
Slapi_Attr *attr;
LDAPControl *ctrl;
- char *attrs[2];
+ char *attrs[3];
char *soa, **ns;
int rc, code, num, i;
@@ -52,7 +52,8 @@ load_soa_ns_attributes (const char *dn, char **soa_result, char ***ns_result)
ctrl = NULL; /* No controls */
attrs[0] = (char*)dnsnotify_soa_attribute;
- attrs[1] = NULL;
+ attrs[1] = (char*)dnsnotify_ns_attribute;
+ attrs[2] = NULL;
trace ("performing internal search");
@@ -77,6 +78,7 @@ load_soa_ns_attributes (const char *dn, char **soa_result, char ***ns_result)
return_val_if_fail (entries, 0);
soa = NULL;
+ ns = NULL;
if (entries[0]) {
if (slapi_entry_attr_find (entries[0], (char*)dnsnotify_soa_attribute, &attr) >= 0 && attr &&
slapi_attr_get_values (attr, &values) >= 0 && values && values[0]) {
@@ -108,7 +110,7 @@ load_soa_ns_attributes (const char *dn, char **soa_result, char ***ns_result)
slapi_pblock_destroy (pb);
/* Only proceed if we have all the data we need */
- if (soa && soa[0] && ns && ns[0] && ns[0]) {
+ if (soa && soa[0] && ns && ns[0]) {
*soa_result = soa;
*ns_result = ns;
return 1;
diff --git a/plugin/plugin.c b/plugin/plugin.c
index c38eb67..c34294a 100644
--- a/plugin/plugin.c
+++ b/plugin/plugin.c
@@ -310,8 +310,10 @@ plugin_init (Slapi_PBlock *pb)
plugin_arguments[i] = slapi_ch_strdup (argv[i]);
arg = trim (plugin_arguments[i]);
- value = strchr (arg, '=');
- if (value) {
+ value = arg + strcspn (arg, ":=");
+ if (!*value) {
+ value = NULL;
+ } else {
*value = 0;
value = trim (value + 1);
}
diff --git a/tools/notify-dns-slaves.c b/tools/notify-dns-slaves.c
index 018af43..4af4b8c 100644
--- a/tools/notify-dns-slaves.c
+++ b/tools/notify-dns-slaves.c
@@ -103,7 +103,7 @@ static int the_socket4 = -1;
static int the_socket6 = -1;
static char stdin_buffer[LINE_LENGTH + 1];
-static size_t stdin_offset = 0;
+static ssize_t stdin_offset = 0;
static int processing_active = 0;
static int input_complete = 0;
@@ -147,9 +147,9 @@ vmessage(int level, int erno, const char* msg, va_list ap)
char buf[MAX_MSGLEN];
size_t len;
- if(debug_level < level)
+/* if(debug_level < level)
return;
-
+*/
assert (msg);
strncpy (buf, msg, MAX_MSGLEN);
@@ -165,7 +165,7 @@ vmessage(int level, int erno, const char* msg, va_list ap)
}
/* Either to syslog or stderr */
- if (is_helper && level != LOG_DEBUG)
+/* if (is_helper && level != LOG_DEBUG) */
vsyslog (level, buf, ap);
vwarnx (buf, ap);
@@ -636,7 +636,7 @@ stdin_callback (int fd, int type, void *arg)
assert (fd == 0);
- num = read (fd, stdin_buffer, LINE_LENGTH - stdin_offset);
+ num = read (fd, stdin_buffer + stdin_offset, LINE_LENGTH - stdin_offset);
if (num < 0) {
if (errno == EAGAIN || errno == EINTR)
return;
@@ -660,15 +660,18 @@ stdin_callback (int fd, int type, void *arg)
line = stdin_buffer + LINE_LENGTH;
}
- if (!line) /* Wait for more data */
+ if (!line) /* Wait for more data */ {
+fprintf (stderr, "waiting for more data %d\n", stdin_offset);
break;
+}
*line = 0;
num = (line + 1) - stdin_buffer;
process_stdin_line (stdin_buffer);
- stdin_offset = LINE_LENGTH - num;
- memmove (stdin_buffer, stdin_buffer + num, stdin_offset);
+ stdin_offset = stdin_offset - num;
+ if (stdin_offset)
+ memmove (stdin_buffer, stdin_buffer + num, stdin_offset);
} while (!input_complete);
@@ -677,6 +680,8 @@ stdin_callback (int fd, int type, void *arg)
server_stop ();
server_unwatch (fd);
}
+
+ assert (stdin_offset >= 0);
}
static void
@@ -743,8 +748,8 @@ make_sockets (void)
static void
usage()
{
- fprintf (stderr, "usage: slapi-dnsnotify-helper -s [-d level]\n");
- fprintf (stderr, "usage: slapi-dnsnotify-helper [-d level] zone server ...\n");
+ fprintf (stderr, "usage: notify-dns-slaves -s [-w wait] [-d level]\n");
+ fprintf (stderr, "usage: notify-dns-slaves [-d level] zone server ...\n");
exit (2);
}
@@ -759,7 +764,7 @@ main(int argc, char *argv[])
{
case 'd':
debug_level = strtol (optarg, &str, 10);
- if (*str || debug_level > 4)
+ if (*str || debug_level < 0 || debug_level > 4)
fatalx (1, "invalid debug log level: %s", optarg);
debug_level += LOG_ERR;
break;
@@ -768,8 +773,10 @@ main(int argc, char *argv[])
break;
case 'w':
delay_interval = strtol (optarg, &str, 10);
- if (*str || delay_interval > 0)
+ if (*str || delay_interval < 0)
fatalx (1, "invalid delay interval: %s", optarg);
+ delay_interval *= 1000;
+ break;
case '?':
default:
usage ();