mirror of
https://gitea.psi.ch/ELOG/elog.git
synced 2026-09-08 17:13:56 +00:00
Version 2.3.3
SVN revision: 444
This commit is contained in:
parent
e753f2a671
commit
c97e6fb5b6
@ -1,3 +1,9 @@
|
|||||||
|
Version 2.3.3, released March 14th, 2003
|
||||||
|
========================================
|
||||||
|
|
||||||
|
- Fixed bug which prevented elogd to bind to port 80 under Linux
|
||||||
|
- Resubmission of entries does not resubmit replies to those entries
|
||||||
|
|
||||||
Version 2.3.2, released March 12th, 2003
|
Version 2.3.2, released March 12th, 2003
|
||||||
========================================
|
========================================
|
||||||
|
|
||||||
|
|||||||
@ -31,7 +31,7 @@
|
|||||||
[<a class=nav href="#links">Links</a>]
|
[<a class=nav href="#links">Links</a>]
|
||||||
* </div>
|
* </div>
|
||||||
<P class=Sub>Home of the <i>Electronic Logbook</i> package by <a href="mailto:Stefan.Ritt@psi.ch">Stefan Ritt</a></P>
|
<P class=Sub>Home of the <i>Electronic Logbook</i> package by <a href="mailto:Stefan.Ritt@psi.ch">Stefan Ritt</a></P>
|
||||||
<div class=version> Current version is : 2.3.2 </div>
|
<div class=version> Current version is : 2.3.3 </div>
|
||||||
|
|
||||||
<hr><a name="whatis">
|
<hr><a name="whatis">
|
||||||
<div class=section> What is ELOG ? </div>
|
<div class=section> What is ELOG ? </div>
|
||||||
|
|||||||
259
src/elogd.c
259
src/elogd.c
@ -6,6 +6,9 @@
|
|||||||
Contents: Web server program for Electronic Logbook ELOG
|
Contents: Web server program for Electronic Logbook ELOG
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.48 2003/03/14 08:55:46 midas
|
||||||
|
Version 2.3.3
|
||||||
|
|
||||||
Revision 1.47 2003/03/10 15:26:18 midas
|
Revision 1.47 2003/03/10 15:26:18 midas
|
||||||
Fixed another bug with parameter filter
|
Fixed another bug with parameter filter
|
||||||
|
|
||||||
@ -659,7 +662,7 @@
|
|||||||
\********************************************************************/
|
\********************************************************************/
|
||||||
|
|
||||||
/* Version of ELOG */
|
/* Version of ELOG */
|
||||||
#define VERSION "2.3.2"
|
#define VERSION "2.3.3"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -3371,7 +3374,7 @@ int el_move_message_thread(LOGBOOK *lbs, int message_id)
|
|||||||
int i, n, size, new_id;
|
int i, n, size, new_id;
|
||||||
char date[80], attrib[MAX_N_ATTR][NAME_LENGTH], text[TEXT_SIZE],
|
char date[80], attrib[MAX_N_ATTR][NAME_LENGTH], text[TEXT_SIZE],
|
||||||
in_reply_to[80], reply_to[256], encoding[80];
|
in_reply_to[80], reply_to[256], encoding[80];
|
||||||
char list[MAX_N_ATTR][NAME_LENGTH];
|
char list[MAX_N_ATTR][NAME_LENGTH], str[256];
|
||||||
char att_file[MAX_ATTACHMENTS][256];
|
char att_file[MAX_ATTACHMENTS][256];
|
||||||
|
|
||||||
/* retrieve message */
|
/* retrieve message */
|
||||||
@ -3391,11 +3394,14 @@ char att_file[MAX_ATTACHMENTS][256];
|
|||||||
el_delete_message(lbs, message_id, FALSE, NULL, FALSE, FALSE);
|
el_delete_message(lbs, message_id, FALSE, NULL, FALSE, FALSE);
|
||||||
|
|
||||||
/* move all replies recursively */
|
/* move all replies recursively */
|
||||||
if (reply_to[0])
|
if (getcfg(lbs->name, "Resubmit replies", str) && atoi(str) == 1)
|
||||||
{
|
{
|
||||||
n = strbreak(reply_to, list, MAX_N_ATTR);
|
if (reply_to[0])
|
||||||
for (i=0 ; i<n ; i++)
|
{
|
||||||
el_move_message_thread(lbs, atoi(list[i]));
|
n = strbreak(reply_to, list, MAX_N_ATTR);
|
||||||
|
for (i=0 ; i<n ; i++)
|
||||||
|
el_move_message_thread(lbs, atoi(list[i]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new_id;
|
return new_id;
|
||||||
@ -11477,7 +11483,7 @@ int ka_time[N_MAX_CONNECTION];
|
|||||||
struct in_addr remote_addr[N_MAX_CONNECTION];
|
struct in_addr remote_addr[N_MAX_CONNECTION];
|
||||||
char remote_host[N_MAX_CONNECTION][256];
|
char remote_host[N_MAX_CONNECTION][256];
|
||||||
|
|
||||||
void server_loop(int tcp_port)
|
void server_loop(int tcp_port, int daemon)
|
||||||
{
|
{
|
||||||
int status, i, n, n_error, authorized, min, i_min, i_conn, length;
|
int status, i, n, n_error, authorized, min, i_min, i_conn, length;
|
||||||
struct sockaddr_in serv_addr, acc_addr;
|
struct sockaddr_in serv_addr, acc_addr;
|
||||||
@ -11562,14 +11568,103 @@ struct stat cfg_stat;
|
|||||||
/* open configuration file */
|
/* open configuration file */
|
||||||
getcfg("dummy", "dummy", str);
|
getcfg("dummy", "dummy", str);
|
||||||
|
|
||||||
|
/* initiate daemon */
|
||||||
|
if (daemon)
|
||||||
|
{
|
||||||
|
printf("Becoming a daemon...\n");
|
||||||
|
ss_daemon_init();
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef OS_UNIX
|
#ifdef OS_UNIX
|
||||||
|
/* create PID file if given as command line parameter or if running under root */
|
||||||
|
|
||||||
|
if (geteuid() == 0 || pidfile[0])
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
char buf[20];
|
||||||
|
struct stat finfo;
|
||||||
|
|
||||||
|
if (pidfile[0] == 0)
|
||||||
|
strcpy(pidfile, PIDFILE);
|
||||||
|
|
||||||
|
/* check if file exists */
|
||||||
|
if (stat(pidfile, &finfo) >= 0)
|
||||||
|
{
|
||||||
|
printf("File \"%s\" exists, using \"%s.%d\" instead.\n", pidfile, pidfile, tcp_port);
|
||||||
|
sprintf(pidfile + strlen(pidfile), ".%d", tcp_port);
|
||||||
|
|
||||||
|
/* check again for the new name */
|
||||||
|
if (stat(pidfile, &finfo) >= 0)
|
||||||
|
{
|
||||||
|
/* never overwrite a file */
|
||||||
|
printf("Refuse to overwrite existing file \"%s\".\n", pidfile);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fd = open(pidfile, O_CREAT | O_RDWR, 0644);
|
||||||
|
if (fd < 0)
|
||||||
|
{
|
||||||
|
sprintf(str, "Error creating pid file \"%s\"", pidfile);
|
||||||
|
perror(str);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf(buf, "%d\n", (int)getpid());
|
||||||
|
if (write(fd, buf, strlen(buf)) == -1)
|
||||||
|
{
|
||||||
|
sprintf(str, "Error writing to pid file \"%s\"", pidfile);
|
||||||
|
perror(str);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
|
||||||
/* install signal handler */
|
/* install signal handler */
|
||||||
signal(SIGTERM, ctrlc_handler);
|
signal(SIGTERM, ctrlc_handler);
|
||||||
signal(SIGINT, ctrlc_handler);
|
signal(SIGINT, ctrlc_handler);
|
||||||
signal(SIGPIPE, SIG_IGN);
|
signal(SIGPIPE, SIG_IGN);
|
||||||
|
|
||||||
|
/* give up root privilege */
|
||||||
|
|
||||||
|
if (geteuid() == 0)
|
||||||
|
{
|
||||||
|
if (!getcfg("global", "Grp", str) || setgroup(str) < 0)
|
||||||
|
{
|
||||||
|
printf("Falling back to default group \"elog\"\n");
|
||||||
|
if (setgroup("elog") < 0)
|
||||||
|
{
|
||||||
|
printf("Falling back to default group \"%s\"\n", DEFAULT_GROUP);
|
||||||
|
if (setgroup(DEFAULT_GROUP) < 0)
|
||||||
|
{
|
||||||
|
printf("Refuse to run as setgid root.\n");
|
||||||
|
printf("Please consider to define a Grp statement in configuration file\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!getcfg("global", "Usr", str) || setuser(str) < 0)
|
||||||
|
{
|
||||||
|
printf("Falling back to default user \"elog\"\n");
|
||||||
|
if (setuser("elog") < 0)
|
||||||
|
{
|
||||||
|
printf("Falling back to default user \"%s\"\n", DEFAULT_USER);
|
||||||
|
if (setuser(DEFAULT_USER) < 0)
|
||||||
|
{
|
||||||
|
printf("Refuse to run as setuid root.\n");
|
||||||
|
printf("Please consider to define a Usr statement in configuration file\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* build logbook indices */
|
||||||
|
if (el_index_logbooks(FALSE) != EL_SUCCESS)
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
|
||||||
/* listen for connection */
|
/* listen for connection */
|
||||||
status = listen(lsock, SOMAXCONN);
|
status = listen(lsock, SOMAXCONN);
|
||||||
if (status < 0)
|
if (status < 0)
|
||||||
@ -12503,6 +12598,12 @@ char read_pwd[80], write_pwd[80], admin_pwd[80], str[256], logbook[256];
|
|||||||
time_t now;
|
time_t now;
|
||||||
struct tm *tms;
|
struct tm *tms;
|
||||||
|
|
||||||
|
#ifdef OS_UNIX
|
||||||
|
/* save gid/uid to regain later */
|
||||||
|
orig_gid = getegid();
|
||||||
|
orig_uid = geteuid();
|
||||||
|
#endif
|
||||||
|
|
||||||
/* register cleanup function */
|
/* register cleanup function */
|
||||||
atexit(cleanup);
|
atexit(cleanup);
|
||||||
|
|
||||||
@ -12541,7 +12642,7 @@ struct tm *tms;
|
|||||||
if (fh < 0)
|
if (fh < 0)
|
||||||
{
|
{
|
||||||
printf("Configuration file \"%s\" not found.\n", config_file);
|
printf("Configuration file \"%s\" not found.\n", config_file);
|
||||||
return 1;
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
close(fh);
|
close(fh);
|
||||||
|
|
||||||
@ -12570,7 +12671,7 @@ struct tm *tms;
|
|||||||
printf("Actual date/time: %02d%02d%02d_%02d%02d%02d\n",
|
printf("Actual date/time: %02d%02d%02d_%02d%02d%02d\n",
|
||||||
tms->tm_year % 100, tms->tm_mon+1, tms->tm_mday,
|
tms->tm_year % 100, tms->tm_mon+1, tms->tm_mday,
|
||||||
tms->tm_hour, tms->tm_min, tms->tm_sec);
|
tms->tm_hour, tms->tm_min, tms->tm_sec);
|
||||||
return 0;
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
else if (argv[i][0] == '-')
|
else if (argv[i][0] == '-')
|
||||||
{
|
{
|
||||||
@ -12613,149 +12714,36 @@ usage:
|
|||||||
printf(" -l <logbook> specify logbook for -r and -w commands\n\n");
|
printf(" -l <logbook> specify logbook for -r and -w commands\n\n");
|
||||||
printf(" -k do not use keep-alive\n");
|
printf(" -k do not use keep-alive\n");
|
||||||
printf(" -f path/filename for PID file\n\n");
|
printf(" -f path/filename for PID file\n\n");
|
||||||
return 0;
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get port from configuration file */
|
if ((read_pwd[0] || write_pwd[0] || admin_pwd[0]) && !logbook[0])
|
||||||
if (tcp_port_cl != 0)
|
|
||||||
tcp_port = tcp_port_cl;
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if (getcfg("global", "Port", str))
|
printf("Must specify a lookbook via the -l parameter.\n");
|
||||||
tcp_port = atoi(str);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* initiate daemon */
|
|
||||||
if (daemon)
|
|
||||||
{
|
|
||||||
printf("Becoming a daemon...\n");
|
|
||||||
ss_daemon_init();
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef OS_UNIX
|
|
||||||
/* create PID file if given as command line parameter or if running under root */
|
|
||||||
|
|
||||||
if (!read_pwd[0] && !write_pwd[0] && !admin_pwd[0])
|
|
||||||
{
|
|
||||||
if (geteuid() == 0 || pidfile[0])
|
|
||||||
{
|
|
||||||
int fd;
|
|
||||||
char buf[20];
|
|
||||||
struct stat finfo;
|
|
||||||
|
|
||||||
if (pidfile[0] == 0)
|
|
||||||
strcpy(pidfile, PIDFILE);
|
|
||||||
|
|
||||||
/* check if file exists */
|
|
||||||
if (stat(pidfile, &finfo) >= 0)
|
|
||||||
{
|
|
||||||
printf("File \"%s\" exists, using \"%s.%d\" instead.\n", pidfile, pidfile, tcp_port);
|
|
||||||
sprintf(pidfile + strlen(pidfile), ".%d", tcp_port);
|
|
||||||
|
|
||||||
/* check again for the new name */
|
|
||||||
if (stat(pidfile, &finfo) >= 0)
|
|
||||||
{
|
|
||||||
/* never overwrite a file */
|
|
||||||
printf("Refuse to overwrite existing file \"%s\".\n", pidfile);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fd = open(pidfile, O_CREAT | O_RDWR, 0644);
|
|
||||||
if (fd < 0)
|
|
||||||
{
|
|
||||||
sprintf(str, "Error creating pid file \"%s\"", pidfile);
|
|
||||||
perror(str);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
sprintf(buf, "%d\n", (int)getpid());
|
|
||||||
if (write(fd, buf, strlen(buf)) == -1)
|
|
||||||
{
|
|
||||||
sprintf(str, "Error writing to pid file \"%s\"", pidfile);
|
|
||||||
perror(str);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* save gid/uid to regain later for deleting the PID file */
|
|
||||||
orig_gid = getegid();
|
|
||||||
orig_uid = geteuid();
|
|
||||||
|
|
||||||
/* give up root privilege */
|
|
||||||
|
|
||||||
if (geteuid() == 0)
|
|
||||||
{
|
|
||||||
if (!getcfg("global", "Grp", str) || setgroup(str) < 0)
|
|
||||||
{
|
|
||||||
printf("Falling back to default group \"elog\"\n");
|
|
||||||
if (setgroup("elog") < 0)
|
|
||||||
{
|
|
||||||
printf("Falling back to default group \"%s\"\n", DEFAULT_GROUP);
|
|
||||||
if (setgroup(DEFAULT_GROUP) < 0)
|
|
||||||
{
|
|
||||||
printf("Refuse to run as setgid root.\n");
|
|
||||||
printf("Please consider to define a Grp statement in configuration file\n");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!getcfg("global", "Usr", str) || setuser(str) < 0)
|
|
||||||
{
|
|
||||||
printf("Falling back to default user \"elog\"\n");
|
|
||||||
if (setuser("elog") < 0)
|
|
||||||
{
|
|
||||||
printf("Falling back to default user \"%s\"\n", DEFAULT_USER);
|
|
||||||
if (setuser(DEFAULT_USER) < 0)
|
|
||||||
{
|
|
||||||
printf("Refuse to run as setuid root.\n");
|
|
||||||
printf("Please consider to define a Usr statement in configuration file\n");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (read_pwd[0])
|
if (read_pwd[0])
|
||||||
{
|
{
|
||||||
if (!logbook[0])
|
|
||||||
{
|
|
||||||
printf("Must specify a lookbook via the -l parameter.\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
do_crypt(read_pwd, str);
|
do_crypt(read_pwd, str);
|
||||||
create_password(logbook, "Read Password", str);
|
create_password(logbook, "Read Password", str);
|
||||||
return 0;
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (write_pwd[0])
|
if (write_pwd[0])
|
||||||
{
|
{
|
||||||
if (!logbook[0])
|
|
||||||
{
|
|
||||||
printf("Must specify a lookbook via the -l parameter.\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
do_crypt(write_pwd, str);
|
do_crypt(write_pwd, str);
|
||||||
create_password(logbook, "Write Password", str);
|
create_password(logbook, "Write Password", str);
|
||||||
return 0;
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (admin_pwd[0])
|
if (admin_pwd[0])
|
||||||
{
|
{
|
||||||
if (!logbook[0])
|
|
||||||
{
|
|
||||||
printf("Must specify a lookbook via the -l parameter.\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
do_crypt(admin_pwd, str);
|
do_crypt(admin_pwd, str);
|
||||||
create_password(logbook, "Admin Password", str);
|
create_password(logbook, "Admin Password", str);
|
||||||
return 0;
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* extract resource directory from configuration file if not given */
|
/* extract resource directory from configuration file if not given */
|
||||||
@ -12800,11 +12788,16 @@ usage:
|
|||||||
printf("Logbook dir : %s\n", logbook_dir[0] ? logbook_dir : "current dir");
|
printf("Logbook dir : %s\n", logbook_dir[0] ? logbook_dir : "current dir");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* build logbook indices */
|
/* get port from configuration file */
|
||||||
if (el_index_logbooks(FALSE) != EL_SUCCESS)
|
if (tcp_port_cl != 0)
|
||||||
exit(EXIT_FAILURE);
|
tcp_port = tcp_port_cl;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (getcfg("global", "Port", str))
|
||||||
|
tcp_port = atoi(str);
|
||||||
|
}
|
||||||
|
|
||||||
server_loop(tcp_port);
|
server_loop(tcp_port, daemon);
|
||||||
|
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user