1. 03 2月, 2017 1 次提交
    • 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
  2. 25 1月, 2017 1 次提交
    • M
      nsfs: Add an ioctl() to return the namespace type · e5ff5ce6
      Michael Kerrisk (man-pages) 提交于
      Linux 4.9 added two ioctl() operations that can be used to discover:
      
      * the parental relationships for hierarchical namespaces (user and PID)
        [NS_GET_PARENT]
      * the user namespaces that owns a specified non-user-namespace
        [NS_GET_USERNS]
      
      For no good reason that I can glean, NS_GET_USERNS was made synonymous
      with NS_GET_PARENT for user namespaces. It might have been better if
      NS_GET_USERNS had returned an error if the supplied file descriptor
      referred to a user namespace, since it suggests that the caller may be
      confused. More particularly, if it had generated an error, then I wouldn't
      need the new ioctl() operation proposed here. (On the other hand, what
      I propose here may be more generally useful.)
      
      I would like to write code that discovers namespace relationships for
      the purpose of understanding the namespace setup on a running system.
      In particular, given a file descriptor (or pathname) for a namespace,
      N, I'd like to obtain the corresponding user namespace.  Namespace N
      might be a user namespace (in which case my code would just use N) or
      a non-user namespace (in which case my code will use NS_GET_USERNS to
      get the user namespace associated with N). The problem is that there
      is no way to tell the difference by looking at the file descriptor
      (and if I try to use NS_GET_USERNS on an N that is a user namespace, I
      get the parent user namespace of N, which is not what I want).
      
      This patch therefore adds a new ioctl(), NS_GET_NSTYPE, which, given
      a file descriptor that refers to a user namespace, returns the
      namespace type (one of the CLONE_NEW* constants).
      Signed-off-by: NMichael Kerrisk <mtk-manpages@gmail.com>
      Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
      e5ff5ce6
  3. 23 9月, 2016 2 次提交