Exemple #1
0
static void 
s_load_certs_from_disk (zcertstore_t *self)
{
    s_empty_store (self);
    zdir_t *dir = zdir_new (self->location, NULL);
    if (dir) {
        //  Load all certificates including those in subdirectories
        zfile_t **filelist = zdir_flatten (dir);
        uint index;
        for (index = 0;; index++) {
            zfile_t *file = filelist [index];
            if (!file)
                break;      //  End of list
            if (zfile_is_regular (file)) {
                zcert_t *cert = zcert_load (zfile_filename (file, NULL));
                if (cert)
                    zcertstore_insert (self, &cert);
            }
        }
        zdir_flatten_free (&filelist);
        self->modified = zdir_modified (dir);
        self->count = zdir_count (dir);
        self->cursize = zdir_cursize (dir);

        zdir_destroy (&dir);
    }
}
Exemple #2
0
void
zdir_fprint (zdir_t *self, FILE *stream, int indent)
{
    assert (self);

    zfile_t **files = zdir_flatten (self);
    uint index;
    for (index = 0;; index++) {
        zfile_t *file = files [index];
        if (!file)
            break;
        fprintf (stream, "%s\n", zfile_filename (file, NULL));
    }
    zdir_flatten_free (&files);
}
Exemple #3
0
zlist_t *
zdir_list (zdir_t *self)
{
    zfile_t **files = zdir_flatten (self);
    zlist_t *list = zlist_new ();
    size_t index;

    if (files)
    {
        for (index = 0 ; files[index] ; index++)
        {
            zlist_append (list, files[index]);
        }
    }

    zdir_flatten_free (&files);
    return list;
}
Exemple #4
0
static void
s_disk_loader (zcertstore_t *certstore)
{
    disk_loader_state *state = (disk_loader_state *)certstore->state;
    zdir_t *dir = zdir_new (state->location, NULL);
    if (dir
    && (state->modified != zdir_modified (dir)
    ||  state->count != zdir_count (dir)
    ||  state->cursize != (size_t) zdir_cursize (dir)))
    {
        zhashx_purge (certstore->certs);

        //  Load all certificates including those in subdirectories
        zfile_t **filelist = zdir_flatten (dir);
        assert (filelist);
        zrex_t *rex = zrex_new ("_secret$");
        assert (rex);

        uint index;
        for (index = 0;; index++) {
            zfile_t *file = filelist [index];
            if (!file)
                break;      //  End of list
            if (zfile_is_regular (file)
            && !zrex_matches (rex, zfile_filename (file, NULL))) {
                zcert_t *cert = zcert_load (zfile_filename (file, NULL));
                if (cert)
                    zcertstore_insert (certstore, &cert);
            }
        }
        zdir_flatten_free (&filelist);
        state->modified = zdir_modified (dir);
        state->count = zdir_count (dir);
        state->cursize = zdir_cursize (dir);

        zrex_destroy (&rex);
    }
    zdir_destroy (&dir);
}