diff --git a/doc/config.html b/doc/config.html index ab713703..ba27c031 100755 --- a/doc/config.html +++ b/doc/config.html @@ -1,50 +1,58 @@ - - - ELOG - Syntax of elogd.cfg - - - - - - - - - -
  ELOG - Syntax of elogd.cfg  
-

-

-

-

-

-

Global and individual logbook options for an ELOG server
- -
-

-The configuration file elogd.cfg contains entries which define -the structure of logbooks and the behaviour of elogd. The file has a simple ASCII -format. Each logbook is defined by a [<name>] section -where <name> is the name of the logbook. The [global] -section is used for settings common to all logbooks. Each line contains a setting -name, followed by an equal sign and the value for this setting. Lines starting with -";" are treated as comments. -

-Here is a simple example, which define two logbooks, "Linux" and "PC": -

-

+

+ The passwords are encoded. New users can either be created by hitting + Register as new user on the login page if Self register = + 1 in the configuration file, or by the admin user in the + Config page by pressing New user. When a user is logged it, + the entry for this user can be modified via the Config command. +

+

+ To start a new password file, follow these steps: +

+ +

+ The presence of a password file requires all users to "log in" + using their name and password, except when a guest login is allowed via + the "Guest menu commands" option. An additional advantage of this + method is that the user name can be used as an attribute value for + creating logbook entries. For example, the following line could be added + to the configuration file to fill in the Author and the + Email attributes with the current user name and email: +

+ + +

+ Thus the author name is not user-input anymore, ensuring the entry always + contains the actual user name. For a full listing of substitutions, see + the "Subst <attrib>" option. +

+

+ The user name and password are stored as cookies on the user side. The + expiration is controlled by the Remember me checkbox + during the login. If unchecked, the cookies expire after the current + browser session. If checked, they expire after 31 days by default, which + can be changed with the Login expiration option, + giving the expiration time in hours. Setting this to 24 for example, + makes the password expire after one day. If presistent cookies are not + desired, the Login expiration option can be set to + zero, in which case the Remember me checkbox is not + displayed. +

+

+ The Admin user = <user list> is a list of one + or more user names, which have admin rights. They see a button + Change elogd.cfg on the config page by which they can + edit elogd.cfg through the web. They can also modify other users on the + Config page, change their passwords or remove them. + In addition, the admin user(s) can delete or edit entries from other + users if Restrict edit = 1. +

+

+ The Login user = <user list> is a list of users + who can log in to a specific logbook. This option can be used with a + global password file. If a Password file is present + under the [global] section, the registered users in + that password file can log in to all logbooks. It might be required that + only certain users can log in to certain logbooks. This can be achieved + with the Login user option, places in each individual + logbook section in the configuration file. Only those users listed in + this statement can log in to the logbook where the statement is defined. + This method has the advantage over the option of definining individual + password files for individual logbooks that only one central password + file exists. So if a user changes her/his password, this becomes then + valid for all logbooks. If there would be individual logbook password + files, one would have to change the password in all logbooks + individually. +

+ +

+ With this option it is possible for new users to self-register an user + account. At the login page, a link is displayed "Register as a new + user" which leads the user to a configuration page where one can + enter the account name, full name and email address. A flag allows for + automatic email notification on new entries on the logbook. These + settings can later be changed with the Config menu command. +

+

+ Setting this option to 0 disables self registration. With option + 1, users can silently register, while setting it to 2 + causes elogd to send an email notification to the admin user(s). The + option 3 is used to only send an email notification to tha + admin users(s), which then can validate the account and commit it by + hitting the URL given in the email notification. +

+ +

+ Enables or disabled the ability for users to change their password. If + disabled, the "Forgot password? link in the login page is ommitted + as well. The admin user(s) can always change passwords. +

+ +

+ Commands can be restricted to certain login names (separated by commas). + For each command in the list defined with the "Menu commands" + option, a list of user names can be specified, which are allowed to + execute that command. If the allow option is not present, all users may + execute that command by default. +

+ +

+ Used to deny a certain command to a list of users. This can be used to + deny a guest user to enter new messages or modify a message. +

+ +

+ These two settings can be used to restrict the access to the logbook to + certain computers. It is similar to the UNIX hosts.allow and + hosts.deny files. The list can consist of individual host names or + IP numbers, subnet masks like 123.213. (note the + trailing '.') or .mit.edu, or the word + All. The following rules are applied: +

+ +

+ These rules are applied before any password is checked. To debug + problems, start elogd with the "-v" flag, in which + case the rule checking is printed on the screen. +

+

+ The global option Logfile = <filename> can be + specified to log all user login/logout activities plus all successful + user connections. +

+

+ If any of the password statements are in the [global] + area of the configuration files, they are used for all logbooks. If one + logs in at one logbook, access is automaticlly granted to all logbooks. + If the password statements are in the individual logbook sections, one + has to log in to each logbook separately. +

+

+ +

+
+
+   EMail notification   +
+ +

+ To send email automatically when new entries are created in a logbook, a + SMTP host = entry must be present in the + [global] section of the configuration file. To submit + an email based on an attribute value, use the statement Email + <attribute> <value> = <list>. Whenever an + entry is submitted where attribute is equal to + value, an email notification is sent to the email + addresses in list. Several mail addresses may be + supplied, separated by commas. The mail addresses can contain attributes + via the "$" substitution. If a logbook contains for example an + attribute name which contains email names, then one can put + $name@domain to form a valid email address. +

+

+ Multiple Email xxx statements may occur in a + configuration file. If either the attribute or the value contains one or + more blanks the string must be enclosed with quotation marks, as in: +

+ +

+ The statement Email All = <list> sends an email + notification independent of the type and category. The Use Email + Subject = <string> statement specifies which text is + used as the email subject. The text can contain + $<attribute> statements which are substituted + with the current value of that attribute. For a full list of possible + substitutions, see the "Subst <attribute>" option. The + Use Email Heading = <string> specifies the text + for the email heading line. Default is "A new entry has been submitted + on [host]". The option Use Email Heading Edit = + <string> works the same way for updated (edited) + entries. +

+

+ The option Use Email From = <string> is used + for the "From:" field in the email. Since more and more email + servers do not accept invalid "From:" addresses in order to reduce + spam mail, it might be important that a "real" email address is used in + the "From:" field. By default, the email address of the currently + logged in user is used for the "From:" field. If no user is logged + in, or the current user has not specified a email address in the password + database, the setting of the option Use Email From is + used for the "From:" field. Only if this option is not specified, + a generic address ELOG@<hostname> is used, which might be + rejected by the SMTP server however. +

+

+ If the flag Omit Email To is set to 1, the + To: field in the email is left empty instead set to the real email + address of the recipients. This can be useful if one recipient should not + see the email addresses of the other recipients. +

+

+ The flag Suppress Email to users can be set to + "1" if email should only be sent to the recipients of the + Email <attribute> <value> = <list> + statements but not to the users who have registerd for automatic email + notification. +

+

+ If one wants to send only some attributes but not all in an email + notification, one can use the option Email attributes = + <list>, where a subset of the attributes can be + specified as well as their order. +

+
+
+   Flags   +
+ +

+ +

+
+
+   Themes   +
+

+ Themes are layout and color schemes which determine the look and feel of + a logbook (sometimes called "skins"). A theme consists of a set of + images, which are used for the title banner and browse buttons, and a + Cascading Style Scheet (CSS), which defines the colors, fonts and spacing + of the ELOG pages. +

+

+ Each theme resides in a separate subdirectory and is specified with the + theme = <dir> option in the configuration file. + Each theme can contain several CSSs, which can be selected with the + CSS = <filename> option. +

+

+ A default theme is contained in the distribution. If new themes are + developed by users, they can be sent back to the author, to be included + in future releases. +

+

+ To change colors and fonts, the source of a ELOG page can be examined. + All elements use CSS classes which are specified in the + class="<name>" statements. These classes can be + found in the .../themes/default/default.css file and + changed accordingly. For a description of all options, please consult for + example the W3C consortium. +

+

+ If the CSS file is edited, most browsers require a "reload" to refresh + the modified file. The elogd daemon does not have to be restarted + after a change in the CSS file. +

+

+ These two images display the same logbook entry using different themes: +

+

+    +

+

+ +

+
+
+   Mirroring   +
+

+ Sometimes it can be useful to have the same ELOG logbook on two different + computers. This might be the case if you travel with your laptop, but + want to keep the logbooks from your desktop computer on the laptop. The + problem is that if you add an entry on your laptop, the logbooks on the + laptop and the desktop get out of sync. Merging only the ELOG database + files does not help, since two entries could be made at the same day on + the laptop and the desktop, which would lead to a conflict in that day's + database file. +

+

+ To solve this problem, mirroring was introduced from Version 2.5.0 + on. This technology allows to synchronize one ELOG server with a number + of other servers on a per-entry basis. No additional software is needed, + only two elogd daemons talking to each other. The synchronization can be + executed manually or periodically. If entries are changed/added/deleted + on both sides, they get merged properly during synchronization. In order + to minimize network traffic, each ELOG server calculates a MD5 checksum + for each message, which gets exchanged during synchronization. Only when + the MD5 checksum differs, entries are transferred. +

+

+ To set-up mirroring, install two elogd servers on two machines (for + testing purpose that also works on one machine with two elogd servers + running on different ports). This can be done in two ways: +

+
    +
  1. + Automatic configuration +

    + A complete elog server can be transferred to a secondary server using + the clone command. Assume the existing server + resides at http://master.your.domain/, and you + want to mirror this server to a new location at + http://slave.your.domain/. You do that by + installing the elog package at the slave machine, and then executing + on the slave: +

    +
    +elogd -C http://master.your.domain
    +
    +

    + This command tells elogd to retrieve the configuration file, and + optionally all logbook entries and password files from the master + machine. Note that both servers must be version 2.5.4 or later. In + case of trouble, you can turn on verbose messaging: +

    +
    +elogd -v -C http://master.your.domain
    +
    +

    + which could give some hints. If a logbook on the master server uses + restricted access, you have to specify the admin user name and + password. After everything has been transferred, you can start elogd + in the normal way. +

    +
  2. +
  3. + Manual configuration +

    + First, copy the elogd.cfg file from the master to the slave server. + Make sure that the files are identical (except the port setting if + you run two servers on the same machine). Then, add the following + configuration options. They should be put into the [global] section + of the cofiguration file: +

    + +
  4. +
+

+ If the statement Mirror server is present in the + configuration file, a new menu option "Synchronize" + appears on the elog page. Clicking on this menu options starts the + synchronization:
+
+
+
+ On the left side one sees the entry ID's. Entries which are equal locally + and remotely are not displayed. Here are the rules for + synchronization:
+
+

+ +

+ By starting the synchronization on one elogd server, this server becomes + the client and the other one becomes the server. This means that the + local server actively compares the local and the remote messages, and + updates one or the other if necessary. The other (remote) server does not + need to have any mirror option in its configuration file, since the local + server simulates a web browser to send and retrieve messages to the + remote server. It is however allowed that the remote server also contains + some mirror settings in the configuration file, this way the + synchronization can be started from both servers. +

+
+ + + diff --git a/doc/download.html b/doc/download.html index d5e4a748..d6076ce9 100755 --- a/doc/download.html +++ b/doc/download.html @@ -29,8 +29,8 @@ containing bug fixes or some new and not yet completely debugged code. This is usually the case if some user asks for some new features, which are then implemented and sent to the user for testing. The minor releases are named x.y.z-r where r is the release number. -A web access to the -source code contains the complete development history of ELOG. To check out the complete +A web access +to the source code contains the complete development history of ELOG. To check out the complete Subversion tree, use:

svn checkout svn+ssh://svn@savannah.psi.ch/afs/psi.ch/project/meg/svn/elog/trunk elog
diff --git a/doc/elog.css b/doc/elog.css index 7c653a5e..31771a61 100755 --- a/doc/elog.css +++ b/doc/elog.css @@ -2,7 +2,6 @@ .title { padding: 5px 10px; background-color: rgb(72, 96, 144); - font-family: Verdana,Arial,Helvetica,Sans-Serif; font-size: x-large; color: white; text-align: center; @@ -10,19 +9,17 @@ .version { padding: 5px 10px; color: rgb(72, 96, 144); - font-family: Verdana,Arial,Helvetica,Sans-Serif; text-align: center; font-weight: bold; } - .Sub { font-family: Verdana,Arial,Helvetica,Sans-Serif; + .Sub { font-size: medium; text-align: center; } .menu { padding: 5px 10px; background-color: rgb(72, 96, 144); - font-family: Verdana,Arial,Helvetica,Sans-Serif; font-size: medium; color: white; text-align: center; @@ -34,7 +31,6 @@ .section { padding: 5px 10px; background-color: rgb(72, 96, 144); - font-family: Verdana,Arial,Helvetica,Sans-Serif; font-size: large; color: white; text-align: left; @@ -42,13 +38,17 @@ .footer { padding: 5px 10px; background-color: rgb(72, 96, 144); - font-family: Verdana,Arial,Helvetica,Sans-Serif; font-size: small; color: white; text-align: left; } - p { margin-left: 10px; + body { + font-family: Verdana,Arial,Helvetica,Sans-Serif; + } + + p { + margin-left: 10px; margin-right: 10px; } diff --git a/src/elogd.c b/src/elogd.c index aaa00f92..751d2b3c 100755 --- a/src/elogd.c +++ b/src/elogd.c @@ -251,6 +251,7 @@ char author_list[MAX_N_LIST][NAME_LENGTH] = { #define AF_TIME (1<<10) #define AF_NUMERIC (1<<11) #define AF_USERLIST (1<<12) +#define AF_HIDDEN (1<<13) /* attribute format flags */ #define AFF_SAME_LINE 1 @@ -552,6 +553,32 @@ size_t my_strftime(char *s, size_t max, const char *fmt, const struct tm * tm) return strftime(s, max, fmt, tm); } +/* signal save read function */ +int my_read(int fh, void *buffer, unsigned int bytes) +{ +#ifdef OS_UNIX + int i, n = 0; + + do { + i = read(fh, buffer+n, bytes-n); + + /* don't return if an alarm signal was cought */ + if (i == -1 && errno == EINTR) + continue; + + if (i == -1) + return -1; + + n += i; + + } while (n < bytes); +#else + return read(fh, buffer, bytes); +#endif + + return 0; +} + /*---- Compose RFC2822 compliant date ---*/ void get_rfc2822_date(char *date, int size, time_t ltime) @@ -4041,7 +4068,7 @@ int el_retrieve(LOGBOOK * lbs, message = malloc(TEXT_SIZE + 1000); lseek(fh, lbs->el_index[index].offset, SEEK_SET); - i = read(fh, message, TEXT_SIZE + 1000 - 1); + i = my_read(fh, message, TEXT_SIZE + 1000 - 1); if (i <= 0) { free(message); close(fh); @@ -4260,7 +4287,7 @@ int el_retrieve_attachment(LOGBOOK * lbs, int message_id, int n, char name[MAX_P } lseek(fh, lbs->el_index[index].offset, SEEK_SET); - i = read(fh, message, sizeof(message) - 1); + i = my_read(fh, message, sizeof(message) - 1); if (i <= 0) { close(fh); return EL_FILE_ERROR; @@ -4381,7 +4408,7 @@ int el_submit(LOGBOOK * lbs, int message_id, BOOL bedit, } lseek(fh, lbs->el_index[index].offset, SEEK_SET); - i = read(fh, message, TEXT_SIZE + 100); + i = my_read(fh, message, TEXT_SIZE + 100); message[i] = 0; /* check for valid message */ @@ -4430,7 +4457,7 @@ int el_submit(LOGBOOK * lbs, int message_id, BOOL bedit, buffer = xmalloc(tail_size); lseek(fh, lbs->el_index[index].offset + size, SEEK_SET); - n = read(fh, buffer, tail_size); + n = my_read(fh, buffer, tail_size); } lseek(fh, lbs->el_index[index].offset, SEEK_SET); } else { @@ -4679,7 +4706,7 @@ int el_delete_message(LOGBOOK * lbs, int message_id, message = xmalloc(TEXT_SIZE + 1000); lseek(fh, lbs->el_index[index].offset, SEEK_SET); - i = read(fh, message, TEXT_SIZE + 1000 - 1); + i = my_read(fh, message, TEXT_SIZE + 1000 - 1); if (i <= 0) { xfree(message); close(fh); @@ -4756,7 +4783,7 @@ int el_delete_message(LOGBOOK * lbs, int message_id, buffer = xmalloc(tail_size); lseek(fh, lbs->el_index[index].offset + size, SEEK_SET); - n = read(fh, buffer, tail_size); + n = my_read(fh, buffer, tail_size); } lseek(fh, lbs->el_index[index].offset, SEEK_SET); @@ -6185,139 +6212,154 @@ void set_location(LOGBOOK * lbs, char *rel_path) char str[NAME_LENGTH], group[NAME_LENGTH], list[NAME_LENGTH], *p; int i; - /* if path contains http(s), go directly there */ - if (strncmp(rel_path, "http://", 7) == 0) { - rsputs("Location: "); - rsputs(rel_path); - } else if (strncmp(rel_path, "https://", 8) == 0) { - rsputs("Location: "); - rsputs(rel_path); - } else { + if (getcfg(lbs->name, "Relative redirect", str, sizeof(str)) && + atoi(str) == 1) { - /* check for URL options */ - str[0] = 0; - if (lbs) - getcfg(lbs->name, "URL", str, sizeof(str)); + if (rel_path[0]) + strlcpy(str, rel_path, sizeof(str)); else - getcfg("global", "URL", str, sizeof(str)); + strlcpy(str, ".", sizeof(str)); - if (str[0] == 0) { + rsputs("Location: "); + rsputs(str); - /* get redirection from referer and host */ - - if (referer[0]) { - strlcpy(str, referer, sizeof(str)); - - /* strip any parameter */ - if (strchr(str, '?')) - *strchr(str, '?') = 0; - - /* strip rightmost '/' */ - if (str[strlen(str) - 1] == '/') - str[strlen(str) - 1] = 0; - - /* extract last subdir */ - p = str + strlen(str); - while (p > str && *p != '/') - p--; - if (*p == '/') - p++; - - /* if last subdir equals any logbook name, strip it */ - for (i = 0; lb_list[i].name[0]; i++) - if (stricmp(p, lb_list[i].name_enc) == 0) { - *p = 0; - break; - } - - /* if last subdir equals any group, strip it */ - sprintf(group, "Group %s", p); - if (getcfg("global", group, list, sizeof(list))) - *p = 0; - - /* if last subdir equals any top group, strip it */ - sprintf(group, "Top group %s", p); - if (getcfg("global", group, list, sizeof(list))) - *p = 0; - - } else { - /* assemble absolute path from host name and port */ - sprintf(str, "http://%s", http_host); - if (elog_tcp_port != 80 && strchr(str, ':') == NULL) - sprintf(str + strlen(str), ":%d", elog_tcp_port); - strlcat(str, "/", sizeof(str)); - } - - /* add trailing '/' if not present */ - if (str[strlen(str) - 1] != '/') - strlcat(str, "/", sizeof(str)); - - /* add top group if existing and not logbook */ - if (!lbs && getcfg_topgroup()) { - strlcat(str, getcfg_topgroup(), sizeof(str)); - strlcat(str, "/", sizeof(str)); - } - - if (strncmp(rel_path, "../", 3) == 0) - strlcat(str, rel_path + 3, sizeof(str)); - else if (strcmp(rel_path, ".") == 0) { - if (lbs) - strlcat(str, lbs->name_enc, sizeof(str)); - } else if (rel_path[0] == '/') - strlcat(str, rel_path + 1, sizeof(str)); - else { - if (lbs) { - strlcat(str, lbs->name_enc, sizeof(str)); - strlcat(str, "/", sizeof(str)); - strlcat(str, rel_path, sizeof(str)); - } else - strlcat(str, rel_path, sizeof(str)); - } + } else { + /* Absolute redirect */ + /* if path contains http(s), go directly there */ + if (strncmp(rel_path, "http://", 7) == 0) { rsputs("Location: "); - rsputs(str); - + rsputs(rel_path); + } else if (strncmp(rel_path, "https://", 8) == 0) { + rsputs("Location: "); + rsputs(rel_path); } else { - /* use redirection via URL */ + /* check for URL options */ + str[0] = 0; + if (lbs) + getcfg(lbs->name, "URL", str, sizeof(str)); + else + getcfg("global", "URL", str, sizeof(str)); - /* if HTTP request comes from localhost, use localhost as - absolute link (needed if running on DSL at home) */ - if (!str[0] && strstr(http_host, "localhost")) { - strlcpy(str, "http://localhost", sizeof(str)); - if (elog_tcp_port != 80) - sprintf(str + strlen(str), ":%d", elog_tcp_port); - strlcat(str, "/", sizeof(str)); - } + if (str[0] == 0) { - /* add trailing '/' if not present */ - if (str[strlen(str) - 1] != '/') - strlcat(str, "/", sizeof(str)); + /* get redirection from referer and host */ - /* add top group if existing and not logbook */ - if (!lbs && getcfg_topgroup()) { - strlcat(str, getcfg_topgroup(), sizeof(str)); - strlcat(str, "/", sizeof(str)); - } + if (referer[0]) { + strlcpy(str, referer, sizeof(str)); - if (strncmp(rel_path, "../", 3) == 0) - strlcat(str, rel_path + 3, sizeof(str)); - else if (strcmp(rel_path, ".") == 0) { - if (lbs) - strlcat(str, lbs->name_enc, sizeof(str)); - } else if (rel_path[0] == '/') - strlcat(str, rel_path + 1, sizeof(str)); - else { - if (lbs) { - strlcat(str, lbs->name_enc, sizeof(str)); + /* strip any parameter */ + if (strchr(str, '?')) + *strchr(str, '?') = 0; + + /* strip rightmost '/' */ + if (str[strlen(str) - 1] == '/') + str[strlen(str) - 1] = 0; + + /* extract last subdir */ + p = str + strlen(str); + while (p > str && *p != '/') + p--; + if (*p == '/') + p++; + + /* if last subdir equals any logbook name, strip it */ + for (i = 0; lb_list[i].name[0]; i++) + if (stricmp(p, lb_list[i].name_enc) == 0) { + *p = 0; + break; + } + + /* if last subdir equals any group, strip it */ + sprintf(group, "Group %s", p); + if (getcfg("global", group, list, sizeof(list))) + *p = 0; + + /* if last subdir equals any top group, strip it */ + sprintf(group, "Top group %s", p); + if (getcfg("global", group, list, sizeof(list))) + *p = 0; + + } else { + /* assemble absolute path from host name and port */ + sprintf(str, "http://%s", http_host); + if (elog_tcp_port != 80 && strchr(str, ':') == NULL) + sprintf(str + strlen(str), ":%d", elog_tcp_port); strlcat(str, "/", sizeof(str)); - strlcat(str, rel_path, sizeof(str)); - } else - strlcat(str, rel_path, sizeof(str)); - } + } - rsputs("Location: "); - rsputs(str); + /* add trailing '/' if not present */ + if (str[strlen(str) - 1] != '/') + strlcat(str, "/", sizeof(str)); + + /* add top group if existing and not logbook */ + if (!lbs && getcfg_topgroup()) { + strlcat(str, getcfg_topgroup(), sizeof(str)); + strlcat(str, "/", sizeof(str)); + } + + if (strncmp(rel_path, "../", 3) == 0) + strlcat(str, rel_path + 3, sizeof(str)); + else if (strcmp(rel_path, ".") == 0) { + if (lbs) + strlcat(str, lbs->name_enc, sizeof(str)); + } else if (rel_path[0] == '/') + strlcat(str, rel_path + 1, sizeof(str)); + else { + if (lbs) { + strlcat(str, lbs->name_enc, sizeof(str)); + strlcat(str, "/", sizeof(str)); + strlcat(str, rel_path, sizeof(str)); + } else + strlcat(str, rel_path, sizeof(str)); + } + + rsputs("Location: "); + rsputs(str); + + } else { + + /* use redirection via URL */ + + /* if HTTP request comes from localhost, use localhost as + absolute link (needed if running on DSL at home) */ + if (!str[0] && strstr(http_host, "localhost")) { + strlcpy(str, "http://localhost", sizeof(str)); + if (elog_tcp_port != 80) + sprintf(str + strlen(str), ":%d", elog_tcp_port); + strlcat(str, "/", sizeof(str)); + } + + /* add trailing '/' if not present */ + if (str[strlen(str) - 1] != '/') + strlcat(str, "/", sizeof(str)); + + /* add top group if existing and not logbook */ + if (!lbs && getcfg_topgroup()) { + strlcat(str, getcfg_topgroup(), sizeof(str)); + strlcat(str, "/", sizeof(str)); + } + + if (strncmp(rel_path, "../", 3) == 0) + strlcat(str, rel_path + 3, sizeof(str)); + else if (strcmp(rel_path, ".") == 0) { + if (lbs) + strlcat(str, lbs->name_enc, sizeof(str)); + } else if (rel_path[0] == '/') + strlcat(str, rel_path + 1, sizeof(str)); + else { + if (lbs) { + strlcat(str, lbs->name_enc, sizeof(str)); + strlcat(str, "/", sizeof(str)); + strlcat(str, rel_path, sizeof(str)); + } else + strlcat(str, rel_path, sizeof(str)); + } + + rsputs("Location: "); + rsputs(str); + } } } @@ -6575,6 +6617,15 @@ and attr_flags arrays */ attr_flags[j] |= AF_FIXED_REPLY; } + /* check if hidden attribute */ + getcfg(logbook, "Hidden Attributes", list, sizeof(list)); + m = strbreak(list, tmp_list, MAX_N_ATTR, ","); + for (i = 0; i < m; i++) { + for (j = 0; j < n; j++) + if (strieq(attr_list[j], tmp_list[i])) + attr_flags[j] |= AF_HIDDEN; + } + /* check for extendable options */ getcfg(logbook, "Extendable Options", list, sizeof(list)); m = strbreak(list, tmp_list, MAX_N_ATTR, ","); @@ -7224,8 +7275,8 @@ void show_top_text(LOGBOOK * lbs) void show_bottom_text(LOGBOOK * lbs) { - char str[NAME_LENGTH]; - int size; + char str[NAME_LENGTH], slist[20][NAME_LENGTH], svalue[20][NAME_LENGTH]; + int i, size; if (getcfg(lbs->name, "bottom text", str, sizeof(str))) { FILE *f; @@ -7246,14 +7297,22 @@ void show_bottom_text(LOGBOOK * lbs) size = TELL(fileno(f)); fseek(f, 0, SEEK_SET); - buf = xmalloc(size + 1); + buf = xmalloc(size + 100); fread(buf, 1, size, f); buf[size] = 0; fclose(f); + i = build_subst_list(lbs, slist, svalue, NULL, TRUE); + strsubst_list(buf, size+100, slist, svalue, i); + rsputs(buf); - } else + xfree(buf); + } else { + i = build_subst_list(lbs, slist, svalue, NULL, TRUE); + strsubst_list(str, sizeof(str), slist, svalue, i); + rsputs(str); + } } } else /* add little logo */ @@ -7661,6 +7720,13 @@ int build_subst_list(LOGBOOK * lbs, char list[][NAME_LENGTH], char value[][NAME_ sprintf(str, "%d", (int) t); strcpy(value[i++], str); + /* add ELOG version and revision */ + strcpy(list[i], "version"); + strcpy(value[i++], VERSION); + + strcpy(list[i], "revision"); + sprintf(value[i++], "%d", atoi(svn_revision + 13)); + return i; } @@ -8919,6 +8985,10 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL index = attr_index[aindex]; + /* if attribute is hidden, skip it */ + if (attr_flags[index] & AF_HIDDEN) + continue; + strcpy(class_name, "attribname"); strcpy(class_value, "attribvalue"); input_size = 80; @@ -9973,7 +10043,7 @@ void show_find_form(LOGBOOK * lbs) if (i > 2) { if (!getcfg(lbs->name, "Search all logbooks", str, sizeof(str)) || atoi(str) == 1) { - rsprintf("\n"); + rsprintf(""); rsprintf("
\n", loc("Search all logbooks")); } } @@ -12081,7 +12151,7 @@ int show_download_page(LOGBOOK * lbs, char *path) return EL_FILE_ERROR; lseek(fh, lbs->el_index[index].offset, SEEK_SET); - i = read(fh, message, sizeof(message) - 1); + i = my_read(fh, message, sizeof(message) - 1); if (i <= 0) { close(fh); return EL_FILE_ERROR; @@ -14488,7 +14558,7 @@ void display_line(LOGBOOK * lbs, int message_id, int number, char *mode, ref[0] = 0; if (absolute_link) compose_base_url(lbs, ref, sizeof(ref)); - sprintf(ref + strlen(ref), "%d", message_id); + sprintf(ref + strlen(ref), "../%s/%d", lbs->name_enc, message_id); if (strieq(mode, "Summary")) { if (highlight_mid == message_id) { @@ -17997,7 +18067,7 @@ void format_email_attachments(LOGBOOK * lbs, int message_id, int attachment_type fh = open(file_name, O_RDONLY | O_BINARY); if (fh > 0) { do { - n = read(fh, buffer, 45); + n = my_read(fh, buffer, 45); if (n <= 0) break; @@ -20638,7 +20708,7 @@ BOOL convert_password_file(char *file_name) lseek(fh, 0, SEEK_SET); buf = malloc(len + 1); assert(buf); - i = read(fh, buf, len); + i = my_read(fh, buf, len); buf[i] = 0; close(fh); @@ -21142,7 +21212,6 @@ BOOL check_user_password(LOGBOOK * lbs, char *user, char *password, char *redir) if (user == NULL) status = 1; else { - status = get_user_line(lbs, user, upwd, full_name, email, NULL, NULL); if (status == 1 && user[0]) @@ -24378,7 +24447,7 @@ int ss_getchar(BOOL reset) } memset(c, 0, 3); - i = read(fd, c, 1); + i = my_read(fd, c, 1); if (i == 0) return 0; @@ -24524,7 +24593,7 @@ void create_password(char *logbook, char *name, char *pwd) length = lseek(fh, 0, SEEK_END); lseek(fh, 0, SEEK_SET); cfgbuffer = xmalloc(length + 1); - length = read(fh, cfgbuffer, length); + length = my_read(fh, cfgbuffer, length); cfgbuffer[length] = 0; close(fh); fh = open(config_file, O_TRUNC | O_WRONLY, 0640);