Subject: Re: [vserver] tags (lsxid) when the host create files within vserver directories
From: Allan Latham <alatham@flexsys-group.de>
Date: Tue, 28 May 2013 12:33:07 +0200

Hi all

really bad form - answering your own questions - please forgive me.

I do so in the hope it will help someone else in the future.

All command run from host.

vtag --migrate --tag 1234 -- prog-you-want-run

Beware however: although prog-you-want-run will create its output files
with tag 1234 it may not be able to read its input files. The trick then
is to read the input outside the vtag context and pipe it through vtag e.g.

prog-which-reads-data | \
vtag --migrate --tag 1234 -- prog-which-creates-files

In my case

tar -cz X Y Z | vtag --migrate --tag 1234 -- tee A.tgz >/dev/null

Not always possible in every case maybe but much nicer than chxid on the
output files after the event.

All the best to everyone on the list

Allan

On 27/05/13 16:09, Allan Latham wrote:
> Hi all
> 
> This is answered by this FAQ:
> 
> http://linux-vserver.org/Frequently_Asked_Questions#How_do_I_tag_a_guest.27s_directory_with_xid.3F
> 
> and this is indeed what happens.
> 
> I need to have such files tagged for the vserver and I have a clumsy
> workround with chxid run from the host.
> 
> Somewhere in my reading about vservers I'm sure I read that the tag
> would be copied from the directory tag when a new file is created.
> 
> It may be that this happens only when inside a vserver context - but
> maybe some other flag or whatever changes this behaviour. I cannot find
> this web page again.
> 
> Is there some way to do this from the host other than fixing it with
> chxid afterwards?
> 
> Could I set some flag on the parent directory?
> 
> Could I run the program which creates the file from the host but in a
> vserver context - if so how?
> 
> vserver exec can't work because the program is on the host and is not
> present inside the vserver.
> 
> Thanks in advance
> 
> Allan
> 
>