Date: Mon, 1 Jul 2002 20:41:40 +0200 From: Johan Karlsson <johan@freebsd.org> To: freebsd-audit@freebsd.org Cc: sheldonh@freebsd.org Subject: accounting to appen only file Message-ID: <20020701204140.A49191@numeri.campus.luth.se>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
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
[-- Attachment #2 --]
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;
}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020701204140.A49191>
