[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20090205171055.GA2809@x200.localdomain>
Date: Thu, 5 Feb 2009 20:10:55 +0300
From: Alexey Dobriyan <adobriyan@...il.com>
To: Kentaro Takeda <takedakn@...data.co.jp>
Cc: jmorris@...ei.org, linux-security-module@...r.kernel.org,
linux-kernel@...r.kernel.org, akpm@...ux-foundation.org,
haradats@...data.co.jp,
Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>
Subject: Re: [TOMOYO #15 6/8] LSM adapter functions.
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@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists