ReactOS  0.4.13-dev-257-gfabbd7c
idmap.c File Reference
#include <windows.h>
#include <strsafe.h>
#include <winldap.h>
#include <stdlib.h>
#include <errno.h>
#include <time.h>
#include "idmap.h"
#include "nfs41_const.h"
#include "list.h"
#include "daemon_debug.h"
Include dependency graph for idmap.c:

Go to the source code of this file.

Classes

struct  idmap_lookup
 
struct  idmap_config
 
struct  config_option
 
struct  config_pair
 
struct  cache_ops
 
struct  idmap_cache
 
struct  idmap_user
 
struct  idmap_group
 
struct  idmap_context
 

Macros

#define IDLVL   2 /* dprintf level for idmap logging */
 
#define FILTER_LEN   1024
 
#define NAME_LEN   32
 
#define VAL_LEN   257
 
#define ATTR_FLAG(attr)   (1 << (attr))
 
#define ATTR_ISSET(mask, attr)   (((mask) & ATTR_FLAG(attr)) != 0)
 
#define OPT_INT(key, def, field)   { key, def, TYPE_INT, FIELD_OFFSET(struct idmap_config, field), 0 }
 
#define OPT_STR(key, def, field, len)   { key, def, TYPE_STR, FIELD_OFFSET(struct idmap_config, field), len }
 
#define OPT_CLASS(key, def, index)   { key, def, TYPE_STR, FIELD_OFFSET(struct idmap_config, classes[index]), NAME_LEN }
 
#define OPT_ATTR(key, def, index)   { key, def, TYPE_STR, FIELD_OFFSET(struct idmap_config, attributes[index]), NAME_LEN }
 

Typedefs

typedef struct list_entry *(* entry_alloc_fn) ()
 
typedef void(* entry_free_fn) (struct list_entry *)
 
typedef void(* entry_copy_fn) (struct list_entry *, const struct list_entry *)
 

Enumerations

enum  ldap_class { CLASS_USER, CLASS_GROUP, NUM_CLASSES }
 
enum  ldap_attr {
  ATTR_USER_NAME, ATTR_GROUP_NAME, ATTR_PRINCIPAL, ATTR_UID,
  ATTR_GID, NUM_ATTRIBUTES
}
 
enum  config_type { TYPE_STR, TYPE_INT }
 

Functions

static int config_parse_pair (char *line, struct config_pair *pair)
 
static BOOL parse_uint (const char *str, UINT *id_out)
 
static int config_defaults (struct idmap_config *config)
 
static int config_find_option (const struct config_pair *pair, const struct config_option **option)
 
static int config_load (struct idmap_config *config, const char *filename)
 
static int config_init (struct idmap_config *config)
 
static void cache_init (struct idmap_cache *cache, const struct cache_ops *ops)
 
static void cache_cleanup (struct idmap_cache *cache)
 
static int cache_insert (struct idmap_cache *cache, const struct idmap_lookup *lookup, const struct list_entry *src)
 
static int cache_lookup (struct idmap_cache *cache, const struct idmap_lookup *lookup, struct list_entry *entry_out)
 
static struct list_entryuser_cache_alloc ()
 
static void user_cache_free (struct list_entry *entry)
 
static void user_cache_copy (struct list_entry *lhs, const struct list_entry *rhs)
 
static struct list_entrygroup_cache_alloc ()
 
static void group_cache_free (struct list_entry *entry)
 
static void group_cache_copy (struct list_entry *lhs, const struct list_entry *rhs)
 
static int idmap_filter (struct idmap_config *config, const struct idmap_lookup *lookup, char *filter, size_t filter_len)
 
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 idmap_lookup_user (struct idmap_context *context, const struct idmap_lookup *lookup, struct idmap_user *user)
 
static int idmap_lookup_group (struct idmap_context *context, const struct idmap_lookup *lookup, struct idmap_group *group)
 
int nfs41_idmap_create (struct idmap_context **context_out)
 
void nfs41_idmap_free (struct idmap_context *context)
 
static int username_cmp (const struct list_entry *list, const void *value)
 
int nfs41_idmap_name_to_ids (struct idmap_context *context, const char *username, uid_t *uid_out, gid_t *gid_out)
 
static int uid_cmp (const struct list_entry *list, const void *value)
 
int nfs41_idmap_uid_to_name (struct idmap_context *context, uid_t uid, 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 int group_cmp (const struct list_entry *list, const void *value)
 
int nfs41_idmap_group_to_gid (struct idmap_context *context, const char *name, gid_t *gid_out)
 
static int gid_cmp (const struct list_entry *list, const void *value)
 
int nfs41_idmap_gid_to_group (struct idmap_context *context, gid_t gid, char *name, size_t len)
 

Variables

static const char CONFIG_FILENAME [] = "C:\\ReactOS\\System32\\drivers\\etc\\ms-nfs41-idmap.conf"
 
static const struct config_option g_options []
 
static const struct cache_ops user_cache_ops
 
static const struct cache_ops group_cache_ops
 

Macro Definition Documentation

◆ ATTR_FLAG

#define ATTR_FLAG (   attr)    (1 << (attr))

Definition at line 59 of file idmap.c.

◆ ATTR_ISSET

#define ATTR_ISSET (   mask,
  attr 
)    (((mask) & ATTR_FLAG(attr)) != 0)

Definition at line 60 of file idmap.c.

◆ FILTER_LEN

#define FILTER_LEN   1024

Definition at line 37 of file idmap.c.

◆ IDLVL

#define IDLVL   2 /* dprintf level for idmap logging */

Definition at line 35 of file idmap.c.

◆ NAME_LEN

#define NAME_LEN   32

Definition at line 38 of file idmap.c.

◆ OPT_ATTR

#define OPT_ATTR (   key,
  def,
  index 
)    { key, def, TYPE_STR, FIELD_OFFSET(struct idmap_config, attributes[index]), NAME_LEN }

Definition at line 119 of file idmap.c.

◆ OPT_CLASS

#define OPT_CLASS (   key,
  def,
  index 
)    { key, def, TYPE_STR, FIELD_OFFSET(struct idmap_config, classes[index]), NAME_LEN }

Definition at line 117 of file idmap.c.

◆ OPT_INT

#define OPT_INT (   key,
  def,
  field 
)    { key, def, TYPE_INT, FIELD_OFFSET(struct idmap_config, field), 0 }

Definition at line 113 of file idmap.c.

◆ OPT_STR

#define OPT_STR (   key,
  def,
  field,
  len 
)    { key, def, TYPE_STR, FIELD_OFFSET(struct idmap_config, field), len }

Definition at line 115 of file idmap.c.

◆ VAL_LEN

#define VAL_LEN   257

Definition at line 39 of file idmap.c.

Typedef Documentation

◆ entry_alloc_fn

typedef struct list_entry*(* entry_alloc_fn) ()

Definition at line 408 of file idmap.c.

◆ entry_copy_fn

typedef void(* entry_copy_fn) (struct list_entry *, const struct list_entry *)

Definition at line 410 of file idmap.c.

◆ entry_free_fn

typedef void(* entry_free_fn) (struct list_entry *)

Definition at line 409 of file idmap.c.

Enumeration Type Documentation

◆ config_type

Enumerator
TYPE_STR 
TYPE_INT 

Definition at line 99 of file idmap.c.

99  {
100  TYPE_STR,
101  TYPE_INT
102 };

◆ ldap_attr

Enumerator
ATTR_USER_NAME 
ATTR_GROUP_NAME 
ATTR_PRINCIPAL 
ATTR_UID 
ATTR_GID 
NUM_ATTRIBUTES 

Definition at line 49 of file idmap.c.

49  {
53  ATTR_UID,
54  ATTR_GID,
55 
57 };
Definition: idmap.c:53
Definition: idmap.c:54

◆ ldap_class

Enumerator
CLASS_USER 
CLASS_GROUP 
NUM_CLASSES 

Definition at line 42 of file idmap.c.

42  {
43  CLASS_USER,
45 
47 };

Function Documentation

◆ cache_cleanup()

static void cache_cleanup ( struct idmap_cache cache)
static

Definition at line 434 of file idmap.c.

436 {
437  struct list_entry *entry, *tmp;
438  list_for_each_tmp(entry, tmp, &cache->head)
439  cache->ops->entry_free(entry);
440  list_init(&cache->head);
441 }
Definition: cache.c:46
struct outqueuenode * head
Definition: adnsresfilter.c:66
uint32_t entry
Definition: isohybrid.c:63
Definition: list.h:27
#define list_for_each_tmp(entry, tmp, head)
Definition: list.h:39
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149

Referenced by nfs41_idmap_free().

◆ cache_init()

static void cache_init ( struct idmap_cache cache,
const struct cache_ops ops 
)
static

Definition at line 425 of file idmap.c.

428 {
429  list_init(&cache->head);
430  cache->ops = ops;
432 }
Definition: cache.c:46
HANDLE lock
Definition: cache.c:50
VOID WINAPI InitializeSRWLock(PSRWLOCK Lock)
Definition: sync.c:75
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149

Referenced by nfs41_idmap_create().

◆ cache_insert()

static int cache_insert ( struct idmap_cache cache,
const struct idmap_lookup lookup,
const struct list_entry src 
)
static

Definition at line 443 of file idmap.c.

447 {
448  struct list_entry *entry;
449  int status = NO_ERROR;
450 
452 
453  /* search for an existing match */
454  entry = list_search(&cache->head, lookup->value, lookup->compare);
455  if (entry) {
456  /* overwrite the existing entry with the new results */
457  cache->ops->entry_copy(entry, src);
458  goto out;
459  }
460 
461  /* initialize a new entry and add it to the list */
462  entry = cache->ops->entry_alloc();
463  if (entry == NULL) {
464  status = GetLastError();
465  goto out;
466  }
467  cache->ops->entry_copy(entry, src);
468  list_add_head(&cache->head, entry);
469 out:
471  return status;
472 }
Definition: cache.c:46
VOID WINAPI AcquireSRWLockExclusive(PSRWLOCK Lock)
Definition: sync.c:54
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
Definition: list.h:96
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
static ULONG lookup[16]
Definition: vga.c:46
#define NO_ERROR
Definition: dderror.h:5
smooth NULL
Definition: ftsmooth.c:416
HANDLE lock
Definition: cache.c:50
static FILE * out
Definition: regtests2xml.c:44
VOID WINAPI ReleaseSRWLockExclusive(PSRWLOCK Lock)
Definition: sync.c:82
uint32_t entry
Definition: isohybrid.c:63
GLenum src
Definition: glext.h:6340
static struct list_entry * list_search(const struct list_entry *head, const void *value, list_compare_fn compare)
Definition: list.h:102
Definition: list.h:27
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by idmap_lookup_group(), and idmap_lookup_user().

◆ cache_lookup()

static int cache_lookup ( struct idmap_cache cache,
const struct idmap_lookup lookup,
struct list_entry entry_out 
)
static

Definition at line 474 of file idmap.c.

478 {
479  struct list_entry *entry;
480  int status = ERROR_NOT_FOUND;
481 
483 
484  entry = list_search(&cache->head, lookup->value, lookup->compare);
485  if (entry) {
486  /* make a copy for use outside of the lock */
487  cache->ops->entry_copy(entry_out, entry);
488  status = NO_ERROR;
489  }
490 
492  return status;
493 }
Definition: cache.c:46
static ULONG lookup[16]
Definition: vga.c:46
#define NO_ERROR
Definition: dderror.h:5
HANDLE lock
Definition: cache.c:50
uint32_t entry
Definition: isohybrid.c:63
static struct list_entry * list_search(const struct list_entry *head, const void *value, list_compare_fn compare)
Definition: list.h:102
Definition: list.h:27
#define ERROR_NOT_FOUND
Definition: winerror.h:690
static SERVICE_STATUS status
Definition: service.c:31
VOID WINAPI AcquireSRWLockShared(PSRWLOCK Lock)
Definition: sync.c:61
VOID WINAPI ReleaseSRWLockShared(PSRWLOCK Lock)
Definition: sync.c:89
Definition: ps.c:97

Referenced by idmap_lookup_group(), and idmap_lookup_user().

◆ config_defaults()

static int config_defaults ( struct idmap_config config)
static

Definition at line 243 of file idmap.c.

245 {
246  const struct config_option *option;
247  const int count = ARRAYSIZE(g_options);
248  char *dst;
249  int i, status = NO_ERROR;
250 
251  for (i = 0; i < count; i++) {
252  option = &g_options[i];
253  dst = (char*)config + option->offset;
254 
255  if (option->type == TYPE_INT) {
256  if (!parse_uint(option->def, (UINT*)dst)) {
258  eprintf("failed to parse default value of %s=\"%s\": "
259  "expected a number\n", option->key, option->def);
260  break;
261  }
262  } else {
263  if (FAILED(StringCchCopyA(dst, option->max_len, option->def))) {
265  eprintf("failed to parse default value of %s=\"%s\": "
266  "buffer overflow > %u\n", option->key, option->def,
267  option->max_len);
268  break;
269  }
270  }
271  }
272  return status;
273 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
void eprintf(LPCSTR format,...)
Definition: daemon_debug.c:86
#define NO_ERROR
Definition: dderror.h:5
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
Definition: glfuncs.h:248
Definition: getopt.h:108
static BOOL parse_uint(const char *str, UINT *id_out)
Definition: idmap.c:223
GLuint GLenum option
Definition: glext.h:11211
if(!(yy_init))
Definition: macro.lex.yy.c:714
STRSAFEAPI StringCchCopyA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:145
GLenum GLenum dst
Definition: glext.h:6340
unsigned int UINT
Definition: ndis.h:50
static const struct config_option g_options[]
Definition: idmap.c:123
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by config_init().

◆ config_find_option()

static int config_find_option ( const struct config_pair pair,
const struct config_option **  option 
)
static

Definition at line 275 of file idmap.c.

278 {
279  int i, count = ARRAYSIZE(g_options);
280  int status = ERROR_NOT_FOUND;
281 
282  /* find the config_option by key */
283  for (i = 0; i < count; i++) {
284  if (stricmp(pair->key, g_options[i].key) == 0) {
285  *option = &g_options[i];
286  status = NO_ERROR;
287  break;
288  }
289  }
290  return status;
291 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define NO_ERROR
Definition: dderror.h:5
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
Definition: glfuncs.h:248
Definition: getopt.h:108
_Check_return_ _CRTIMP int __cdecl stricmp(_In_z_ const char *_Str1, _In_z_ const char *_Str2)
Definition: _pair.h:47
#define ERROR_NOT_FOUND
Definition: winerror.h:690
static const struct config_option g_options[]
Definition: idmap.c:123
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by config_load().

◆ config_init()

static int config_init ( struct idmap_config config)
static

Definition at line 362 of file idmap.c.

364 {
365  int status;
366 #ifdef __REACTOS__
367  char config_path[MAX_PATH];
368 #endif
369 
370  /* load default values */
372  if (status) {
373  eprintf("config_defaults() failed with %d\n", status);
374  goto out;
375  }
376 
377 #ifdef __REACTOS__
378  if (GetSystemDirectoryA(config_path, ARRAYSIZE(config_path)))
379  {
380  StringCchCatA(config_path, ARRAYSIZE(config_path), "\\drivers\\etc\\ms-nfs41-idmap.conf");
381  }
382  else
383  {
384  StringCchCopyA(config_path, ARRAYSIZE(config_path), "C:\\ReactOS\\system32\\drivers\\etc\\ms-nfs41-idmap.conf");
385  }
386 #endif
387 
388  /* load configuration from file */
389 #ifdef __REACTOS__
390  status = config_load(config, config_path);
391 #else
393 #endif
394  if (status) {
395 #ifdef __REACTOS__
396  eprintf("config_load('%s') failed with %d\n", config_path, status);
397 #else
398  eprintf("config_load('%s') failed with %d\n", CONFIG_FILENAME, status);
399 #endif
400  goto out;
401  }
402 out:
403  return status;
404 }
UINT WINAPI GetSystemDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2282
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
void eprintf(LPCSTR format,...)
Definition: daemon_debug.c:86
STRSAFEAPI StringCchCatA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:320
static int config_defaults(struct idmap_config *config)
Definition: idmap.c:243
#define MAX_PATH
Definition: compat.h:26
static FILE * out
Definition: regtests2xml.c:44
STRSAFEAPI StringCchCopyA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:145
static int config_load(struct idmap_config *config, const char *filename)
Definition: idmap.c:293
static const char CONFIG_FILENAME[]
Definition: idmap.c:79
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by nfs41_idmap_create().

◆ config_load()

static int config_load ( struct idmap_config config,
const char filename 
)
static

Definition at line 293 of file idmap.c.

296 {
297  char buffer[1024], *pos;
298  FILE *file;
299  struct config_pair pair;
300  const struct config_option *option;
301  int line = 0;
302  int status = NO_ERROR;
303 
304  /* open the file */
305  file = fopen(filename, "r");
306  if (file == NULL) {
307  eprintf("config_load() failed to open file '%s'\n", filename);
308  goto out;
309  }
310 
311  /* read each line */
312  while (fgets(buffer, sizeof(buffer), file)) {
313  line++;
314 
315  /* skip whitespace */
316  pos = buffer;
317  while (isspace(*pos)) pos++;
318 
319  /* skip comments and empty lines */
320  if (*pos == '#' || *pos == 0)
321  continue;
322 
323  /* parse line into a key=value pair */
325  if (status) {
326  eprintf("error on line %d: %s\n", line, buffer);
327  break;
328  }
329 
330  /* find the config_option by key */
332  if (status) {
333  eprintf("unrecognized option '%s' on line %d: %s\n",
334  pair.key, line, buffer);
336  break;
337  }
338 
339  if (option->type == TYPE_INT) {
340  if (!parse_uint(pair.value, (UINT*)((char*)config + option->offset))) {
342  eprintf("expected a number on line %d: %s=\"%s\"\n",
343  line, pair.key, pair.value);
344  break;
345  }
346  } else {
347  if (FAILED(StringCchCopyNA((char*)config + option->offset,
348  option->max_len, pair.value, pair.value_len))) {
350  eprintf("overflow on line %d: %s=\"%s\"\n",
351  line, pair.key, pair.value);
352  break;
353  }
354  }
355  }
356 
357  fclose(file);
358 out:
359  return status;
360 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define isspace(c)
Definition: acclib.h:69
static int config_find_option(const struct config_pair *pair, const struct config_option **option)
Definition: idmap.c:275
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
void eprintf(LPCSTR format,...)
Definition: daemon_debug.c:86
GLuint buffer
Definition: glext.h:5915
const char * filename
Definition: ioapi.h:135
#define NO_ERROR
Definition: dderror.h:5
STRSAFEAPI StringCchCopyNA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc, size_t cchToCopy)
Definition: strsafe.h:230
smooth NULL
Definition: ftsmooth.c:416
Definition: getopt.h:108
Definition: parser.c:48
static BOOL parse_uint(const char *str, UINT *id_out)
Definition: idmap.c:223
GLuint GLenum option
Definition: glext.h:11211
const char file[]
Definition: icontest.c:11
static FILE * out
Definition: regtests2xml.c:44
_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)
_Check_return_opt_ _CRTIMP char *__cdecl fgets(_Out_writes_z_(_MaxCount) char *_Buf, _In_ int _MaxCount, _Inout_ FILE *_File)
Definition: _pair.h:47
unsigned int UINT
Definition: ndis.h:50
static SERVICE_STATUS status
Definition: service.c:31
static int config_parse_pair(char *line, struct config_pair *pair)
Definition: idmap.c:153
Definition: fci.c:126
Definition: ps.c:97

Referenced by config_init().

◆ config_parse_pair()

static int config_parse_pair ( char line,
struct config_pair pair 
)
static

Definition at line 153 of file idmap.c.

156 {
157  char *pos = line;
158  int status = NO_ERROR;
159 
160  /* terminate at comment */
161  pos = strchr(line, '#');
162  if (pos) *pos = 0;
163 
164  /* skip whitespace before key */
165  pos = line;
166  while (isspace(*pos)) pos++;
167  pair->key = pos;
168 
169  pos = strchr(pos, '=');
170  if (pos == NULL) {
171  eprintf("missing '='\n");
173  goto out;
174  }
175 
176  /* skip whitespace after key */
177  pair->key_len = pos - pair->key;
178  while (pair->key_len && isspace(pair->key[pair->key_len-1]))
179  pair->key_len--;
180 
181  if (pair->key_len <= 0) {
182  eprintf("empty key\n");
184  goto out;
185  }
186 
187  /* skip whitespace after = */
188  pos++;
189  while (isspace(*pos)) pos++;
190 
191  if (*pos == 0) {
192  eprintf("end of line looking for value\n");
194  goto out;
195  }
196 
197  if (*pos == '\"') {
198  /* value is between the "s */
199  pair->value = pos + 1;
200  pos = strchr(pair->value, '\"');
201  if (pos == NULL) {
202  eprintf("no matching '\"'\n");
204  goto out;
205  }
206  pair->value_len = pos - pair->value;
207  } else {
208  pair->value = pos;
209  pair->value_len = strlen(pair->value);
210 
211  /* skip whitespace after value */
212  while (pair->value_len && isspace(pair->value[pair->value_len-1]))
213  pair->value_len--;
214  }
215 
216  /* on success, null terminate the key and value */
217  ((char*)pair->key)[pair->key_len] = 0;
218  ((char*)pair->value)[pair->value_len] = 0;
219 out:
220  return status;
221 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define isspace(c)
Definition: acclib.h:69
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
void eprintf(LPCSTR format,...)
Definition: daemon_debug.c:86
#define NO_ERROR
Definition: dderror.h:5
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
static FILE * out
Definition: regtests2xml.c:44
char line[200]
Definition: main.c:97
Definition: _pair.h:47
char * strchr(const char *String, int ch)
Definition: utclib.c:501
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by config_load().

◆ gid_cmp()

static int gid_cmp ( const struct list_entry list,
const void value 
)
static

Definition at line 1045 of file idmap.c.

1046 {
1047  const struct idmap_group *entry = list_container(list,
1048  const struct idmap_group, entry);
1049  const UINT_PTR gid = (const UINT_PTR)value;
1050  return (UINT)gid - entry->gid;
1051 }
unsigned __int3264 UINT_PTR
Definition: activex.cpp:275
gid_t gid
Definition: idmap.c:538
#define list_container(entry, type, field)
Definition: list.h:33
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
uint32_t entry
Definition: isohybrid.c:63
Definition: _list.h:228
unsigned int UINT
Definition: ndis.h:50

Referenced by nfs41_idmap_gid_to_group().

◆ group_cache_alloc()

static struct list_entry* group_cache_alloc ( )
static

Definition at line 542 of file idmap.c.

543 {
544  struct idmap_group *group = calloc(1, sizeof(struct idmap_group));
545  return group == NULL ? NULL : &group->entry;
546 }
smooth NULL
Definition: ftsmooth.c:416
GLboolean GLuint group
Definition: glext.h:11120
#define calloc
Definition: rosglue.h:14

◆ group_cache_copy()

static void group_cache_copy ( struct list_entry lhs,
const struct list_entry rhs 
)
static

Definition at line 551 of file idmap.c.

554 {
555  struct idmap_group *dst = list_container(lhs, struct idmap_group, entry);
556  const struct idmap_group *src = list_container(rhs, const struct idmap_group, entry);
557  StringCchCopyA(dst->name, VAL_LEN, src->name);
558  dst->gid = src->gid;
559  dst->last_updated = src->last_updated;
560 }
char * name
Definition: wpp.c:36
#define list_container(entry, type, field)
Definition: list.h:33
uint32_t entry
Definition: isohybrid.c:63
GLenum src
Definition: glext.h:6340
#define VAL_LEN
Definition: idmap.c:39
STRSAFEAPI StringCchCopyA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:145
GLenum GLenum dst
Definition: glext.h:6340

◆ group_cache_free()

static void group_cache_free ( struct list_entry entry)
static

Definition at line 547 of file idmap.c.

548 {
550 }
#define free
Definition: debug_ros.c:5
#define list_container(entry, type, field)
Definition: list.h:33
uint32_t entry
Definition: isohybrid.c:63

◆ group_cmp()

static int group_cmp ( const struct list_entry list,
const void value 
)
static

Definition at line 1007 of file idmap.c.

1008 {
1009  const struct idmap_group *entry = list_container(list,
1010  const struct idmap_group, entry);
1011  const char *group = (const char*)value;
1012  return strcmp(entry->name, group);
1013 }
#define list_container(entry, type, field)
Definition: list.h:33
GLboolean GLuint group
Definition: glext.h:11120
uint32_t entry
Definition: isohybrid.c:63
Definition: _list.h:228
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

Referenced by nfs41_idmap_group_to_gid().

◆ idmap_filter()

static int idmap_filter ( struct idmap_config config,
const struct idmap_lookup lookup,
char filter,
size_t  filter_len 
)
static

Definition at line 577 of file idmap.c.

582 {
583  UINT_PTR i;
584  int status = NO_ERROR;
585 
586  switch (lookup->type) {
587  case TYPE_INT:
588  i = (UINT_PTR)lookup->value;
589  if (FAILED(StringCchPrintfA(filter, filter_len,
590  "(&(objectClass=%s)(%s=%u))",
591  config->classes[lookup->klass],
592  config->attributes[lookup->attr], (UINT)i))) {
594  eprintf("ldap filter buffer overflow: '%s=%u'\n",
595  config->attributes[lookup->attr], (UINT)i);
596  }
597  break;
598 
599  case TYPE_STR:
600  if (FAILED(StringCchPrintfA(filter, filter_len,
601  "(&(objectClass=%s)(%s=%s))",
602  config->classes[lookup->klass],
603  config->attributes[lookup->attr], lookup->value))) {
605  eprintf("ldap filter buffer overflow: '%s=%s'\n",
606  config->attributes[lookup->attr], lookup->value);
607  }
608  break;
609 
610  default:
612  break;
613  }
614  return status;
615 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
unsigned __int3264 UINT_PTR
Definition: activex.cpp:275
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
static ULONG lookup[16]
Definition: vga.c:46
void eprintf(LPCSTR format,...)
Definition: daemon_debug.c:86
#define NO_ERROR
Definition: dderror.h:5
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
Definition: glfuncs.h:248
STRSAFEAPI StringCchPrintfA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszFormat,...)
Definition: strsafe.h:520
if(!(yy_init))
Definition: macro.lex.yy.c:714
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
unsigned int UINT
Definition: ndis.h:50
static SERVICE_STATUS status
Definition: service.c:31
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
Definition: ps.c:97

Referenced by idmap_query_attrs().

◆ idmap_lookup_group()

static int idmap_lookup_group ( struct idmap_context context,
const struct idmap_lookup lookup,
struct idmap_group group 
)
static

Definition at line 748 of file idmap.c.

752 {
754  const unsigned attributes = ATTR_FLAG(ATTR_GROUP_NAME)
755  | ATTR_FLAG(ATTR_GID);
756  int i, status;
757 
758  /* check the group cache for an existing entry */
759  status = cache_lookup(&context->groups, lookup, &group->entry);
760  if (status == NO_ERROR) {
761  /* don't return expired entries; query new attributes
762  * and overwrite the entry with cache_insert() */
763  if (time(NULL) - group->last_updated < context->config.cache_ttl)
764  goto out;
765  }
766 
767  /* send the query to the ldap server */
769  attributes, 0, values, NUM_ATTRIBUTES);
770  if (status)
771  goto out_free_values;
772 
773  /* parse attributes */
774  if (FAILED(StringCchCopyA(group->name, VAL_LEN,
775  *values[ATTR_GROUP_NAME]))) {
776  eprintf("ldap attribute %s='%s' longer than %u characters\n",
777  context->config.attributes[ATTR_GROUP_NAME],
780  goto out_free_values;
781  }
782  if (!parse_uint(*values[ATTR_GID], &group->gid)) {
783  eprintf("failed to parse ldap attribute %s='%s'\n",
784  context->config.attributes[ATTR_GID], *values[ATTR_GID]);
786  goto out_free_values;
787  }
788  group->last_updated = time(NULL);
789 
790  if (context->config.cache_ttl) {
791  /* insert the entry into the cache */
792  cache_insert(&context->groups, lookup, &group->entry);
793  }
794 out_free_values:
795  for (i = 0; i < NUM_ATTRIBUTES; i++)
797 out:
798  return status;
799 }
signed char * PCHAR
Definition: retypes.h:7
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
Definition: http.c:6587
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
static int cache_lookup(struct idmap_cache *cache, const struct idmap_lookup *lookup, struct list_entry *entry_out)
Definition: idmap.c:474
GLboolean GLenum GLenum GLvoid * values
Definition: glext.h:5666
static ULONG lookup[16]
Definition: vga.c:46
void eprintf(LPCSTR format,...)
Definition: daemon_debug.c:86
__u16 time
Definition: mkdosfs.c:366
#define NO_ERROR
Definition: dderror.h:5
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
Definition: glfuncs.h:248
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)
Definition: idmap.c:617
#define ldap_value_free
Definition: winldap.h:689
smooth NULL
Definition: ftsmooth.c:416
static BOOL parse_uint(const char *str, UINT *id_out)
Definition: idmap.c:223
GLboolean GLuint group
Definition: glext.h:11120
static FILE * out
Definition: regtests2xml.c:44
#define ATTR_FLAG(attr)
Definition: idmap.c:59
#define VAL_LEN
Definition: idmap.c:39
static int cache_insert(struct idmap_cache *cache, const struct idmap_lookup *lookup, const struct list_entry *src)
Definition: idmap.c:443
STRSAFEAPI StringCchCopyA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:145
Definition: idmap.c:54
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by nfs41_idmap_gid_to_group(), and nfs41_idmap_group_to_gid().

◆ idmap_lookup_user()

static int idmap_lookup_user ( struct idmap_context context,
const struct idmap_lookup lookup,
struct idmap_user user 
)
static

Definition at line 677 of file idmap.c.

681 {
683  const unsigned attributes = ATTR_FLAG(ATTR_USER_NAME)
686  | ATTR_FLAG(ATTR_GID);
687  /* principal is optional; we'll cache it if we have it */
688  const unsigned optional = ATTR_FLAG(ATTR_PRINCIPAL);
689  int i, status;
690 
691  /* check the user cache for an existing entry */
692  status = cache_lookup(&context->users, lookup, &user->entry);
693  if (status == NO_ERROR) {
694  /* don't return expired entries; query new attributes
695  * and overwrite the entry with cache_insert() */
696  if (time(NULL) - user->last_updated < context->config.cache_ttl)
697  goto out;
698  }
699 
700  /* send the query to the ldap server */
702  attributes, optional, values, NUM_ATTRIBUTES);
703  if (status)
704  goto out_free_values;
705 
706  /* parse attributes */
707  if (FAILED(StringCchCopyA(user->username, VAL_LEN,
708  *values[ATTR_USER_NAME]))) {
709  eprintf("ldap attribute %s='%s' longer than %u characters\n",
710  context->config.attributes[ATTR_USER_NAME],
713  goto out_free_values;
714  }
715  if (FAILED(StringCchCopyA(user->principal, VAL_LEN,
717  eprintf("ldap attribute %s='%s' longer than %u characters\n",
718  context->config.attributes[ATTR_PRINCIPAL],
721  goto out_free_values;
722  }
723  if (!parse_uint(*values[ATTR_UID], &user->uid)) {
724  eprintf("failed to parse ldap attribute %s='%s'\n",
725  context->config.attributes[ATTR_UID], *values[ATTR_UID]);
727  goto out_free_values;
728  }
729  if (!parse_uint(*values[ATTR_GID], &user->gid)) {
730  eprintf("failed to parse ldap attribute %s='%s'\n",
731  context->config.attributes[ATTR_GID], *values[ATTR_GID]);
733  goto out_free_values;
734  }
735  user->last_updated = time(NULL);
736 
737  if (context->config.cache_ttl) {
738  /* insert the entry into the cache */
739  cache_insert(&context->users, lookup, &user->entry);
740  }
741 out_free_values:
742  for (i = 0; i < NUM_ATTRIBUTES; i++)
744 out:
745  return status;
746 }
signed char * PCHAR
Definition: retypes.h:7
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
Definition: http.c:6587
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
static int cache_lookup(struct idmap_cache *cache, const struct idmap_lookup *lookup, struct list_entry *entry_out)
Definition: idmap.c:474
Definition: idmap.c:53
GLboolean GLenum GLenum GLvoid * values
Definition: glext.h:5666
static ULONG lookup[16]
Definition: vga.c:46
void eprintf(LPCSTR format,...)
Definition: daemon_debug.c:86
__u16 time
Definition: mkdosfs.c:366
#define NO_ERROR
Definition: dderror.h:5
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
Definition: glfuncs.h:248
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)
Definition: idmap.c:617
#define ldap_value_free
Definition: winldap.h:689
smooth NULL
Definition: ftsmooth.c:416
Definition: msg.h:41
static BOOL parse_uint(const char *str, UINT *id_out)
Definition: idmap.c:223
static FILE * out
Definition: regtests2xml.c:44
#define ATTR_FLAG(attr)
Definition: idmap.c:59
#define VAL_LEN
Definition: idmap.c:39
static int cache_insert(struct idmap_cache *cache, const struct idmap_lookup *lookup, const struct list_entry *src)
Definition: idmap.c:443
STRSAFEAPI StringCchCopyA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:145
Definition: idmap.c:54
static SERVICE_STATUS status
Definition: service.c:31
void user(int argc, const char *argv[])
Definition: cmds.c:1350
Definition: ps.c:97

Referenced by nfs41_idmap_name_to_ids(), nfs41_idmap_principal_to_ids(), and nfs41_idmap_uid_to_name().

◆ idmap_query_attrs()

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

Definition at line 617 of file idmap.c.

624 {
625  char filter[FILTER_LEN];
626  struct idmap_config *config = &context->config;
627  LDAPMessage *res = NULL, *entry;
628  int i, status;
629 
630  /* format the ldap filter */
632  if (status)
633  goto out;
634 
635  /* send the ldap query */
636  status = ldap_search_st(context->ldap, config->base,
638  if (status) {
639  eprintf("ldap search for '%s' failed with %d: %s\n",
642  goto out;
643  }
644 
645  entry = ldap_first_entry(context->ldap, res);
646  if (entry == NULL) {
648  eprintf("ldap search for '%s' failed with %d: %s\n",
651  goto out;
652  }
653 
654  /* fetch the attributes */
655  for (i = 0; i < len; i++) {
656  if (ATTR_ISSET(attributes, i)) {
657  values[i] = ldap_get_values(context->ldap,
658  entry, config->attributes[i]);
659 
660  /* fail if required attributes are missing */
661  if (values[i] == NULL && !ATTR_ISSET(optional, i)) {
663  eprintf("ldap entry for '%s' missing required "
664  "attribute '%s', returning %d: %s\n",
665  filter, config->attributes[i],
668  goto out;
669  }
670  }
671  }
672 out:
673  if (res) ldap_msgfree(res);
674  return status;
675 }
WINLDAPAPI ULONG ldap_msgfree(LDAPMessage *)
Definition: http.c:6587
#define ldap_get_values
Definition: winldap.h:670
static int idmap_filter(struct idmap_config *config, const struct idmap_lookup *lookup, char *filter, size_t filter_len)
Definition: idmap.c:577
#define ATTR_ISSET(mask, attr)
Definition: idmap.c:60
GLboolean GLenum GLenum GLvoid * values
Definition: glext.h:5666
WINLDAPAPI PLDAPMessage ldap_first_entry(LDAP *, LDAPMessage *)
static ULONG lookup[16]
Definition: vga.c:46
void eprintf(LPCSTR format,...)
Definition: daemon_debug.c:86
PCHAR CDECL ldap_err2stringA(ULONG err)
Definition: error.c:71
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
Definition: glfuncs.h:248
ULONG CDECL LdapMapErrorToWin32(ULONG err)
Definition: error.c:302
#define ldap_search_st
Definition: winldap.h:680
smooth NULL
Definition: ftsmooth.c:416
Definition: msg.h:41
#define LDAP_NO_RESULTS_RETURNED
Definition: winldap.h:114
char attributes[NUM_ATTRIBUTES][NAME_LEN]
Definition: idmap.c:91
static FILE * out
Definition: regtests2xml.c:44
#define LDAP_NO_SUCH_ATTRIBUTE
Definition: winldap.h:74
uint32_t entry
Definition: isohybrid.c:63
GLenum GLsizei len
Definition: glext.h:6722
#define FILTER_LEN
Definition: idmap.c:37
#define LDAP_SCOPE_SUBTREE
Definition: winldap.h:190
GLuint res
Definition: glext.h:9613
static SERVICE_STATUS status
Definition: service.c:31
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
Definition: ps.c:97

Referenced by idmap_lookup_group(), and idmap_lookup_user().

◆ nfs41_idmap_create()

int nfs41_idmap_create ( struct idmap_context **  context_out)

Definition at line 803 of file idmap.c.

805 {
806  struct idmap_context *context;
807  int status = NO_ERROR;
808 
809  context = calloc(1, sizeof(struct idmap_context));
810  if (context == NULL) {
811  status = GetLastError();
812  goto out;
813  }
814 
815  /* initialize the caches */
816  cache_init(&context->users, &user_cache_ops);
817  cache_init(&context->groups, &group_cache_ops);
818 
819  /* load ldap configuration from file */
820  status = config_init(&context->config);
821  if (status) {
822  eprintf("config_init() failed with %d\n", status);
823  goto out_err_free;
824  }
825 
826  /* initialize ldap and configure options */
827  context->ldap = ldap_init(context->config.hostname, context->config.port);
828  if (context->ldap == NULL) {
830  eprintf("ldap_init(%s) failed with %d: %s\n",
831  context->config.hostname, status, ldap_err2stringA(status));
833  goto out_err_free;
834  }
835 
837  (void *)&context->config.version);
838  if (status != LDAP_SUCCESS) {
839  eprintf("ldap_set_option(version=%d) failed with %d\n",
840  context->config.version, status);
842  goto out_err_free;
843  }
844 
845  if (context->config.timeout) {
847  (void *)&context->config.timeout);
848  if (status != LDAP_SUCCESS) {
849  eprintf("ldap_set_option(timeout=%d) failed with %d\n",
850  context->config.timeout, status);
852  goto out_err_free;
853  }
854  }
855 
856  *context_out = context;
857 out:
858  return status;
859 
860 out_err_free:
862  goto out;
863 }
static const struct cache_ops group_cache_ops
Definition: idmap.c:561
Definition: http.c:6587
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
void eprintf(LPCSTR format,...)
Definition: daemon_debug.c:86
PCHAR CDECL ldap_err2stringA(ULONG err)
Definition: error.c:71
#define NO_ERROR
Definition: dderror.h:5
#define LDAP_OPT_PROTOCOL_VERSION
Definition: winldap.h:145
#define LDAP_OPT_TIMELIMIT
Definition: winldap.h:133
ULONG CDECL LdapMapErrorToWin32(ULONG err)
Definition: error.c:302
smooth NULL
Definition: ftsmooth.c:416
static const struct cache_ops user_cache_ops
Definition: idmap.c:527
static FILE * out
Definition: regtests2xml.c:44
#define ldap_init
Definition: winldap.h:638
ULONG CDECL LdapGetLastError(void)
Definition: error.c:184
#define LDAP_SUCCESS
Definition: winldap.h:59
static int config_init(struct idmap_config *config)
Definition: idmap.c:362
#define calloc
Definition: rosglue.h:14
#define ldap_set_option
Definition: winldap.h:641
static void cache_init(struct idmap_cache *cache, const struct cache_ops *ops)
Definition: idmap.c:425
static SERVICE_STATUS status
Definition: service.c:31
void nfs41_idmap_free(struct idmap_context *context)
Definition: idmap.c:865
Definition: ps.c:97

Referenced by ServiceStart().

◆ nfs41_idmap_free()

void nfs41_idmap_free ( struct idmap_context context)

Definition at line 865 of file idmap.c.

867 {
868  /* clean up the connection */
869  if (context->ldap)
870  ldap_unbind(context->ldap);
871 
872  cache_cleanup(&context->users);
873  cache_cleanup(&context->groups);
874  free(context);
875 }
Definition: http.c:6587
#define free
Definition: debug_ros.c:5
WINLDAPAPI ULONG ldap_unbind(LDAP *)
static void cache_cleanup(struct idmap_cache *cache)
Definition: idmap.c:434

Referenced by nfs41_idmap_create(), and ServiceStart().

◆ nfs41_idmap_gid_to_group()

int nfs41_idmap_gid_to_group ( struct idmap_context context,
gid_t  gid,
char name,
size_t  len 
)

Definition at line 1053 of file idmap.c.

1058 {
1059  UINT_PTR gidp = gid; /* convert to pointer size to pass as void* */
1061  struct idmap_group group;
1062  int status;
1063 
1064  dprintf(IDLVL, "--> nfs41_idmap_gid_to_group(%u)\n", gid);
1065 
1066  lookup.value = (const void*)gidp;
1067 
1068  /* look up the group entry */
1070  if (status) {
1071  dprintf(IDLVL, "<-- nfs41_idmap_gid_to_group(%u) "
1072  "failed with %d\n", gid, status);
1073  goto out;
1074  }
1075 
1076  if (FAILED(StringCchCopyA(name, len, group.name))) {
1078  eprintf("group name buffer overflow: '%s' > %u\n",
1079  group.name, len);
1080  goto out;
1081  }
1082 
1083  dprintf(IDLVL, "<-- nfs41_idmap_gid_to_group(%u) "
1084  "returning '%s'\n", gid, name);
1085 out:
1086  return status;
1087 }
Definition: http.c:6587
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
static ULONG lookup[16]
Definition: vga.c:46
void eprintf(LPCSTR format,...)
Definition: daemon_debug.c:86
gid_t gid
Definition: idmap.c:538
#define dprintf
Definition: regdump.c:33
#define IDLVL
Definition: idmap.c:35
GLboolean GLuint group
Definition: glext.h:11120
static int idmap_lookup_group(struct idmap_context *context, const struct idmap_lookup *lookup, struct idmap_group *group)
Definition: idmap.c:748
static FILE * out
Definition: regtests2xml.c:44
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
GLenum GLsizei len
Definition: glext.h:6722
static int gid_cmp(const struct list_entry *list, const void *value)
Definition: idmap.c:1045
STRSAFEAPI StringCchCopyA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:145
Definition: name.c:36
Definition: idmap.c:54
static SERVICE_STATUS status
Definition: service.c:31
WCHAR * name
Definition: name.c:40
Definition: ps.c:97

◆ nfs41_idmap_group_to_gid()

int nfs41_idmap_group_to_gid ( struct idmap_context context,
const char name,
gid_t gid_out 
)

Definition at line 1015 of file idmap.c.

1019 {
1020  struct idmap_lookup lookup = { ATTR_GROUP_NAME,
1022  struct idmap_group group;
1023  int status;
1024 
1025  dprintf(IDLVL, "--> nfs41_idmap_group_to_gid('%s')\n", name);
1026 
1027  lookup.value = name;
1028 
1029  /* look up the group entry */
1031  if (status) {
1032  dprintf(IDLVL, "<-- nfs41_idmap_group_to_gid('%s') "
1033  "failed with %d\n", name, status);
1034  goto out;
1035  }
1036 
1037  *gid_out = group.gid;
1038  dprintf(IDLVL, "<-- nfs41_idmap_group_to_gid('%s') "
1039  "returning %u\n", name, group.gid);
1040 out:
1041  return status;
1042 }
Definition: http.c:6587
static ULONG lookup[16]
Definition: vga.c:46
#define dprintf
Definition: regdump.c:33
static int group_cmp(const struct list_entry *list, const void *value)
Definition: idmap.c:1007
#define IDLVL
Definition: idmap.c:35
GLboolean GLuint group
Definition: glext.h:11120
static int idmap_lookup_group(struct idmap_context *context, const struct idmap_lookup *lookup, struct idmap_group *group)
Definition: idmap.c:748
static FILE * out
Definition: regtests2xml.c:44
Definition: name.c:36
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97
GLuint const GLchar * name
Definition: glext.h:6031

◆ nfs41_idmap_name_to_ids()

int nfs41_idmap_name_to_ids ( struct idmap_context context,
const char username,
uid_t uid_out,
gid_t gid_out 
)

Definition at line 887 of file idmap.c.

892 {
895  struct idmap_user user;
896  int status;
897 
898  if (context == NULL)
899  return ERROR_FILE_NOT_FOUND;
900 
901  dprintf(IDLVL, "--> nfs41_idmap_name_to_ids('%s')\n", username);
902 
903  lookup.value = username;
904 
905  /* look up the user entry */
907  if (status) {
908  dprintf(IDLVL, "<-- nfs41_idmap_name_to_ids('%s') "
909  "failed with %d\n", username, status);
910  goto out;
911  }
912 
913  *uid_out = user.uid;
914  *gid_out = user.gid;
915  dprintf(IDLVL, "<-- nfs41_idmap_name_to_ids('%s') "
916  "returning uid=%u, gid=%u\n", username, user.uid, user.gid);
917 out:
918  return status;
919 }
Definition: http.c:6587
static ULONG lookup[16]
Definition: vga.c:46
static int idmap_lookup_user(struct idmap_context *context, const struct idmap_lookup *lookup, struct idmap_user *user)
Definition: idmap.c:677
static int username_cmp(const struct list_entry *list, const void *value)
Definition: idmap.c:879
#define dprintf
Definition: regdump.c:33
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
static WCHAR username[]
Definition: url.c:32
#define IDLVL
Definition: idmap.c:35
static FILE * out
Definition: regtests2xml.c:44
static SERVICE_STATUS status
Definition: service.c:31
void user(int argc, const char *argv[])
Definition: cmds.c:1350
Definition: ps.c:97

Referenced by map_user_to_ids().

◆ nfs41_idmap_principal_to_ids()

int nfs41_idmap_principal_to_ids ( struct idmap_context context,
const char principal,
uid_t uid_out,
gid_t gid_out 
)

Definition at line 975 of file idmap.c.

980 {
983  struct idmap_user user;
984  int status;
985 
986  dprintf(IDLVL, "--> nfs41_idmap_principal_to_ids('%s')\n", principal);
987 
988  lookup.value = principal;
989 
990  /* look up the user entry */
992  if (status) {
993  dprintf(IDLVL, "<-- nfs41_idmap_principal_to_ids('%s') "
994  "failed with %d\n", principal, status);
995  goto out;
996  }
997 
998  *uid_out = user.uid;
999  *gid_out = user.gid;
1000  dprintf(IDLVL, "<-- nfs41_idmap_principal_to_ids('%s') "
1001  "returning uid=%u, gid=%u\n", principal, user.uid, user.gid);
1002 out:
1003  return status;
1004 }
Definition: http.c:6587
static ULONG lookup[16]
Definition: vga.c:46
static int idmap_lookup_user(struct idmap_context *context, const struct idmap_lookup *lookup, struct idmap_user *user)
Definition: idmap.c:677
static int principal_cmp(const struct list_entry *list, const void *value)
Definition: idmap.c:967
#define dprintf
Definition: regdump.c:33
#define IDLVL
Definition: idmap.c:35
static FILE * out
Definition: regtests2xml.c:44
char principal[VAL_LEN]
Definition: idmap.c:500
static SERVICE_STATUS status
Definition: service.c:31
void user(int argc, const char *argv[])
Definition: cmds.c:1350
Definition: ps.c:97

◆ nfs41_idmap_uid_to_name()

int nfs41_idmap_uid_to_name ( struct idmap_context context,
uid_t  uid,
char name,
size_t  len 
)

Definition at line 930 of file idmap.c.

935 {
936  UINT_PTR uidp = uid; /* convert to pointer size to pass as void* */
938  struct idmap_user user;
939  int status;
940 
941  dprintf(IDLVL, "--> nfs41_idmap_uid_to_name(%u)\n", uid);
942 
943  lookup.value = (const void*)uidp;
944 
945  /* look up the user entry */
947  if (status) {
948  dprintf(IDLVL, "<-- nfs41_idmap_uid_to_name(%u) "
949  "failed with %d\n", uid, status);
950  goto out;
951  }
952 
953  if (FAILED(StringCchCopyA(name, len, user.username))) {
955  eprintf("username buffer overflow: '%s' > %u\n",
956  user.username, len);
957  goto out;
958  }
959 
960  dprintf(IDLVL, "<-- nfs41_idmap_uid_to_name(%u) "
961  "returning '%s'\n", uid, name);
962 out:
963  return status;
964 }
Definition: http.c:6587
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
uid_t uid
Definition: idmap.c:501
static int uid_cmp(const struct list_entry *list, const void *value)
Definition: idmap.c:922
Definition: idmap.c:53
static ULONG lookup[16]
Definition: vga.c:46
void eprintf(LPCSTR format,...)
Definition: daemon_debug.c:86
static int idmap_lookup_user(struct idmap_context *context, const struct idmap_lookup *lookup, struct idmap_user *user)
Definition: idmap.c:677
#define dprintf
Definition: regdump.c:33
#define IDLVL
Definition: idmap.c:35
static FILE * out
Definition: regtests2xml.c:44
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
GLenum GLsizei len
Definition: glext.h:6722
STRSAFEAPI StringCchCopyA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:145
Definition: name.c:36
static SERVICE_STATUS status
Definition: service.c:31
void user(int argc, const char *argv[])
Definition: cmds.c:1350
Definition: ps.c:97

◆ parse_uint()

static BOOL parse_uint ( const char str,
UINT id_out 
)
static

Definition at line 223 of file idmap.c.

226 {
227  PCHAR endp;
228  const UINT id = strtoul(str, &endp, 10);
229 
230  /* must convert the whole string */
231  if ((endp - str) < (ptrdiff_t)strlen(str))
232  return FALSE;
233 
234  /* result must fit in 32 bits */
235  if (id == ULONG_MAX && errno == ERANGE)
236  return FALSE;
237 
238  *id_out = id;
239  return TRUE;
240 }
signed char * PCHAR
Definition: retypes.h:7
UINT32 strtoul(const char *String, char **Terminator, UINT32 Base)
Definition: utclib.c:696
#define TRUE
Definition: types.h:120
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
int errno
const WCHAR * str
#define ERANGE
Definition: acclib.h:92
unsigned int UINT
Definition: ndis.h:50
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
GLenum GLuint id
Definition: glext.h:5579
#define ULONG_MAX
Definition: limits.h:44

Referenced by config_defaults(), config_load(), idmap_lookup_group(), and idmap_lookup_user().

◆ principal_cmp()

static int principal_cmp ( const struct list_entry list,
const void value 
)
static

Definition at line 967 of file idmap.c.

968 {
969  const struct idmap_user *entry = list_container(list,
970  const struct idmap_user, entry);
971  const char *principal = (const char*)value;
972  return strcmp(entry->principal, principal);
973 }
#define list_container(entry, type, field)
Definition: list.h:33
uint32_t entry
Definition: isohybrid.c:63
Definition: _list.h:228
char principal[VAL_LEN]
Definition: idmap.c:500
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

Referenced by nfs41_idmap_principal_to_ids().

◆ uid_cmp()

static int uid_cmp ( const struct list_entry list,
const void value 
)
static

Definition at line 922 of file idmap.c.

923 {
924  const struct idmap_user *entry = list_container(list,
925  const struct idmap_user, entry);
926  const UINT_PTR uid = (const UINT_PTR)value;
927  return (UINT)uid - entry->uid;
928 }
unsigned __int3264 UINT_PTR
Definition: activex.cpp:275
uid_t uid
Definition: idmap.c:501
#define list_container(entry, type, field)
Definition: list.h:33
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
uint32_t entry
Definition: isohybrid.c:63
Definition: _list.h:228
unsigned int UINT
Definition: ndis.h:50

Referenced by nfs41_idmap_uid_to_name().

◆ user_cache_alloc()

static struct list_entry* user_cache_alloc ( )
static

Definition at line 506 of file idmap.c.

507 {
508  struct idmap_user *user = calloc(1, sizeof(struct idmap_user));
509  return user == NULL ? NULL : &user->entry;
510 }
smooth NULL
Definition: ftsmooth.c:416
#define calloc
Definition: rosglue.h:14
void user(int argc, const char *argv[])
Definition: cmds.c:1350

◆ user_cache_copy()

static void user_cache_copy ( struct list_entry lhs,
const struct list_entry rhs 
)
static

Definition at line 515 of file idmap.c.

518 {
519  struct idmap_user *dst = list_container(lhs, struct idmap_user, entry);
520  const struct idmap_user *src = list_container(rhs, const struct idmap_user, entry);
521  StringCchCopyA(dst->username, VAL_LEN, src->username);
522  StringCchCopyA(dst->principal, VAL_LEN, src->principal);
523  dst->uid = src->uid;
524  dst->gid = src->gid;
525  dst->last_updated = src->last_updated;
526 }
#define list_container(entry, type, field)
Definition: list.h:33
uint32_t entry
Definition: isohybrid.c:63
GLenum src
Definition: glext.h:6340
#define VAL_LEN
Definition: idmap.c:39
STRSAFEAPI StringCchCopyA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:145
GLenum GLenum dst
Definition: glext.h:6340

◆ user_cache_free()

static void user_cache_free ( struct list_entry entry)
static

Definition at line 511 of file idmap.c.

512 {
514 }
#define free
Definition: debug_ros.c:5
#define list_container(entry, type, field)
Definition: list.h:33
uint32_t entry
Definition: isohybrid.c:63

◆ username_cmp()

static int username_cmp ( const struct list_entry list,
const void value 
)
static

Definition at line 879 of file idmap.c.

880 {
881  const struct idmap_user *entry = list_container(list,
882  const struct idmap_user, entry);
883  const char *username = (const char*)value;
884  return strcmp(entry->username, username);
885 }
#define list_container(entry, type, field)
Definition: list.h:33
static WCHAR username[]
Definition: url.c:32
uint32_t entry
Definition: isohybrid.c:63
Definition: _list.h:228
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

Referenced by nfs41_idmap_name_to_ids().

Variable Documentation

◆ CONFIG_FILENAME

const char CONFIG_FILENAME[] = "C:\\ReactOS\\System32\\drivers\\etc\\ms-nfs41-idmap.conf"
static

Definition at line 79 of file idmap.c.

Referenced by config_init().

◆ g_options

const struct config_option g_options[]
static
Initial value:
= {
OPT_STR("ldap_hostname", "localhost", hostname, NFS41_HOSTNAME_LEN+1),
OPT_INT("ldap_port", "389", port),
OPT_INT("ldap_version", "3", version),
OPT_INT("ldap_timeout", "0", timeout),
OPT_STR("ldap_base", "cn=localhost", base, VAL_LEN),
OPT_CLASS("ldap_class_users", "user", CLASS_USER),
OPT_CLASS("ldap_class_groups", "group", CLASS_GROUP),
OPT_ATTR("ldap_attr_username", "cn", ATTR_USER_NAME),
OPT_ATTR("ldap_attr_groupname", "cn", ATTR_GROUP_NAME),
OPT_ATTR("ldap_attr_gssAuthName", "gssAuthName", ATTR_PRINCIPAL),
OPT_ATTR("ldap_attr_uidNumber", "uidNumber", ATTR_UID),
OPT_ATTR("ldap_attr_gidNumber", "gidNumber", ATTR_GID),
OPT_INT("cache_ttl", "60", cache_ttl),
}
#define OPT_ATTR(key, def, index)
Definition: idmap.c:119
Definition: idmap.c:53
Definition: dhcpd.h:245
#define OPT_INT(key, def, field)
Definition: idmap.c:113
char * hostname
Definition: ftp.c:88
#define NFS41_HOSTNAME_LEN
Definition: nfs41_const.h:48
static const WCHAR version[]
Definition: asmname.c:64
#define VAL_LEN
Definition: idmap.c:39
#define OPT_STR(key, def, field, len)
Definition: idmap.c:115
Definition: idmap.c:54
#define OPT_CLASS(key, def, index)
Definition: idmap.c:117
USHORT port
Definition: uri.c:227

Definition at line 123 of file idmap.c.

Referenced by config_defaults(), and config_find_option().

◆ group_cache_ops

const struct cache_ops group_cache_ops
static
Initial value:
= {
}
static void group_cache_free(struct list_entry *entry)
Definition: idmap.c:547
static void group_cache_copy(struct list_entry *lhs, const struct list_entry *rhs)
Definition: idmap.c:551
static struct list_entry * group_cache_alloc()
Definition: idmap.c:542

Definition at line 561 of file idmap.c.

Referenced by nfs41_idmap_create().

◆ user_cache_ops

const struct cache_ops user_cache_ops
static
Initial value:
= {
}
static struct list_entry * user_cache_alloc()
Definition: idmap.c:506
static void user_cache_free(struct list_entry *entry)
Definition: idmap.c:511
static void user_cache_copy(struct list_entry *lhs, const struct list_entry *rhs)
Definition: idmap.c:515

Definition at line 527 of file idmap.c.

Referenced by nfs41_idmap_create().