File: sasl_login.c

package info (click to toggle)
cvm 0.96-1.1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 928 kB
  • ctags: 622
  • sloc: ansic: 4,126; sh: 1,382; makefile: 120; sql: 15
file content (37 lines) | stat: -rw-r--r-- 952 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "sasl.h"
#include "sasl_internal.h"

static const char cusername[] = "Username:";
static const char cpassword[] = "Password:";

static int response2(struct sasl_state* ss,
		     const str* response, str* challenge)
{
  if (response->len == 0)
    return SASL_RESP_BAD;
  return sasl_authenticate_plain(ss, ss->username.s, response->s);
  (void)challenge;
}

static int response1(struct sasl_state* ss,
		     const str* response, str* challenge)
{
  if (response->len == 0)
    return SASL_RESP_BAD;
  if (!str_copy(&ss->username, response) ||
      !str_copys(challenge, cpassword))
    return SASL_TEMP_FAIL;
  ss->response = response2;
  return SASL_CHALLENGE;
}

int sasl_login_start(struct sasl_state* ss,
		     const str* response, str* challenge)
{
  if (response)
    return response1(ss, response, challenge);
  if (!str_copys(challenge, cusername))
    return SASL_TEMP_FAIL;
  ss->response = response1;
  return SASL_CHALLENGE;
}