[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <m17h4g2jqy.fsf@fess.ebiederm.org>
Date: Fri, 07 Oct 2011 21:24:37 -0700
From: ebiederm@...ssion.com (Eric W. Biederman)
To: Lennart Poettering <mzxreary@...inter.de>
Cc: Matt Helsley <matthltc@...ibm.com>,
Kay Sievers <kay.sievers@...y.org>,
linux-kernel@...r.kernel.org, harald@...hat.com, david@...ar.dk,
greg@...ah.com
Subject: Re: A Plumber’s Wish List for Linux
Lennart Poettering <mzxreary@...inter.de> writes:
> On Fri, 07.10.11 00:49, Matt Helsley (matthltc@...ibm.com) wrote:
>
>>
>> On Fri, Oct 07, 2011 at 01:17:02AM +0200, Kay Sievers wrote:
>>
>> <snip>
>>
>> > * simple, reliable and future-proof way to detect whether a specific pid
>> > is running in a CLONE_NEWPID container, i.e. not in the root PID
>> > namespace. Currently, there are available a few ugly hacks to detect
>>
>> Is that precisely what's needed or would it be sufficient to know
>> that the pid is running in a child pid namespace of the current pid
>> namespace? If so, I think this could eventually be done by comparing
>> the inode numbers assigned to /proc/<pid>/ns/pid to those of
>> /proc/1/ns/pid.
>
> I think the most interesting test would be to figure out for a process
> if itself is running in a PID namespace. And for that comparing inodes
> wouldn't work since the namespace process would never get access to the
> inode of the outside init.
Strictly correct answer. All processes are running in a pid namespace.
I think we can implement that in a libc header.
static inline bool in_pid_namespace(void)
{
return true;
}
Why does it matter if you are running in something other than the
initial pid namespace? I expect what you are really after is something
else entirely, and you are asking the wrong question.
Eric
--
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