~ubuntu-branches/ubuntu/maverick/postfix/maverick-security

« back to all changes in this revision

Viewing changes to src/smtpd/smtpd_sasl_glue.c

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones, Wietse Venema, LaMont Jones
  • Date: 2009-06-03 14:17:08 UTC
  • mfrom: (1.1.22 upstream)
  • Revision ID: james.westby@ubuntu.com-20090603141708-o9u59xlor7nmd2x1
[Wietse Venema]

* New upstream release: 2.6.2~rc1

[LaMont Jones]

* move postfix-add-{filter,policy} manpages to section 8, and deliver
* provide: default-mta on ubuntu

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
/*
9
9
/*      void    smtpd_sasl_initialize()
10
10
/*
11
 
/*      void    smtpd_sasl_connect(state, sasl_opts_name, sasl_opts_val)
 
11
/*      void    smtpd_sasl_activate(state, sasl_opts_name, sasl_opts_val)
12
12
/*      SMTPD_STATE *state;
13
13
/*      const char *sasl_opts_name;
14
14
/*      const char *sasl_opts_val;
21
21
/*      void    smtpd_sasl_logout(state)
22
22
/*      SMTPD_STATE *state;
23
23
/*
24
 
/*      void    smtpd_sasl_disconnect(state)
 
24
/*      void    smtpd_sasl_deactivate(state)
 
25
/*      SMTPD_STATE *state;
 
26
/*
 
27
/*      int     smtpd_sasl_is_active(state)
 
28
/*      SMTPD_STATE *state;
 
29
/*
 
30
/*      int     smtpd_sasl_set_inactive(state)
25
31
/*      SMTPD_STATE *state;
26
32
/* DESCRIPTION
27
33
/*      This module encapsulates most of the detail specific to SASL
32
38
/*      need access to the file system for run-time loading of
33
39
/*      plug-in modules. There is no corresponding cleanup routine.
34
40
/*
35
 
/*      smtpd_sasl_connect() performs per-connection initialization.
 
41
/*      smtpd_sasl_activate() performs per-connection initialization.
36
42
/*      This routine should be called once at the start of every
37
43
/*      connection. The sasl_opts_name and sasl_opts_val parameters
38
44
/*      are the postfix configuration parameters setting the security
54
60
/*      smtpd_sasl_logout() cleans up after smtpd_sasl_authenticate().
55
61
/*      This routine exists for the sake of symmetry.
56
62
/*
57
 
/*      smtpd_sasl_disconnect() performs per-connection cleanup.
 
63
/*      smtpd_sasl_deactivate() performs per-connection cleanup.
58
64
/*      This routine should be called at the end of every connection.
59
65
/*
 
66
/*      smtpd_sasl_is_active() is a predicate that returns true
 
67
/*      if the SMTP server session state is between smtpd_sasl_activate()
 
68
/*      and smtpd_sasl_deactivate().
 
69
/*
 
70
/*      smtpd_sasl_set_inactive() initializes the SMTP session
 
71
/*      state before the first smtpd_sasl_activate() call.
 
72
/*
60
73
/*      Arguments:
61
74
/* .IP state
62
75
/*      SMTP session context.
145
158
 
146
159
}
147
160
 
148
 
/* smtpd_sasl_connect - per-connection initialization */
 
161
/* smtpd_sasl_activate - per-connection initialization */
149
162
 
150
 
void    smtpd_sasl_connect(SMTPD_STATE *state, const char *sasl_opts_name,
151
 
                                   const char *sasl_opts_val)
 
163
void    smtpd_sasl_activate(SMTPD_STATE *state, const char *sasl_opts_name,
 
164
                                    const char *sasl_opts_val)
152
165
{
153
166
    const char *mechanism_list;
 
167
    XSASL_SERVER_CREATE_ARGS create_args;
 
168
    int     tls_flag;
 
169
 
 
170
    /*
 
171
     * Sanity check.
 
172
     */
 
173
    if (smtpd_sasl_is_active(state))
 
174
        msg_panic("smtpd_sasl_activate: already active");
154
175
 
155
176
    /*
156
177
     * Initialize SASL-specific state variables. Use long-lived storage for
168
189
     * Set up a new server context for this connection.
169
190
     */
170
191
#define SMTPD_SASL_SERVICE "smtp"
 
192
#ifdef USE_TLS
 
193
    tls_flag = state->tls_context != 0;
 
194
#else
 
195
    tls_flag = 0;
 
196
#endif
 
197
#define ADDR_OR_EMPTY(addr, unknown) (strcmp(addr, unknown) ? addr : "")
 
198
#define REALM_OR_NULL(realm) (*(realm) ? (realm) : (char *) 0)
171
199
 
172
200
    if ((state->sasl_server =
173
 
         xsasl_server_create(smtpd_sasl_impl, state->client,
174
 
                             SMTPD_SASL_SERVICE, *var_smtpd_sasl_realm ?
175
 
                             var_smtpd_sasl_realm : (char *) 0,
176
 
                             sasl_opts_val)) == 0)
 
201
         XSASL_SERVER_CREATE(smtpd_sasl_impl, &create_args,
 
202
                             stream = state->client,
 
203
                             server_addr = "",  /* need smtpd_peer.c update */
 
204
                             client_addr = ADDR_OR_EMPTY(state->addr,
 
205
                                                       CLIENT_ADDR_UNKNOWN),
 
206
                             service = SMTPD_SASL_SERVICE,
 
207
                             user_realm = REALM_OR_NULL(var_smtpd_sasl_realm),
 
208
                             security_options = sasl_opts_val,
 
209
                             tls_flag = tls_flag)) == 0)
177
210
        msg_fatal("SASL per-connection initialization failed");
178
211
 
179
212
    /*
185
218
    state->sasl_mechanism_list = mystrdup(mechanism_list);
186
219
}
187
220
 
188
 
/* smtpd_sasl_disconnect - per-connection cleanup */
 
221
/* smtpd_sasl_deactivate - per-connection cleanup */
189
222
 
190
 
void    smtpd_sasl_disconnect(SMTPD_STATE *state)
 
223
void    smtpd_sasl_deactivate(SMTPD_STATE *state)
191
224
{
192
225
    if (state->sasl_reply) {
193
226
        vstring_free(state->sasl_reply);