28 static pthread_mutex_t
m_auth = PTHREAD_MUTEX_INITIALIZER;
47 if ((info = malloc(len)) == NULL)
return NULL;
50 info->
domain = (
char *) (info + 1);
98 DPRINTF(10,
"domain=%s, user=%s, password=%s\n",
106 if (info == NULL)
return NULL;
125 item = malloc(
sizeof(
struct authitem) + strlen(
name) + 1);
126 if (item == NULL)
return NULL;
128 memset(item, 0 ,
sizeof(
struct authitem));
129 item->
name = (
char *) (item + 1);
144 for(i = item->
child_cnt - 1; i >= 0; i--){
179 int first = 0, last = item->
child_cnt - 1;
181 while(first <= last){
182 int i = (first + last) >> 1;
185 if (result == 0)
return i;
186 if (result < 0) first = i + 1;
202 if ((pos > item->
child_cnt) || (pos < 0))
return -1;
210 new_childs = realloc(item->
childs,
211 new_max_cnt *
sizeof(
struct authitem *));
212 if (new_childs == NULL)
return -1;
215 item->
childs = new_childs;
219 memmove(&item->
childs[pos + 1],
223 item->
childs[pos] = subitem;
238 if (subitem == NULL)
return NULL;
258 DPRINTF(10,
"domain=%s, server=%s, share=%s\n",
domain, server, share);
260 if ((server == NULL) || (*server ==
'\0'))
return NULL;
262 if (share == NULL) share =
"";
267 pthread_mutex_lock(&
m_auth);
268 if (item->
info != NULL){
274 if ((pos >= 0) && (item->
childs[pos]->
info != NULL)){
282 if (item->
info != NULL){
287 if (*share ==
'\0')
goto end;
290 if (item->
info != NULL){
297 pthread_mutex_unlock(&
m_auth);
298 DPRINTF(10,
"domain=%s, user=%s, password=%s, suitability=%d\n",
304 pthread_mutex_lock(&
m_auth);
306 pthread_mutex_unlock(&
m_auth);
319 DPRINTF(10,
"smb://%s/%s, domain=%s, user=%s, password=%s\n",
322 if ((user == NULL) || (*user ==
'\0'))
return -1;
323 if (server == NULL) server =
"";
324 if (share == NULL) share =
"";
325 if (domain == NULL) domain =
"";
326 if (password == NULL) password =
"";
327 if ((*server ==
'\0') && (*share !=
'\0'))
return -1;
331 pthread_mutex_lock(&
m_auth);
332 if (*server ==
'\0')
goto update_info;
335 if (*share ==
'\0')
goto update_info;
339 if ((item->
info == NULL) ||
343 if (
info == NULL)
goto error;
351 pthread_mutex_unlock(&
m_auth);
356 pthread_mutex_lock(&
m_auth);
358 pthread_mutex_unlock(&
m_auth);
#define AUTH_MATCH_DEFAULT
#define AUTH_MATCH_SERVER
#define AUTH_MATCH_RESOURCE
#define AUTH_MATCH_DOMAIN_COMPAT
static int authitem_insert_subitem(struct authitem *item, struct authitem *subitem, int pos)
static struct authinfo authinfo_default
void auth_delete_obsolete(time_t threshold)
static char auth_login[64]
static struct authinfo * authinfo_find_in_list(const char *domain, const char *user, const char *password)
static void authinfo_delete(struct authinfo *info)
static char * auth_fake_password
static struct authitem * authitem_get_subitem(struct authitem *item, const char *name)
static void authitem_delete_obsolete_items(struct authitem *item, time_t threshold)
static LIST authinfo_list
void auth_set_default_login_name(const char *name)
static struct authitem * authitem_create_item(const char *name)
struct authinfo * auth_get_authinfo(const char *domain, const char *server, const char *share, int *suitability)
static struct authinfo * authinfo_store_list(const char *domain, const char *user, const char *password)
static struct authitem authroot
static int authitem_find_subitem(struct authitem *item, const char *name)
static pthread_mutex_t m_auth
static int authinfo_compare(struct authinfo *info, const char *domain, const char *user, const char *password)
static void authinfo_release(struct authinfo *info)
int auth_store_auth_data(const char *server, const char *share, const char *domain, const char *user, const char *password)
static void authitem_delete_item(struct authitem *item)
static struct authinfo * authinfo_create_new(const char *domain, const char *user, const char *password)
void auth_release_authinfo(struct authinfo *info)
#define DPRINTF(level, fmt, args...)
static int is_valid_list_elem(LIST *list, LIST *elem)
static LIST * first_list_elem(LIST *list)
static void add_to_list_back(LIST *list, LIST *elem)
#define list_entry(ptr, type, member)
#define STATIC_LIST_INITIALIZER(list)
static void remove_from_list(LIST *list, LIST *elem)
struct authitem ** childs