- Just discovered some patches originating from Debian

project - included most of them as they make sense.
  (Hint: People, if you get fixes, please drop me a note
  and a .diff - I won't be biting you)
This commit is contained in:
Thomas Ries
2007-05-25 18:58:10 +00:00
parent b2084e47ef
commit 4ff6e84e72
6 changed files with 61 additions and 22 deletions

View File

@@ -1,5 +1,9 @@
0.6.0
=====
25-May-2007: - Just discovered some patches originating from Debian
project - included most of them as they make sense.
(Hint: People, if you get fixes, please drop me a note
and a .diff - I won't be biting you)
24-May-2007: - new feature: can masquerade User-agent header
- new feature: can add ;rport to my own Via Headers
13-May-2007: - deal with locally running UAs on same host (inboud IF side)

View File

@@ -66,6 +66,14 @@ static int silence_level=1;
*/
static pthread_mutex_t log_mutex = PTHREAD_MUTEX_INITIALIZER;
void log_init(void) {
openlog(NULL,LOG_NDELAY|LOG_PID,LOG_DAEMON);
}
void log_end(void) {
closelog();
}
void log_set_pattern(unsigned int pattern) {
debug_pattern=pattern;
return;
@@ -239,7 +247,7 @@ void log_debug(unsigned int class, char *file, int line, const char *format, ...
va_copy(ap_copy, ap);
vsnprintf(string, sizeof(string), format, ap_copy);
va_end(ap_copy);
syslog(LOG_USER|LOG_DEBUG, "%s:%i %s", file, line, string);
syslog(LOG_DAEMON|LOG_DEBUG, "%s:%i %s", file, line, string);
}
/*
* Log to TCP
@@ -296,7 +304,7 @@ void log_error(char *file, int line, const char *format, ...) {
va_copy(ap_copy, ap);
vsnprintf(string, sizeof(string), format, ap_copy);
va_end(ap_copy);
syslog(LOG_USER|LOG_WARNING, "%s:%i ERROR:%s", file, line, string);
syslog(LOG_DAEMON|LOG_WARNING, "%s:%i ERROR:%s", file, line, string);
}
/*
* Log to TCP
@@ -353,7 +361,7 @@ void log_warn(char *file, int line, const char *format, ...) {
va_copy(ap_copy, ap);
vsnprintf(string, sizeof(string), format, ap_copy);
va_end(ap_copy);
syslog(LOG_USER|LOG_NOTICE, "%s:%i WARNING:%s", file, line, string);
syslog(LOG_DAEMON|LOG_NOTICE, "%s:%i WARNING:%s", file, line, string);
}
/*
* Log to TCP
@@ -410,7 +418,7 @@ void log_info(char *file, int line, const char *format, ...) {
va_copy(ap_copy, ap);
vsnprintf(string, sizeof(string), format, ap_copy);
va_end(ap_copy);
syslog(LOG_USER|LOG_NOTICE, "%s:%i INFO:%s", file, line, string);
syslog(LOG_DAEMON|LOG_NOTICE, "%s:%i INFO:%s", file, line, string);
}
/*
* Log to TCP

View File

@@ -38,6 +38,8 @@
#define DBCLASS_RTPBABL 0x00002000 /* RTP babble */
#define DBCLASS_ALL 0xffffffff /* All classes */
void log_init(void);
void log_end(void);
void log_set_pattern(unsigned int pattern);
unsigned int log_get_pattern(void);

View File

@@ -97,6 +97,8 @@ int main (int argc, char *argv[])
char *pidfilename=NULL;
struct sigaction act;
log_init();
log_set_stderr(1);
/*
@@ -120,7 +122,6 @@ int main (int argc, char *argv[])
* prepare default configuration
*/
make_default_config();
log_set_pattern(configuration.debuglevel);
/*
@@ -202,8 +203,6 @@ int main (int argc, char *argv[])
log_set_pattern(configuration.debuglevel);
log_set_listen_port(configuration.debugport);
/* change user and group IDs */
secure_enviroment();
/* daemonize if requested to */
if (configuration.daemonize) {
@@ -216,24 +215,23 @@ int main (int argc, char *argv[])
INFO("daemonized, pid=%i", getpid());
}
/* write PID file of main thread */
/* prepare for creating PID file */
if (pidfilename == NULL) pidfilename = configuration.pid_file;
if (pidfilename) {
FILE *pidfile;
DEBUGC(DBCLASS_CONFIG,"creating PID file [%s]", pidfilename);
sts=unlink(configuration.pid_file);
if ((sts==0) ||(errno == ENOENT)) {
if ((pidfile=fopen(pidfilename, "w"))) {
fprintf(pidfile,"%i\n",(int)getpid());
fclose(pidfile);
} else {
WARN("couldn't create new PID file: %s", strerror(errno));
}
} else {
WARN("couldn't delete old PID file: %s", strerror(errno));
}
/* If going to dive into a chroot jail, create a PID file outside
* the jail, too. However, it will be owned by root and not deleted
* on process termination... */
if (configuration.chrootjail && ((getuid()==0) || (geteuid()==0))) {
if (pidfilename) createpidfile(pidfilename);
}
/* change user and group IDs */
secure_enviroment();
/* write PID file of main thread as changed siproxd user and
* possibly into the chroot jail file tree */
if (pidfilename) createpidfile(pidfilename);
/* initialize the RTP proxy */
sts=rtpproxy_init();
if (sts != STS_SUCCESS) {
@@ -565,6 +563,7 @@ int main (int argc, char *argv[])
}
/* END */
log_end();
return 0;
} /* main */

View File

@@ -162,6 +162,7 @@ int get_ip_by_ifname(char *ifname, struct in_addr *retaddr); /*X*/
int get_interface_ip(int interface, struct in_addr *retaddr); /*X*/
char *utils_inet_ntoa(struct in_addr in);
int utils_inet_aton(const char *cp, struct in_addr *inp);
int createpidfile(char *pidfilename); /*X*/
/* sip_utils.c */
osip_message_t * msg_make_template_reply (sip_ticket_t *ticket, int code);

View File

@@ -19,6 +19,7 @@
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
@@ -501,3 +502,27 @@ int utils_inet_aton(const char *cp, struct in_addr *inp) {
#error "need inet_pton() or inet_aton()"
#endif
}
/*
* Create the PID file
*/
int createpidfile(char *pidfilename) {
FILE *f = NULL;
int sts;
DEBUGC(DBCLASS_CONFIG,"creating PID file [%s]", pidfilename);
sts=unlink(pidfilename);
if ((sts==0) || (errno == ENOENT)) {
if ((f=fopen(pidfilename, "w"))) {
fprintf(f,"%i\n",(int)getpid());
fclose(f);
} else {
WARN("couldn't create new PID file: %s", strerror(errno));
return STS_FAILURE;
}
} else {
WARN("couldn't delete old PID file: %s", strerror(errno));
return STS_FAILURE;
}
return STS_SUCCESS;
}