37#define FILTER_LEN 1024
59#define ATTR_FLAG(attr) (1 << (attr))
60#define ATTR_ISSET(mask, attr) (((mask) & ATTR_FLAG(attr)) != 0)
79static const char CONFIG_FILENAME[] =
"C:\\ReactOS\\System32\\drivers\\etc\\ms-nfs41-idmap.conf";
113#define OPT_INT(key,def,field) \
114 { key, def, TYPE_INT, FIELD_OFFSET(struct idmap_config, field), 0 }
115#define OPT_STR(key,def,field,len) \
116 { key, def, TYPE_STR, FIELD_OFFSET(struct idmap_config, field), len }
117#define OPT_CLASS(key,def,index) \
118 { key, def, TYPE_STR, FIELD_OFFSET(struct idmap_config, classes[index]), NAME_LEN }
119#define OPT_ATTR(key,def,index) \
120 { key, def, TYPE_STR, FIELD_OFFSET(struct idmap_config, attributes[index]), NAME_LEN }
141 OPT_INT(
"cache_ttl",
"60", cache_ttl),
181 if (
pair->key_len <= 0) {
192 eprintf(
"end of line looking for value\n");
217 ((
char*)
pair->key)[
pair->key_len] = 0;
218 ((
char*)
pair->value)[
pair->value_len] = 0;
258 eprintf(
"failed to parse default value of %s=\"%s\": "
265 eprintf(
"failed to parse default value of %s=\"%s\": "
320 if (*
pos ==
'#' || *
pos == 0)
333 eprintf(
"unrecognized option '%s' on line %d: %s\n",
342 eprintf(
"expected a number on line %d: %s=\"%s\"\n",
350 eprintf(
"overflow on line %d: %s=\"%s\"\n",
398 eprintf(
"config_load('%s') failed with %d\n", config_path,
status);
410typedef struct list_entry* (*entry_alloc_fn)();
527 dst->last_updated =
src->last_updated;
561 dst->last_updated =
src->last_updated;
592 "(&(objectClass=%s)(%s=%u))",
596 eprintf(
"ldap filter buffer overflow: '%s=%u'\n",
603 "(&(objectClass=%s)(%s=%s))",
607 eprintf(
"ldap filter buffer overflow: '%s=%s'\n",
622 const unsigned attributes,
641 eprintf(
"ldap search for '%s' failed with %d: %s\n",
650 eprintf(
"ldap search for '%s' failed with %d: %s\n",
657 for (
i = 0;
i <
len;
i++) {
665 eprintf(
"ldap entry for '%s' missing required "
666 "attribute '%s', returning %d: %s\n",
706 goto out_free_values;
711 eprintf(
"ldap attribute %s='%s' longer than %u characters\n",
715 goto out_free_values;
719 eprintf(
"ldap attribute %s='%s' longer than %u characters\n",
723 goto out_free_values;
726 eprintf(
"failed to parse ldap attribute %s='%s'\n",
729 goto out_free_values;
732 eprintf(
"failed to parse ldap attribute %s='%s'\n",
735 goto out_free_values;
739 if (
context->config.cache_ttl) {
773 goto out_free_values;
778 eprintf(
"ldap attribute %s='%s' longer than %u characters\n",
782 goto out_free_values;
785 eprintf(
"failed to parse ldap attribute %s='%s'\n",
788 goto out_free_values;
792 if (
context->config.cache_ttl) {
832 eprintf(
"ldap_init(%s) failed with %d: %s\n",
839 (
void *)&
context->config.version);
841 eprintf(
"ldap_set_option(version=%d) failed with %d\n",
849 (
void *)&
context->config.timeout);
851 eprintf(
"ldap_set_option(timeout=%d) failed with %d\n",
945 lookup.value = (
const void*)uidp;
957 eprintf(
"username buffer overflow: '%s' > %u\n",
963 "returning '%s'\n",
uid,
name);
995 dprintf(
IDLVL,
"<-- nfs41_idmap_principal_to_ids('%s') "
1000 *uid_out =
user.uid;
1001 *gid_out =
user.gid;
1002 dprintf(
IDLVL,
"<-- nfs41_idmap_principal_to_ids('%s') "
1039 *gid_out =
group.gid;
1068 lookup.value = (
const void*)gidp;
1080 eprintf(
"group name buffer overflow: '%s' > %u\n",
1086 "returning '%s'\n",
gid,
name);
int strcmp(const char *String1, const char *String2)
UINT32 strtoul(const char *String, char **Terminator, UINT32 Base)
ACPI_SIZE strlen(const char *String)
char * strchr(const char *String, int ch)
void user(int argc, const char *argv[])
#define list_container(entry, type, field)
#define list_for_each_tmp(entry, tmp, head)
int(* list_compare_fn)(const struct list_entry *, const void *)
static void list_add_head(struct list_entry *head, struct list_entry *entry)
static struct list_entry * list_search(const struct list_entry *head, const void *value, list_compare_fn compare)
static void list_init(struct list_entry *head)
void eprintf(LPCSTR format,...)
#define ERROR_INVALID_PARAMETER
#define stricmp(_String1, _String2)
static const WCHAR version[]
UINT WINAPI GetSystemDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
VOID WINAPI ReleaseSRWLockShared(PSRWLOCK Lock)
VOID WINAPI AcquireSRWLockExclusive(PSRWLOCK Lock)
VOID WINAPI AcquireSRWLockShared(PSRWLOCK Lock)
VOID WINAPI ReleaseSRWLockExclusive(PSRWLOCK Lock)
VOID WINAPI InitializeSRWLock(PSRWLOCK Lock)
PCHAR CDECL ldap_err2stringA(ULONG err)
ULONG CDECL LdapMapErrorToWin32(ULONG err)
ULONG CDECL LdapGetLastError(void)
__kernel_ptrdiff_t ptrdiff_t
GLuint GLuint GLsizei count
GLboolean GLenum GLenum GLvoid * values
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
#define OPT_INT(key, def, field)
int nfs41_idmap_group_to_gid(struct idmap_context *context, const char *name, gid_t *gid_out)
static int idmap_query_attrs(struct idmap_context *context, const struct idmap_lookup *lookup, const unsigned attributes, const unsigned optional, PCHAR *values[], const int len)
static int cache_insert(struct idmap_cache *cache, const struct idmap_lookup *lookup, const struct list_entry *src)
static void user_cache_free(struct list_entry *entry)
static int config_load(struct idmap_config *config, const char *filename)
static void user_cache_copy(struct list_entry *lhs, const struct list_entry *rhs)
static int uid_cmp(const struct list_entry *list, const void *value)
static const struct cache_ops group_cache_ops
static int idmap_filter(struct idmap_config *config, const struct idmap_lookup *lookup, char *filter, size_t filter_len)
static int config_defaults(struct idmap_config *config)
static int config_find_option(const struct config_pair *pair, const struct config_option **option)
static void group_cache_free(struct list_entry *entry)
static int group_cmp(const struct list_entry *list, const void *value)
static BOOL parse_uint(const char *str, UINT *id_out)
int nfs41_idmap_name_to_ids(struct idmap_context *context, const char *username, uid_t *uid_out, gid_t *gid_out)
int nfs41_idmap_create(struct idmap_context **context_out)
static int config_parse_pair(char *line, struct config_pair *pair)
void nfs41_idmap_free(struct idmap_context *context)
static int config_init(struct idmap_config *config)
void(* entry_copy_fn)(struct list_entry *, const struct list_entry *)
static int gid_cmp(const struct list_entry *list, const void *value)
static void group_cache_copy(struct list_entry *lhs, const struct list_entry *rhs)
int nfs41_idmap_uid_to_name(struct idmap_context *context, uid_t uid, char *name, size_t len)
#define ATTR_ISSET(mask, attr)
static void cache_cleanup(struct idmap_cache *cache)
int nfs41_idmap_gid_to_group(struct idmap_context *context, gid_t gid, char *name, size_t len)
static int principal_cmp(const struct list_entry *list, const void *value)
int nfs41_idmap_principal_to_ids(struct idmap_context *context, const char *principal, uid_t *uid_out, gid_t *gid_out)
static const char CONFIG_FILENAME[]
static const struct cache_ops user_cache_ops
void(* entry_free_fn)(struct list_entry *)
struct list_entry *(* entry_alloc_fn)()
static int username_cmp(const struct list_entry *list, const void *value)
static int cache_lookup(struct idmap_cache *cache, const struct idmap_lookup *lookup, struct list_entry *entry_out)
static int idmap_lookup_user(struct idmap_context *context, const struct idmap_lookup *lookup, struct idmap_user *user)
#define OPT_STR(key, def, field, len)
static struct list_entry * group_cache_alloc()
static struct list_entry * user_cache_alloc()
static int idmap_lookup_group(struct idmap_context *context, const struct idmap_lookup *lookup, struct idmap_group *group)
#define OPT_ATTR(key, def, index)
#define OPT_CLASS(key, def, index)
static const struct config_option g_options[]
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP char *__cdecl fgets(_Out_writes_z_(_MaxCount) char *_Buf, _In_ int _MaxCount, _Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
#define ERROR_FILE_NOT_FOUND
unsigned __int3264 UINT_PTR
#define NFS41_HOSTNAME_LEN
STRSAFEAPI StringCchCatA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
STRSAFEAPI StringCchCopyA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
STRSAFEAPI StringCchPrintfA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszFormat,...)
entry_alloc_fn entry_alloc
const struct cache_ops * ops
char classes[NUM_CLASSES][NAME_LEN]
char attributes[NUM_ATTRIBUTES][NAME_LEN]
char hostname[NFS41_HOSTNAME_LEN+1]
DWORD WINAPI GetLastError(void)
#define ERROR_BUFFER_OVERFLOW
#define LDAP_NO_SUCH_ATTRIBUTE
WINLDAPAPI ULONG ldap_msgfree(LDAPMessage *)
#define LDAP_SCOPE_SUBTREE
#define LDAP_OPT_TIMELIMIT
WINLDAPAPI ULONG ldap_unbind(LDAP *)
WINLDAPAPI PLDAPMessage ldap_first_entry(LDAP *, LDAPMessage *)
#define LDAP_OPT_PROTOCOL_VERSION
#define LDAP_NO_RESULTS_RETURNED