src/server/daemon/auth.h

changeset 415
d938228c382e
parent 400
d814b29e8d96
equal deleted inserted replaced
414:99a34860c105 415:d938228c382e
31 31
32 #include <sys/types.h> 32 #include <sys/types.h>
33 #include <inttypes.h> 33 #include <inttypes.h>
34 #include "../public/auth.h" 34 #include "../public/auth.h"
35 35
36 #include <ucx/map.h> 36 #include <cx/map.h>
37 #include <cx/string.h>
37 38
38 #ifdef __cplusplus 39 #ifdef __cplusplus
39 extern "C" { 40 extern "C" {
40 #endif 41 #endif
41 42
42 typedef struct { 43 typedef struct {
43 User user; 44 User user;
44 char *authdb; 45 char *authdb;
45 sstr_t *groups; 46 cxmutstr *groups;
46 size_t numgroups; 47 size_t numgroups;
47 char *password; 48 char *password;
48 uint32_t ref; 49 uint32_t ref;
49 } CachedUser; 50 } CachedUser;
50 51
51 typedef struct user_cache_elm UserCacheElm; 52 typedef struct user_cache_elm UserCacheElm;
52 struct user_cache_elm { 53 struct user_cache_elm {
53 CachedUser *user; 54 CachedUser *user;
54 UserCacheElm *next_user; // next elm in the cached user list 55 UserCacheElm *next_user; // next elm in the cached user list
55 struct UcxMapKey key; // key to access this element 56 CxHashKey key; // key to access this element
56 size_t slot; // slot in the map 57 size_t slot; // slot in the map
57 UserCacheElm *next_elm; // next element in this map slot 58 UserCacheElm *next_elm; // next element in this map slot
58 time_t created; 59 time_t created;
59 }; 60 };
60 61
67 UserCacheElm *trail; 68 UserCacheElm *trail;
68 } UserCache; 69 } UserCache;
69 70
70 void auth_cache_init(); 71 void auth_cache_init();
71 72
72 User* auth_cache_get(char *authdb, char *user); 73 User* auth_cache_get(char *authdb, const char *user);
73 void auth_cache_add( 74 void auth_cache_add(
74 char *authdb, 75 char *authdb,
75 User *user, 76 User *user,
76 char *password, 77 const char *password,
77 char **groups, 78 const char **groups,
78 size_t numgroups); 79 size_t numgroups);
79 80
80 void auth_cache_remove_from_map(UserCacheElm *elm); 81 void auth_cache_remove_from_map(UserCacheElm *elm);
81 82
82 int cached_user_verify_password(CachedUser *user, char *password); 83 int cached_user_verify_password(CachedUser *user, const char *password);
83 int cached_user_check_group(CachedUser *user, char *group); 84 int cached_user_check_group(CachedUser *user, const char *group);
84 void cached_user_unref(CachedUser *user); 85 void cached_user_unref(CachedUser *user);
85 void cached_user_delete(CachedUser *user); 86 void cached_user_delete(CachedUser *user);
86 87
87 #ifdef __cplusplus 88 #ifdef __cplusplus
88 } 89 }

mercurial