37 #define FILTER_LEN 1024 59 #define ATTR_FLAG(attr) (1 << (attr)) 60 #define ATTR_ISSET(mask, attr) (((mask) & ATTR_FLAG(attr)) != 0) 79 static 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);
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);
#define ERROR_INVALID_PARAMETER
unsigned __int3264 UINT_PTR
UINT32 strtoul(const char *String, char **Terminator, UINT32 Base)
static const struct cache_ops group_cache_ops
static int config_find_option(const struct config_pair *pair, const struct config_option **option)
#define OPT_ATTR(key, def, index)
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
int nfs41_idmap_group_to_gid(struct idmap_context *context, const char *name, gid_t *gid_out)
WINLDAPAPI ULONG ldap_msgfree(LDAPMessage *)
static struct list_entry * user_cache_alloc()
ACPI_SIZE strlen(const char *String)
#define ERROR_BUFFER_OVERFLOW
static int uid_cmp(const struct list_entry *list, const void *value)
GLuint GLuint GLsizei count
static int cache_lookup(struct idmap_cache *cache, const struct idmap_lookup *lookup, struct list_entry *entry_out)
static int idmap_filter(struct idmap_config *config, const struct idmap_lookup *lookup, char *filter, size_t filter_len)
#define ATTR_ISSET(mask, attr)
GLboolean GLenum GLenum GLvoid * values
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
WINLDAPAPI PLDAPMessage ldap_first_entry(LDAP *, LDAPMessage *)
UINT WINAPI GetSystemDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
WINLDAPAPI ULONG ldap_unbind(LDAP *)
DWORD WINAPI GetLastError(VOID)
void eprintf(LPCSTR format,...)
int nfs41_idmap_name_to_ids(struct idmap_context *context, const char *username, uid_t *uid_out, gid_t *gid_out)
PCHAR CDECL ldap_err2stringA(ULONG err)
static int idmap_lookup_user(struct idmap_context *context, const struct idmap_lookup *lookup, struct idmap_user *user)
static int principal_cmp(const struct list_entry *list, const void *value)
#define LDAP_OPT_PROTOCOL_VERSION
#define LDAP_OPT_TIMELIMIT
#define OPT_INT(key, def, field)
char hostname[NFS41_HOSTNAME_LEN+1]
int nfs41_idmap_principal_to_ids(struct idmap_context *context, const char *principal, uid_t *uid_out, gid_t *gid_out)
ULONG CDECL LdapMapErrorToWin32(ULONG err)
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)
STRSAFEAPI StringCchCopyNA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc, size_t cchToCopy)
static int username_cmp(const struct list_entry *list, const void *value)
VOID WINAPI AcquireSRWLockShared(PSRWLOCK Lock)
STRSAFEAPI StringCchCatA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
#define NFS41_HOSTNAME_LEN
static void user_cache_free(struct list_entry *entry)
STRSAFEAPI StringCchPrintfA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszFormat,...)
static const WCHAR version[]
static int group_cmp(const struct list_entry *list, const void *value)
static void cache_cleanup(struct idmap_cache *cache)
entry_alloc_fn entry_alloc
static void group_cache_free(struct list_entry *entry)
#define list_container(entry, type, field)
int nfs41_idmap_uid_to_name(struct idmap_context *context, uid_t uid, char *name, size_t len)
#define ERROR_FILE_NOT_FOUND
static BOOL parse_uint(const char *str, UINT *id_out)
_Check_return_ _CRTIMP int __cdecl stricmp(_In_z_ const char *_Str1, _In_z_ const char *_Str2)
#define LDAP_NO_RESULTS_RETURNED
char attributes[NUM_ATTRIBUTES][NAME_LEN]
static void group_cache_copy(struct list_entry *lhs, const struct list_entry *rhs)
char classes[NUM_CLASSES][NAME_LEN]
static const struct cache_ops user_cache_ops
VOID WINAPI ReleaseSRWLockExclusive(PSRWLOCK Lock)
static int config_defaults(struct idmap_config *config)
static int idmap_lookup_group(struct idmap_context *context, const struct idmap_lookup *lookup, struct idmap_group *group)
struct list_entry *(* entry_alloc_fn)()
unsigned __int3264 UINT_PTR
_In_opt_ PVOID _In_ ULONG _In_ PVOID context
const struct cache_ops * ops
int(* list_compare_fn)(const struct list_entry *, const void *)
#define LDAP_NO_SUCH_ATTRIBUTE
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
void(* entry_copy_fn)(struct list_entry *, const struct list_entry *)
static int gid_cmp(const struct list_entry *list, const void *value)
#define LDAP_SCOPE_SUBTREE
#define OPT_STR(key, def, field, len)
static struct list_entry * list_search(const struct list_entry *head, const void *value, list_compare_fn compare)
static int cache_insert(struct idmap_cache *cache, const struct idmap_lookup *lookup, const struct list_entry *src)
STRSAFEAPI StringCchCopyA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
_Check_return_opt_ _CRTIMP char *__cdecl fgets(_Out_writes_z_(_MaxCount) char *_Buf, _In_ int _MaxCount, _Inout_ FILE *_File)
ULONG CDECL LdapGetLastError(void)
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
static int config_load(struct idmap_config *config, const char *filename)
__kernel_ptrdiff_t ptrdiff_t
static const char CONFIG_FILENAME[]
char * strchr(const char *String, int ch)
static const struct config_option g_options[]
int nfs41_idmap_gid_to_group(struct idmap_context *context, gid_t gid, char *name, size_t len)
static void user_cache_copy(struct list_entry *lhs, const struct list_entry *rhs)
static int config_init(struct idmap_config *config)
#define list_for_each_tmp(entry, tmp, head)
VOID WINAPI InitializeSRWLock(PSRWLOCK Lock)
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
int strcmp(const char *String1, const char *String2)
static struct list_entry * group_cache_alloc()
int nfs41_idmap_create(struct idmap_context **context_out)
#define OPT_CLASS(key, def, index)
static void cache_init(struct idmap_cache *cache, const struct cache_ops *ops)
static SERVICE_STATUS status
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
void user(int argc, const char *argv[])
void nfs41_idmap_free(struct idmap_context *context)
void(* entry_free_fn)(struct list_entry *)
VOID WINAPI ReleaseSRWLockShared(PSRWLOCK Lock)
static int config_parse_pair(char *line, struct config_pair *pair)
VOID WINAPI AcquireSRWLockExclusive(PSRWLOCK Lock)
GLuint const GLchar * name