]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - support/nfs/rpc_socket.c
nfs-utils: add and use nfs_authsys_create
[nfs-utils.git] / support / nfs / rpc_socket.c
index 0e20824cb614e4a23e69799a05a52adbdce6b58b..aa6a2055772a2fe2f178be8340fe2f6b1683b2c8 100644 (file)
@@ -557,3 +557,24 @@ rpcprog_t nfs_getrpcbyname(const rpcprog_t program, const char *table[])
 
        return program;
 }
+
+/*
+ * AUTH_SYS doesn't allow more than 16 gids in the supplemental group list.
+ * If there are more than that, trying to determine which ones to include
+ * in the list is problematic. This function creates an auth handle that
+ * only has the primary gid in the supplemental gids list. It's intended to
+ * be used for protocols where credentials really don't matter much (the MNT
+ * protocol, for instance).
+ */
+AUTH *
+nfs_authsys_create(void)
+{
+       char machname[MAXHOSTNAMELEN + 1];
+       uid_t   uid = geteuid();
+       gid_t   gid = getegid();
+
+       if (gethostname(machname, sizeof(machname)) == -1)
+               return NULL;
+
+       return authsys_create(machname, uid, gid, 1, &gid);
+}