nfs: add structures and functions for parsing netgroups
Netgroups are often used by enterprises to group a set of systems. The NFS /etc/exports file support the @netgroup notation, and Gluster/NFS will get extended to support this notation as well. For this, it is needed that Gluster/NFS learns to parse the netgroup format. A change to glusterfsd (Change-Id I24c40d5) will add test cases where the parsing is used for regression testing. BUG: 1143880 Change-Id: Ie04800d4dc26f99df922c9fcc00845f53291cf4f Original-author: Shreyas Siravara <shreyas.siravara@gmail.com> CC: Richard Wareing <rwareing@fb.com> CC: Jiffin Tony Thottan <jthottan@redhat.com> Signed-off-by: Niels de Vos <ndevos@redhat.com> Reviewed-on: http://review.gluster.org/9360 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
This commit is contained in:
parent
381abb5bd2
commit
02d42a5e80
xlators/nfs/server/src
@ -4,13 +4,13 @@ nfsrpclibdir = $(top_srcdir)/rpc/rpc-lib/src
|
||||
server_la_LDFLAGS = -module -avoid-version
|
||||
server_la_SOURCES = nfs.c nfs-common.c nfs-fops.c nfs-inodes.c \
|
||||
nfs-generics.c mount3.c nfs3-fh.c nfs3.c nfs3-helpers.c nlm4.c \
|
||||
nlmcbk_svc.c mount3udp_svc.c acl3.c
|
||||
nlmcbk_svc.c mount3udp_svc.c acl3.c netgroups.c
|
||||
server_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la \
|
||||
$(top_builddir)/api/src/libgfapi.la
|
||||
|
||||
noinst_HEADERS = nfs.h nfs-common.h nfs-fops.h nfs-inodes.h nfs-generics.h \
|
||||
mount3.h nfs3-fh.h nfs3.h nfs3-helpers.h nfs-mem-types.h nlm4.h \
|
||||
acl3.h
|
||||
acl3.h netgroups.h
|
||||
|
||||
AM_CPPFLAGS = $(GF_CPPFLAGS) \
|
||||
-DLIBDIR=\"$(libdir)/glusterfs/$(PACKAGE_VERSION)/auth\" \
|
||||
|
1141
xlators/nfs/server/src/netgroups.c
Normal file
1141
xlators/nfs/server/src/netgroups.c
Normal file
File diff suppressed because it is too large
Load Diff
54
xlators/nfs/server/src/netgroups.h
Normal file
54
xlators/nfs/server/src/netgroups.h
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
Copyright 2014-present Facebook. All Rights Reserved
|
||||
|
||||
This file is part of GlusterFS.
|
||||
|
||||
Author :
|
||||
Shreyas Siravara <shreyas.siravara@gmail.com>
|
||||
|
||||
This file is licensed to you under your choice of the GNU Lesser
|
||||
General Public License, version 3 or any later version (LGPLv3 or
|
||||
later), or the GNU General Public License, version 2 (GPLv2), in all
|
||||
cases as published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#ifndef _NETGROUPS_H
|
||||
#define _NETGROUPS_H
|
||||
|
||||
#include "nfs-mem-types.h"
|
||||
#include "dict.h"
|
||||
#include "nfs.h"
|
||||
|
||||
#define GF_NG GF_NFS"-netgroup"
|
||||
|
||||
#define NG_FILE_PARSE_REGEX "([a-zA-Z0-9.(,)]+)"
|
||||
#define NG_HOST_PARSE_REGEX "([a-zA-Z0-9.]+)"
|
||||
|
||||
struct netgroup_host {
|
||||
char *hostname; /* Hostname of entry */
|
||||
char *user; /* User field in the entry */
|
||||
char *domain; /* Domain field in the entry */
|
||||
};
|
||||
|
||||
struct netgroup_entry {
|
||||
char *netgroup_name; /* Name of the netgroup */
|
||||
dict_t *netgroup_ngs; /* Dict of netgroups in this netgroup */
|
||||
dict_t *netgroup_hosts; /* Dict of hosts in this netgroup. */
|
||||
};
|
||||
|
||||
struct netgroups_file {
|
||||
char *filename; /* Filename on disk */
|
||||
dict_t *ng_file_dict; /* Dict of netgroup entries */
|
||||
};
|
||||
|
||||
struct netgroups_file *
|
||||
ng_file_parse (const char *filepath);
|
||||
|
||||
struct netgroup_entry *
|
||||
ng_file_get_netgroup (const struct netgroups_file *ngfile,
|
||||
const char *netgroup);
|
||||
|
||||
void
|
||||
ng_file_deinit (struct netgroups_file *ngfile);
|
||||
|
||||
#endif /* _NETGROUPS_H */
|
@ -46,6 +46,7 @@ enum gf_nfs_mem_types_ {
|
||||
gf_nfs_mt_aux_gids,
|
||||
gf_nfs_mt_inode_ctx,
|
||||
gf_nfs_mt_auth_spec,
|
||||
gf_nfs_mt_netgroups,
|
||||
gf_nfs_mt_arr,
|
||||
gf_nfs_mt_end
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user