File: sasl_login.c

package info (click to toggle)
cvm 0.97-0.1
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 1,036 kB
  • sloc: ansic: 4,065; sh: 2,758; makefile: 235; sql: 15
file content (37 lines) | stat: -rw-r--r-- 952 bytes parent folder | download | duplicates (5)
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;
}