git/list[1] front-page[2] threads[3] people[4] search[5] about
 

RE: git archive setting user and group

From
Jason Pyeron <jpyeron@pdinc.us>
Date
Jan 22, 2021, 22:51 UTC
Message-ID
<078701d6f111$14d304c0$3e790e40$@pdinc.us>
In-Reply-To
<xmqqsg6s61x2.fsf@gitster.c.googlers.com>
Show 21 quoted lines
> From: Junio C Hamano
> Sent: Friday, January 22, 2021 5:29 PM
> 
> René Scharfe <l.s.r@web.de> writes:
> 
> > Am 22.01.21 um 21:40 schrieb Jason Pyeron:
> > ...
> >>         xsnprintf(header->uid, sizeof(header->uid), "%07o", 0);
> >>         xsnprintf(header->gid, sizeof(header->gid), "%07o", 0);
> >>         strlcpy(header->uname, "root", sizeof(header->uname));
> >>         strlcpy(header->gname, "root", sizeof(header->gname));
> >
> > Adding support for using a custom user and group should be easy.  Is
> > this just a cosmetic thing?  Regular users would ignore the user info in
> > the archive, and root should not be used for extracting, and on systems
> > that don't have a logwatch user this wouldn't make a difference anyway,
> > right?
> 
> I am not particularly interested in cosmetics, but it probably is OK
> to make uname/gname overridable.  I do not see any point in uid/gid
> numeric values overridable, though.  Just like user names and group
Interesting. So logwatch(0) vs logwatch(1100) ? I guess it is as good as any value, but tar never uses 0.
On a system without the logwatch user/group tar behaves as follows:
$ tar czf /tmp/logwatch.tgz --owner=logwatch --group=logwatch .

$ tar tvzf /tmp/logwatch.tgz | head -n 1 drwxrwxr-x logwatch/logwatch 0 2020-03-14 15:01 ./

$ tar tvzf /tmp/logwatch.tgz --numeric-owner | head -n 1 drwxrwxr-x 1049681/1049088 0 2020-03-14 15:01 ./

$ id uid=1049681(myuser) gid=1049088(mygroup) groups=no one cares...

but when the user / group is known...
$ tar czf /tmp/logwatch.tgz --owner=Guest --group=Users .

$ tar tvzf /tmp/logwatch.tgz | head -n 1 drwxrwxr-x Guest/Users 0 2020-03-14 15:01 ./

$ tar tvzf /tmp/logwatch.tgz --numeric-owner | head -n 1 drwxrwxr-x 1049077/545 0 2020-03-14 15:01 ./

$ getent passwd Guest | cut -f 3 -d : 1049077

$ getent group Users | cut -f 3 -d : 545

> names do not name the same user and group on every machine, uid/gid
> are even less so.
> 
> 
Previous: Junio C Hamano
Message 12 of 12 in “RE: git archive setting user and group”
  1. Jason PyeronJan 22, 2021
  2. René ScharfeJan 22, 2021
  3. Jason PyeronJan 22, 2021
  4. Konstantin RyabitsevJan 22, 2021
  5. Jason PyeronJan 22, 2021
  6. Ævar Arnfjörð BjarmasonJan 22, 2021
  7. brian m. carlsonJan 23, 2021
  8. Jeff KingJan 23, 2021
  9. Konstantin RyabitsevJan 23, 2021
  10. Konstantin RyabitsevJan 23, 2021
  11. Junio C HamanoJan 22, 2021
  12. Jason PyeronJan 22, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.