~ubuntu-branches/ubuntu/utopic/dovecot/utopic-proposed

« back to all changes in this revision

Viewing changes to src/auth/db-ldap.h

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-01-08 09:35:49 UTC
  • mfrom: (4.1.35 sid)
  • Revision ID: package-import@ubuntu.com-20140108093549-i72o93pux8p0dlaf
Tags: 1:2.2.9-1ubuntu1
* Merge from Debian unstable, remaining changes:
  + Add mail-stack-delivery package:
    - Update d/rules
    - d/control: convert existing dovecot-postfix package to a dummy
      package and add new mail-stack-delivery package.
    - Update maintainer scripts.
    - Rename d/dovecot-postfix.* to debian/mail-stack-delivery.*
    - d/mail-stack-delivery.preinst: Move previously installed backups and
      config files to a new package namespace.
    - d/mail-stack-delivery.prerm: Added to handle downgrades.
  + Use Snakeoil SSL certificates by default:
    - d/control: Depend on ssl-cert.
    - d/dovecot-core.postinst: Relax grep for SSL_* a bit.
  + Add autopkgtest to debian/tests/*.
  + Add ufw integration:
    - d/dovecot-core.ufw.profile: new ufw profile.
    - d/rules: install profile in dovecot-core.
    - d/control: dovecot-core - suggest ufw.
  + d/dovecot-core.dirs: Added usr/share/doc/dovecot-core
  + Add apport hook:
    - d/rules, d/source_dovecot.py
  + Add upstart job:
    - d/rules, d/dovecot-core.dovecot.upstart, d/control,
      d/dovecot-core.dirs, dovecot-imapd.{postrm, postinst, prerm},
      d/dovecot-pop3d.{postinst, postrm, prerm}.
      d/mail-stack-deliver.postinst: Convert init script to upstart.
  + Use the autotools-dev dh addon to update config.guess/config.sub for
    arm64.
* Dropped changes, included in Debian:
  - Update Dovecot name to reflect distribution in login greeting.
  - Update Drac plugin for >= 2.0.0 support.
* d/control: Drop dovecot-postfix package as its no longer required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
76
76
        LDAP_REQUEST_TYPE_BIND
77
77
};
78
78
 
 
79
struct ldap_field {
 
80
        /* Dovecot field name. */
 
81
        const char *name;
 
82
        /* Field value template with %vars. NULL = same as LDAP value. */
 
83
        const char *value;
 
84
        /* LDAP attribute name, or "" if this is a static field. */
 
85
        const char *ldap_attr_name;
 
86
 
 
87
        /* LDAP value contains a DN, which is looked up and used for @name
 
88
           attributes. */
 
89
        bool value_is_dn;
 
90
        /* This attribute is used internally only via %{ldap_ptr},
 
91
           it shouldn't be returned in iteration. */
 
92
        bool skip;
 
93
};
 
94
ARRAY_DEFINE_TYPE(ldap_field, struct ldap_field);
 
95
 
79
96
struct ldap_request {
80
97
        enum ldap_request_type type;
81
98
 
84
101
        /* timestamp when request was created */
85
102
        time_t create_time;
86
103
 
 
104
        bool failed;
 
105
 
87
106
        db_search_callback_t *callback;
88
107
        struct auth_request *auth_request;
89
 
 
90
 
        /* If expect_one_reply=TRUE, this contains the first LDAP entry.
91
 
           If another one comes, we'll return an error. */
92
 
        LDAPMessage *first_entry;
93
 
 
94
 
        unsigned int expect_one_reply:1;
 
108
};
 
109
 
 
110
struct ldap_request_named_result {
 
111
        const struct ldap_field *field;
 
112
        const char *dn;
 
113
        LDAPMessage *result;
95
114
};
96
115
 
97
116
struct ldap_request_search {
100
119
        const char *base;
101
120
        const char *filter;
102
121
        char **attributes; /* points to pass_attr_names / user_attr_names */
 
122
        const ARRAY_TYPE(ldap_field) *attr_map;
 
123
 
 
124
        LDAPMessage *result;
 
125
        ARRAY(struct ldap_request_named_result) named_results;
 
126
        unsigned int name_idx;
 
127
 
 
128
        bool multi_entry;
103
129
};
104
130
 
105
131
struct ldap_request_bind {
119
145
        LDAP_CONN_STATE_BOUND_DEFAULT
120
146
};
121
147
 
122
 
struct ldap_field {
123
 
        /* Dovecot field name. */
124
 
        const char *name;
125
 
        /* Field value template with %vars. NULL = same as LDAP value. */
126
 
        const char *value;
127
 
        /* LDAP attribute name, or "" if this is a static field. */
128
 
        const char *ldap_attr_name;
129
 
};
130
 
ARRAY_DEFINE_TYPE(ldap_field, struct ldap_field);
131
 
 
132
148
struct ldap_connection {
133
149
        struct ldap_connection *next;
134
150
 
149
165
        /* Request queue contains sent requests at tail (msgid != -1) and
150
166
           queued requests at head (msgid == -1). */
151
167
        struct aqueue *request_queue;
152
 
        ARRAY_DEFINE(request_array, struct ldap_request *);
 
168
        ARRAY(struct ldap_request *) request_array;
153
169
        /* Number of messages in queue with msgid != -1 */
154
170
        unsigned int pending_count;
155
171
 
167
183
 
168
184
void db_ldap_set_attrs(struct ldap_connection *conn, const char *attrlist,
169
185
                       char ***attr_names_r, ARRAY_TYPE(ldap_field) *attr_map,
170
 
                       const char *skip_attr);
 
186
                       const char *skip_attr) ATTR_NULL(5);
171
187
 
172
188
struct ldap_connection *db_ldap_init(const char *config_path, bool userdb);
173
189
void db_ldap_unref(struct ldap_connection **conn);
181
197
const char *ldap_get_error(struct ldap_connection *conn);
182
198
 
183
199
struct db_ldap_result_iterate_context *
184
 
db_ldap_result_iterate_init(struct ldap_connection *conn, LDAPMessage *entry,
185
 
                            struct auth_request *auth_request,
186
 
                            const ARRAY_TYPE(ldap_field) *attr_map);
 
200
db_ldap_result_iterate_init(struct ldap_connection *conn,
 
201
                            struct ldap_request_search *ldap_request,
 
202
                            LDAPMessage *res, bool skip_null_values);
187
203
bool db_ldap_result_iterate_next(struct db_ldap_result_iterate_context *ctx,
188
204
                                 const char **name_r,
189
205
                                 const char *const **values_r);