"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/elogd.c" between
elog-3.1.4-2.tar.gz and elog-3.1.4-3.tar.gz

About: ELOG is an Electronic Logbook (weblog).

elogd.c  (elog-3.1.4-2):elogd.c  (elog-3.1.4-3)
skipping to change at line 8480 skipping to change at line 8480
return_buffer = xrealloc(return_buffer, return_buffer_size + delta); return_buffer = xrealloc(return_buffer, return_buffer_size + delta);
memset(return_buffer + return_buffer_size, 0, delta); memset(return_buffer + return_buffer_size, 0, delta);
return_buffer_size += delta; return_buffer_size += delta;
} }
return_length = strlen(return_buffer) + length; return_length = strlen(return_buffer) + length;
read(fh, return_buffer + strlen(return_buffer), length); read(fh, return_buffer + strlen(return_buffer), length);
close(fh); close(fh);
} else { } else {
char encodedname[256]; char encodedname[256], str[256];
show_html_header(NULL, FALSE, "404 Not Found", TRUE, FALSE, NULL, FALSE, 0 ); show_html_header(NULL, FALSE, "404 Not Found", TRUE, FALSE, NULL, FALSE, 0 );
rsprintf("<body><h1>Not Found</h1>\r\n"); rsprintf("<body><h1>404 Not Found</h1>\r\n");
rsprintf("The requested file <b>"); rsprintf("The requested file <b>");
strencode2(encodedname, file_name, sizeof(encodedname)); strencode2(encodedname, file_name, sizeof(encodedname));
if (strchr(file_name, DIR_SEPARATOR)) if (strrchr(encodedname, DIR_SEPARATOR))
rsprintf("%s", encodedname); rsprintf("%s", strrchr(encodedname, DIR_SEPARATOR)+1, sizeof(str));
else else
rsprintf("%s%c%s", dir, DIR_SEPARATOR, encodedname); rsprintf("%s", encodedname);
rsprintf("</b> was not found on this server<p>\r\n"); rsprintf("</b> was not found on this server<p>\r\n");
rsprintf("<hr><address>ELOG version %s</address></body></html>\r\n\r\n", V ERSION);
return_length = strlen_retbuf; return_length = strlen_retbuf;
keep_alive = FALSE; keep_alive = FALSE;
} }
} }
/*------------------------------------------------------------------*/ /*------------------------------------------------------------------*/
void strencode(char *text) { void strencode(char *text) {
int i; int i;
skipping to change at line 17641 skipping to change at line 17640
strcpy(rowstyle, "threadreply"); strcpy(rowstyle, "threadreply");
} }
} }
} }
rsprintf("<tr>"); rsprintf("<tr>");
/* check attributes for row style */ /* check attributes for row style */
for (i = 0; i < n_attr; i++) { for (i = 0; i < n_attr; i++) {
if (attrib[i][0] == 0) if (attrib[i][0] == 0)
sprintf(str, "Style %s \"\"", attr_list[i]); snprintf(str, sizeof(str), "Style %s \"\"", attr_list[i]);
else else
sprintf(str, "Style %s %s", attr_list[i], attrib[i]); snprintf(str, sizeof(str), "Style %s %s", attr_list[i], attrib[i]);
if (getcfg(lbs->name, str, display, sizeof(display))) { if (getcfg(lbs->name, str, display, sizeof(display))) {
sprintf(str, "%s\" style=\"%s", rowstyle, display); sprintf(str, "%s\" style=\"%s", rowstyle, display);
strlcpy(rowstyle, str, sizeof(rowstyle)); strlcpy(rowstyle, str, sizeof(rowstyle));
break; break;
} }
} }
/* only single cell for threaded display */ /* only single cell for threaded display */
if (strieq(mode, "Threaded")) { if (strieq(mode, "Threaded")) {
rsprintf("<td align=left class=\"%s\">", rowstyle); rsprintf("<td align=left class=\"%s\">", rowstyle);
skipping to change at line 17876 skipping to change at line 17875
else else
rsprintf("\n<td class=\"%s\" %s>%s</td>\n", rowstyle, nowrap, str); rsprintf("\n<td class=\"%s\" %s>%s</td>\n", rowstyle, nowrap, str);
} }
} }
for (i = 0; i < n_attr; i++) for (i = 0; i < n_attr; i++)
if (strieq(disp_attr[index], attr_list[i])) { if (strieq(disp_attr[index], attr_list[i])) {
/* check attributes for cell style */ /* check attributes for cell style */
strlcpy(tdstyle, rowstyle, sizeof(tdstyle)); strlcpy(tdstyle, rowstyle, sizeof(tdstyle));
sprintf(str, "Cell Style %s %s", attr_list[i], attrib[i]); snprintf(str, sizeof(str), "Cell Style %s %s", attr_list[i], attr ib[i]);
if (getcfg(lbs->name, str, display, sizeof(display))) { if (getcfg(lbs->name, str, display, sizeof(display))) {
sprintf(str, "%s\" style=\"%s", rowstyle, display); sprintf(str, "%s\" style=\"%s", rowstyle, display);
strlcpy(tdstyle, str, sizeof(rowstyle)); strlcpy(tdstyle, str, sizeof(rowstyle));
} }
if (strieq(mode, "Threaded")) { if (strieq(mode, "Threaded")) {
if (strieq(attr_options[i][0], "boolean")) { if (strieq(attr_options[i][0], "boolean")) {
if (atoi(attrib[i]) == 1) { if (atoi(attrib[i]) == 1) {
if (skip_comma) { if (skip_comma) {
rsprintf(" "); rsprintf(" ");
skipping to change at line 23391 skipping to change at line 23390
message_id = atoi(getparam("edit_id")); message_id = atoi(getparam("edit_id"));
strcpy(in_reply_to, "<keep>"); strcpy(in_reply_to, "<keep>");
strcpy(reply_to, "<keep>"); strcpy(reply_to, "<keep>");
strcpy(date, "<keep>"); strcpy(date, "<keep>");
if (bdraft) if (bdraft)
strcpy(locked_by, "<keep>"); strcpy(locked_by, "<keep>");
} else } else
strcpy(in_reply_to, isparam("reply_to") ? getparam("reply_to") : ""); strcpy(in_reply_to, isparam("reply_to") ? getparam("reply_to") : "");
} }
if (_logging_level > 1) {
if (bmultiedit)
sprintf(str, "EDIT multiple entries");
else if (bdraft)
sprintf(str, "DRAFT entry #%d", message_id);
else if (bedit && !resubmit_orig)
sprintf(str, "EDIT entry #%d", message_id);
else
sprintf(str, "NEW entry #%d", message_id);
write_logfile(lbs, str);
}
if (bmultiedit) { if (bmultiedit) {
for (i = n = 0; i < atoi(getparam("nsel")); i++) { for (i = n = 0; i < atoi(getparam("nsel")); i++) {
sprintf(str, "s%d", i); sprintf(str, "s%d", i);
if (isparam(str)) { if (isparam(str)) {
message_id = atoi(getparam(str)); message_id = atoi(getparam(str));
status = submit_elog_reply(lbs, message_id, attrib, getparam("text") ); status = submit_elog_reply(lbs, message_id, attrib, getparam("text") );
if (status != EL_SUCCESS) { if (status != EL_SUCCESS) {
sprintf(str, loc("New entry cannot be written to directory \"%s\" "), lbs->data_dir); sprintf(str, loc("New entry cannot be written to directory \"%s\" "), lbs->data_dir);
skipping to change at line 23444 skipping to change at line 23430
return; return;
} }
if (bdraft) { if (bdraft) {
show_http_header(lbs, FALSE, NULL); show_http_header(lbs, FALSE, NULL);
rsprintf("OK %d\n", message_id); rsprintf("OK %d\n", message_id);
return; return;
} }
} }
if (_logging_level > 1) {
if (bmultiedit)
sprintf(str, "EDIT multiple entries");
else if (bdraft)
sprintf(str, "DRAFT entry #%d", message_id);
else if (bedit && !resubmit_orig)
sprintf(str, "EDIT entry #%d", message_id);
else
sprintf(str, "NEW entry #%d", message_id);
write_logfile(lbs, str);
}
/* evaluate propagation of attributes */ /* evaluate propagation of attributes */
if (getcfg(lbs->name, "Propagate attributes", str, sizeof(str))) if (getcfg(lbs->name, "Propagate attributes", str, sizeof(str)))
propagate_attrib(lbs, find_thread_head(lbs, message_id), attrib); propagate_attrib(lbs, find_thread_head(lbs, message_id), attrib);
/* resubmit thread if requested */ /* resubmit thread if requested */
if (resubmit_orig) if (resubmit_orig)
message_id = el_move_message_thread(lbs, resubmit_orig); message_id = el_move_message_thread(lbs, resubmit_orig);
/* retrieve submission date */ /* retrieve submission date */
if (date[0] == 0) if (date[0] == 0)
skipping to change at line 29520 skipping to change at line 29519
SSL_library_init(); SSL_library_init();
SSL_load_error_strings(); SSL_load_error_strings();
#if OPENSSL_VERSION_NUMBER > 0x1010000fL #if OPENSSL_VERSION_NUMBER > 0x1010000fL
meth = (SSL_METHOD *) TLS_method(); meth = (SSL_METHOD *) TLS_method();
#else #else
meth = (SSL_METHOD *) TLSv1_2_method(); meth = (SSL_METHOD *) TLSv1_2_method();
#endif #endif
ctx = SSL_CTX_new(meth); ctx = SSL_CTX_new(meth);
#if OPENSSL_VERSION_NUMBER > 0x1010000fL
// disable obsolete SSL and TLS, need TLSv1_2 for Internet Explorer
SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 |
SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_1);
if (SSL_CTX_set_cipher_list(ctx,
"ECDH+AESGCM:ECDH+AES256:ECDH+AES:DH+AESGCM:DH+AES256:DH+AES:!aNULL:!
ADH:!DSS:!kDH:!kECDH") <= 0) {
eprintf("Error setting the cipher list.\n");
return NULL;
}
#endif
if (getcfg("global", "SSL Passphrase", pwd, sizeof(pwd))) { if (getcfg("global", "SSL Passphrase", pwd, sizeof(pwd))) {
SSL_CTX_set_default_passwd_cb_userdata(ctx, pwd); SSL_CTX_set_default_passwd_cb_userdata(ctx, pwd);
} }
strlcpy(str, resource_dir, sizeof(str)); strlcpy(str, resource_dir, sizeof(str));
strlcat(str, "ssl/server.crt", sizeof(str)); strlcat(str, "ssl/server.crt", sizeof(str));
if (!file_exist(str)) { if (!file_exist(str)) {
eprintf("Cerificate file \"%s\" not found, aborting\n", str); eprintf("Cerificate file \"%s\" not found, aborting\n", str);
return NULL; return NULL;
} }
skipping to change at line 29710 skipping to change at line 29721
if (geteuid() == 0 || pidfile[0]) { if (geteuid() == 0 || pidfile[0]) {
int fd; int fd;
char buf[20]; char buf[20];
struct stat finfo; struct stat finfo;
if (pidfile[0] == 0) if (pidfile[0] == 0)
strcpy(pidfile, PIDFILE); strcpy(pidfile, PIDFILE);
/* check if file exists */ /* check if file exists */
if (stat(pidfile, &finfo) >= 0) { if (stat(pidfile, &finfo) >= 0) {
eprintf("File \"%s\" exists, using \"%s.%d\" instead.\n", pidfile, pidf /* if it exists remove it */
ile, elog_tcp_port); eprintf("File \"%s\" exists, overwriting it.\n", pidfile);
sprintf(pidfile + strlen(pidfile), ".%d", elog_tcp_port); remove(pidfile);
/* check again for the new name */
if (stat(pidfile, &finfo) >= 0) {
/* never overwrite a file */
eprintf("Refuse to overwrite existing file \"%s\".\n", pidfile);
_exit(EXIT_FAILURE); /* don't call atexit() hook */
}
} }
fd = open(pidfile, O_CREAT | O_RDWR, 0644); fd = open(pidfile, O_CREAT | O_RDWR, 0644);
if (fd < 0) { if (fd < 0) {
sprintf(str, "Error creating pid file \"%s\"", pidfile); sprintf(str, "Error creating pid file \"%s\"", pidfile);
eprintf("%s; %s\n", str, strerror(errno)); eprintf("%s; %s\n", str, strerror(errno));
exit(EXIT_FAILURE);
} }
sprintf(buf, "%d\n", (int) getpid()); sprintf(buf, "%d\n", (int) getpid());
if (write(fd, buf, strlen(buf)) == -1) { if (write(fd, buf, strlen(buf)) == -1) {
sprintf(str, "Error writing to pid file \"%s\"", pidfile); sprintf(str, "Error writing to pid file \"%s\"", pidfile);
eprintf("%s; %s\n", str, strerror(errno)); eprintf("%s; %s\n", str, strerror(errno));
exit(EXIT_FAILURE);
} }
close(fd); close(fd);
} }
/* install signal handlers */ /* install signal handlers */
ctrlc_handle.sa_handler = ctrlc_handler; ctrlc_handle.sa_handler = ctrlc_handler;
sigemptyset(&ctrlc_handle.sa_mask); sigemptyset(&ctrlc_handle.sa_mask);
ctrlc_handle.sa_flags = 0; ctrlc_handle.sa_flags = 0;
sigaction(SIGTERM, &ctrlc_handle, NULL); sigaction(SIGTERM, &ctrlc_handle, NULL);
skipping to change at line 30035 skipping to change at line 30038
if (!more_requests) { if (!more_requests) {
do { do {
FD_ZERO(&readfds); FD_ZERO(&readfds);
FD_SET(_sock, &readfds); FD_SET(_sock, &readfds);
timeout.tv_sec = 6; timeout.tv_sec = 6;
timeout.tv_usec = 0; timeout.tv_usec = 0;
status = select(FD_SETSIZE, (void *) &readfds, NULL, NUL L, (void *) &timeout); status = select(FD_SETSIZE, (void *) &readfds, NULL, NUL L, (void *) &timeout);
if (FD_ISSET(_sock, &readfds)) { if (FD_ISSET(_sock, &readfds)) {
#ifdef HAVE_SSL #ifdef HAVE_SSL
if (_ssl_flag) if (_ssl_flag) {
i = SSL_read(_ssl_con, net_buffer + len, net_buffe r_size - len); i = SSL_read(_ssl_con, net_buffer + len, net_buffe r_size - len);
else if (i <= 0) {
int ssl_error = SSL_get_error(_ssl_con, i);
if (ssl_error == SSL_ERROR_WANT_READ ||
ssl_error == SSL_ERROR_WANT_WRITE)
continue; // continue reading if SSL layer w
ants more data
}
} else
#endif #endif
i = recv(_sock, net_buffer + len, net_buffer_size - len, 0); i = recv(_sock, net_buffer + len, net_buffer_size - len, 0);
if (get_verbose() == VERBOSE_URL) if (get_verbose() == VERBOSE_URL)
eprintf("Connection #%d received %d bytes on socke t %d\n", i_conn, i, _sock); eprintf("Connection #%d received %d bytes on socke t %d\n", i_conn, i, _sock);
} else } else
break; break;
/* abort if connection got broken */ /* abort if connection got broken */
skipping to change at line 30072 skipping to change at line 30081
if (len == net_buffer_size) { if (len == net_buffer_size) {
net_buffer = xrealloc(net_buffer, net_buffer_size + 1 00000); net_buffer = xrealloc(net_buffer, net_buffer_size + 1 00000);
if (net_buffer == NULL) { if (net_buffer == NULL) {
sprintf(str, sprintf(str,
"Error: Cannot increase net_buffer, out of memory, net_buffer_size = %d", "Error: Cannot increase net_buffer, out of memory, net_buffer_size = %d",
net_buffer_size); net_buffer_size);
show_error(str); show_error(str);
break; break;
} }
if (net_buffer_size >= 100000000) { if (net_buffer_size >= 1024*1024*1024) {
sprintf(str, sprintf(str, "Error: Request extends 1 GB, dropped
"Error: Request extends 100 MB, dropped"); ");
show_error(str); show_error(str);
break; break;
} }
memset(net_buffer + net_buffer_size, 0, 100000); memset(net_buffer + net_buffer_size, 0, 100000);
net_buffer_size += 100000; net_buffer_size += 100000;
} }
/* repeat until empty line received (fragmented TCP pack ets!) */ /* repeat until empty line received (fragmented TCP pack ets!) */
} while (strstr(net_buffer, "\r\n\r\n") == 0); } while (strstr(net_buffer, "\r\n\r\n") == 0);
 End of changes. 17 change blocks. 
39 lines changed or deleted 49 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)