const char *pcf_parse_master_entry(PCF_MASTER_ENT *masterp, const char *buf) { ARGV *argv; /* * We can't use the master daemon's master_ent routines in their current * form. They convert everything to internal form, and they skip disabled * services. * * The postconf command needs to show default fields as "-", and needs to * know about all service names so that it can generate service-dependent * parameter names (transport-dependent etc.). * * XXX Do per-field sanity checks. */ argv = argv_splitq(buf, PCF_MASTER_BLANKS, CHARS_BRACE); if (argv->argc < PCF_MASTER_MIN_FIELDS) { argv_free(argv); /* Coverity 201311 */ return ("bad field count"); } pcf_check_master_entry(argv, buf); pcf_normalize_daemon_args(argv); masterp->name_space = concatenate(argv->argv[0], PCF_NAMESP_SEP_STR, argv->argv[1], (char *) 0); masterp->argv = argv; masterp->valid_names = 0; masterp->all_params = 0; return (0); }
DICT *dict_random_open(const char *name, int open_flags, int dict_flags) { DICT_RANDOM *dict_random; char *saved_name = 0; size_t len; /* * Clarity first. Let the optimizer worry about redundant code. */ #define DICT_RANDOM_RETURN(x) do { \ if (saved_name != 0) \ myfree(saved_name); \ return (x); \ } while (0) /* * Sanity checks. */ if (open_flags != O_RDONLY) DICT_RANDOM_RETURN(dict_surrogate(DICT_TYPE_RANDOM, name, open_flags, dict_flags, "%s:%s map requires O_RDONLY access mode", DICT_TYPE_RANDOM, name)); /* * Split the name name into its constituent parts. */ if ((len = balpar(name, "{}")) == 0 || name[len] != 0 || *(saved_name = mystrndup(name + 1, len - 2)) == 0) DICT_RANDOM_RETURN(dict_surrogate(DICT_TYPE_RANDOM, name, open_flags, dict_flags, "bad syntax: \"%s:%s\"; " "need \"%s:{type:name...}\"", DICT_TYPE_RANDOM, name, DICT_TYPE_RANDOM)); /* * Bundle up the result. */ dict_random = (DICT_RANDOM *) dict_alloc(DICT_TYPE_RANDOM, name, sizeof(*dict_random)); dict_random->dict.lookup = dict_random_lookup; dict_random->dict.close = dict_random_close; dict_random->dict.flags = dict_flags | DICT_FLAG_PATTERN; dict_random->replies = argv_splitq(saved_name, ", \t\r\n", "{}"); dict_random->dict.owner.status = DICT_OWNER_TRUSTED; dict_random->dict.owner.uid = 0; DICT_RANDOM_RETURN(DICT_DEBUG (&dict_random->dict)); }
DICT *dict_union_open(const char *name, int open_flags, int dict_flags) { static const char myname[] = "dict_union_open"; DICT_UNION *dict_union; char *saved_name = 0; char *dict_type_name; ARGV *argv = 0; char **cpp; DICT *dict; int match_flags = 0; struct DICT_OWNER aggr_owner; size_t len; /* * Clarity first. Let the optimizer worry about redundant code. */ #define DICT_UNION_RETURN(x) do { \ if (saved_name != 0) \ myfree(saved_name); \ if (argv != 0) \ argv_free(argv); \ return (x); \ } while (0) /* * Sanity checks. */ if (open_flags != O_RDONLY) DICT_UNION_RETURN(dict_surrogate(DICT_TYPE_UNION, name, open_flags, dict_flags, "%s:%s map requires O_RDONLY access mode", DICT_TYPE_UNION, name)); /* * Split the table name into its constituent parts. */ if ((len = balpar(name, CHARS_BRACE)) == 0 || name[len] != 0 || *(saved_name = mystrndup(name + 1, len - 2)) == 0 || ((argv = argv_splitq(saved_name, CHARS_COMMA_SP, CHARS_BRACE)), (argv->argc == 0))) DICT_UNION_RETURN(dict_surrogate(DICT_TYPE_UNION, name, open_flags, dict_flags, "bad syntax: \"%s:%s\"; " "need \"%s:{type:name...}\"", DICT_TYPE_UNION, name, DICT_TYPE_UNION)); /* * The least-trusted table in the set determines the over-all trust * level. The first table determines the pattern-matching flags. */ DICT_OWNER_AGGREGATE_INIT(aggr_owner); for (cpp = argv->argv; (dict_type_name = *cpp) != 0; cpp++) { if (msg_verbose) msg_info("%s: %s", myname, dict_type_name); if (strchr(dict_type_name, ':') == 0) DICT_UNION_RETURN(dict_surrogate(DICT_TYPE_UNION, name, open_flags, dict_flags, "bad syntax: \"%s:%s\"; " "need \"%s:{type:name...}\"", DICT_TYPE_UNION, name, DICT_TYPE_UNION)); if ((dict = dict_handle(dict_type_name)) == 0) dict = dict_open(dict_type_name, open_flags, dict_flags); dict_register(dict_type_name, dict); DICT_OWNER_AGGREGATE_UPDATE(aggr_owner, dict->owner); if (cpp == argv->argv) match_flags = dict->flags & (DICT_FLAG_FIXED | DICT_FLAG_PATTERN); } /* * Bundle up the result. */ dict_union = (DICT_UNION *) dict_alloc(DICT_TYPE_UNION, name, sizeof(*dict_union)); dict_union->dict.lookup = dict_union_lookup; dict_union->dict.close = dict_union_close; dict_union->dict.flags = dict_flags | match_flags; dict_union->dict.owner = aggr_owner; dict_union->re_buf = vstring_alloc(100); dict_union->map_union = argv; argv = 0; DICT_UNION_RETURN(DICT_DEBUG (&dict_union->dict)); }