From owner-freebsd-audit Mon Jul 1 11:41:48 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4AE6C37B400; Mon, 1 Jul 2002 11:41:44 -0700 (PDT) Received: from numeri.campus.luth.se (numeri.campus.luth.se [130.240.197.103]) by mx1.FreeBSD.org (Postfix) with ESMTP id 22E5343E0A; Mon, 1 Jul 2002 11:41:43 -0700 (PDT) (envelope-from k@numeri.campus.luth.se) Received: (from k@localhost) by numeri.campus.luth.se (8.11.6/8.11.6) id g61IffF50336; Mon, 1 Jul 2002 20:41:41 +0200 (CEST) (envelope-from k) Date: Mon, 1 Jul 2002 20:41:40 +0200 From: Johan Karlsson To: freebsd-audit@freebsd.org Cc: sheldonh@freebsd.org Subject: accounting to appen only file Message-ID: <20020701204140.A49191@numeri.campus.luth.se> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="PNTmBPCT7hxwcZjr" Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --PNTmBPCT7hxwcZjr Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi I would like to get your comments on the attached patch. It changes the opening of the accounting file to be opened in append mode. According to acct(5) the file should only be appended to. See PR 7169 for more details. I have been running with the equivalent patch on stable for a while and it works as supposed for me. However, since I'm not that familiar with the vn code I would like to get feedback if this might be harmfull in any way. /Johan K -- Johan Karlsson mailto:johan@freebsd.org --PNTmBPCT7hxwcZjr Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="acct.diff" Index: src/sys/kern//kern_acct.c =================================================================== RCS file: /home/ncvs/src/sys/kern/kern_acct.c,v retrieving revision 1.44 diff -u -r1.44 kern_acct.c --- src/sys/kern//kern_acct.c 16 May 2002 21:28:11 -0000 1.44 +++ src/sys/kern//kern_acct.c 30 Jun 2002 19:39:55 -0000 @@ -119,6 +119,9 @@ struct nameidata nd; int error, flags; + /* Open file for append writing only */ + flags = FWRITE | FAPPEND; + /* Make sure that the caller is root. */ error = suser(td); if (error) @@ -126,20 +129,19 @@ mtx_lock(&Giant); /* - * If accounting is to be started to a file, open that file for - * writing and make sure it's a 'normal'. + * If accounting is to be started to a file, open that file + * and make sure it's a 'normal'. */ if (SCARG(uap, path) != NULL) { NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, SCARG(uap, path), td); - flags = FWRITE; error = vn_open(&nd, &flags, 0); if (error) goto done2; NDFREE(&nd, NDF_ONLY_PNBUF); VOP_UNLOCK(nd.ni_vp, 0, td); if (nd.ni_vp->v_type != VREG) { - vn_close(nd.ni_vp, FWRITE, td->td_ucred, td); + vn_close(nd.ni_vp, flags, td->td_ucred, td); error = EACCES; goto done2; } @@ -151,7 +153,7 @@ */ if (acctp != NULLVP || savacctp != NULLVP) { callout_stop(&acctwatch_callout); - error = vn_close((acctp != NULLVP ? acctp : savacctp), FWRITE, + error = vn_close((acctp != NULLVP ? acctp : savacctp), flags, td->td_ucred, td); acctp = savacctp = NULLVP; } --PNTmBPCT7hxwcZjr-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message