• M
    nsfs: Add an ioctl() to return owner UID of a userns · d95fa3c7
    Michael Kerrisk (man-pages) 提交于
    I'd like to write code that discovers the user namespace hierarchy on a
    running system, and also shows who owns the various user namespaces.
    Currently, there is no way of getting the owner UID of a user namespace.
    Therefore, this patch adds a new NS_GET_CREATOR_UID ioctl() that fetches
    the UID (as seen in the user namespace of the caller) of the creator of
    the user namespace referred to by the specified file descriptor.
    
    If the supplied file descriptor does not refer to a user namespace,
    the operation fails with the error EINVAL. If the owner UID does
    not have a mapping in the caller's user namespace return the
    overflow UID as that appears easier to deal with in practice
    in user-space applications.
    
    -- EWB Changed the handling of unmapped UIDs from -EOVERFLOW
       back to the overflow uid.  Per conversation with
       Michael Kerrisk after examining his test code.
    Acked-by: NAndrey Vagin <avagin@openvz.org>
    Signed-off-by: NMichael Kerrisk <mtk-manpages@gmail.com>
    Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
    d95fa3c7
nsfs.c 5.5 KB