PERFORCE change 93605 for review
Robert Watson
rwatson at FreeBSD.org
Sun Mar 19 21:52:26 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=93605
Change 93605 by rwatson at rwatson_peppercorn on 2006/03/19 21:49:49
Set some syslog() calls to LOG_DEBUG and LOG_ERR instead of
LOG_INFO. Remove carriage returns from log messages.
Affected files ...
.. //depot/projects/trustedbsd/openbsm/bin/auditd/auditd.c#15 edit
Differences ...
==== //depot/projects/trustedbsd/openbsm/bin/auditd/auditd.c#15 (text+ko) ====
@@ -30,7 +30,7 @@
*
* @APPLE_BSD_LICENSE_HEADER_END@
*
- * $P4: //depot/projects/trustedbsd/openbsm/bin/auditd/auditd.c#14 $
+ * $P4: //depot/projects/trustedbsd/openbsm/bin/auditd/auditd.c#15 $
*/
#include <sys/types.h>
@@ -127,7 +127,7 @@
const char *sep = "/";
curdir = dirent->dirname;
- syslog(LOG_INFO, "dir = %s\n", dirent->dirname);
+ syslog(LOG_DEBUG, "dir = %s", dirent->dirname);
fn = malloc(strlen(curdir) + strlen(sep) + (2 * POSTFIX_LEN) + 1);
if (fn == NULL)
@@ -158,10 +158,10 @@
*ptr = '.';
strcpy(ptr+1, TS);
if (rename(oldname, lastfile) != 0)
- syslog(LOG_ERR, "Could not rename %s to %s \n",
+ syslog(LOG_ERR, "Could not rename %s to %s",
oldname, lastfile);
else
- syslog(LOG_INFO, "renamed %s to %s \n",
+ syslog(LOG_INFO, "renamed %s to %s",
oldname, lastfile);
}
free(lastfile);
@@ -241,7 +241,7 @@
/* Try until we succeed. */
while ((dirent = TAILQ_FIRST(&dir_q))) {
if ((fn = affixdir(timestr, dirent)) == NULL) {
- syslog(LOG_INFO, "Failed to swap log at time %s\n",
+ syslog(LOG_INFO, "Failed to swap log at time %s",
timestr);
return (-1);
}
@@ -250,7 +250,7 @@
* Create and open the file; then close and pass to the
* kernel if all went well.
*/
- syslog(LOG_INFO, "New audit file is %s\n", fn);
+ syslog(LOG_INFO, "New audit file is %s", fn);
#ifdef AUDIT_REVIEW_GROUP
fd = open_trail(fn, uid, gid);
#else
@@ -262,7 +262,7 @@
error = auditctl(fn);
if (error) {
syslog(LOG_ERR,
- "auditctl failed setting log file! : %s\n",
+ "auditctl failed setting log file! : %s",
strerror(errno));
close(fd);
} else {
@@ -284,7 +284,7 @@
free(dirent->dirname);
free(dirent);
}
- syslog(LOG_INFO, "Log directories exhausted\n");
+ syslog(LOG_ERR, "Log directories exhausted\n");
return (-1);
}
@@ -326,7 +326,7 @@
allhardcount = 0;
if (swap_audit_file() == -1) {
- syslog(LOG_ERR, "Could not swap audit file\n");
+ syslog(LOG_ERR, "Could not swap audit file");
/*
* XXX Faulty directory listing? - user should be given
* XXX an opportunity to change the audit_control file
@@ -341,16 +341,16 @@
* XXX is generated here?
*/
if (0 == (ret = getacmin(&minval))) {
- syslog(LOG_INFO, "min free = %d\n", minval);
+ syslog(LOG_DEBUG, "min free = %d\n", minval);
if (auditon(A_GETQCTRL, &qctrl, sizeof(qctrl)) != 0) {
syslog(LOG_ERR,
- "could not get audit queue settings\n");
+ "could not get audit queue settings");
return (-1);
}
qctrl.aq_minfree = minval;
if (auditon(A_SETQCTRL, &qctrl, sizeof(qctrl)) != 0) {
syslog(LOG_ERR,
- "could not set audit queue settings\n");
+ "could not set audit queue settings");
return (-1);
}
}
@@ -372,20 +372,20 @@
/* Generate an audit record. */
if ((aufd = au_open()) == -1)
- syslog(LOG_ERR, "Could not create audit shutdown event.\n");
+ syslog(LOG_ERR, "Could not create audit shutdown event.");
else {
if ((tok = au_to_text("auditd::Audit shutdown")) != NULL)
au_write(aufd, tok);
if (au_close(aufd, 1, AUE_audit_shutdown) == -1)
syslog(LOG_ERR,
- "Could not close audit shutdown event.\n");
+ "Could not close audit shutdown event.");
}
/* Flush contents. */
cond = AUC_DISABLED;
err_ret = auditon(A_SETCOND, &cond, sizeof(cond));
if (err_ret != 0) {
- syslog(LOG_ERR, "Disabling audit failed! : %s\n",
+ syslog(LOG_ERR, "Disabling audit failed! : %s",
strerror(errno));
err_ret = 1;
}
@@ -396,15 +396,15 @@
free_dir_q();
if ((remove(AUDITD_PIDFILE) == -1) || err_ret) {
- syslog(LOG_ERR, "Could not unregister\n");
+ syslog(LOG_ERR, "Could not unregister");
audit_warn_postsigterm();
return (1);
}
endac();
if (close(triggerfd) != 0)
- syslog(LOG_ERR, "Error closing control file\n");
- syslog(LOG_INFO, "Finished.\n");
+ syslog(LOG_ERR, "Error closing control file");
+ syslog(LOG_INFO, "Finished");
return (0);
}
@@ -437,23 +437,22 @@
/* Set up the signal hander. */
if (signal(SIGTERM, relay_signal) == SIG_ERR) {
syslog(LOG_ERR,
- "Could not set signal handler for SIGTERM\n");
+ "Could not set signal handler for SIGTERM");
fail_exit();
}
if (signal(SIGCHLD, relay_signal) == SIG_ERR) {
syslog(LOG_ERR,
- "Could not set signal handler for SIGCHLD\n");
+ "Could not set signal handler for SIGCHLD");
fail_exit();
}
if (signal(SIGHUP, relay_signal) == SIG_ERR) {
syslog(LOG_ERR,
- "Could not set signal handler for SIGHUP\n");
+ "Could not set signal handler for SIGHUP");
fail_exit();
}
if ((pidfile = fopen(AUDITD_PIDFILE, "a")) == NULL) {
- syslog(LOG_ERR,
- "Could not open PID file\n");
+ syslog(LOG_ERR, "Could not open PID file");
audit_warn_tmpfile();
return (-1);
}
@@ -462,7 +461,7 @@
fd = fileno(pidfile);
if (flock(fd, LOCK_EX | LOCK_NB) < 0) {
syslog(LOG_ERR,
- "PID file is locked (is another auditd running?).\n");
+ "PID file is locked (is another auditd running?).");
audit_warn_ebusy();
return (-1);
}
@@ -516,7 +515,7 @@
switch(trigger) {
case AUDIT_TRIGGER_LOW_SPACE:
- syslog(LOG_INFO, "Got low space trigger\n");
+ syslog(LOG_INFO, "Got low space trigger");
if (dirent && (dirent->softlim != 1)) {
TAILQ_REMOVE(&dir_q, dirent, dirs);
/* Add this node to the end of the list. */
@@ -526,7 +525,7 @@
if (TAILQ_NEXT(TAILQ_FIRST(&dir_q), dirs) != NULL &&
swap_audit_file() == -1)
- syslog(LOG_ERR, "Error swapping audit file\n");
+ syslog(LOG_ERR, "Error swapping audit file");
/*
* Check if the next dir has already reached its soft
@@ -548,7 +547,7 @@
break;
case AUDIT_TRIGGER_NO_SPACE:
- syslog(LOG_INFO, "Got no space trigger\n");
+ syslog(LOG_INFO, "Got no space trigger");
/* Delete current dir, go on to next. */
TAILQ_REMOVE(&dir_q, dirent, dirs);
@@ -557,7 +556,7 @@
free(dirent);
if (swap_audit_file() == -1)
- syslog(LOG_ERR, "Error swapping audit file\n");
+ syslog(LOG_ERR, "Error swapping audit file");
/* We are out of log directories. */
audit_warn_allhard(++allhardcount);
@@ -568,21 +567,21 @@
* Create a new file and swap with the one being used in
* kernel
*/
- syslog(LOG_INFO, "Got open new trigger\n");
+ syslog(LOG_INFO, "Got open new trigger");
if (swap_audit_file() == -1)
- syslog(LOG_ERR, "Error swapping audit file\n");
+ syslog(LOG_ERR, "Error swapping audit file");
break;
case AUDIT_TRIGGER_READ_FILE:
- syslog(LOG_INFO, "Got read file trigger\n");
+ syslog(LOG_INFO, "Got read file trigger");
if (read_control_file() == -1)
- syslog(LOG_ERR, "Error in audit control file\n");
+ syslog(LOG_ERR, "Error in audit control file");
if (config_audit_controls() == -1)
- syslog(LOG_ERR, "Error setting audit controls\n");
+ syslog(LOG_ERR, "Error setting audit controls");
break;
default:
- syslog(LOG_ERR, "Got unknown trigger %d\n", trigger);
+ syslog(LOG_ERR, "Got unknown trigger %d", trigger);
break;
}
}
@@ -607,24 +606,24 @@
for (;;) {
num = read(triggerfd, &trigger, sizeof(trigger));
if ((num == -1) && (errno != EINTR)) {
- syslog(LOG_ERR, "%s: error %d\n", __FUNCTION__, errno);
+ syslog(LOG_ERR, "%s: error %d", __FUNCTION__, errno);
return (-1);
}
if (sigterms != sigterms_handled) {
- syslog(LOG_INFO, "%s: SIGTERM", __FUNCTION__);
+ syslog(LOG_DEBUG, "%s: SIGTERM", __FUNCTION__);
break;
}
if (sighups != sighups_handled) {
- syslog(LOG_INFO, "%s: SIGHUP", __FUNCTION__);
+ syslog(LOG_DEBUG, "%s: SIGHUP", __FUNCTION__);
handle_sighup();
}
if ((num == -1) && (errno == EINTR))
continue;
if (num == 0) {
- syslog(LOG_INFO, "%s: read EOF\n", __FUNCTION__);
+ syslog(LOG_ERR, "%s: read EOF", __FUNCTION__);
return (-1);
}
- syslog(LOG_INFO, "%s: read %d\n", __FUNCTION__, trigger);
+ syslog(LOG_DEBUG, "%s: read %d", __FUNCTION__, trigger);
if (trigger == AUDIT_TRIGGER_CLOSE_AND_DIE)
break;
else
@@ -645,7 +644,7 @@
while ((child = waitpid(-1, &wstatus, WNOHANG)) > 0) {
if (!wstatus)
continue;
- syslog(LOG_INFO, "warn process [pid=%d] %s %d.\n", child,
+ syslog(LOG_INFO, "warn process [pid=%d] %s %d.", child,
((WIFEXITED(wstatus)) ? "exited with non-zero status" :
"exited as a result of signal"),
((WIFEXITED(wstatus)) ? WEXITSTATUS(wstatus) :
@@ -700,7 +699,7 @@
if (ctr == 0)
syslog(LOG_ERR, "No events to class mappings registered.");
else
- syslog(LOG_INFO, "Registered %d event to class mappings.",
+ syslog(LOG_DEBUG, "Registered %d event to class mappings.",
ctr);
/*
@@ -713,7 +712,7 @@
syslog(LOG_ERR,
"Failed to register non-attributable event mask.");
else
- syslog(LOG_INFO,
+ syslog(LOG_DEBUG,
"Registered non-attributable event mask.");
} else
syslog(LOG_ERR,
@@ -735,31 +734,31 @@
token_t *tok;
if ((triggerfd = open(AUDIT_TRIGGER_FILE, O_RDONLY, 0)) < 0) {
- syslog(LOG_ERR, "Error opening trigger file\n");
+ syslog(LOG_ERR, "Error opening trigger file");
fail_exit();
}
TAILQ_INIT(&dir_q);
if (read_control_file() == -1) {
- syslog(LOG_ERR, "Error reading control file\n");
+ syslog(LOG_ERR, "Error reading control file");
fail_exit();
}
/* Generate an audit record. */
if ((aufd = au_open()) == -1)
- syslog(LOG_ERR, "Could not create audit startup event.\n");
+ syslog(LOG_ERR, "Could not create audit startup event.");
else {
if ((tok = au_to_text("auditd::Audit startup")) != NULL)
au_write(aufd, tok);
if (au_close(aufd, 1, AUE_audit_startup) == -1)
syslog(LOG_ERR,
- "Could not close audit startup event.\n");
+ "Could not close audit startup event.");
}
if (config_audit_controls() == 0)
- syslog(LOG_INFO, "Audit controls init successful\n");
+ syslog(LOG_INFO, "Audit controls init successful");
else
- syslog(LOG_INFO, "Audit controls init failed\n");
+ syslog(LOG_ERR, "Audit controls init failed");
}
int
@@ -800,22 +799,22 @@
#else
openlog("auditd", LOG_CONS | LOG_PID, LOG_AUTH);
#endif
- syslog(LOG_INFO, "starting...\n");
+ syslog(LOG_INFO, "starting...");
if (debug == 0 && daemon(0, 0) == -1) {
- syslog(LOG_ERR, "Failed to daemonize\n");
+ syslog(LOG_ERR, "Failed to daemonize");
exit(1);
}
if (register_daemon() == -1) {
- syslog(LOG_ERR, "Could not register as daemon\n");
+ syslog(LOG_ERR, "Could not register as daemon");
exit(1);
}
setup();
rc = wait_for_events();
- syslog(LOG_INFO, "auditd exiting.\n");
+ syslog(LOG_INFO, "auditd exiting.");
exit(rc);
}
More information about the trustedbsd-cvs
mailing list