* per-chroot clock module ?
@ 2010-11-27 18:21 Jason Vas Dias
2010-11-27 18:57 ` Ben Gamari
2010-12-03 19:36 ` Pavel Machek
0 siblings, 2 replies; 10+ messages in thread
From: Jason Vas Dias @ 2010-11-27 18:21 UTC (permalink / raw)
To: linux-kernel
Greetings -
Sorry in advance if this is a stupid idea, but -
I'd really like to be able to set a distinct "clock" for a specific chroot environment,
such that the super-user could call :
const char *my_chroot_directory = "/some_chroot";
struct stat st;
if(stat( my_chroot_directory, &st) ==0)
sys_clock_settime ((clockid_t) st.st_inode, (struct timespec *)tp)
( from glibc )
and there would be a real-time clock offset association in the kernel between the
inode number of the directory to which a "chroot" has succeeded, and a real-time
clock offset , so that ALL processes that run with their "root" directory of such
chroot directories can get the same values for time() or gettimeofday() which would be
offset from the real-time clock by the current offset of the last "clock_settime(inode, timespec)"
second parameter for that directory inode (first parameter).
Eventually, the coreutils "date(1)" command could be extended to support setting the system
date and time for different chroot() root directories.
Does anyone know of a module that does this ?
If not, and if no-one convinces me this is a stupid idea, I'm going to write one.
Thanks in advance for any replies,
All the best,
Jason Vas Dias (a software engineer) <jason.vas.dias@gmail.com>
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: per-chroot clock module ?
2010-11-27 18:21 per-chroot clock module ? Jason Vas Dias
@ 2010-11-27 18:57 ` Ben Gamari
2010-11-27 19:22 ` Jason Vas Dias
2010-11-27 19:27 ` Elias Gabriel Amaral da Silva
2010-12-03 19:36 ` Pavel Machek
1 sibling, 2 replies; 10+ messages in thread
From: Ben Gamari @ 2010-11-27 18:57 UTC (permalink / raw)
To: jason.vas.dias, linux-kernel
On Sat, 27 Nov 2010 18:21:34 +0000, Jason Vas Dias <jason.vas.dias@gmail.com> wrote:
> Greetings -
>
> Sorry in advance if this is a stupid idea, but -
>
> I'd really like to be able to set a distinct "clock" for a specific chroot environment,
> such that the super-user could call :
> [snip]
It certainly doesn't sound like a particularly good idea to me. This
would add great complexity to the kernel while having very few
users. Perhaps there's something I haven't considered but I can't think
of any good applications for this sort of functionality. Do you have
something in particular in mind?
It seems like what you want here is simple virtualization. Have you
considered KVM? The closest thing to your request currently upstream is
containers, although I'm unsure of whether a container can be created
with an independent clock. Might be something to look into.
Cheers,
- Ben
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: per-chroot clock module ?
2010-11-27 18:57 ` Ben Gamari
@ 2010-11-27 19:22 ` Jason Vas Dias
2010-11-27 23:51 ` Andre Tomt
2010-11-27 19:27 ` Elias Gabriel Amaral da Silva
1 sibling, 1 reply; 10+ messages in thread
From: Jason Vas Dias @ 2010-11-27 19:22 UTC (permalink / raw)
To: Ben Gamari; +Cc: linux-kernel
On Saturday 27 November 2010 18:57:19 Ben Gamari wrote:
> On Sat, 27 Nov 2010 18:21:34 +0000, Jason Vas Dias <jason.vas.dias@gmail.com> wrote:
> > Greetings -
> >
> > Sorry in advance if this is a stupid idea, but -
> >
> > I'd really like to be able to set a distinct "clock" for a specific chroot environment,
> > such that the super-user could call :
> > [snip]
>
> It certainly doesn't sound like a particularly good idea to me. This
> would add great complexity to the kernel while having very few
> users. Perhaps there's something I haven't considered but I can't think
> of any good applications for this sort of functionality. Do you have
> something in particular in mind?
I'm not sure that it need be that complex -
o kernel knows chroot() has succeeded so adds the inode of that directory to a "inode <-> clock_offset" mapping
initialized to 0.
o this mapping could perhaps also be used to provide other future per-chroot specific features - as for instance
a per-chroot list of extra acceptable binary executable formats ?
o clock_gettime() and gettimeofday() and time() and clock_settime() are modified to see if the root device inode
number has a non-zero real-time clock offset, and, if so, apply it to the real-time clock returned or in the case
of clock_settime(), set the associated offset to a non-zero value.
RE: why ?
This would allow one to very easily support websites for totally different timezones , where offsets need not be
restricted to legal timezone offsets but could encompass years - also nice if you want to run applications whose
license key has expired . Also very easy to support multiple instances of cron(1) running in different timezones.
In any case, the module would ensure that the time the kernel sees internally for all processes is the actual real-time
clock value; only processes which have their root directory in one of the special chroot directories would get
a different gettimeofday() or clock_gettime() value .
>
> It seems like what you want here is simple virtualization. Have you
> considered KVM? The closest thing to your request currently upstream is
> containers, although I'm unsure of whether a container can be created
> with an independent clock. Might be something to look into.
>
To me, using virtualization to solve this problem is like using a sledgehammer to crack a nut,
particularly if the optimal performance of the processes running in such chroot environments
is of paramount importance.
> Cheers,
>
> - Ben
>
Thanks for your comments, but I think it is still a good idea and I'm investigating now -
it doesn't seem to need to be too complex to me.
All the best,
Jason.
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: per-chroot clock module ?
2010-11-27 19:22 ` Jason Vas Dias
@ 2010-11-27 23:51 ` Andre Tomt
0 siblings, 0 replies; 10+ messages in thread
From: Andre Tomt @ 2010-11-27 23:51 UTC (permalink / raw)
To: jason.vas.dias; +Cc: Ben Gamari, linux-kernel
On 11/27/2010 08:22 PM, Jason Vas Dias wrote:
> RE: why ?
> This would allow one to very easily support websites for totally different timezones , where offsets need not be
> restricted to legal timezone offsets but could encompass years - also nice if you want to run applications whose
> license key has expired . Also very easy to support multiple instances of cron(1) running in different timezones.
> In any case, the module would ensure that the time the kernel sees internally for all processes is the actual real-time
> clock value; only processes which have their root directory in one of the special chroot directories would get
> a different gettimeofday() or clock_gettime() value .
>
>>
>> It seems like what you want here is simple virtualization. Have you
>> considered KVM? The closest thing to your request currently upstream is
>> containers, although I'm unsure of whether a container can be created
>> with an independent clock. Might be something to look into.
>>
>
> To me, using virtualization to solve this problem is like using a sledgehammer to crack a nut,
> particularly if the optimal performance of the processes running in such chroot environments
> is of paramount importance.
You might want to take a look at Linux-Vserver; it has containers (that
is, chroot on stereoids) with support for "virtualized time"/clock offset.
Virtualized time is not without downsides, it adds overhead. It will be
tiny compared to using a sledgehammer of course. The vserver guys puts
it this way;
"This enables per guest time offsets to allow for adjusting the system
clock individually per guest. this adds some overhead to the time
functions and therefore should not be enabled without good reason."
http://linux-vserver.org/
It could be useful to implement such a thing in a "time" namespace,
making it available to lxc containers and cgroups also.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: per-chroot clock module ?
2010-11-27 18:57 ` Ben Gamari
2010-11-27 19:22 ` Jason Vas Dias
@ 2010-11-27 19:27 ` Elias Gabriel Amaral da Silva
1 sibling, 0 replies; 10+ messages in thread
From: Elias Gabriel Amaral da Silva @ 2010-11-27 19:27 UTC (permalink / raw)
To: Ben Gamari; +Cc: jason.vas.dias, linux-kernel
2010/11/27 Ben Gamari <bgamari@gmail.com>:
> On Sat, 27 Nov 2010 18:21:34 +0000, Jason Vas Dias <jason.vas.dias@gmail.com> wrote:
>> Greetings -
>>
>> Sorry in advance if this is a stupid idea, but -
>>
>> I'd really like to be able to set a distinct "clock" for a specific chroot environment,
>> such that the super-user could call :
>> [snip]
>
> It certainly doesn't sound like a particularly good idea to me. This
> would add great complexity to the kernel while having very few
> users. Perhaps there's something I haven't considered but I can't think
> of any good applications for this sort of functionality. Do you have
> something in particular in mind?
>
> It seems like what you want here is simple virtualization. Have you
> considered KVM? The closest thing to your request currently upstream is
> containers, although I'm unsure of whether a container can be created
> with an independent clock. Might be something to look into.
KVM needs hardware support (but chroot runs wherever Linux runs)
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: per-chroot clock module ?
2010-11-27 18:21 per-chroot clock module ? Jason Vas Dias
2010-11-27 18:57 ` Ben Gamari
@ 2010-12-03 19:36 ` Pavel Machek
2010-12-30 20:31 ` webmaster
1 sibling, 1 reply; 10+ messages in thread
From: Pavel Machek @ 2010-12-03 19:36 UTC (permalink / raw)
To: Jason Vas Dias; +Cc: linux-kernel
Hi!
> I'd really like to be able to set a distinct "clock" for a specific chroot environment,
> such that the super-user could call :
> const char *my_chroot_directory = "/some_chroot";
> struct stat st;
> if(stat( my_chroot_directory, &st) ==0)
> sys_clock_settime ((clockid_t) st.st_inode, (struct timespec *)tp)
> ( from glibc )
See subterfugue.net... it can do this.
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: per-chroot clock module ?
2010-12-03 19:36 ` Pavel Machek
@ 2010-12-30 20:31 ` webmaster
2011-01-02 5:32 ` Pavel Machek
0 siblings, 1 reply; 10+ messages in thread
From: webmaster @ 2010-12-30 20:31 UTC (permalink / raw)
To: Pavel Machek; +Cc: linux-kernel
On Friday 03 December 2010 19:36:59 Pavel Machek wrote:
> Hi!
>
> > I'd really like to be able to set a distinct "clock" for a specific chroot environment,
> > such that the super-user could call :
> > const char *my_chroot_directory = "/some_chroot";
> > struct stat st;
> > if(stat( my_chroot_directory, &st) ==0)
> > sys_clock_settime ((clockid_t) st.st_inode, (struct timespec *)tp)
> > ( from glibc )
>
> See subterfugue.net... it can do this.
>
Sorry for the delay in responding -
but I've been very busy, amongst other things working on the "per-chroot" module, which
now works in a very basic but sufficient mode.
If anyone else would find it useful, I'll fill it out some more and post it to this list.
I'd like to see this "subterfuge.net" - but I'm unable to connect with HTTP:
$ curl http://subterfuge.net --trace-ascii /dev/fd/2
== Info: About to connect() to subterfuge.net port 80 (#0)
== Info: Trying 184.82.15.90... == Info: No route to host
== Info: couldn't connect to host
== Info: Closing connection #0
curl: (7) couldn't connect to host
while google just finds "subterfuge.com" which appears to be a Spanish record company ...
Is this server now down / being blocked ?
Did I get the URL incorrect ? What is / was the software at subterfuge.net ?
All the best & happy new year to all ,
Jason
^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <fTxH4-2pP-5@gated-at.bofh.it>]
end of thread, other threads:[~2011-01-02 5:31 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-27 18:21 per-chroot clock module ? Jason Vas Dias
2010-11-27 18:57 ` Ben Gamari
2010-11-27 19:22 ` Jason Vas Dias
2010-11-27 23:51 ` Andre Tomt
2010-11-27 19:27 ` Elias Gabriel Amaral da Silva
2010-12-03 19:36 ` Pavel Machek
2010-12-30 20:31 ` webmaster
2011-01-02 5:32 ` Pavel Machek
[not found] <fTxH4-2pP-5@gated-at.bofh.it>
[not found] ` <fTya5-30n-9@gated-at.bofh.it>
[not found] ` <fTyD7-3UB-11@gated-at.bofh.it>
2010-11-28 11:15 ` Bodo Eggert
2010-11-29 12:52 ` Jason Vas Dias
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox