コード例 #1
0
ファイル: funcs.c プロジェクト: carmark/illumos-gate
static const char *
check_auditflags(const char *auditflags)
{
	au_mask_t mask;
	char	*flags;
	char	*last = NULL;
	char	*err = "NULL";

	/* if deleting audit_flags */
	if (*auditflags == '\0') {
		return (NULL);
	}

	if ((flags = _strdup_null((char *)auditflags)) == NULL) {
		errmsg(M_NOSPACE);
		exit(EX_FAILURE);
	}

	if (!__chkflags(_strtok_escape(flags, KV_AUDIT_DELIMIT, &last), &mask,
	    B_FALSE, &err)) {
		(void) snprintf(auditerr, sizeof (auditerr),
		    "always mask \"%s\"", err);
		free(flags);
		return (auditerr);
	}
	if (!__chkflags(_strtok_escape(NULL, KV_AUDIT_DELIMIT, &last), &mask,
	    B_FALSE, &err)) {
		(void) snprintf(auditerr, sizeof (auditerr),
		    "never mask \"%s\"", err);
		free(flags);
		return (auditerr);
	}
	if (last != NULL) {
		(void) snprintf(auditerr, sizeof (auditerr), "\"%s\"",
		    auditflags);
		free(flags);
		return (auditerr);
	}
	free(flags);

	return (NULL);
}
コード例 #2
0
ファイル: getdaent.c プロジェクト: andreiw/polaris
/*
 * da_interpret -
 *	parses val and initializes pointers in devalloc_t.
 * 	returns pointer to parsed devalloc_t entry, else returns NULL on error.
 */
static devalloc_t  *
da_interpret(char *val)
{
	struct _dabuff	*_da = _daalloc();
	char	*opts;
	int	i;
	kva_t	*kvap;
	kv_t	*kvp;

	if (_da == NULL)
		return (NULL);

	(void) strcpy(interpdaline, val);
	interpdevalloc.da_devname = getdadmfield(interpdaline, KV_DELIMITER);
	interpdevalloc.da_devtype = getdadmfield(NULL, KV_DELIMITER);
	opts = getdadmfield(NULL, KV_DELIMITER);
	(void) getdadmfield(NULL, KV_DELIMITER);	/* reserved field */
	interpdevalloc.da_devauth = getdadmfield(NULL, KV_DELIMITER);
	interpdevalloc.da_devexec = getdadmfield(NULL, KV_DELIMITER);
	interpdevalloc.da_devopts = NULL;
	if (interpdevalloc.da_devname == NULL ||
	    interpdevalloc.da_devtype == NULL)
		return (NULL);
	if ((opts != NULL) &&
	    (strncmp(opts, DA_RESERVED, strlen(DA_RESERVED)) != 0)) {
		interpdevalloc.da_devopts =
		    _str2kva(opts, KV_ASSIGN, KV_TOKEN_DELIMIT);
	}
	/* remove any extraneous whitespace in the options */
	if ((kvap = interpdevalloc.da_devopts) != NULL) {
		for (i = 0, kvp = kvap->data; i < kvap->length; i++, kvp++) {
			(void) pack_white(kvp->key);
			(void) pack_white(kvp->value);
		}
	}

	if (system_labeled) {
		/* if label range is not defined, use the default range. */
		int		i = 0, nlen = 0;
		char		*minstr = NULL, *maxstr = NULL;
		kva_t		*nkvap = NULL;
		kv_t		*ndata = NULL, *odata = NULL;

		if (kvap == NULL) {
			nlen = 2;	/* minlabel, maxlabel */
		} else {
			nlen += kvap->length;
			if ((minstr = kva_match(kvap, DAOPT_MINLABEL)) == NULL)
				nlen++;
			if ((maxstr = kva_match(kvap, DAOPT_MAXLABEL)) == NULL)
				nlen++;
		}
		if ((minstr != NULL) && (maxstr != NULL))
			/*
			 * label range provided; we don't need to construct
			 * default range.
			 */
			goto out;
		nkvap = _new_kva(nlen);
		ndata = nkvap->data;
		if (kvap != NULL) {
			for (i = 0; i < kvap->length; i++) {
				odata = kvap->data;
				ndata[i].key = _strdup_null(odata[i].key);
				ndata[i].value = _strdup_null(odata[i].value);
				nkvap->length++;
			}
		}
		if (minstr == NULL) {
			ndata[i].key = strdup(DAOPT_MINLABEL);
			ndata[i].value = strdup(DA_DEFAULT_MIN);
			nkvap->length++;
			i++;
		}
		if (maxstr == NULL) {
			ndata[i].key = strdup(DAOPT_MAXLABEL);
			ndata[i].value = strdup(DA_DEFAULT_MAX);
			nkvap->length++;
		}
		interpdevalloc.da_devopts = nkvap;
	}

out:
	return (&interpdevalloc);
}