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

« back to all changes in this revision

Viewing changes to source4/heimdal/lib/krb5/keytab.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:
73
73
 *   store the keytab in a AFS keyfile (usually /usr/afs/etc/KeyFile ),
74
74
 *   the type's name is AFSKEYFILE. The residual part is a filename.
75
75
 *
76
 
 * - krb4
77
 
 *   the keytab is a Kerberos 4 srvtab that is on-the-fly converted to
78
 
 *   a keytab. The type's name is krb4 The residual part is a
79
 
 *   filename.
80
 
 *
81
76
 * - memory
82
77
 *   The keytab is stored in a memory segment. This allows sensitive
83
78
 *   and/or temporary data not to be stored on disk. The type's name
84
79
 *   is MEMORY. Each MEMORY keytab is referenced counted by and
85
80
 *   opened by the residual name, so two handles can point to the
86
 
 *   same memory area.  When the last user closes the entry, it
87
 
 *   disappears.
 
81
 *   same memory area.  When the last user closes using krb5_kt_close()
 
82
 *   the keytab, the keys in they keytab is memset() to zero and freed
 
83
 *   and can no longer be looked up by name.
88
84
 *
89
85
 *
90
86
 * @subsection krb5_keytab_example Keytab example
113
109
    if (ret)
114
110
        krb5_err(context, 1, ret, "krb5_kt_start_seq_get");
115
111
    while((ret = krb5_kt_next_entry(context, keytab, &entry, &cursor)) == 0){
116
 
        krb5_unparse_name_short(context, entry.principal, &principal);
 
112
        krb5_unparse_name(context, entry.principal, &principal);
117
113
        printf("principal: %s\n", principal);
118
114
        free(principal);
119
115
        krb5_kt_free_entry(context, &entry);
143
139
 * @ingroup krb5_keytab
144
140
 */
145
141
 
146
 
krb5_error_code KRB5_LIB_FUNCTION
 
142
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
147
143
krb5_kt_register(krb5_context context,
148
144
                 const krb5_kt_ops *ops)
149
145
{
169
165
    return 0;
170
166
}
171
167
 
 
168
static const char *
 
169
keytab_name(const char * name, const char ** ptype, size_t * ptype_len)
 
170
{
 
171
    const char * residual;
 
172
 
 
173
    residual = strchr(name, ':');
 
174
 
 
175
    if (residual == NULL
 
176
 
 
177
#ifdef _WIN32
 
178
 
 
179
        /* Avoid treating <drive>:<path> as a keytab type
 
180
         * specification */
 
181
 
 
182
        || name + 1 == residual
 
183
#endif
 
184
        ) {
 
185
 
 
186
        *ptype = "FILE";
 
187
        *ptype_len = strlen(*ptype);
 
188
        residual = name;
 
189
    } else {
 
190
        *ptype = name;
 
191
        *ptype_len = residual - name;
 
192
        residual++;
 
193
    }
 
194
 
 
195
    return residual;
 
196
}
 
197
 
172
198
/**
173
199
 * Resolve the keytab name (of the form `type:residual') in `name'
174
200
 * into a keytab in `id'.
183
209
 */
184
210
 
185
211
 
186
 
krb5_error_code KRB5_LIB_FUNCTION
 
212
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
187
213
krb5_kt_resolve(krb5_context context,
188
214
                const char *name,
189
215
                krb5_keytab *id)
194
220
    size_t type_len;
195
221
    krb5_error_code ret;
196
222
 
197
 
    residual = strchr(name, ':');
198
 
    if(residual == NULL) {
199
 
        type = "FILE";
200
 
        type_len = strlen(type);
201
 
        residual = name;
202
 
    } else {
203
 
        type = name;
204
 
        type_len = residual - name;
205
 
        residual++;
206
 
    }
 
223
    residual = keytab_name(name, &type, &type_len);
207
224
 
208
225
    for(i = 0; i < context->num_kt_types; i++) {
209
226
        if(strncasecmp(type, context->kt_types[i].prefix, type_len) == 0)
244
261
 * @ingroup krb5_keytab
245
262
 */
246
263
 
247
 
krb5_error_code KRB5_LIB_FUNCTION
 
264
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
248
265
krb5_kt_default_name(krb5_context context, char *name, size_t namesize)
249
266
{
250
267
    if (strlcpy (name, context->default_keytab, namesize) >= namesize) {
266
283
 * @ingroup krb5_keytab
267
284
 */
268
285
 
269
 
krb5_error_code KRB5_LIB_FUNCTION
 
286
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
270
287
krb5_kt_default_modify_name(krb5_context context, char *name, size_t namesize)
271
288
{
272
289
    const char *kt = NULL;
303
320
 * @ingroup krb5_keytab
304
321
 */
305
322
 
306
 
krb5_error_code KRB5_LIB_FUNCTION
 
323
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
307
324
krb5_kt_default(krb5_context context, krb5_keytab *id)
308
325
{
309
326
    return krb5_kt_resolve (context, context->default_keytab, id);
325
342
 * @ingroup krb5_keytab
326
343
 */
327
344
 
328
 
krb5_error_code KRB5_LIB_FUNCTION
 
345
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
329
346
krb5_kt_read_service_key(krb5_context context,
330
347
                         krb5_pointer keyprocarg,
331
348
                         krb5_principal principal,
368
385
 * @ingroup krb5_keytab
369
386
 */
370
387
 
371
 
krb5_error_code KRB5_LIB_FUNCTION
 
388
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
372
389
krb5_kt_get_type(krb5_context context,
373
390
                 krb5_keytab keytab,
374
391
                 char *prefix,
391
408
 * @ingroup krb5_keytab
392
409
 */
393
410
 
394
 
krb5_error_code KRB5_LIB_FUNCTION
 
411
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
395
412
krb5_kt_get_name(krb5_context context,
396
413
                 krb5_keytab keytab,
397
414
                 char *name,
414
431
 * @ingroup krb5_keytab
415
432
 */
416
433
 
417
 
krb5_error_code KRB5_LIB_FUNCTION
 
434
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
418
435
krb5_kt_get_full_name(krb5_context context,
419
436
                      krb5_keytab keytab,
420
437
                      char **str)
454
471
 * @ingroup krb5_keytab
455
472
 */
456
473
 
457
 
krb5_error_code KRB5_LIB_FUNCTION
 
474
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
458
475
krb5_kt_close(krb5_context context,
459
476
              krb5_keytab id)
460
477
{
478
495
 * @ingroup krb5_keytab
479
496
 */
480
497
 
481
 
krb5_error_code KRB5_LIB_FUNCTION
 
498
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
482
499
krb5_kt_destroy(krb5_context context,
483
500
                krb5_keytab id)
484
501
{
523
540
 * @ingroup krb5_keytab
524
541
 */
525
542
 
526
 
krb5_boolean KRB5_LIB_FUNCTION
 
543
KRB5_LIB_FUNCTION krb5_boolean KRB5_LIB_CALL
527
544
krb5_kt_compare(krb5_context context,
528
545
                krb5_keytab_entry *entry,
529
546
                krb5_const_principal principal,
590
607
 * @ingroup krb5_keytab
591
608
 */
592
609
 
593
 
krb5_error_code KRB5_LIB_FUNCTION
 
610
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
594
611
krb5_kt_get_entry(krb5_context context,
595
612
                  krb5_keytab id,
596
613
                  krb5_const_principal principal,
651
668
 * @ingroup krb5_keytab
652
669
 */
653
670
 
654
 
krb5_error_code KRB5_LIB_FUNCTION
 
671
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
655
672
krb5_kt_copy_entry_contents(krb5_context context,
656
673
                            const krb5_keytab_entry *in,
657
674
                            krb5_keytab_entry *out)
687
704
 * @ingroup krb5_keytab
688
705
 */
689
706
 
690
 
krb5_error_code KRB5_LIB_FUNCTION
 
707
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
691
708
krb5_kt_free_entry(krb5_context context,
692
709
                   krb5_keytab_entry *entry)
693
710
{
709
726
 * @ingroup krb5_keytab
710
727
 */
711
728
 
712
 
krb5_error_code KRB5_LIB_FUNCTION
 
729
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
713
730
krb5_kt_start_seq_get(krb5_context context,
714
731
                      krb5_keytab id,
715
732
                      krb5_kt_cursor *cursor)
738
755
 * @ingroup krb5_keytab
739
756
 */
740
757
 
741
 
krb5_error_code KRB5_LIB_FUNCTION
 
758
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
742
759
krb5_kt_next_entry(krb5_context context,
743
760
                   krb5_keytab id,
744
761
                   krb5_keytab_entry *entry,
766
783
 * @ingroup krb5_keytab
767
784
 */
768
785
 
769
 
krb5_error_code KRB5_LIB_FUNCTION
 
786
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
770
787
krb5_kt_end_seq_get(krb5_context context,
771
788
                    krb5_keytab id,
772
789
                    krb5_kt_cursor *cursor)
792
809
 * @ingroup krb5_keytab
793
810
 */
794
811
 
795
 
krb5_error_code KRB5_LIB_FUNCTION
 
812
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
796
813
krb5_kt_add_entry(krb5_context context,
797
814
                  krb5_keytab id,
798
815
                  krb5_keytab_entry *entry)
820
837
 * @ingroup krb5_keytab
821
838
 */
822
839
 
823
 
krb5_error_code KRB5_LIB_FUNCTION
 
840
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
824
841
krb5_kt_remove_entry(krb5_context context,
825
842
                     krb5_keytab id,
826
843
                     krb5_keytab_entry *entry)