Re: [TOMOYO #15 6/8] LSM adapter functions.
From: Alexey Dobriyan
Date: Thu Feb 05 2009 - 12:05:22 EST
On Thu, Feb 05, 2009 at 05:18:16PM +0900, Kentaro Takeda wrote:
> +/**
> + * tomoyo_sysctl_path - return the realpath of a ctl_table.
> + * @table: pointer to "struct ctl_table".
> + *
> + * Returns realpath(3) of the @table on success.
> + * Returns NULL on failure.
> + *
> + * This function uses tomoyo_alloc(), so the caller must call tomoyo_free()
> + * if this function didn't return NULL.
> + */
> +static char *tomoyo_sysctl_path(struct ctl_table *table)
> +{
> + int buflen = TOMOYO_MAX_PATHNAME_LEN;
> + char *buf = tomoyo_alloc(buflen);
> + char *end = buf + buflen;
> + int error = -ENOMEM;
> +
> + if (!buf)
> + return NULL;
> +
> + *--end = '\0';
> + buflen--;
> + while (table) {
> + char buf[32];
> + const char *sp = table->procname;
> +
> + if (!sp) {
> + memset(buf, 0, sizeof(buf));
> + snprintf(buf, sizeof(buf) - 1, "=%d=", table->ctl_name);
> + sp = buf;
> + }
> + if (tomoyo_prepend(&end, &buflen, sp) ||
> + tomoyo_prepend(&end, &buflen, "/"))
> + goto out;
> + table = table->parent;
> + }
> + if (tomoyo_prepend(&end, &buflen, "/proc/sys"))
Hardcoded path?
> + goto out;
> + error = tomoyo_encode(buf, end - buf, end);
> + out:
> + if (!error)
> + return buf;
> + tomoyo_free(buf);
> + return NULL;
> +}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/