From 55647de1632a0ec50d95f5d3657d9c06f781132a Mon Sep 17 00:00:00 2001 From: Stefan Ritt Date: Fri, 29 Oct 2004 19:32:56 +0000 Subject: [PATCH] Added -m and -M command line switches SVN revision: 1120 --- doc/adminguide.html | 97 +++++++------- src/elogd.c | 316 ++++++++++++++++++++++++-------------------- 2 files changed, 221 insertions(+), 192 deletions(-) diff --git a/doc/adminguide.html b/doc/adminguide.html index 6e9431b2..94497667 100755 --- a/doc/adminguide.html +++ b/doc/adminguide.html @@ -1,7 +1,7 @@ ELOG Administrator's Guide - + @@ -9,7 +9,7 @@ - +
  ELOG Administrator's Guide  

@@ -46,14 +46,14 @@ workstations. It should also compile and run on other UNIX flavours.

Since version 2.0, ELOG contains a RPM file which eases the installation. Get the -file elog-x.x.x-x.i386.rpm from the download +file elog-x.x.x-x.i386.rpm from the download section and execute as root "rpm -i elog-x.x.x-x.i386.rpm". This will -install the elogd daemon in /usr/local/sbin -and the elog and elconv programs in -/usr/local/bin. The sample configuration file elogd.cfg -together with the sample logbook will be installed under /usr/local/elog -and the documentation goes to /usr/share/doc. The elogd startup script -will be installed at /etc/rc.d/init.d/elogd. To start the daemon, enter +install the elogd daemon in /usr/local/sbin +and the elog and elconv programs in +/usr/local/bin. The sample configuration file elogd.cfg +together with the sample logbook will be installed under /usr/local/elog +and the documentation goes to /usr/share/doc. The elogd startup script +will be installed at /etc/rc.d/init.d/elogd. To start the daemon, enter

@@ -78,9 +78,9 @@ which the daemon runs.


Installation from the tarball:

-Download the latest elog-x.x.x.tar.gz package. +Download the latest elog-x.x.x.tar.gz package.

-Expand the compressed TAR file with tar -xzvf elog-x.x.x.tar.gz. +Expand the compressed TAR file with tar -xzvf elog-x.x.x.tar.gz. This creates a subdirectory elog-x.x.x where x.x.x is the version number. In that directory execute make, which creates the executables elogd, elog and @@ -105,7 +105,7 @@ and tries to fall-back to a non-root account. This is necessary to avoid securit It looks in the configuration file for the statements Usr and Grp.. If found, elogd uses that user and goupe name to run under. The names must of course be present on the system (usually -/etc/passwd and /etc/group). If the statements +/etc/passwd and /etc/group). If the statements Usr and Grp. are not present, elogd tries user and group elog, then the default user and group (normally nogroup and nobody). Care has to be taken @@ -162,10 +162,10 @@ Redirect permanent /elog http://your.host.domain/elog/ ProxyPass /elog/ http://your.host.domain:8080/

-Make sure that the Apache modules mod_proxy.c and mod_alias.c are activated. Justin Dieters <enderak@yahoo.com> +Make sure that the Apache modules mod_proxy.c and mod_alias.c are activated. Justin Dieters <enderak@yahoo.com> reports that mod_proxy_http.c is also required. The Redirect statement is necessary to automatically append a "/" to a request like -http://your.host.domain/elog. Apache then works as a proxy and forwards all requests +http://your.host.domain/elog. Apache then works as a proxy and forwards all requests staring with /elog to the elogd daemon.

Note: Do not put "ProxyRequests On" into your configuration file. This option is not necessary @@ -188,7 +188,7 @@ the proxy host (anybody knows how to fix that???).


Notes for the Solaris platform:

-

Martin Huber reports that +

Martin Huber reports that under Solaris 7 the following command line is needed to compile elog:

@@ -200,8 +200,8 @@ the "-k" flag to the elogd command line to turn keep-


Note for Mac OS X:

-

Sridhar Anandakrishnan and -Recai Oktas report that under Mac OS X there is a problem with +

Sridhar Anandakrishnan and +Recai Oktas report that under Mac OS X there is a problem with the default stack size. The command limit stacksize unlimited (for tcsh) or ulimit -s unlimited (for bash) increases the stacksize and fixes this problem. Read the according thread in the forum. @@ -226,37 +226,42 @@ are still possible, they are not recommended any more.

Under Windows, the ports below 1024 can be used without restriction. So if no web server is running on the same PC the ELOG daemon can be started under the standard Web port 80. This is achieved by changing the port=8080 -option in elogd.cfg to port=80 and restarting elogd.

+option in elogd.cfg to port=80 and restarting elogd.


  Server Configuration  

The ELOG daemon elogd can be executed with the following options : -

+
    elogd [-p port] [-h hostname/IP] [-C] [-m] [-M] [-D] [-c file] [-s dir] [-d dir] [-v] [-k] [-f file] [-x]

with :

    -
  • -p <port> : TCP port number to use for the http server (if other than 80) -
  • -h <hostname or IP address> : in the case of a "multihomed" server, host name or IP address of the interface ELOG should run on -
  • -D : become a daemon (Unix only) -
  • -c <file> : specify the configuration file (full path mandatory if -D is used) +
  • -p <port>  TCP port number to use for the http server (if other than 80) +
  • -h <hostname or IP address> in the case of a "multihomed" server, host name or IP + address of the interface ELOG should run on +
  • -C <url>  clone remote elogd configuration  +
  • -m  synchronize logbook(s) with remote server +
  • -M  synchronize with removing deleted entries +
  • -l <logbook>  optionally specify logbook for -m and -M commands
  • +
  • -D   become a daemon (Unix only) +
  • -c <file>  specify the configuration file (full path mandatory if -D is used)
  • -s <dir> specify resource directory (themes, icons, ...)
  • -d <dir> specify logbook root directory -
  • -v : verbose output for debugging -
  • -k : do not use TCP keep-alive -
  • -f <file> : specify PID file where elogd process ID is written when server is started -
  • -x : enables execution of shell commands +
  • -v  verbose output for debugging +
  • -k  do not use TCP keep-alive +
  • -f <file> specify PID file where elogd process ID is written when server is started +
  • -x  enables execution of shell commands

It may also be used to generate passwords : -

    elogd [-r pwd] [-w pwd] [-a pwd] [-l logbook]
+
    elogd [-r pwd] [-w pwd] [-a pwd] [-l logbook]

with :

    -
  • -r <pwd> : create/overwrite read password in config file -
  • -w <pwd> : create/overwrite write password in config file -
  • -a <pwd> : create/overwrite administrative password in config file -
  • -l <logbook> : specify logbook for -r and -w commands +
  • -r <pwd> create/overwrite read password in config file +
  • -w <pwd> create/overwrite write password in config file +
  • -a <pwd> create/overwrite administrative password in config file +
  • -l <logbook> specify logbook for -r and -w commands

The appearance, functionality and behaviour of the various logbooks on an ELOG server are @@ -269,15 +274,15 @@ having to restart the server. Instead of restarting the server, under Unix one c like "killall -HUP elogd" to tell the server to re-read its configuration.

The many options of this unique but very important file are documented on the separate elogd.cfg syntax page.

+"config.html" config.html??>elogd.cfg syntax page.

To better control appearance and layout of the logbooks, elogd.cfg may optionally specify the use of additional files containing HTML code, and/or custom "themes" configurations. These need to be edited directly from the file system right now.

-The meaning of the directory flags -s and -d is explained -in the section covering the configuration options Resource dir and -Logbook dir in the elogd.cfg description.

+The meaning of the directory flags -s and -d is explained +in the section covering the configuration options Resource dir and +Logbook dir in the elogd.cfg description.


  Secure Connections HOWTO  
@@ -294,11 +299,11 @@ To use elogd togethwer with
  1. Start elogd. If another Web server is running on port 80, use a different port. -

    +

  2. Configure stunnel. This requires the creation of a certificate. See the manual for details. -

    +

  3. Start the stunnel program if not already done and start it with:

    @@ -306,14 +311,14 @@ details. Substitute the port 80 if you started elogd on another port. This causes stunnel to receive requests on the https port 443 and forward them to the elogd port. -

    +

  4. Put the URL under which elogd runs into elogd.cfg:

    URL = https://your.host.name/
    Note the https at the beginning of the URL, which is mandatory. Once you use the https URL, elog won't work correctly when accessed not through stunnel via http://.., since any - redirection would always bring you back to https://...).

    + redirection would always bring you back to https://...).

  5. Connect to your logbook with a browser which supports SSL via:

    @@ -322,7 +327,7 @@ details.

    stunnel -f -d 443 -r your.host.name:80
    -This reveals any potential error.

    +This reveals any potential error.

@@ -363,7 +368,7 @@ reads logbook entries from its database and formats them into HTML. Since only forms and tables are used, no Java or Javascript is necessary, which makes the logbook display very fast. The system does not use any images on purpose to reduce the amount of data to be transferred. Since the ELOG daemon contains its own http server, no additional server like Apache is required.

The "database" in which ELOG saves its entries is in plain ASCII format. -One file is created for each day in the form YYMMDDa.log +One file is created for each day in the form YYMMDDa.log (where YY is the year, MM the month and DD the day). For ELOG versions 1.x.x, the format was YYMMDD.log. Messages are separated internally by the string $@MID@$. If this string is entered in a message @@ -381,10 +386,10 @@ files from March 2001, just select them with 0103??a.log


- - + + diff --git a/src/elogd.c b/src/elogd.c index 7deedc3d..f76a02b9 100755 --- a/src/elogd.c +++ b/src/elogd.c @@ -6,6 +6,9 @@ Contents: Web server program for Electronic Logbook ELOG $Log$ + Revision 1.504 2004/10/29 19:32:56 midas + Added -m and -M command line switches + Revision 1.503 2004/10/27 07:00:44 midas Version 2.5.4-6 @@ -12315,10 +12318,10 @@ void synchronize_logbook(LOGBOOK * lbs, int mode, BOOL sync_all) mprint(lbs, mode, error_str); else mprint(lbs, mode, "Local config submitted"); + md5_cache[0].message_id = -1; } else mprint(lbs, mode, "Local config should be submitted"); - md5_cache[0].message_id = -1; } else /* if config has been changed remotely, but not on this server, receive it */ @@ -12336,11 +12339,11 @@ void synchronize_logbook(LOGBOOK * lbs, int mode, BOOL sync_all) mprint(lbs, mode, error_str); else mprint(lbs, mode, "Remote config received"); + + md5_cache[0].message_id = -1; } else mprint(lbs, mode, loc("Remote config should be received")); - md5_cache[0].message_id = -1; - } else /* if config has been changed remotely and on this server, show conflict */ if (!equal_md5(md5_cache[0].md5_digest, md5_remote[0].md5_digest) @@ -12403,35 +12406,30 @@ void synchronize_logbook(LOGBOOK * lbs, int mode, BOOL sync_all) && equal_md5(md5_cache[i_cache].md5_digest, md5_remote[i_remote].md5_digest)) { all_identical = FALSE; - if (mode == SYNC_CLONE) { - eprintf("Warning: Entry #%d has been changed locally, will not be retrieved\n", message_id); + if (_logging_level > 1) + write_logfile(lbs, "MIRROR send entry #%d", message_id); - } else { + /* submit local message */ + if (!getcfg(lbs->name, "Mirror simulate", str, sizeof(str)) + || atoi(str) == 0) { + submit_message(lbs, list[index], message_id, error_str); - if (_logging_level > 1) - write_logfile(lbs, "MIRROR send entry #%d", message_id); + /* not that submit_message() may have changed attr_list !!! */ - /* submit local message */ - if (!getcfg(lbs->name, "Mirror simulate", str, sizeof(str)) - || atoi(str) == 0) { - submit_message(lbs, list[index], message_id, error_str); - - /* not that submit_message() may have changed attr_list !!! */ - - if (error_str[0]) - sprintf(str, "%s: %s", loc("Error sending local entry"), error_str); - else - sprintf(str, "ID%d:\t%s", message_id, loc("Local entry submitted")); - mprint(lbs, mode, str); - } else { - sprintf(str, "ID%d:\t%s", message_id, loc("Local entry should be submitted")); - mprint(lbs, mode, str); - } + if (error_str[0]) + sprintf(str, "%s: %s", loc("Error sending local entry"), error_str); + else + sprintf(str, "ID%d:\t%s", message_id, loc("Local entry submitted")); + mprint(lbs, mode, str); md5_cache[i_cache].message_id = -1; + } else { + sprintf(str, "ID%d:\t%s", message_id, loc("Local entry should be submitted")); + mprint(lbs, mode, str); } + } else /* if message has been changed remotely, but not on this server, receive it */ if (!equal_md5(md5_cache[i_cache].md5_digest, md5_remote[i_remote].md5_digest) @@ -12440,7 +12438,7 @@ void synchronize_logbook(LOGBOOK * lbs, int mode, BOOL sync_all) all_identical = FALSE; if (mode == SYNC_CLONE) { - eprintf("ID%s:\t", message_id); + eprintf("ID%d:\t", message_id); } else if (mode == SYNC_HTML) { if (getcfg_topgroup()) rsprintf("ID%d:\t", lbs->name_enc, message_id, message_id); @@ -12470,13 +12468,14 @@ void synchronize_logbook(LOGBOOK * lbs, int mode, BOOL sync_all) sprintf(str, "ID%d:\t%s", message_id, loc("Remote entry received")); mprint(lbs, mode, str); } + + md5_cache[i_cache].message_id = -1; + } else { sprintf(str, "ID%d:\t%s", message_id, loc("Remote entry should be received")); mprint(lbs, mode, str); } - md5_cache[i_cache].message_id = -1; - } else /* if message has been changed remotely and on this server, show conflict */ if (!equal_md5(md5_cache[i_cache].md5_digest, md5_remote[i_remote].md5_digest) @@ -12526,33 +12525,27 @@ void synchronize_logbook(LOGBOOK * lbs, int mode, BOOL sync_all) all_identical = FALSE; - if (mode == SYNC_CLONE) { + if (_logging_level > 1) + write_logfile(lbs, "MIRROR send entry #%d", message_id); - eprintf("Warning: Entry #%d has been changed locally, will not be retrieved\n", message_id); + /* submit local message */ + if (!getcfg(lbs->name, "Mirror simulate", str, sizeof(str)) + || atoi(str) == 0) { + submit_message(lbs, list[index], message_id, error_str); - } else { + /* not that submit_message() may have changed attr_list !!! */ - if (_logging_level > 1) - write_logfile(lbs, "MIRROR send entry #%d", message_id); - - /* submit local message */ - if (!getcfg(lbs->name, "Mirror simulate", str, sizeof(str)) - || atoi(str) == 0) { - submit_message(lbs, list[index], message_id, error_str); - - /* not that submit_message() may have changed attr_list !!! */ - - if (error_str[0]) - sprintf(str, "%s: %s", loc("Error sending local message"), error_str); - else - sprintf(str, "ID%d:\t%s", message_id, loc("Local entry submitted")); - mprint(lbs, mode, str); - } else { - sprintf(str, "ID%d:\t%s", message_id, loc("Local entry should be submitted")); - mprint(lbs, mode, str); - } + if (error_str[0]) + sprintf(str, "%s: %s", loc("Error sending local message"), error_str); + else + sprintf(str, "ID%d:\t%s", message_id, loc("Local entry submitted")); + mprint(lbs, mode, str); md5_cache[i_cache].message_id = -1; + + } else { + sprintf(str, "ID%d:\t%s", message_id, loc("Local entry should be submitted")); + mprint(lbs, mode, str); } } else { @@ -12573,15 +12566,17 @@ void synchronize_logbook(LOGBOOK * lbs, int mode, BOOL sync_all) rsprintf("ID%d:\t%s\n", message_id, str); n_delete++; - } else { + } if (!isparam("confirm") && mode == SYNC_CLONE) { + sprintf(str, "ID%d:\t%s", message_id, loc("Entry should be deleted locally")); + mprint(lbs, mode, str); + + } else { + all_identical = FALSE; - if (_logging_level > 1) - write_logfile(lbs, "MIRROR delete local entry #%d", message_id); + if (mode == SYNC_CLONE) { - if (!getcfg(lbs->name, "Mirror simulate", str, sizeof(str)) - || atoi(str) == 0) { el_delete_message(lbs, message_id, TRUE, NULL, TRUE, TRUE); sprintf(str, "ID%d:\t%s", message_id, loc("Entry deleted locally")); @@ -12589,9 +12584,25 @@ void synchronize_logbook(LOGBOOK * lbs, int mode, BOOL sync_all) /* message got deleted from local message list, so redo current index */ i_msg--; + } else { - sprintf(str, "ID%d:\t%s", message_id, loc("Entry should be deleted locally")); - mprint(lbs, mode, str); + + if (_logging_level > 1) + write_logfile(lbs, "MIRROR delete local entry #%d", message_id); + + if (!getcfg(lbs->name, "Mirror simulate", str, sizeof(str)) + || atoi(str) == 0) { + el_delete_message(lbs, message_id, TRUE, NULL, TRUE, TRUE); + + sprintf(str, "ID%d:\t%s", message_id, loc("Entry deleted locally")); + mprint(lbs, mode, str); + + /* message got deleted from local message list, so redo current index */ + i_msg--; + } else { + sprintf(str, "ID%d:\t%s", message_id, loc("Entry should be deleted locally")); + mprint(lbs, mode, str); + } } /* mark message non-conflicting */ @@ -12606,33 +12617,26 @@ void synchronize_logbook(LOGBOOK * lbs, int mode, BOOL sync_all) all_identical = FALSE; - if (mode == SYNC_CLONE) { + if (_logging_level > 1) + write_logfile(lbs, "MIRROR send entry #%d", message_id); - eprintf("Warning: Entry #%d exists only locally, should be sent to server\n", message_id); + remote_id = 0; + if (!getcfg(lbs->name, "Mirror simulate", str, sizeof(str)) + || atoi(str) == 0) { + remote_id = submit_message(lbs, list[index], message_id, error_str); + if (error_str[0]) + sprintf(str, "%s: %s", loc("Error sending local entry"), error_str); + else if (remote_id != message_id) + sprintf(str, + "Error: Submitting entry #%d resulted in remote entry #%d\n", + message_id, remote_id); + else + sprintf(str, "ID%d:\t%s", message_id, loc("Local entry submitted")); + mprint(lbs, mode, str); } else { - - if (_logging_level > 1) - write_logfile(lbs, "MIRROR send entry #%d", message_id); - - remote_id = 0; - if (!getcfg(lbs->name, "Mirror simulate", str, sizeof(str)) - || atoi(str) == 0) { - remote_id = submit_message(lbs, list[index], message_id, error_str); - - if (error_str[0]) - sprintf(str, "%s: %s", loc("Error sending local entry"), error_str); - else if (remote_id != message_id) - sprintf(str, - "Error: Submitting entry #%d resulted in remote entry #%d\n", - message_id, remote_id); - else - sprintf(str, "ID%d:\t%s", message_id, loc("Local entry submitted")); - mprint(lbs, mode, str); - } else { - sprintf(str, "ID%d:\t%s", message_id, loc("Local entry should be submitted")); - mprint(lbs, mode, str); - } + sprintf(str, "ID%d:\t%s", message_id, loc("Local entry should be submitted")); + mprint(lbs, mode, str); } } @@ -12644,41 +12648,34 @@ void synchronize_logbook(LOGBOOK * lbs, int mode, BOOL sync_all) all_identical = FALSE; - if (mode == SYNC_CLONE) { + /* find max id both locally and remotely */ + max_id = 1; + for (i = 0; i < *lbs->n_el_index; i++) + if (lbs->el_index[i].message_id > max_id) + max_id = lbs->el_index[i].message_id; - eprintf("Warning: Entry #%d is new locally and remotely, will not be retrieved\n", message_id); + for (i = 0; i < n_remote; i++) + if (md5_remote[i].message_id > max_id) + max_id = md5_remote[i].message_id; + if (_logging_level > 1) + write_logfile(lbs, "MIRROR change entry #%d to #%d", message_id, max_id + 1); + + /* rearrange local message not to conflict with remote message */ + if (!getcfg(lbs->name, "Mirror simulate", str, sizeof(str)) + || atoi(str) == 0) { + el_move_message(lbs, message_id, max_id + 1); + + sprintf(str, "ID%d:\t", message_id); + sprintf(str + strlen(str), loc("Changed local entry ID to %d"), max_id + 1); + mprint(lbs, mode, str); + + /* current message has been changed, so start over */ + i_msg--; } else { - - /* find max id both locally and remotely */ - max_id = 1; - for (i = 0; i < *lbs->n_el_index; i++) - if (lbs->el_index[i].message_id > max_id) - max_id = lbs->el_index[i].message_id; - - for (i = 0; i < n_remote; i++) - if (md5_remote[i].message_id > max_id) - max_id = md5_remote[i].message_id; - - if (_logging_level > 1) - write_logfile(lbs, "MIRROR change entry #%d to #%d", message_id, max_id + 1); - - /* rearrange local message not to conflict with remote message */ - if (!getcfg(lbs->name, "Mirror simulate", str, sizeof(str)) - || atoi(str) == 0) { - el_move_message(lbs, message_id, max_id + 1); - - sprintf(str, "ID%d:\t", message_id); - sprintf(str + strlen(str), loc("Changed local entry ID to %d"), max_id + 1); - mprint(lbs, mode, str); - - /* current message has been changed, so start over */ - i_msg--; - } else { - sprintf(str, "ID%d:\t", message_id); - sprintf(str + strlen(str), loc("Local entry ID should be changed to %d"), max_id + 1); - mprint(lbs, mode, str); - } + sprintf(str, "ID%d:\t", message_id); + sprintf(str + strlen(str), loc("Local entry ID should be changed to %d"), max_id + 1); + mprint(lbs, mode, str); } } @@ -12773,50 +12770,49 @@ void synchronize_logbook(LOGBOOK * lbs, int mode, BOOL sync_all) all_identical = FALSE; - if (mode != SYNC_CLONE) { + if (!isparam("confirm") && mode == SYNC_HTML) { - if (!isparam("confirm") && mode == SYNC_HTML) { + combine_url(lbs, list[index], "", str, sizeof(str)); + sprintf(rem_ref, "%s", str, + message_id, loc("Remote entry")); - combine_url(lbs, list[index], "", str, sizeof(str)); - sprintf(rem_ref, "%s", str, - message_id, loc("Remote entry")); + sprintf(str, loc("%s should be deleted"), rem_ref); + rsprintf("ID%d:\t%s\n", message_id, str); + n_delete++; - sprintf(str, loc("%s should be deleted"), rem_ref); - rsprintf("ID%d:\t%s\n", message_id, str); - n_delete++; + } else if (!isparam("confirm") && mode == SYNC_CLONE) { - } + sprintf(str, "ID%d:\t%s", message_id, loc("Entry should be deleted remotely")); + mprint(lbs, mode, str); - if (isparam("confirm") || mode == SYNC_CRON) { + } else { - if (_logging_level > 1) - write_logfile(lbs, "MIRROR delete remote entry #%d", message_id); + if (_logging_level > 1) + write_logfile(lbs, "MIRROR delete remote entry #%d", message_id); - sprintf(str, "%d?cmd=%s&confirm=%s", message_id, loc("Delete"), loc("Yes")); - combine_url(lbs, list[index], str, url, sizeof(url)); + sprintf(str, "%d?cmd=%s&confirm=%s", message_id, loc("Delete"), loc("Yes")); + combine_url(lbs, list[index], str, url, sizeof(url)); - if (!getcfg(lbs->name, "Mirror simulate", str, sizeof(str)) - || atoi(str) == 0) { - retrieve_url(url, &buffer, NULL); + if (!getcfg(lbs->name, "Mirror simulate", str, sizeof(str)) + || atoi(str) == 0) { + retrieve_url(url, &buffer, NULL); - if (strstr(buffer, "Location: ")) { - if (mode == SYNC_HTML) - rsprintf("ID%d:\t%s\n", message_id, loc("Entry deleted remotely")); - } else { - - if (mode == SYNC_HTML && isparam("debug")) - rsputs(buffer); - - mprint(lbs, mode, loc("Error deleting remote entry")); - } - - xfree(buffer); + if (strstr(buffer, "Location: ")) { + if (mode == SYNC_HTML) + rsprintf("ID%d:\t%s\n", message_id, loc("Entry deleted remotely")); } else { - sprintf(str, "ID%d:\t%s", message_id, loc("Entry should be deleted remotely")); - mprint(lbs, mode, str); + + if (mode == SYNC_HTML && isparam("debug")) + rsputs(buffer); + + mprint(lbs, mode, loc("Error deleting remote entry")); } md5_cache[i_cache].message_id = -1; + xfree(buffer); + } else { + sprintf(str, "ID%d:\t%s", message_id, loc("Entry should be deleted remotely")); + mprint(lbs, mode, str); } } } @@ -21182,7 +21178,7 @@ int run_service(void) int main(int argc, char *argv[]) { - int i, j, n, fh, tcp_port_cl, silent; + int i, j, n, fh, tcp_port_cl, silent, sync_flag; char read_pwd[80], write_pwd[80], admin_pwd[80], str[256], logbook[256], clone_url[256], error_str[256], file_name[256]; time_t now; @@ -21204,7 +21200,7 @@ int main(int argc, char *argv[]) /* initialize variables */ read_pwd[0] = write_pwd[0] = admin_pwd[0] = logbook[0] = clone_url[0] = 0; logbook_dir[0] = resource_dir[0] = logbook_dir[0] = 0; - silent = tcp_port_cl = 0; + silent = tcp_port_cl = sync_flag = 0; use_keepalive = TRUE; running_as_daemon = FALSE; @@ -21244,6 +21240,10 @@ int main(int argc, char *argv[]) use_keepalive = FALSE; else if (argv[i][0] == '-' && argv[i][1] == 'x') enable_execute = TRUE; + else if (argv[i][0] == '-' && argv[i][1] == 'm') + sync_flag = 1; + else if (argv[i][0] == '-' && argv[i][1] == 'M') + sync_flag = 2; else if (argv[i][1] == 't') { time(&now); tms = localtime(&now); @@ -21308,6 +21308,8 @@ int main(int argc, char *argv[]) printf(" -a create/overwrite admin password in config file\n"); printf(" -c specify configuration file\n"); printf(" -C clone remote elogd configuration\n"); + printf(" -m synchronize logbook(s) with remote server\n"); + printf(" -M synchronize with removing deleted entries\n"); printf(" -D become a daemon\n"); printf(" -d specify logbook root directory\n"); #ifdef OS_UNIX @@ -21315,7 +21317,7 @@ int main(int argc, char *argv[]) #endif printf(" -h this help\n"); printf(" -k do not use keep-alive\n"); - printf(" -l specify logbook for -r and -w commands\n"); + printf(" -l specify logbook for -r, -w and -m commands\n"); printf(" -n TCP/IP hostname\n"); printf(" -p TCP/IP port\n"); printf(" -r create/overwrite read password in config file\n"); @@ -21456,6 +21458,28 @@ int main(int argc, char *argv[]) && logbook_dir[strlen(logbook_dir) - 1] != DIR_SEPARATOR) strlcat(logbook_dir, DIR_SEPARATOR_STR, sizeof(logbook_dir)); + if (sync_flag) { + el_index_logbooks(); + + if (sync_flag == 2) + setparam("confirm", "yes"); + + if (logbook[0]) { + for (i=0 ; lb_list[i].name[0] ; i++) + if (stricmp(lb_list[i].name, logbook)) + break; + if (!lb_list[i].name[0]) { + eprintf("Logbook \"%s\" not defined in configuration file\n", logbook); + exit(EXIT_FAILURE); + } + + synchronize(&lb_list[i], SYNC_CLONE); + } else + synchronize(NULL, SYNC_CLONE); + + exit(EXIT_SUCCESS); + } + if (clone_url[0]) { /* force re-read of config file */