accounting to appen only file
Johan Karlsson <[email protected]>
| Newsgroups | gmane.os.freebsd.devel.audit |
|---|---|
| Message-ID | <[email protected]> |
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:[email protected]
acct.diff
(text/plain, 1.5 KB)
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;
}