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

« back to all changes in this revision

Viewing changes to source4/heimdal/lib/krb5/replay.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:
38
38
    char *name;
39
39
};
40
40
 
41
 
krb5_error_code KRB5_LIB_FUNCTION
 
41
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
42
42
krb5_rc_resolve(krb5_context context,
43
43
                krb5_rcache id,
44
44
                const char *name)
52
52
    return 0;
53
53
}
54
54
 
55
 
krb5_error_code KRB5_LIB_FUNCTION
 
55
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
56
56
krb5_rc_resolve_type(krb5_context context,
57
57
                     krb5_rcache *id,
58
58
                     const char *type)
73
73
    return 0;
74
74
}
75
75
 
76
 
krb5_error_code KRB5_LIB_FUNCTION
 
76
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
77
77
krb5_rc_resolve_full(krb5_context context,
78
78
                     krb5_rcache *id,
79
79
                     const char *string_name)
99
99
    return ret;
100
100
}
101
101
 
102
 
const char* KRB5_LIB_FUNCTION
 
102
KRB5_LIB_FUNCTION const char* KRB5_LIB_CALL
103
103
krb5_rc_default_name(krb5_context context)
104
104
{
105
105
    return "FILE:/var/run/default_rcache";
106
106
}
107
107
 
108
 
const char* KRB5_LIB_FUNCTION
 
108
KRB5_LIB_FUNCTION const char* KRB5_LIB_CALL
109
109
krb5_rc_default_type(krb5_context context)
110
110
{
111
111
    return "FILE";
112
112
}
113
113
 
114
 
krb5_error_code KRB5_LIB_FUNCTION
 
114
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
115
115
krb5_rc_default(krb5_context context,
116
116
                krb5_rcache *id)
117
117
{
123
123
    unsigned char data[16];
124
124
};
125
125
 
126
 
krb5_error_code KRB5_LIB_FUNCTION
 
126
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
127
127
krb5_rc_initialize(krb5_context context,
128
128
                   krb5_rcache id,
129
129
                   krb5_deltat auth_lifespan)
133
133
    int ret;
134
134
 
135
135
    if(f == NULL) {
 
136
        char buf[128];
136
137
        ret = errno;
137
 
        krb5_set_error_message(context, ret, "open(%s): %s", id->name,
138
 
                               strerror(ret));
 
138
        rk_strerror_r(ret, buf, sizeof(buf));
 
139
        krb5_set_error_message(context, ret, "open(%s): %s", id->name, buf);
139
140
        return ret;
140
141
    }
141
142
    tmp.stamp = auth_lifespan;
144
145
    return 0;
145
146
}
146
147
 
147
 
krb5_error_code KRB5_LIB_FUNCTION
 
148
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
148
149
krb5_rc_recover(krb5_context context,
149
150
                krb5_rcache id)
150
151
{
151
152
    return 0;
152
153
}
153
154
 
154
 
krb5_error_code KRB5_LIB_FUNCTION
 
155
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
155
156
krb5_rc_destroy(krb5_context context,
156
157
                krb5_rcache id)
157
158
{
158
159
    int ret;
159
160
 
160
161
    if(remove(id->name) < 0) {
 
162
        char buf[128];
161
163
        ret = errno;
162
 
        krb5_set_error_message(context, ret, "remove(%s): %s", id->name,
163
 
                               strerror(ret));
 
164
        rk_strerror_r(ret, buf, sizeof(buf));
 
165
        krb5_set_error_message(context, ret, "remove(%s): %s", id->name, buf);
164
166
        return ret;
165
167
    }
166
168
    return krb5_rc_close(context, id);
167
169
}
168
170
 
169
 
krb5_error_code KRB5_LIB_FUNCTION
 
171
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
170
172
krb5_rc_close(krb5_context context,
171
173
              krb5_rcache id)
172
174
{
178
180
static void
179
181
checksum_authenticator(Authenticator *auth, void *data)
180
182
{
181
 
    MD5_CTX md5;
182
 
    int i;
183
 
 
184
 
    MD5_Init (&md5);
185
 
    MD5_Update (&md5, auth->crealm, strlen(auth->crealm));
 
183
    EVP_MD_CTX *m = EVP_MD_CTX_create();
 
184
    unsigned i;
 
185
 
 
186
    EVP_DigestInit_ex(m, EVP_md5(), NULL);
 
187
 
 
188
    EVP_DigestUpdate(m, auth->crealm, strlen(auth->crealm));
186
189
    for(i = 0; i < auth->cname.name_string.len; i++)
187
 
        MD5_Update(&md5, auth->cname.name_string.val[i],
 
190
        EVP_DigestUpdate(m, auth->cname.name_string.val[i],
188
191
                   strlen(auth->cname.name_string.val[i]));
189
 
    MD5_Update (&md5, &auth->ctime, sizeof(auth->ctime));
190
 
    MD5_Update (&md5, &auth->cusec, sizeof(auth->cusec));
191
 
    MD5_Final (data, &md5);
 
192
    EVP_DigestUpdate(m, &auth->ctime, sizeof(auth->ctime));
 
193
    EVP_DigestUpdate(m, &auth->cusec, sizeof(auth->cusec));
 
194
 
 
195
    EVP_DigestFinal_ex(m, data, NULL);
 
196
    EVP_MD_CTX_destroy(m);
192
197
}
193
198
 
194
 
krb5_error_code KRB5_LIB_FUNCTION
 
199
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
195
200
krb5_rc_store(krb5_context context,
196
201
              krb5_rcache id,
197
202
              krb5_donot_replay *rep)
205
210
    checksum_authenticator(rep, ent.data);
206
211
    f = fopen(id->name, "r");
207
212
    if(f == NULL) {
 
213
        char buf[128];
208
214
        ret = errno;
209
 
        krb5_set_error_message(context, ret, "open(%s): %s", id->name,
210
 
                               strerror(ret));
 
215
        rk_strerror_r(ret, buf, sizeof(buf));
 
216
        krb5_set_error_message(context, ret, "open(%s): %s", id->name, buf);
211
217
        return ret;
212
218
    }
213
219
    rk_cloexec_file(f);
223
229
        }
224
230
    }
225
231
    if(ferror(f)){
 
232
        char buf[128];
226
233
        ret = errno;
227
234
        fclose(f);
 
235
        rk_strerror_r(ret, buf, sizeof(buf));
228
236
        krb5_set_error_message(context, ret, "%s: %s",
229
 
                               id->name, strerror(ret));
 
237
                               id->name, buf);
230
238
        return ret;
231
239
    }
232
240
    fclose(f);
233
241
    f = fopen(id->name, "a");
234
242
    if(f == NULL) {
 
243
        char buf[128];
 
244
        rk_strerror_r(errno, buf, sizeof(buf));
235
245
        krb5_set_error_message(context, KRB5_RC_IO_UNKNOWN,
236
 
                               "open(%s): %s", id->name,
237
 
                               strerror(errno));
 
246
                               "open(%s): %s", id->name, buf);
238
247
        return KRB5_RC_IO_UNKNOWN;
239
248
    }
240
249
    fwrite(&ent, 1, sizeof(ent), f);
242
251
    return 0;
243
252
}
244
253
 
245
 
krb5_error_code KRB5_LIB_FUNCTION
 
254
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
246
255
krb5_rc_expunge(krb5_context context,
247
256
                krb5_rcache id)
248
257
{
249
258
    return 0;
250
259
}
251
260
 
252
 
krb5_error_code KRB5_LIB_FUNCTION
 
261
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
253
262
krb5_rc_get_lifespan(krb5_context context,
254
263
                     krb5_rcache id,
255
264
                     krb5_deltat *auth_lifespan)
267
276
    return KRB5_RC_IO_UNKNOWN;
268
277
}
269
278
 
270
 
const char* KRB5_LIB_FUNCTION
 
279
KRB5_LIB_FUNCTION const char* KRB5_LIB_CALL
271
280
krb5_rc_get_name(krb5_context context,
272
281
                 krb5_rcache id)
273
282
{
274
283
    return id->name;
275
284
}
276
285
                
277
 
const char* KRB5_LIB_FUNCTION
 
286
KRB5_LIB_FUNCTION const char* KRB5_LIB_CALL
278
287
krb5_rc_get_type(krb5_context context,
279
288
                 krb5_rcache id)
280
289
{
281
290
    return "FILE";
282
291
}
283
292
                
284
 
krb5_error_code KRB5_LIB_FUNCTION
 
293
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
285
294
krb5_get_server_rcache(krb5_context context,
286
295
                       const krb5_data *piece,
287
296
                       krb5_rcache *id)
299
308
    }
300
309
    strvisx(tmp, piece->data, piece->length, VIS_WHITE | VIS_OCTAL);
301
310
#ifdef HAVE_GETEUID
302
 
    asprintf(&name, "FILE:rc_%s_%u", tmp, (unsigned)geteuid());
 
311
    ret = asprintf(&name, "FILE:rc_%s_%u", tmp, (unsigned)geteuid());
303
312
#else
304
 
    asprintf(&name, "FILE:rc_%s", tmp);
 
313
    ret = asprintf(&name, "FILE:rc_%s", tmp);
305
314
#endif
306
315
    free(tmp);
307
 
    if(name == NULL) {
 
316
    if(ret < 0 || name == NULL) {
308
317
        krb5_set_error_message(context, ENOMEM,
309
318
                               N_("malloc: out of memory", ""));
310
319
        return ENOMEM;