~ubuntu-branches/ubuntu/vivid/samba/vivid

« back to all changes in this revision

Viewing changes to source4/heimdal/lib/krb5/build_auth.c

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2011-12-21 13:18:04 UTC
  • mfrom: (0.39.21 sid)
  • Revision ID: package-import@ubuntu.com-20111221131804-xtlr39wx6njehxxr
Tags: 2:3.6.1-3ubuntu1
* Merge from Debian testing.  Remaining changes:
  + debian/patches/VERSION.patch:
    - set SAMBA_VERSION_SUFFIX to Ubuntu.
  + debian/patches/error-trans.fix-276472:
    - Add the translation of Unix Error code -ENOTSUP to NT Error Code
    - NT_STATUS_NOT_SUPPORTED to prevent the Permission denied error.
  + debian/smb.conf:
    - add "(Samba, Ubuntu)" to server string.
    - comment out the default [homes] share, and add a comment about
      "valid users = %S" to show users how to restrict access to
      \\server\username to only username.
    - Set 'usershare allow guests', so that usershare admins are 
      allowed to create public shares in addition to authenticated
      ones.
    - add map to guest = Bad user, maps bad username to guest access.
  + debian/samba-common.config:
    - Do not change priority to high if dhclient3 is installed.
    - Use priority medium instead of high for the workgroup question.
  + debian/control:
    - Don't build against or suggest ctdb.
    - Add dependency on samba-common-bin to samba.
  + Add ufw integration:
    - Created debian/samba.ufw.profile
    - debian/rules, debian/samba.dirs, debian/samba.files: install
      profile
    - debian/control: have samba suggest ufw
  + Add apport hook:
    - Created debian/source_samba.py.
    - debian/rules, debian/samba.dirs, debian/samba-common-bin.files: install
  + Switch to upstart:
    - Add debian/samba.{nmbd,smbd}.upstart.
  + debian/samba.logrotate, debian/samba-common.dhcp, debian/samba.if-up:
    - Make them upstart compatible
  + debian/samba.postinst: 
    - Avoid scary pdbedit warnings on first import.
  + debian/samba-common.postinst: Add more informative error message for
    the case where smb.conf was manually deleted
  + debian/patches/fix-debuglevel-name-conflict.patch: don't use 'debug_level'
    as a global variable name in an NSS module 
  + Dropped:
    - debian/patches/error-trans.fix-276472
    - debian/patches/fix-debuglevel-name-conflict.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
 * SUCH DAMAGE.
32
32
 */
33
33
 
34
 
#include <krb5_locl.h>
 
34
#include "krb5_locl.h"
35
35
 
36
36
static krb5_error_code
37
37
make_etypelist(krb5_context context,
99
99
    return 0;
100
100
}
101
101
 
102
 
krb5_error_code KRB5_LIB_FUNCTION
103
 
krb5_build_authenticator (krb5_context context,
104
 
                          krb5_auth_context auth_context,
105
 
                          krb5_enctype enctype,
106
 
                          krb5_creds *cred,
107
 
                          Checksum *cksum,
108
 
                          Authenticator **auth_result,
109
 
                          krb5_data *result,
110
 
                          krb5_key_usage usage)
 
102
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
 
103
_krb5_build_authenticator (krb5_context context,
 
104
                           krb5_auth_context auth_context,
 
105
                           krb5_enctype enctype,
 
106
                           krb5_creds *cred,
 
107
                           Checksum *cksum,
 
108
                           krb5_data *result,
 
109
                           krb5_key_usage usage)
111
110
{
112
 
    Authenticator *auth;
 
111
    Authenticator auth;
113
112
    u_char *buf = NULL;
114
113
    size_t buf_size;
115
114
    size_t len;
116
115
    krb5_error_code ret;
117
116
    krb5_crypto crypto;
118
117
 
119
 
    auth = calloc(1, sizeof(*auth));
120
 
    if (auth == NULL) {
121
 
        krb5_set_error_message(context, ENOMEM, N_("malloc: out of memory", ""));
122
 
        return ENOMEM;
123
 
    }
124
 
 
125
 
    auth->authenticator_vno = 5;
126
 
    copy_Realm(&cred->client->realm, &auth->crealm);
127
 
    copy_PrincipalName(&cred->client->name, &auth->cname);
128
 
 
129
 
    krb5_us_timeofday (context, &auth->ctime, &auth->cusec);
130
 
 
131
 
    ret = krb5_auth_con_getlocalsubkey(context, auth_context, &auth->subkey);
 
118
    memset(&auth, 0, sizeof(auth));
 
119
 
 
120
    auth.authenticator_vno = 5;
 
121
    copy_Realm(&cred->client->realm, &auth.crealm);
 
122
    copy_PrincipalName(&cred->client->name, &auth.cname);
 
123
 
 
124
    krb5_us_timeofday (context, &auth.ctime, &auth.cusec);
 
125
 
 
126
    ret = krb5_auth_con_getlocalsubkey(context, auth_context, &auth.subkey);
132
127
    if(ret)
133
128
        goto fail;
134
129
 
137
132
            krb5_generate_seq_number (context,
138
133
                                      &cred->session,
139
134
                                      &auth_context->local_seqnumber);
140
 
        ALLOC(auth->seq_number, 1);
141
 
        if(auth->seq_number == NULL) {
 
135
        ALLOC(auth.seq_number, 1);
 
136
        if(auth.seq_number == NULL) {
142
137
            ret = ENOMEM;
143
138
            goto fail;
144
139
        }
145
 
        *auth->seq_number = auth_context->local_seqnumber;
 
140
        *auth.seq_number = auth_context->local_seqnumber;
146
141
    } else
147
 
        auth->seq_number = NULL;
148
 
    auth->authorization_data = NULL;
149
 
    auth->cksum = cksum;
 
142
        auth.seq_number = NULL;
 
143
    auth.authorization_data = NULL;
150
144
 
151
 
    if (cksum != NULL && cksum->cksumtype == CKSUMTYPE_GSSAPI) {
152
 
        /*
153
 
         * This is not GSS-API specific, we only enable it for
154
 
         * GSS for now
155
 
         */
156
 
        ret = make_etypelist(context, &auth->authorization_data);
 
145
    if (cksum) {
 
146
        ALLOC(auth.cksum, 1);
 
147
        if (auth.cksum == NULL) {
 
148
            ret = ENOMEM;
 
149
            goto fail;
 
150
        }
 
151
        ret = copy_Checksum(cksum, auth.cksum);
157
152
        if (ret)
158
153
            goto fail;
 
154
 
 
155
        if (auth.cksum->cksumtype == CKSUMTYPE_GSSAPI) {
 
156
            /*
 
157
             * This is not GSS-API specific, we only enable it for
 
158
             * GSS for now
 
159
             */
 
160
            ret = make_etypelist(context, &auth.authorization_data);
 
161
            if (ret)
 
162
                goto fail;
 
163
        }
159
164
    }
160
165
 
161
166
    /* XXX - Copy more to auth_context? */
162
167
 
163
 
    auth_context->authenticator->ctime = auth->ctime;
164
 
    auth_context->authenticator->cusec = auth->cusec;
 
168
    auth_context->authenticator->ctime = auth.ctime;
 
169
    auth_context->authenticator->cusec = auth.cusec;
165
170
 
166
 
    ASN1_MALLOC_ENCODE(Authenticator, buf, buf_size, auth, &len, ret);
 
171
    ASN1_MALLOC_ENCODE(Authenticator, buf, buf_size, &auth, &len, ret);
167
172
    if (ret)
168
173
        goto fail;
169
174
    if(buf_size != len)
175
180
    ret = krb5_encrypt (context,
176
181
                        crypto,
177
182
                        usage /* KRB5_KU_AP_REQ_AUTH */,
178
 
                        buf + buf_size - len,
 
183
                        buf,
179
184
                        len,
180
185
                        result);
181
186
    krb5_crypto_destroy(context, crypto);
183
188
    if (ret)
184
189
        goto fail;
185
190
 
 
191
 fail:
 
192
    free_Authenticator (&auth);
186
193
    free (buf);
187
194
 
188
 
    if (auth_result)
189
 
        *auth_result = auth;
190
 
    else {
191
 
        /* Don't free the `cksum', it's allocated by the caller */
192
 
        auth->cksum = NULL;
193
 
        free_Authenticator (auth);
194
 
        free (auth);
195
 
    }
196
 
    return ret;
197
 
  fail:
198
 
    free_Authenticator (auth);
199
 
    free (auth);
200
 
    free (buf);
201
195
    return ret;
202
196
}