Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Don't reset file size limit to infinity on exit. I...



details:   https://anonhg.NetBSD.org/src/rev/1ecbab310daf
branches:  trunk
changeset: 485909:1ecbab310daf
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Mon May 08 19:06:36 2000 +0000

description:
Don't reset file size limit to infinity on exit.  Instead, temporarily
raise the limit to infinity when writing out the accounting file.

>From Artur Grabowski <art%stacken.kth.se@localhost>.

diffstat:

 sys/kern/kern_acct.c |  20 +++++++++++++++++++-
 sys/kern/kern_exit.c |   4 ++--
 2 files changed, 21 insertions(+), 3 deletions(-)

diffs (73 lines):

diff -r 1883822d31f3 -r 1ecbab310daf sys/kern/kern_acct.c
--- a/sys/kern/kern_acct.c      Mon May 08 18:51:17 2000 +0000
+++ b/sys/kern/kern_acct.c      Mon May 08 19:06:36 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_acct.c,v 1.48 2000/03/10 01:13:18 enami Exp $     */
+/*     $NetBSD: kern_acct.c,v 1.49 2000/05/08 19:06:36 thorpej Exp $   */
 
 /*-
  * Copyright (c) 1994 Christopher G. Demetriou
@@ -265,6 +265,7 @@
        struct rusage *r;
        struct timeval ut, st, tmp;
        int s, t, error = 0;
+       struct plimit *oplim = NULL;
 
        ACCT_LOCK();
 
@@ -273,6 +274,18 @@
                goto out;
 
        /*
+        * Raise the file limit so that accounting can't be stopped by
+        * the user.
+        *
+        * XXX We should think about the CPU limit, too.
+        */
+       if (p->p_limit->p_refcnt > 1) {
+               oplim = p->p_limit;
+               p->p_limit = limcopy(p->p_limit);
+       }
+       p->p_rlimit[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
+
+       /*
         * Get process accounting information.
         */
 
@@ -326,6 +339,11 @@
        if (error != 0)
                log(LOG_ERR, "Accounting: write failed %d\n", error);
 
+       if (oplim) {
+               limfree(p->p_limit);
+               p->p_limit = oplim;
+       }
+
  out:
        ACCT_UNLOCK();
        return (error);
diff -r 1883822d31f3 -r 1ecbab310daf sys/kern/kern_exit.c
--- a/sys/kern/kern_exit.c      Mon May 08 18:51:17 2000 +0000
+++ b/sys/kern/kern_exit.c      Mon May 08 19:06:36 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_exit.c,v 1.76 2000/03/30 09:27:11 augustss Exp $  */
+/*     $NetBSD: kern_exit.c,v 1.77 2000/05/08 19:06:36 thorpej Exp $   */
 
 /*-
  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -239,7 +239,6 @@
                sp->s_leader = NULL;
        }
        fixjobc(p, p->p_pgrp, 0);
-       p->p_rlimit[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
        (void)acct_process(p);
 #ifdef KTRACE
        /* 
@@ -327,6 +326,7 @@
         */
        curproc = NULL;
        limfree(p->p_limit);
+       p->p_limit = NULL;
 
        /*
         * Finally, call machine-dependent code to switch to a new



Home | Main Index | Thread Index | Old Index