]> nv-tegra.nvidia Code Review - linux-2.6.git/blobdiff - kernel/acct.c
security: remove dead hook acct
[linux-2.6.git] / kernel / acct.c
index 9f3391090b3e826d1d7cb935e58f7d01aa054b37..9e53bb2acfff6e63b6e786b45ba53ff4ecc730fe 100644 (file)
@@ -216,7 +216,6 @@ static int acct_on(char *name)
 {
        struct file *file;
        struct vfsmount *mnt;
-       int error;
        struct pid_namespace *ns;
        struct bsd_acct_struct *acct = NULL;
 
@@ -244,13 +243,6 @@ static int acct_on(char *name)
                }
        }
 
-       error = security_acct(file);
-       if (error) {
-               kfree(acct);
-               filp_close(file, NULL);
-               return error;
-       }
-
        spin_lock(&acct_lock);
        if (ns->bacct == NULL) {
                ns->bacct = acct;
@@ -281,7 +273,7 @@ static int acct_on(char *name)
  */
 SYSCALL_DEFINE1(acct, const char __user *, name)
 {
-       int error;
+       int error = 0;
 
        if (!capable(CAP_SYS_PACCT))
                return -EPERM;
@@ -299,13 +291,11 @@ SYSCALL_DEFINE1(acct, const char __user *, name)
                if (acct == NULL)
                        return 0;
 
-               error = security_acct(NULL);
-               if (!error) {
-                       spin_lock(&acct_lock);
-                       acct_file_reopen(acct, NULL, NULL);
-                       spin_unlock(&acct_lock);
-               }
+               spin_lock(&acct_lock);
+               acct_file_reopen(acct, NULL, NULL);
+               spin_unlock(&acct_lock);
        }
+
        return error;
 }
 
@@ -491,13 +481,17 @@ static void do_acct_process(struct bsd_acct_struct *acct,
        u64 run_time;
        struct timespec uptime;
        struct tty_struct *tty;
+       const struct cred *orig_cred;
+
+       /* Perform file operations on behalf of whoever enabled accounting */
+       orig_cred = override_creds(file->f_cred);
 
        /*
         * First check to see if there is enough free_space to continue
         * the process accounting system.
         */
        if (!check_free_space(acct, file))
-               return;
+               goto out;
 
        /*
         * Fill the accounting struct with the needed info as recorded
@@ -532,7 +526,8 @@ static void do_acct_process(struct bsd_acct_struct *acct,
        do_div(elapsed, AHZ);
        ac.ac_btime = get_seconds() - elapsed;
        /* we really need to bite the bullet and change layout */
-       current_uid_gid(&ac.ac_uid, &ac.ac_gid);
+       ac.ac_uid = orig_cred->uid;
+       ac.ac_gid = orig_cred->gid;
 #if ACCT_VERSION==2
        ac.ac_ahz = AHZ;
 #endif
@@ -578,16 +573,8 @@ static void do_acct_process(struct bsd_acct_struct *acct,
                               sizeof(acct_t), &file->f_pos);
        current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
        set_fs(fs);
-}
-
-/**
- * acct_init_pacct - initialize a new pacct_struct
- * @pacct: per-process accounting info struct to initialize
- */
-void acct_init_pacct(struct pacct_struct *pacct)
-{
-       memset(pacct, 0, sizeof(struct pacct_struct));
-       pacct->ac_utime = pacct->ac_stime = cputime_zero;
+out:
+       revert_creds(orig_cred);
 }
 
 /**