MCPcopy Create free account
hub / github.com/apache/httpd / pfs_save

Function pfs_save

modules/md/md_store_fs.c:626–685  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

624}
625
626static apr_status_t pfs_save(void *baton, apr_pool_t *p, apr_pool_t *ptemp, va_list ap)
627{
628 md_store_fs_t *s_fs = baton;
629 const char *gdir, *dir, *fpath, *name, *aspect;
630 md_store_vtype_t vtype;
631 md_store_group_t group;
632 void *value;
633 int create;
634 apr_status_t rv;
635 const perms_t *perms;
636 const char *pass;
637 apr_size_t pass_len;
638
639 group = (md_store_group_t)va_arg(ap, int);
640 name = va_arg(ap, const char*);
641 aspect = va_arg(ap, const char*);
642 vtype = (md_store_vtype_t)va_arg(ap, int);
643 value = va_arg(ap, void *);
644 create = va_arg(ap, int);
645
646 perms = gperms(s_fs, group);
647
648 if ( MD_OK(mk_group_dir(&gdir, s_fs, group, NULL, p))
649 && MD_OK(mk_group_dir(&dir, s_fs, group, name, p))
650 && MD_OK(md_util_path_merge(&fpath, ptemp, dir, aspect, NULL))) {
651
652 md_log_perror(MD_LOG_MARK, MD_LOG_TRACE2, 0, ptemp, "storing in %s", fpath);
653 switch (vtype) {
654 case MD_SV_TEXT:
655 rv = (create? md_text_fcreatex(fpath, perms->file, p, value)
656 : md_text_freplace(fpath, perms->file, p, value));
657 break;
658 case MD_SV_JSON:
659 rv = (create? md_json_fcreatex((md_json_t *)value, p, MD_JSON_FMT_INDENT,
660 fpath, perms->file)
661 : md_json_freplace((md_json_t *)value, p, MD_JSON_FMT_INDENT,
662 fpath, perms->file));
663 break;
664 case MD_SV_CERT:
665 rv = md_cert_fsave((md_cert_t *)value, ptemp, fpath, perms->file);
666 break;
667 case MD_SV_PKEY:
668 /* Take care that we write private key with access only to the user,
669 * unless we write the key encrypted */
670 get_pass(&pass, &pass_len, s_fs, group);
671 rv = md_pkey_fsave((md_pkey_t *)value, ptemp, pass, pass_len,
672 fpath, (pass && pass_len)? perms->file : MD_FPROT_F_UONLY);
673 break;
674 case MD_SV_CHAIN:
675 rv = md_chain_fsave((apr_array_header_t*)value, ptemp, fpath, perms->file);
676 break;
677 default:
678 return APR_ENOTIMPL;
679 }
680 if (APR_SUCCESS == rv) {
681 rv = dispatch(s_fs, MD_S_FS_EV_CREATED, group, fpath, APR_REG, p);
682 }
683 }

Callers

nothing calls this directly

Calls 13

gpermsFunction · 0.85
mk_group_dirFunction · 0.85
md_util_path_mergeFunction · 0.85
md_log_perrorFunction · 0.85
md_text_fcreatexFunction · 0.85
md_text_freplaceFunction · 0.85
md_json_fcreatexFunction · 0.85
md_json_freplaceFunction · 0.85
md_cert_fsaveFunction · 0.85
get_passFunction · 0.85
md_pkey_fsaveFunction · 0.85
md_chain_fsaveFunction · 0.85

Tested by

no test coverage detected