librelist archives

« back to archive

.git/index changing owner

.git/index changing owner

From:
Dan Christensen
Date:
2014-02-11 @ 02:17
I've arranged for my git checkout of attic to be runnable live, by 
doing

  pip3 install -e .

as root.  (I want root to be able to run it as well, to do system-wide
backups, and I want to eat my own dogfood.)

I can't reproduce this on demand, but every five or ten minutes, I find
that the owner and group of the file .git/index has changed to root.
I can run lots of attic commands, including "attic -h", and the ownership
doesn't change, but then I run one of them again and the ownership
changes.

I know that attic uses git to generate a version number, but I'm puzzled
by the fact that I can't reproduce this.  Does git only update the index
file after a certain amount of time has passed?

In any case, any suggestion for a workaround?  Once root owns that file,
the regular user can't change it.  I guess I could just copy the tree
to elsewhere, and run pip3 install in the copy, but it would be better
if running attic didn't change the tree.

Dan

Re: [attic] .git/index changing owner

From:
Jonas Borgström
Date:
2014-02-11 @ 19:20
On 2014-02-11 03:17, Dan Christensen wrote:
> I've arranged for my git checkout of attic to be runnable live, by 
> doing
> 
>   pip3 install -e .
> 
> as root.  (I want root to be able to run it as well, to do system-wide
> backups, and I want to eat my own dogfood.)
> 
> I can't reproduce this on demand, but every five or ten minutes, I find
> that the owner and group of the file .git/index has changed to root.
> I can run lots of attic commands, including "attic -h", and the ownership
> doesn't change, but then I run one of them again and the ownership
> changes.
> 
> I know that attic uses git to generate a version number, but I'm puzzled
> by the fact that I can't reproduce this.  Does git only update the index
> file after a certain amount of time has passed?
> 
> In any case, any suggestion for a workaround?  Once root owns that file,
> the regular user can't change it.  I guess I could just copy the tree
> to elsewhere, and run pip3 install in the copy, but it would be better
> if running attic didn't change the tree.

I'm not sure what you're seeing but this is what I'm doing and it seems
to work well:

(As a regular user)

$ virtualenv -p python3.3 /somewhere/env
$ /somewhere/env/bin/pip install -e .

Now you just need to append /somwhere/env/bin to $PATH or symlink
/usr/local/bin/attic to /somewhere/env/bin/attic

/ Jonas

Re: [attic] .git/index changing owner

From:
Dan Christensen
Date:
2014-02-12 @ 01:37
Jonas Borgström <jonas@borgstrom.se> writes:

> I'm not sure what you're seeing but this is what I'm doing and it seems
> to work well:
>
> (As a regular user)
>
> $ virtualenv -p python3.3 /somewhere/env
> $ /somewhere/env/bin/pip install -e .

I did the above with python 3.2, and also installed msgpack_python,
cython and llfuse into /somewhere/env.  Then I edited the attic startup
script to read

  #!/somewhere/env/bin/python
  from attic.archiver import main
  main()

and put it in /somewhere/env/bin/attic.  Then when I run

  /somewhere/env/bin/attic -h

as root, the file .git/index still gets changed to have owner and group
root.  (Again, not every time.)

I'm using Ubuntu's git 1:1.7.9.5-1, in case that matters.

Dan

PS:  When I use pip to install attic, it creates a startup script
that contains

  #!/somewhere/env/bin/python3.2
  # EASY-INSTALL-DEV-SCRIPT: 'Attic==0.10-35-ga79acdd','attic'
  __requires__ = 'Attic==0.10-35-ga79acdd'
  from pkg_resources import require; require('Attic==0.10-35-ga79acdd')
  del require
  __file__ = '/path/to/attic/scripts/attic'
  execfile(__file__)

but python3 doesn't have execfile, so this doesn't run.  This makes it
hard to people to get attic running.  Any idea why it happens?

Re: [attic] .git/index changing owner

From:
Jonas Borgström
Date:
2014-02-12 @ 20:17
On 2014-02-12 02:37, Dan Christensen wrote:
> Jonas Borgström <jonas@borgstrom.se> writes:
> 
>> I'm not sure what you're seeing but this is what I'm doing and it seems
>> to work well:
>>
>> (As a regular user)
>>
>> $ virtualenv -p python3.3 /somewhere/env
>> $ /somewhere/env/bin/pip install -e .
> 
> I did the above with python 3.2, and also installed msgpack_python,
> cython and llfuse into /somewhere/env.  Then I edited the attic startup
> script to read
> 
>   #!/somewhere/env/bin/python
>   from attic.archiver import main
>   main()
> 
> and put it in /somewhere/env/bin/attic.  Then when I run
> 
>   /somewhere/env/bin/attic -h
> 
> as root, the file .git/index still gets changed to have owner and group
> root.  (Again, not every time.)
> 
> I'm using Ubuntu's git 1:1.7.9.5-1, in case that matters.

That's weird. I've never seen that before. I'm using git 1.8.5.4.

> Dan
> 
> PS:  When I use pip to install attic, it creates a startup script
> that contains
> 
>   #!/somewhere/env/bin/python3.2
>   # EASY-INSTALL-DEV-SCRIPT: 'Attic==0.10-35-ga79acdd','attic'
>   __requires__ = 'Attic==0.10-35-ga79acdd'
>   from pkg_resources import require; require('Attic==0.10-35-ga79acdd')
>   del require
>   __file__ = '/path/to/attic/scripts/attic'
>   execfile(__file__)
> 
> but python3 doesn't have execfile, so this doesn't run.  This makes it
> hard to people to get attic running.  Any idea why it happens?

Not really. But it seems like "pip install -e" is broken on python 3.2.
On 3.3 the following code is generated (that also works for 3.2):

try:
    execfile(__file__)
except NameError:
    exec(compile(open(__file__).read(), __file__, 'exec'))

Fortunately a regular "pip install attic" seems to work so this should
not be such a big deal.

/ Jonas

Re: [attic] .git/index changing owner

From:
Dan Christensen
Date:
2014-02-13 @ 16:20
Jonas Borgström <jonas@borgstrom.se> writes:

> On 2014-02-12 02:37, Dan Christensen wrote:
> 
>> Then when I run
>> 
>>   /somewhere/env/bin/attic -h
>> 
>> as root, the file .git/index still gets changed to have owner and group
>> root.  (Again, not every time.)
>> 
>> I'm using Ubuntu's git 1:1.7.9.5-1, in case that matters.
>
> That's weird. I've never seen that before. I'm using git 1.8.5.4.

It's not that important, but I figured out the cause, so I thought I
should explain it here for those who google this thread.  I run unison
every seven minutes to synchronize my home directory between two
machines, and this doesn't synchronize the ctimes.  But .git/index
stores ctimes, so it gets updated when certain git commands are run.
One of the commands that updates the index is

  git describe --tags --dirty --always

which is run by versioneer (see the strace output below).

It would be nice if versioneer didn't need to run a command that might
update .git/index, but it's not a big deal.  I'll just do "pip install
." without the -e, and I suspect all will be fine.  Or maybe I'll just
exclude that file from being synchronized.

I've also described this in this answer at stackoverflow:

  http://stackoverflow.com/a/21759336/380225

Dan

Here's the relevant part of the strace output:

5216  open("versioneer.py", O_RDONLY)   = 3
5216  read(3, "\"\"\"versioneer.py\n\n(like a rocket"..., 25748) = 25748
5216  close(3)                          = 0
5216  readlink(".git/index", 0x7fffdaad8f10, 4096) = -1 EINVAL (Invalid argument)
5216  open(".git/index.lock", O_RDWR|O_CREAT|O_EXCL, 0666) = 3
... five rt_sigaction lines omitted ...
5216  write(3, 
"DIRC\0\0\0\2\0\0\0BR\356\370\3611\4a\304R\356\370\3611\4a\304\0\0\10\5"...,
5696) = 5696
5216  fstat(3, {st_mode=S_IFREG|0640, st_size=5696, ...}) = 0
5216  close(3)                          = 0
5216  rename(".git/index.lock", ".git/index") = 0