From owner-p4-projects@FreeBSD.ORG Sat Feb 4 19:43:23 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 8CB4016A423; Sat, 4 Feb 2006 19:43:23 +0000 (GMT) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4400016A420 for ; Sat, 4 Feb 2006 19:43:23 +0000 (GMT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id EE8A843D46 for ; Sat, 4 Feb 2006 19:43:22 +0000 (GMT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k14JhMZ2042073 for ; Sat, 4 Feb 2006 19:43:22 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k14JhMxd042070 for perforce@freebsd.org; Sat, 4 Feb 2006 19:43:22 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Sat, 4 Feb 2006 19:43:22 GMT Message-Id: <200602041943.k14JhMxd042070@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson To: Perforce Change Reviews Cc: Subject: PERFORCE change 91098 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Feb 2006 19:43:24 -0000 http://perforce.freebsd.org/chv.cgi?CH=91098 Change 91098 by rwatson@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 __FBSDID("$FreeBSD$"); @@ -45,36 +39,17 @@ * login -f name (for pre-authenticated login: datakit, xterm, etc.) */ -#include -#include -#include -#include -#include -#include +#include #include #include #include #include -#include -#include -#include #include -#include -#include #include -#include -#include -#include -#include -#include - -#include -#include #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."); }