userns: Convert bsd process accounting to use kuid and kgid where appropriate
authorEric W. Biederman <ebiederm@xmission.com>
Wed, 8 Feb 2012 00:54:50 +0000 (16:54 -0800)
committerEric W. Biederman <ebiederm@xmission.com>
Tue, 18 Sep 2012 08:01:33 +0000 (01:01 -0700)
BSD process accounting conveniently passes the file the accounting
records will be written into to do_acct_process.  The file credentials
captured the user namespace of the opener of the file.  Use the file
credentials to format the uid and the gid of the current process into
the user namespace of the user that started the bsd process
accounting.

Cc: Pavel Emelyanov <xemul@openvz.org>
Reviewed-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
init/Kconfig
kernel/acct.c

index f0f636cf0ce7ff93b83c1b64ee6cb60c7ef9923f..6de46ef12e3f57aeb573851a0c62d0b5f1123d36 100644 (file)
@@ -931,7 +931,6 @@ config UIDGID_CONVERTED
        depends on FS_POSIX_ACL = n
        depends on QUOTA = n
        depends on QUOTACTL = n
-       depends on BSD_PROCESS_ACCT = n
 
        # Networking
        depends on NET_9P = n
index 02e6167a53b0af6bcbc166cc810cae9ab04e54f7..6cd7529c9e6a31a7702c77f38c45289f72d907b8 100644 (file)
@@ -507,8 +507,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 */
-       ac.ac_uid = orig_cred->uid;
-       ac.ac_gid = orig_cred->gid;
+       ac.ac_uid = from_kuid_munged(file->f_cred->user_ns, orig_cred->uid);
+       ac.ac_gid = from_kgid_munged(file->f_cred->user_ns, orig_cred->gid);
 #if ACCT_VERSION==2
        ac.ac_ahz = AHZ;
 #endif