PERFORCE change 91098 for review
Robert Watson
rwatson at FreeBSD.org
Sat Feb 4 19:43:22 GMT 2006
http://perforce.freebsd.org/chv.cgi?CH=91098
Change 91098 by rwatson at rwatson_zoo on 2006/02/04 19:43:03
Remove trailing white space.
Remove unneeded includes.
Use errx(3) and err(3) instead of fprintf()/exit().
Affected files ...
.. //depot/projects/trustedbsd/audit3/usr.bin/login/login_audit.c#5 edit
Differences ...
==== //depot/projects/trustedbsd/audit3/usr.bin/login/login_audit.c#5 (text+ko) ====
@@ -2,20 +2,20 @@
* Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
*
* @APPLE_BSD_LICENSE_HEADER_START@
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
+ * documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
+ * from this software without specific prior written permission.
+ *
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -26,16 +26,10 @@
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* @APPLE_BSD_LICENSE_HEADER_END@
*/
-#if 0
-#ifndef lint
-static char sccsid[] = "@(#)login.c 8.4 (Berkeley) 4/2/94";
-#endif
-#endif
-
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
@@ -45,36 +39,17 @@
* login -f name (for pre-authenticated login: datakit, xterm, etc.)
*/
-#include <sys/param.h>
-#include <sys/file.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <sys/wait.h>
+#include <sys/types.h>
#include <bsm/libbsm.h>
#include <bsm/audit_uevents.h>
#include <err.h>
#include <errno.h>
-#include <grp.h>
-#include <libutil.h>
-#include <login_cap.h>
#include <pwd.h>
-#include <setjmp.h>
-#include <signal.h>
#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <syslog.h>
-#include <ttyent.h>
-#include <unistd.h>
-
-#include <security/pam_appl.h>
-#include <security/openpam.h>
#include "login.h"
-#include "pathnames.h"
/*
* Audit data
@@ -82,9 +57,9 @@
au_tid_t tid;
/*
- * The following tokens are included in the audit record for a successful
+ * The following tokens are included in the audit record for a successful
* login: header, subject, return.
- */
+ */
void
au_login_success(void)
{
@@ -101,61 +76,43 @@
if (auditon(A_GETCOND, &au_cond, sizeof(long)) < 0) {
if (errno == ENOSYS)
return;
- fprintf(stderr,
- "login: Could not determine audit condition\n");
- exit(1);
+ errx(1, "login: Could not determine audit condition");
}
if (au_cond == AUC_NOAUDIT)
return;
- /* Compute and set the user's preselection mask. */
- if (au_user_mask(pwd->pw_name, &aumask) == -1) {
- fprintf(stderr, "login: Could not set audit mask\n");
- exit(1);
- }
+ /* Compute and set the user's preselection mask. */
+ if (au_user_mask(pwd->pw_name, &aumask) == -1)
+ errx(1, "login: Could not set audit mask\n");
/* Set the audit info for the user. */
auinfo.ai_auid = uid;
auinfo.ai_asid = pid;
bcopy(&tid, &auinfo.ai_termid, sizeof(auinfo.ai_termid));
bcopy(&aumask, &auinfo.ai_mask, sizeof(auinfo.ai_mask));
- if (setaudit(&auinfo) != 0) {
- fprintf(stderr, "login: setaudit failed: %s\n",
- strerror(errno));
- exit(1);
- }
+ if (setaudit(&auinfo) != 0)
+ err(1, "login: setaudit failed");
- if ((aufd = au_open()) == -1) {
- fprintf(stderr, "login: Audit Error: au_open() failed\n");
- exit(1);
- }
+ if ((aufd = au_open()) == -1)
+ errx(1,"login: Audit Error: au_open() failed");
- /* The subject that is created (euid, egid of the current process). */
- if ((tok = au_to_subject32(uid, geteuid(), getegid(),
- uid, gid, pid, pid, &tid)) == NULL) {
- fprintf(stderr,
- "login: Audit Error: au_to_subject32() failed\n");
- exit(1);
- }
+ if ((tok = au_to_subject32(uid, geteuid(), getegid(), uid, gid, pid,
+ pid, &tid)) == NULL)
+ errx(1, "login: Audit Error: au_to_subject32() failed");
au_write(aufd, tok);
- if ((tok = au_to_return32(0, 0)) == NULL) {
- fprintf(stderr,
- "login: Audit Error: au_to_return32() failed\n");
- exit(1);
- }
+ if ((tok = au_to_return32(0, 0)) == NULL)
+ errx(1, "login: Audit Error: au_to_return32() failed");
au_write(aufd, tok);
- if (au_close(aufd, 1, AUE_login) == -1) {
- fprintf(stderr, "login: Audit Record was not committed.\n");
- exit(1);
- }
+ if (au_close(aufd, 1, AUE_login) == -1)
+ errx(1, "login: Audit Record was not committed.");
}
/*
- * The following tokens are included in the audit record for failed
+ * The following tokens are included in the audit record for failed
* login attempts: header, subject, text, return.
- */
+ */
void
au_login_fail(char *errmsg, int na)
{
@@ -170,67 +127,49 @@
if (auditon(A_GETCOND, &au_cond, sizeof(long)) < 0) {
if (errno == ENOSYS)
return;
- fprintf(stderr,
- "login: Could not determine audit condition\n");
- exit(1);
+ errx(1, "login: Could not determine audit condition");
}
if (au_cond == AUC_NOAUDIT)
return;
- if ((aufd = au_open()) == -1) {
- fprintf(stderr, "login: Audit Error: au_open() failed\n");
- exit(1);
- }
+ if ((aufd = au_open()) == -1)
+ errx(1, "login: Audit Error: au_open() failed");
if (na) {
/*
* Non attributable event. Assuming that login is not called
* within a user's session => auid,asid == -1.
*/
- if ((tok = au_to_subject32(-1, geteuid(), getegid(), -1, -1,
- pid, -1, &tid)) == NULL) {
- fprintf(stderr,
- "login: Audit Error: au_to_subject32() failed\n");
- exit(1);
- }
+ if ((tok = au_to_subject32(-1, geteuid(), getegid(), -1, -1,
+ pid, -1, &tid)) == NULL)
+ errx(1, "login: Audit Error: au_to_subject32() failed");
} else {
/* We know the subject -- so use its value instead. */
uid = pwd->pw_uid;
gid = pwd->pw_gid;
if ((tok = au_to_subject32(uid, geteuid(), getegid(), uid,
- gid, pid, pid, &tid)) == NULL) {
- fprintf(stderr,
- "login: Audit Error: au_to_subject32() failed\n");
- exit(1);
- }
+ gid, pid, pid, &tid)) == NULL)
+ errx(1, "login: Audit Error: au_to_subject32() failed");
}
au_write(aufd, tok);
/* Include the error message. */
- if ((tok = au_to_text(errmsg)) == NULL) {
- fprintf(stderr, "login: Audit Error: au_to_text() failed\n");
- exit(1);
- }
+ if ((tok = au_to_text(errmsg)) == NULL)
+ errx(1, "login: Audit Error: au_to_text() failed");
au_write(aufd, tok);
- if ((tok = au_to_return32(1, errno)) == NULL) {
- fprintf(stderr,
- "login: Audit Error: au_to_return32() failed\n");
- exit(1);
- }
+ if ((tok = au_to_return32(1, errno)) == NULL)
+ errx(1, "login: Audit Error: au_to_return32() failed");
au_write(aufd, tok);
- if (au_close(aufd, 1, AUE_login) == -1) {
- fprintf(stderr,
- "login: Audit Error: au_close() was not committed\n");
- exit(1);
- }
+ if (au_close(aufd, 1, AUE_login) == -1)
+ errx(1, "login: Audit Error: au_close() was not committed");
}
/*
* The following tokens are included in the audit record for a logout:
* header, subject, return.
- */
+ */
void
audit_logout(void)
{
@@ -247,36 +186,24 @@
if (auditon(A_GETCOND, &au_cond, sizeof(long)) < 0) {
if (errno == ENOSYS)
return;
- fprintf(stderr,
- "login: Could not determine audit condition\n");
- exit(1);
+ errx(1, "login: Could not determine audit condition");
}
if (au_cond == AUC_NOAUDIT)
return;
- if ((aufd = au_open()) == -1) {
- fprintf(stderr, "login: Audit Error: au_open() failed\n");
- exit(1);
- }
+ if ((aufd = au_open()) == -1)
+ errx(1, "login: Audit Error: au_open() failed");
/* The subject that is created (euid, egid of the current process). */
- if ((tok = au_to_subject32(uid, geteuid(), getegid(),
- uid, gid, pid, pid, &tid)) == NULL) {
- fprintf(stderr,
- "login: Audit Error: au_to_subject32() failed\n");
- exit(1);
- }
+ if ((tok = au_to_subject32(uid, geteuid(), getegid(), uid, gid, pid,
+ pid, &tid)) == NULL)
+ errx(1, "login: Audit Error: au_to_subject32() failed");
au_write(aufd, tok);
- if ((tok = au_to_return32(0, 0)) == NULL) {
- fprintf(stderr,
- "login: Audit Error: au_to_return32() failed\n");
- exit(1);
- }
+ if ((tok = au_to_return32(0, 0)) == NULL)
+ errx(1, "login: Audit Error: au_to_return32() failed");
au_write(aufd, tok);
- if (au_close(aufd, 1, AUE_logout) == -1) {
- fprintf(stderr, "login: Audit Record was not committed.\n");
- exit(1);
- }
+ if (au_close(aufd, 1, AUE_logout) == -1)
+ errx(1, "login: Audit Record was not committed.");
}
To Unsubscribe: send mail to majordomo at trustedbsd.org
with "unsubscribe trustedbsd-cvs" in the body of the message
More information about the trustedbsd-cvs
mailing list