Be careful with openlog/syslog library calls
#include
void foo(){
openlog("FOO", LOG_PID|LOG_PERROR, LOG_USER);
syslog(LOG_INFO, "logging from foo");
}
int main(void){
openlog("MAIN", LOG_PID|LOG_PERROR, LOG_AUTH);
foo();
syslog(LOG_INFO, "logging from MAIN");
}
Ever wonder why sometimes syslog secretly sends logging message to the wrong facility behind your back? It appears openlog call has a process wide effect,
#include
void openlog(const char *ident, int option, int facility);
void syslog(int priority, const char *format, ...);
void closelog(void);
Facility number can be changed at any place in the source code by a call to openlog. Any subsequent call to syslog will use the new facility number specified. In my opinion, it's a bad form of programming to use syslog directly in library code. Watch out for this bug when you use syslog.
void foo(){
openlog("FOO", LOG_PID|LOG_PERROR, LOG_USER);
syslog(LOG_INFO, "logging from foo");
}
int main(void){
openlog("MAIN", LOG_PID|LOG_PERROR, LOG_AUTH);
foo();
syslog(LOG_INFO, "logging from MAIN");
}
Ever wonder why sometimes syslog secretly sends logging message to the wrong facility behind your back? It appears openlog call has a process wide effect,
#include
void openlog(const char *ident, int option, int facility);
void syslog(int priority, const char *format, ...);
void closelog(void);
Facility number can be changed at any place in the source code by a call to openlog. Any subsequent call to syslog will use the new facility number specified. In my opinion, it's a bad form of programming to use syslog directly in library code. Watch out for this bug when you use syslog.
<< Home