ReactOS 0.4.15-dev-7953-g1f49173
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) {
814 goto out;
815 }
816
817 /* initialize the caches */
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;
859out:
860 return status;
861
862out_err_free:
864 goto out;
865}
void eprintf(LPCSTR format,...)
Definition: daemon_debug.c:86
#define NO_ERROR
Definition: dderror.h:5
#define NULL
Definition: types.h:112
PCHAR CDECL ldap_err2stringA(ULONG err)
Definition: error.c:71
ULONG CDECL LdapMapErrorToWin32(ULONG err)
Definition: error.c:302
ULONG CDECL LdapGetLastError(void)
Definition: error.c:184
static const struct cache_ops group_cache_ops
Definition: idmap.c:563
void nfs41_idmap_free(struct idmap_context *context)
Definition: idmap.c:867
static int config_init(struct idmap_config *config)
Definition: idmap.c:362
static const struct cache_ops user_cache_ops
Definition: idmap.c:529
static FILE * out
Definition: regtests2xml.c:44
#define calloc
Definition: rosglue.h:14
Definition: http.c:7252
Definition: ps.c:97
static void cache_init()
Definition: svc_auth_des.c:352
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define ldap_init
Definition: winldap.h:638
#define LDAP_OPT_TIMELIMIT
Definition: winldap.h:133
#define LDAP_OPT_PROTOCOL_VERSION
Definition: winldap.h:145
#define LDAP_SUCCESS
Definition: winldap.h:59
#define ldap_set_option
Definition: winldap.h:641

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}
#define free
Definition: debug_ros.c:5
static void cache_cleanup(struct idmap_cache *cache)
Definition: idmap.c:436
WINLDAPAPI ULONG ldap_unbind(LDAP *)

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
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);
1087out:
1088 return status;
1089}
static ULONG lookup[16]
Definition: vga.c:48
GLboolean GLuint group
Definition: glext.h:11120
GLenum GLsizei len
Definition: glext.h:6722
@ CLASS_GROUP
Definition: idmap.c:44
@ ATTR_GID
Definition: idmap.c:54
#define IDLVL
Definition: idmap.c:35
static int gid_cmp(const struct list_entry *list, const void *value)
Definition: idmap.c:1047
static int idmap_lookup_group(struct idmap_context *context, const struct idmap_lookup *lookup, struct idmap_group *group)
Definition: idmap.c:750
@ TYPE_INT
Definition: idmap.c:101
#define FAILED(hr)
Definition: intsafe.h:51
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define dprintf
Definition: regdump.c:33
STRSAFEAPI StringCchCopyA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:145
gid_t gid
Definition: idmap.c:540
Definition: name.c:39
WCHAR * name
Definition: name.c:42
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185

◆ 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{
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);
1042out:
1043 return status;
1044}
@ ATTR_GROUP_NAME
Definition: idmap.c:51
static int group_cmp(const struct list_entry *list, const void *value)
Definition: idmap.c:1009
@ TYPE_STR
Definition: idmap.c:100
char name[VAL_LEN]
Definition: idmap.c:539

◆ 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)
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);
919out:
920 return status;
921}
void user(int argc, const char *argv[])
Definition: cmds.c:1350
@ CLASS_USER
Definition: idmap.c:43
@ ATTR_USER_NAME
Definition: idmap.c:50
static int username_cmp(const struct list_entry *list, const void *value)
Definition: idmap.c:881
static int idmap_lookup_user(struct idmap_context *context, const struct idmap_lookup *lookup, struct idmap_user *user)
Definition: idmap.c:679
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
static WCHAR username[]
Definition: url.c:32

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);
1004out:
1005 return status;
1006}
@ ATTR_PRINCIPAL
Definition: idmap.c:52
static int principal_cmp(const struct list_entry *list, const void *value)
Definition: idmap.c:969
char principal[VAL_LEN]
Definition: idmap.c:502

◆ 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);
964out:
965 return status;
966}
@ ATTR_UID
Definition: idmap.c:53
static int uid_cmp(const struct list_entry *list, const void *value)
Definition: idmap.c:924
uid_t uid
Definition: idmap.c:503