Back to index

avfs  1.0.1
Classes | Defines | Functions
passwords.h File Reference
#include "avfs.h"
#include "state.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  pass_session
 Note: FTP uses "user@host" or just "user@" for the account key, since the username is passed in as part of the path. More...

Defines

#define USER_SEP_STR   "@"
#define USER_SEP_CHAR   (USER_SEP_STR[0])

Functions

int pass_username_get (struct entry *ent, const char *param, char **resp)
int pass_username_set (struct entry *ent, const char *param, const char *val)
int pass_password_get (struct entry *ent, const char *param, char **resp)
int pass_password_set (struct entry *ent, const char *param, const char *val)
int pass_loggedin_get (struct entry *ent, const char *param, char **resp)
int pass_loggedin_set (struct entry *ent, const char *param, const char *val)
struct pass_sessionpass_get_password (struct pass_session *passd, const char *host, const char *user)
void pass_remove_session (struct pass_session *fts)

Class Documentation

struct pass_session

Note: FTP uses "user@host" or just "user@" for the account key, since the username is passed in as part of the path.

In the FTP case the "username" member in this struct can be left NULL.

HTTP/DAV uses "realm@host" or just "@host", and stores the username as well as the password in this struct.

Definition at line 26 of file passwords.h.

Collaboration diagram for pass_session:
Class Members
char * account
struct pass_session * next
char * password
struct pass_session * prev
char * username

Define Documentation

#define USER_SEP_CHAR   (USER_SEP_STR[0])

Definition at line 16 of file passwords.h.

#define USER_SEP_STR   "@"

Definition at line 15 of file passwords.h.


Function Documentation

struct pass_session* pass_get_password ( struct pass_session passd,
const char *  host,
const char *  user 
) [read]

Definition at line 93 of file passwords.c.

{
    struct pass_session *fts = NULL;
    char *account;

    if (passd == NULL) {
       return NULL;
    }
    if (fts == NULL) {
       account = av_stradd(NULL, user, USER_SEP_STR, host, NULL);
       fts = pass_find_session(passd, account);
       av_free(account);
    }

    if(fts == NULL) {
        account = av_stradd(NULL, user, USER_SEP_STR, NULL);
        fts = pass_find_session(passd, account);
        av_free(account);
    }

    if(fts == NULL) {
        account = av_stradd(NULL, USER_SEP_STR, host, NULL);
        fts = pass_find_session(passd, account);
        av_free(account);
    }

    av_log(AVLOG_DEBUG, "passwords: fts=%lx", (long) fts);
    return fts;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int pass_loggedin_get ( struct entry ent,
const char *  param,
char **  resp 
)

Definition at line 182 of file passwords.c.

{
    struct pass_session *fts;
    struct statefile *sf = (struct statefile *) av_namespace_get(ent);
    struct pass_session *passd = (struct pass_session *) sf->data;

    AV_LOCK(pass_lock);
    fts = pass_find_session(passd, param);
    if(fts == NULL)
        *resp = av_strdup("0\n");
    else
        *resp = av_strdup("1\n");
    AV_UNLOCK(pass_lock);

    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int pass_loggedin_set ( struct entry ent,
const char *  param,
const char *  val 
)

Definition at line 221 of file passwords.c.

{
    int res;
    struct pass_session *fts;
    struct statefile *sf = (struct statefile *) av_namespace_get(ent);
    struct pass_session *passd = (struct pass_session *) sf->data;

    AV_LOCK(pass_lock);
    fts = pass_find_session(passd, param);
    if(fts == NULL)
        res = -EACCES;
    else {
        int ival;

        res = pass_loggedin_val(val, &ival);
        if(res == 0 && ival == 0) {
            /* FIXME: end connections using this session */
            pass_remove_session(fts);
        }
    }
    AV_UNLOCK(pass_lock);

    return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int pass_password_get ( struct entry ent,
const char *  param,
char **  resp 
)

Definition at line 153 of file passwords.c.

{
    *resp = av_strdup("");
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int pass_password_set ( struct entry ent,
const char *  param,
const char *  val 
)

Definition at line 159 of file passwords.c.

{
    struct pass_session *fts;
    struct statefile *sf = (struct statefile *) av_namespace_get(ent);
    struct pass_session *passd = (struct pass_session *) sf->data;
    unsigned int len;

    AV_LOCK(pass_lock);
    fts = pass_get_session(passd, param);
    /* av_log(AVLOG_DEBUG, "passwords: setting password '%s' %s'",
     * param, val);*/

    av_free(fts->password);
    fts->password = av_strdup(val);
    len = strlen(fts->password);
    if(fts->password[len - 1] == '\n')
        fts->password[len - 1] = '\0';

    AV_UNLOCK(pass_lock);

    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pass_remove_session ( struct pass_session fts)

Definition at line 80 of file passwords.c.

{
    struct pass_session *next = fts->next;
    struct pass_session *prev = fts->prev;
    
    next->prev = prev;
    prev->next = next;

    av_free(fts->account);
    av_free(fts->password);
    av_free(fts);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int pass_username_get ( struct entry ent,
const char *  param,
char **  resp 
)

Definition at line 125 of file passwords.c.

{
    *resp = av_strdup("");
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int pass_username_set ( struct entry ent,
const char *  param,
const char *  val 
)

Definition at line 131 of file passwords.c.

{
    struct pass_session *fts;
    struct statefile *sf = (struct statefile *) av_namespace_get(ent);
    struct pass_session *passd = (struct pass_session *) sf->data;
    unsigned int len;

    AV_LOCK(pass_lock);
    fts = pass_get_session(passd, param);
    av_log(AVLOG_DEBUG, "passwords: setting username '%s' %s'", param, val);

    av_free(fts->username);
    fts->username = av_strdup(val);
    len = strlen(fts->username);
    if(fts->username[len - 1] == '\n')
        fts->username[len - 1] = '\0';

    AV_UNLOCK(pass_lock);

    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function: