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

« back to all changes in this revision

Viewing changes to source4/heimdal/lib/hx509/ks_file.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:
367
367
                 const char *residue, hx509_lock lock, outformat format)
368
368
{
369
369
    char *p, *pnext;
370
 
    struct ks_file *f = NULL;
 
370
    struct ks_file *ksf = NULL;
371
371
    hx509_private_key *keys = NULL;
372
372
    int ret;
373
373
    struct pem_ctx pem_ctx;
380
380
    if (lock == NULL)
381
381
        lock = _hx509_empty_lock;
382
382
 
383
 
    f = calloc(1, sizeof(*f));
384
 
    if (f == NULL) {
 
383
    ksf = calloc(1, sizeof(*ksf));
 
384
    if (ksf == NULL) {
385
385
        hx509_clear_error_string(context);
386
386
        return ENOMEM;
387
387
    }
388
 
    f->format = format;
 
388
    ksf->format = format;
389
389
 
390
 
    f->fn = strdup(residue);
391
 
    if (f->fn == NULL) {
 
390
    ksf->fn = strdup(residue);
 
391
    if (ksf->fn == NULL) {
392
392
        hx509_clear_error_string(context);
393
393
        ret = ENOMEM;
394
394
        goto out;
401
401
 
402
402
    if (flags & HX509_CERTS_CREATE) {
403
403
        ret = hx509_certs_init(context, "MEMORY:ks-file-create",
404
 
                               0, lock, &f->certs);
 
404
                               0, lock, &ksf->certs);
405
405
        if (ret)
406
406
            goto out;
407
 
        *data = f;
 
407
        *data = ksf;
408
408
        return 0;
409
409
    }
410
410
 
412
412
    if (ret)
413
413
        goto out;
414
414
 
415
 
    for (p = f->fn; p != NULL; p = pnext) {
 
415
    for (p = ksf->fn; p != NULL; p = pnext) {
416
416
        FILE *f;
417
417
 
418
418
        pnext = strchr(p, ',');
461
461
        }
462
462
    }
463
463
 
464
 
    ret = _hx509_collector_collect_certs(context, pem_ctx.c, &f->certs);
 
464
    ret = _hx509_collector_collect_certs(context, pem_ctx.c, &ksf->certs);
465
465
    if (ret)
466
466
        goto out;
467
467
 
470
470
        int i;
471
471
 
472
472
        for (i = 0; keys[i]; i++)
473
 
            _hx509_certs_keys_add(context, f->certs, keys[i]);
 
473
            _hx509_certs_keys_add(context, ksf->certs, keys[i]);
474
474
        _hx509_certs_keys_free(context, keys);
475
475
    }
476
476
 
477
477
out:
478
478
    if (ret == 0)
479
 
        *data = f;
 
479
        *data = ksf;
480
480
    else {
481
 
        if (f->fn)
482
 
            free(f->fn);
483
 
        free(f);
 
481
        if (ksf->fn)
 
482
            free(ksf->fn);
 
483
        free(ksf);
484
484
    }
485
485
    if (pem_ctx.c)
486
486
        _hx509_collector_free(pem_ctx.c);
507
507
static int
508
508
file_free(hx509_certs certs, void *data)
509
509
{
510
 
    struct ks_file *f = data;
511
 
    hx509_certs_free(&f->certs);
512
 
    free(f->fn);
513
 
    free(f);
 
510
    struct ks_file *ksf = data;
 
511
    hx509_certs_free(&ksf->certs);
 
512
    free(ksf->fn);
 
513
    free(ksf);
514
514
    return 0;
515
515
}
516
516
 
541
541
        free(data.data);
542
542
        if (_hx509_cert_private_key_exportable(c)) {
543
543
            hx509_private_key key = _hx509_cert_private_key(c);
544
 
            ret = _hx509_private_key_export(context, key, &data);
 
544
            ret = _hx509_private_key_export(context, key,
 
545
                                            HX509_KEY_FORMAT_DER, &data);
545
546
            if (ret)
546
547
                break;
547
548
            hx509_pem_write(context, _hx509_private_pem_name(key), NULL, sc->f,
558
559
file_store(hx509_context context,
559
560
           hx509_certs certs, void *data, int flags, hx509_lock lock)
560
561
{
561
 
    struct ks_file *f = data;
 
562
    struct ks_file *ksf = data;
562
563
    struct store_ctx sc;
563
564
    int ret;
564
565
 
565
 
    sc.f = fopen(f->fn, "w");
 
566
    sc.f = fopen(ksf->fn, "w");
566
567
    if (sc.f == NULL) {
567
568
        hx509_set_error_string(context, 0, ENOENT,
568
569
                               "Failed to open file %s for writing");
569
570
        return ENOENT;
570
571
    }
571
572
    rk_cloexec_file(sc.f);
572
 
    sc.format = f->format;
 
573
    sc.format = ksf->format;
573
574
 
574
 
    ret = hx509_certs_iter(context, f->certs, store_func, &sc);
 
575
    ret = hx509_certs_iter_f(context, ksf->certs, store_func, &sc);
575
576
    fclose(sc.f);
576
577
    return ret;
577
578
}
579
580
static int
580
581
file_add(hx509_context context, hx509_certs certs, void *data, hx509_cert c)
581
582
{
582
 
    struct ks_file *f = data;
583
 
    return hx509_certs_add(context, f->certs, c);
 
583
    struct ks_file *ksf = data;
 
584
    return hx509_certs_add(context, ksf->certs, c);
584
585
}
585
586
 
586
587
static int
587
588
file_iter_start(hx509_context context,
588
589
                hx509_certs certs, void *data, void **cursor)
589
590
{
590
 
    struct ks_file *f = data;
591
 
    return hx509_certs_start_seq(context, f->certs, cursor);
 
591
    struct ks_file *ksf = data;
 
592
    return hx509_certs_start_seq(context, ksf->certs, cursor);
592
593
}
593
594
 
594
595
static int
595
596
file_iter(hx509_context context,
596
597
          hx509_certs certs, void *data, void *iter, hx509_cert *cert)
597
598
{
598
 
    struct ks_file *f = data;
599
 
    return hx509_certs_next_cert(context, f->certs, iter, cert);
 
599
    struct ks_file *ksf = data;
 
600
    return hx509_certs_next_cert(context, ksf->certs, iter, cert);
600
601
}
601
602
 
602
603
static int
605
606
              void *data,
606
607
              void *cursor)
607
608
{
608
 
    struct ks_file *f = data;
609
 
    return hx509_certs_end_seq(context, f->certs, cursor);
 
609
    struct ks_file *ksf = data;
 
610
    return hx509_certs_end_seq(context, ksf->certs, cursor);
610
611
}
611
612
 
612
613
static int
615
616
             void *data,
616
617
             hx509_private_key **keys)
617
618
{
618
 
    struct ks_file *f = data;
619
 
    return _hx509_certs_keys_get(context, f->certs, keys);
 
619
    struct ks_file *ksf = data;
 
620
    return _hx509_certs_keys_get(context, ksf->certs, keys);
620
621
}
621
622
 
622
623
static int
625
626
             void *data,
626
627
             hx509_private_key key)
627
628
{
628
 
    struct ks_file *f = data;
629
 
    return _hx509_certs_keys_add(context, f->certs, key);
 
629
    struct ks_file *ksf = data;
 
630
    return _hx509_certs_keys_add(context, ksf->certs, key);
630
631
}
631
632
 
632
633
static struct hx509_keyset_ops keyset_file = {