ReactOS  0.4.14-dev-1296-g56aa513
idmap.h File Reference
#include "nfs41_types.h"
Include dependency graph for idmap.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef struct idmap_context nfs41_idmapper
 

Functions

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)
 

Typedef Documentation

◆ nfs41_idmapper

Definition at line 29 of file idmap.h.

Function Documentation

◆ nfs41_idmap_create()

int nfs41_idmap_create ( nfs41_idmapper **  context_out)

Definition at line 805 of file idmap.c.

807 {
808  struct idmap_context *context;
809  int status = NO_ERROR;
810 
811  context = calloc(1, sizeof(struct idmap_context));
812  if (context == NULL) {
813  status = GetLastError();
814  goto out;
815  }
816 
817  /* initialize the caches */
818  cache_init(&context->users, &user_cache_ops);
819  cache_init(&context->groups, &group_cache_ops);
820 
821  /* load ldap configuration from file */
822  status = config_init(&context->config);
823  if (status) {
824  eprintf("config_init() failed with %d\n", status);
825  goto out_err_free;
826  }
827 
828  /* initialize ldap and configure options */
829  context->ldap = ldap_init(context->config.hostname, context->config.port);
830  if (context->ldap == NULL) {
832  eprintf("ldap_init(%s) failed with %d: %s\n",
833  context->config.hostname, status, ldap_err2stringA(status));
835  goto out_err_free;
836  }
837 
839  (void *)&context->config.version);
840  if (status != LDAP_SUCCESS) {
841  eprintf("ldap_set_option(version=%d) failed with %d\n",
842  context->config.version, status);
844  goto out_err_free;
845  }
846 
847  if (context->config.timeout) {
849  (void *)&context->config.timeout);
850  if (status != LDAP_SUCCESS) {
851  eprintf("ldap_set_option(timeout=%d) failed with %d\n",
852  context->config.timeout, status);
854  goto out_err_free;
855  }
856  }
857 
858  *context_out = context;
859 out:
860  return status;
861 
862 out_err_free:
864  goto out;
865 }
static const struct cache_ops group_cache_ops
Definition: idmap.c:563
Definition: http.c:7094
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:529
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:427
static SERVICE_STATUS status
Definition: service.c:31
void nfs41_idmap_free(struct idmap_context *context)
Definition: idmap.c:867
Definition: ps.c:97

Referenced by ServiceStart().

◆ nfs41_idmap_free()

void nfs41_idmap_free ( nfs41_idmapper context)

Definition at line 867 of file idmap.c.

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

Referenced by nfs41_idmap_create(), and ServiceStart().

◆ nfs41_idmap_gid_to_group()

int nfs41_idmap_gid_to_group ( nfs41_idmapper context,
gid_t  gid,
char name_out,
size_t  len 
)

Definition at line 1055 of file idmap.c.

1060 {
1061  UINT_PTR gidp = gid; /* convert to pointer size to pass as void* */
1063  struct idmap_group group;
1064  int status;
1065 
1066  dprintf(IDLVL, "--> nfs41_idmap_gid_to_group(%u)\n", gid);
1067 
1068  lookup.value = (const void*)gidp;
1069 
1070  /* look up the group entry */
1072  if (status) {
1073  dprintf(IDLVL, "<-- nfs41_idmap_gid_to_group(%u) "
1074  "failed with %d\n", gid, status);
1075  goto out;
1076  }
1077 
1078  if (FAILED(StringCchCopyA(name, len, group.name))) {
1080  eprintf("group name buffer overflow: '%s' > %u\n",
1081  group.name, len);
1082  goto out;
1083  }
1084 
1085  dprintf(IDLVL, "<-- nfs41_idmap_gid_to_group(%u) "
1086  "returning '%s'\n", gid, name);
1087 out:
1088  return status;
1089 }
Definition: http.c:7094
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
static ULONG lookup[16]
Definition: vga.c:45
void eprintf(LPCSTR format,...)
Definition: daemon_debug.c:86
gid_t gid
Definition: idmap.c:540
#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:750
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:1047
STRSAFEAPI StringCchCopyA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:145
Definition: name.c:38
Definition: idmap.c:54
static SERVICE_STATUS status
Definition: service.c:31
WCHAR * name
Definition: name.c:42
Definition: ps.c:97

◆ nfs41_idmap_group_to_gid()

int nfs41_idmap_group_to_gid ( nfs41_idmapper context,
const char name,
gid_t gid_out 
)

Definition at line 1017 of file idmap.c.

1021 {
1022  struct idmap_lookup lookup = { ATTR_GROUP_NAME,
1024  struct idmap_group group;
1025  int status;
1026 
1027  dprintf(IDLVL, "--> nfs41_idmap_group_to_gid('%s')\n", name);
1028 
1029  lookup.value = name;
1030 
1031  /* look up the group entry */
1033  if (status) {
1034  dprintf(IDLVL, "<-- nfs41_idmap_group_to_gid('%s') "
1035  "failed with %d\n", name, status);
1036  goto out;
1037  }
1038 
1039  *gid_out = group.gid;
1040  dprintf(IDLVL, "<-- nfs41_idmap_group_to_gid('%s') "
1041  "returning %u\n", name, group.gid);
1042 out:
1043  return status;
1044 }
Definition: http.c:7094
static ULONG lookup[16]
Definition: vga.c:45
#define dprintf
Definition: regdump.c:33
static int group_cmp(const struct list_entry *list, const void *value)
Definition: idmap.c:1009
#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:750
static FILE * out
Definition: regtests2xml.c:44
Definition: name.c:38
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 ( nfs41_idmapper context,
const char username,
uid_t uid_out,
gid_t gid_out 
)

Definition at line 889 of file idmap.c.

894 {
897  struct idmap_user user;
898  int status;
899 
900  if (context == NULL)
901  return ERROR_FILE_NOT_FOUND;
902 
903  dprintf(IDLVL, "--> nfs41_idmap_name_to_ids('%s')\n", username);
904 
905  lookup.value = username;
906 
907  /* look up the user entry */
909  if (status) {
910  dprintf(IDLVL, "<-- nfs41_idmap_name_to_ids('%s') "
911  "failed with %d\n", username, status);
912  goto out;
913  }
914 
915  *uid_out = user.uid;
916  *gid_out = user.gid;
917  dprintf(IDLVL, "<-- nfs41_idmap_name_to_ids('%s') "
918  "returning uid=%u, gid=%u\n", username, user.uid, user.gid);
919 out:
920  return status;
921 }
Definition: http.c:7094
static ULONG lookup[16]
Definition: vga.c:45
static int idmap_lookup_user(struct idmap_context *context, const struct idmap_lookup *lookup, struct idmap_user *user)
Definition: idmap.c:679
static int username_cmp(const struct list_entry *list, const void *value)
Definition: idmap.c:881
#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 ( nfs41_idmapper context,
const char principal,
uid_t uid_out,
gid_t gid_out 
)

Definition at line 977 of file idmap.c.

982 {
985  struct idmap_user user;
986  int status;
987 
988  dprintf(IDLVL, "--> nfs41_idmap_principal_to_ids('%s')\n", principal);
989 
990  lookup.value = principal;
991 
992  /* look up the user entry */
994  if (status) {
995  dprintf(IDLVL, "<-- nfs41_idmap_principal_to_ids('%s') "
996  "failed with %d\n", principal, status);
997  goto out;
998  }
999 
1000  *uid_out = user.uid;
1001  *gid_out = user.gid;
1002  dprintf(IDLVL, "<-- nfs41_idmap_principal_to_ids('%s') "
1003  "returning uid=%u, gid=%u\n", principal, user.uid, user.gid);
1004 out:
1005  return status;
1006 }
Definition: http.c:7094
static ULONG lookup[16]
Definition: vga.c:45
static int idmap_lookup_user(struct idmap_context *context, const struct idmap_lookup *lookup, struct idmap_user *user)
Definition: idmap.c:679
static int principal_cmp(const struct list_entry *list, const void *value)
Definition: idmap.c:969
#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:502
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 ( nfs41_idmapper context,
uid_t  uid,
char name_out,
size_t  len 
)

Definition at line 932 of file idmap.c.

937 {
938  UINT_PTR uidp = uid; /* convert to pointer size to pass as void* */
940  struct idmap_user user;
941  int status;
942 
943  dprintf(IDLVL, "--> nfs41_idmap_uid_to_name(%u)\n", uid);
944 
945  lookup.value = (const void*)uidp;
946 
947  /* look up the user entry */
949  if (status) {
950  dprintf(IDLVL, "<-- nfs41_idmap_uid_to_name(%u) "
951  "failed with %d\n", uid, status);
952  goto out;
953  }
954 
955  if (FAILED(StringCchCopyA(name, len, user.username))) {
957  eprintf("username buffer overflow: '%s' > %u\n",
958  user.username, len);
959  goto out;
960  }
961 
962  dprintf(IDLVL, "<-- nfs41_idmap_uid_to_name(%u) "
963  "returning '%s'\n", uid, name);
964 out:
965  return status;
966 }
Definition: http.c:7094
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
uid_t uid
Definition: idmap.c:503
static int uid_cmp(const struct list_entry *list, const void *value)
Definition: idmap.c:924
Definition: idmap.c:53
static ULONG lookup[16]
Definition: vga.c:45
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:679
#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:38
static SERVICE_STATUS status
Definition: service.c:31
void user(int argc, const char *argv[])
Definition: cmds.c:1350
Definition: ps.c:97