idmap.c for ldap caching and configuration
struct idmap_context contains configuration data (struct idmap_config), a cache for users, and a cache for groups. idmap_context is declared in idmap.c, and only available as an opaque pointer (nfs41_idmapper) elsewhere. similarly, Winldap.h is only included by idmap.c, and not needed elsewhere nfs41_idmap_create() allocates the idmap_context, loads the configuration from file, and calls ldap_init(). it does not call ldap_connect(); we'll still be able to start the daemon if ldap isn't configured, or the ldap server is down. calling ldap_connect() is optional, as any ldap operation that requires a connection will establish it internally. this behavior, along with the LDAP_OPT_AUTO_RECONNECT option (defaults to on), means that we shouldn't have to maintain a separate connection for each thread nfs41_idmap_*() functions return windows errors codes. LDAP_RETCODEs are mapped to windows errors with LdapMapErrorToWin32() the user and group caches share a common generic interface in struct idmap_cache, which uses a linked list for storage, and protects access with a SRWLOCK. expiration of cache entries can be adjusted by the config option 'cache_ttl' struct config_option g_options[] is a table of available config options and their default values. this patch adds a 'ms-nfs41-idmap.conf' file with all possible options set to default values, and commented out. the daemon expects to find this file under c:\etc\, and won't start if it can't be opened or parsed Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
This commit is contained in:
parent
8321939c90
commit
cd1251758d
6 changed files with 1160 additions and 5 deletions
|
|
@ -105,7 +105,7 @@
|
||||||
<CompileAs>CompileAsC</CompileAs>
|
<CompileAs>CompileAsC</CompileAs>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<AdditionalDependencies>ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>ws2_32.lib;iphlpapi.lib;wldap32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<TargetMachine>MachineX86</TargetMachine>
|
<TargetMachine>MachineX86</TargetMachine>
|
||||||
|
|
@ -131,7 +131,7 @@
|
||||||
<CompileAs>CompileAsC</CompileAs>
|
<CompileAs>CompileAsC</CompileAs>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<AdditionalDependencies>ws2_32.lib;iphlpapi.lib;kernel32.lib;advapi32.lib;shell32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>ws2_32.lib;iphlpapi.lib;wldap32.lib;kernel32.lib;advapi32.lib;shell32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<TargetMachine>MachineX64</TargetMachine>
|
<TargetMachine>MachineX64</TargetMachine>
|
||||||
|
|
@ -154,7 +154,7 @@
|
||||||
<CompileAs>CompileAsC</CompileAs>
|
<CompileAs>CompileAsC</CompileAs>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<AdditionalDependencies>ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>ws2_32.lib;iphlpapi.lib;wldap32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
|
@ -182,7 +182,7 @@
|
||||||
<CompileAs>CompileAsC</CompileAs>
|
<CompileAs>CompileAsC</CompileAs>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<AdditionalDependencies>ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>ws2_32.lib;iphlpapi.lib;wldap32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
|
@ -195,6 +195,7 @@
|
||||||
<ClCompile Include="..\daemon\callback_server.c" />
|
<ClCompile Include="..\daemon\callback_server.c" />
|
||||||
<ClCompile Include="..\daemon\daemon_debug.c" />
|
<ClCompile Include="..\daemon\daemon_debug.c" />
|
||||||
<ClCompile Include="..\daemon\getattr.c" />
|
<ClCompile Include="..\daemon\getattr.c" />
|
||||||
|
<ClCompile Include="..\daemon\idmap.c" />
|
||||||
<ClCompile Include="..\daemon\lock.c" />
|
<ClCompile Include="..\daemon\lock.c" />
|
||||||
<ClCompile Include="..\daemon\lookup.c" />
|
<ClCompile Include="..\daemon\lookup.c" />
|
||||||
<ClCompile Include="..\daemon\mount.c" />
|
<ClCompile Include="..\daemon\mount.c" />
|
||||||
|
|
@ -227,6 +228,7 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\daemon\daemon_debug.h" />
|
<ClInclude Include="..\daemon\daemon_debug.h" />
|
||||||
<ClInclude Include="..\daemon\from_kernel.h" />
|
<ClInclude Include="..\daemon\from_kernel.h" />
|
||||||
|
<ClInclude Include="..\daemon\idmap.h" />
|
||||||
<ClInclude Include="..\daemon\list.h" />
|
<ClInclude Include="..\daemon\list.h" />
|
||||||
<ClInclude Include="..\daemon\name_cache.h" />
|
<ClInclude Include="..\daemon\name_cache.h" />
|
||||||
<ClInclude Include="..\daemon\nfs41.h" />
|
<ClInclude Include="..\daemon\nfs41.h" />
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,9 @@
|
||||||
<ClCompile Include="..\daemon\symlink.c">
|
<ClCompile Include="..\daemon\symlink.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\daemon\idmap.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\daemon\daemon_debug.h">
|
<ClInclude Include="..\daemon\daemon_debug.h">
|
||||||
|
|
@ -160,6 +163,9 @@
|
||||||
<ClInclude Include="..\daemon\service.h">
|
<ClInclude Include="..\daemon\service.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\daemon\idmap.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\daemon\sources">
|
<None Include="..\daemon\sources">
|
||||||
|
|
|
||||||
1058
daemon/idmap.c
Normal file
1058
daemon/idmap.c
Normal file
File diff suppressed because it is too large
Load diff
69
daemon/idmap.h
Normal file
69
daemon/idmap.h
Normal file
|
|
@ -0,0 +1,69 @@
|
||||||
|
/* Copyright (c) 2010
|
||||||
|
* The Regents of the University of Michigan
|
||||||
|
* All Rights Reserved
|
||||||
|
*
|
||||||
|
* Permission is granted to use, copy and redistribute this software
|
||||||
|
* for noncommercial education and research purposes, so long as no
|
||||||
|
* fee is charged, and so long as the name of the University of Michigan
|
||||||
|
* is not used in any advertising or publicity pertaining to the use
|
||||||
|
* or distribution of this software without specific, written prior
|
||||||
|
* authorization. Permission to modify or otherwise create derivative
|
||||||
|
* works of this software is not granted.
|
||||||
|
*
|
||||||
|
* This software is provided as is, without representation or warranty
|
||||||
|
* of any kind either express or implied, including without limitation
|
||||||
|
* the implied warranties of merchantability, fitness for a particular
|
||||||
|
* purpose, or noninfringement. The Regents of the University of
|
||||||
|
* Michigan shall not be liable for any damages, including special,
|
||||||
|
* indirect, incidental, or consequential damages, with respect to any
|
||||||
|
* claim arising out of or in connection with the use of the software,
|
||||||
|
* even if it has been or is hereafter advised of the possibility of
|
||||||
|
* such damages.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef IDMAP_H
|
||||||
|
#define IDMAP_H
|
||||||
|
|
||||||
|
#include "nfs41_types.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* idmap.c */
|
||||||
|
typedef struct idmap_context nfs41_idmapper;
|
||||||
|
|
||||||
|
int nfs41_idmap_create(
|
||||||
|
nfs41_idmapper **context_out);
|
||||||
|
|
||||||
|
void nfs41_idmap_free(
|
||||||
|
nfs41_idmapper *context);
|
||||||
|
|
||||||
|
|
||||||
|
int nfs41_idmap_name_to_ids(
|
||||||
|
nfs41_idmapper *context,
|
||||||
|
const char *username,
|
||||||
|
uid_t *uid_out,
|
||||||
|
gid_t *gid_out);
|
||||||
|
|
||||||
|
int nfs41_idmap_uid_to_name(
|
||||||
|
nfs41_idmapper *context,
|
||||||
|
uid_t uid,
|
||||||
|
char *name_out,
|
||||||
|
size_t len);
|
||||||
|
|
||||||
|
int nfs41_idmap_principal_to_ids(
|
||||||
|
nfs41_idmapper *context,
|
||||||
|
const char *principal,
|
||||||
|
uid_t *uid_out,
|
||||||
|
gid_t *gid_out);
|
||||||
|
|
||||||
|
int nfs41_idmap_group_to_gid(
|
||||||
|
nfs41_idmapper *context,
|
||||||
|
const char *name,
|
||||||
|
gid_t *gid_out);
|
||||||
|
|
||||||
|
int nfs41_idmap_gid_to_group(
|
||||||
|
nfs41_idmapper *context,
|
||||||
|
gid_t gid,
|
||||||
|
char *name_out,
|
||||||
|
size_t len);
|
||||||
|
|
||||||
|
#endif /* !IDMAP_H */
|
||||||
|
|
@ -5,7 +5,7 @@ SOURCES=nfs41_daemon.c daemon_debug.c nfs41_ops.c nfs41_compound.c nfs41_xdr.c \
|
||||||
mount.c open.c readwrite.c lock.c readdir.c getattr.c setattr.c upcall.c \
|
mount.c open.c readwrite.c lock.c readdir.c getattr.c setattr.c upcall.c \
|
||||||
nfs41_rpc.c util.c pnfs_layout.c pnfs_device.c pnfs_debug.c pnfs_io.c \
|
nfs41_rpc.c util.c pnfs_layout.c pnfs_device.c pnfs_debug.c pnfs_io.c \
|
||||||
name_cache.c namespace.c rbtree.c volume.c callback_server.c callback_xdr.c \
|
name_cache.c namespace.c rbtree.c volume.c callback_server.c callback_xdr.c \
|
||||||
service.c symlink.c
|
service.c symlink.c idmap.c
|
||||||
UMTYPE=console
|
UMTYPE=console
|
||||||
USE_LIBCMT=1
|
USE_LIBCMT=1
|
||||||
#USE_MSVCRT=1
|
#USE_MSVCRT=1
|
||||||
|
|
|
||||||
20
ms-nfs41-idmap.conf
Normal file
20
ms-nfs41-idmap.conf
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
# ldap server information
|
||||||
|
#ldap_hostname="localhost"
|
||||||
|
#ldap_port="389"
|
||||||
|
#ldap_version="3"
|
||||||
|
#ldap_timeout="5"
|
||||||
|
|
||||||
|
# ldap schema information
|
||||||
|
#ldap_base="cn=localhost"
|
||||||
|
|
||||||
|
#ldap_class_users="user"
|
||||||
|
#ldap_class_groups="group"
|
||||||
|
|
||||||
|
#ldap_attr_username="cn"
|
||||||
|
#ldap_attr_groupname="cn"
|
||||||
|
#ldap_attr_gssAuthName="gssAuthName"
|
||||||
|
#ldap_attr_uidNumber="uidNumber"
|
||||||
|
#ldap_attr_gidNumber="gidNumber"
|
||||||
|
|
||||||
|
# caching configuration
|
||||||
|
#cache_ttl="60"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue