mirror of
https://github.com/bklang/ldap2dns.git
synced 2025-10-28 06:44:14 -04:00
Fix daemon mode handling
Add option to stay in the foreground git-svn-id: https://svn.alkaloid.net/gpl/ldap2dns/trunk@460 06cd67b6-e706-0410-b29e-9de616bca6e9
This commit is contained in:
@@ -3,6 +3,8 @@ Version 0.5.0-beta (latest)
|
|||||||
* BACKWARD COMPATIBILITY BREAK: DNS TXT records now store their data in the new
|
* BACKWARD COMPATIBILITY BREAK: DNS TXT records now store their data in the new
|
||||||
DNSTXT attribute instead of the old DNScname attribute. You must manually
|
DNSTXT attribute instead of the old DNScname attribute. You must manually
|
||||||
update any DNS TXT records for them to continue working.
|
update any DNS TXT records for them to continue working.
|
||||||
|
* Fix handling of background daemon mode
|
||||||
|
* Add option to run in daemon mode without forking, staying in the foreground
|
||||||
|
|
||||||
Version 0.4.2
|
Version 0.4.2
|
||||||
* Add SMF manifest
|
* Add SMF manifest
|
||||||
|
|||||||
11
ldap2dns.c
11
ldap2dns.c
@@ -116,6 +116,7 @@ static struct
|
|||||||
int usedhosts;
|
int usedhosts;
|
||||||
int useduris;
|
int useduris;
|
||||||
int is_daemon;
|
int is_daemon;
|
||||||
|
int foreground;
|
||||||
unsigned int update_iv;
|
unsigned int update_iv;
|
||||||
unsigned int output;
|
unsigned int output;
|
||||||
int verbose;
|
int verbose;
|
||||||
@@ -162,7 +163,7 @@ static void set_datadir(void)
|
|||||||
static void print_usage(void)
|
static void print_usage(void)
|
||||||
{
|
{
|
||||||
print_version();
|
print_version();
|
||||||
printf("usage: ldap2dns[d] [-o data|db] [-h host] [-p port] [-H hostURI] \\\n");
|
printf("usage: ldap2dns[d] [-df] [-o data|db] [-h host] [-p port] [-H hostURI] \\\n");
|
||||||
printf("\t\t[-D binddn] [-w password] [-L[filename]] [-u numsecs] \\\n");
|
printf("\t\t[-D binddn] [-w password] [-L[filename]] [-u numsecs] \\\n");
|
||||||
printf("\t\t[-b searchbase] [-v[v]] [-V] [-t timeout] [-M maxrecords]\n");
|
printf("\t\t[-b searchbase] [-v[v]] [-V] [-t timeout] [-M maxrecords]\n");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
@@ -182,6 +183,8 @@ static void print_usage(void)
|
|||||||
printf(" -u numsecs\tUpdate DNS data after numsecs. Defaults to %d. Daemon mode only\n\t\t", UPDATE_INTERVAL);
|
printf(" -u numsecs\tUpdate DNS data after numsecs. Defaults to %d. Daemon mode only\n\t\t", UPDATE_INTERVAL);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf(" -e \"exec-cmd\"\tCommand to execute after data is generated\n");
|
printf(" -e \"exec-cmd\"\tCommand to execute after data is generated\n");
|
||||||
|
printf(" -d\t\tRun as a daemon (same as if invoked as ldap2dnsd)\n");
|
||||||
|
printf(" -f\t\tIf running as a daemon stay in the foreground (do not fork)\n");
|
||||||
printf(" -v\t\trun in verbose mode, repeat for more verbosity\n");
|
printf(" -v\t\trun in verbose mode, repeat for more verbosity\n");
|
||||||
printf(" -V\t\tprint version and exit\n\n");
|
printf(" -V\t\tprint version and exit\n\n");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
@@ -374,6 +377,8 @@ static int parse_options()
|
|||||||
{"version", 0, 0, 'V'},
|
{"version", 0, 0, 'V'},
|
||||||
{"timeout", 1, 0, 't'},
|
{"timeout", 1, 0, 't'},
|
||||||
{"maxrecords", 1, 0, 'M'},
|
{"maxrecords", 1, 0, 'M'},
|
||||||
|
{"daemonize", 1, 0, 'd'},
|
||||||
|
{"foreground", 1, 0, 'f'},
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -462,7 +467,7 @@ static int parse_options()
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (options.is_daemon==0 && options.update_iv>0)
|
if (options.is_daemon==1 && options.foreground==1)
|
||||||
options.is_daemon = 2; /* foreground daemon */
|
options.is_daemon = 2; /* foreground daemon */
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1238,7 +1243,6 @@ int main(int argc, char** argv)
|
|||||||
sleep(options.update_iv);
|
sleep(options.update_iv);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//if (options.is_daemon) {
|
|
||||||
calc_checksum(&old_numzones, &old_checksum);
|
calc_checksum(&old_numzones, &old_checksum);
|
||||||
if (old_numzones!=soa_numzones || old_checksum!=soa_checksum) {
|
if (old_numzones!=soa_numzones || old_checksum!=soa_checksum) {
|
||||||
if (options.verbose&1)
|
if (options.verbose&1)
|
||||||
@@ -1248,7 +1252,6 @@ int main(int argc, char** argv)
|
|||||||
} else {
|
} else {
|
||||||
goto skip;
|
goto skip;
|
||||||
}
|
}
|
||||||
//}
|
|
||||||
if (options.ldifname[0]) {
|
if (options.ldifname[0]) {
|
||||||
if (options.ldifname[0]=='-')
|
if (options.ldifname[0]=='-')
|
||||||
ldifout = stdout;
|
ldifout = stdout;
|
||||||
|
|||||||
Reference in New Issue
Block a user