Exemple #1
0
int auth_unix(Display *display)
{
    const char *key, *passwd;

    key = get_key(getuid());
    if (!key)
        return 0;

    passwd = xgetstr(display, NULL, 0);
    return (strcmp(key, crypt(passwd, key)) == 0) ? 1 : 0;
}
Exemple #2
0
static int xconv(int num_msg, const struct pam_message **msgm,
                 struct pam_response **response, void *display)
{
    int i;
    char *string;
    struct pam_response *reply;

    if (num_msg < 1)
        return PAM_CONV_ERR;

    reply = (struct pam_response *) calloc(num_msg,
            sizeof(struct pam_response));
    if (!reply)
        return PAM_CONV_ERR;

    for (i = 0; i < num_msg; i++) {
        string = NULL;
        switch (msgm[i]->msg_style) {
        case PAM_PROMPT_ECHO_ON:
            printf("%s\n", msgm[i]->msg);
        case PAM_PROMPT_ECHO_OFF:
            string = xgetstr((Display *) display, NULL, -1);
            break;
        case PAM_ERROR_MSG:
            fprintf(stderr, "%s\n", msgm[i]->msg);
            break;
        case PAM_TEXT_INFO:
            printf("%s\n", msgm[i]->msg);
            break;
        }
        if (string) {
            reply[i].resp_retcode = 0;
            reply[i].resp = string;
        }
    }

    *response = reply;

    return PAM_SUCCESS;
}
Exemple #3
0
int auth_static(Display *display)
{
    const char *passwd;
    passwd = xgetstr(display, NULL, 0);
    return (strcmp(static_key, crypt(passwd, static_key)) == 0) ? 1 : 0;
}