ar failing on files with long UID. [root@hostname ~]# echo 123 > tst.txt [root@hostname ~]# chown napetrov tst.txt [root@hostname ~]# ls -anl tst.txt -rw-r--r-- 1 11299695 0 4 Dec 9 12:04 tst.txt [root@hostname ~]# ar -rc test.a tst.txt ar: fatal: Numeric user ID too large
The ar format only allows 6 decimal characters for the uid/gid, so there's no way to encode your uid. Using the -D option (deterministic mode) should avoid this issue, because it replaces the time, uid and gid fields with 0. Can you see how GNU ar (from the binutils port/pkg) handles this case?
GNU ar just store first 6 characters with no errors: [root@BSD ~]# echo 123 > tst.txt [root@BSD ~]# chown napetrov tst.txt [root@BSD ~]# ls -anl tst.txt -rw-r--r-- 1 11299695 0 4 Dec 10 14:15 tst.txt [root@BSD ~]# /usr/local/bin/ar -rc test.a tst.txt [root@BSD ~]# /usr/local/bin/ar -V GNU ar (GNU Binutils) 2.25 Copyright (C) 2014 Free Software Foundation, Inc. This program is free software; you may redistribute it under the terms of the GNU General Public License version 3 or (at your option) any later version. This program has absolutely no warranty. [root@BSD ~]# strings test.a !<arch> tst.txt/ 1418195726 1129960 100644 4 ` [root@BSD ~]# cat test.a | od -c 0000000 ! < a r c h > \n t s t . t x t / 0000020 1 4 1 8 1 9 5 7 0000040 2 6 1 1 2 9 9 6 0 0000060 1 0 0 6 4 4 4 0000100 ` \n 1 2 3 \n 0000110
Ed, I've verified this is still an issue on 11-CURRENT. Since you've been touching ar(1) lately, would you mind taking a look? root@nucleus:~ # cat tst.txt 123 root@nucleus:~ # chown 123456789:123456789 tst.txt root@nucleus:~ # ll total 5 -rw-r--r-- 1 123456789 123456789 4 Jul 8 09:07 tst.txt root@nucleus:~ # ar -rc tst.a tst.txt ar: fatal: Numeric user ID too large
(In reply to Glen Barber from comment #3) The ar format cannot store UIDs longer than 6 decimal digits. This needs to be addressed by using ar -D, which I see is set by default in ARFLAGS. I would like to enable deterministic mode directly in ar, but only after we add the -U flag to disable it. ELF Tool Chain's ar(1) is a cousin of the one in the FreeBSD tree, and I've submitted a ticket to track this there: https://sourceforge.net/p/elftoolchain/tickets/500/ The likely path forward is for -U to be added to ELF Tool Chain's ar first, and then migrate to it in a subsequent ELF Tool Chain update in FreeBSD. GNU ar's behaviour is a bug; storing the first 6 digits of a longer UID is bogus.
A commit references this bug: Author: emaste Date: Fri Jul 24 17:46:44 UTC 2015 New revision: 285844 URL: https://svnweb.freebsd.org/changeset/base/285844 Log: ar: add -U (unique) option to disable -D (deterministic) mode This is required in order for us to support deterministic mode by default. If multiple -D or -U options are specified on the command line, the final one takes precedence. GNU ar also uses -U for this. An equivalent change will be applied to ELF Tool Chain's version of ar. PR: 196929 MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D3175 Changes: head/usr.bin/ar/ar.1 head/usr.bin/ar/ar.c
Enabling -D mode by default is in review: https://reviews.freebsd.org/D3190
A commit references this bug: Author: emaste Date: Wed Jul 29 13:36:19 UTC 2015 New revision: 286010 URL: https://svnweb.freebsd.org/changeset/base/286010 Log: ar: enable deterministic mode by default Ar cannot handle UIDs with more than 6 digits, and storing the mtime, uid, gid and mode provides little to negative value anyhow for ar's uses. Turn on deterministic (-D) mode by default; it can be disabled by the user with -U. PR: 196929 Relnotes: Yes Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D3190 Changes: head/usr.bin/ar/ar.1 head/usr.bin/ar/ar.c
A commit references this bug: Author: emaste Date: Mon Aug 31 17:30:14 UTC 2015 New revision: 287326 URL: https://svnweb.freebsd.org/changeset/base/287326 Log: MFC r285844: ar: add -U (unique) option to disable -D (deterministic) mode This is required in order for us to support deterministic mode by default. If multiple -D or -U options are specified on the command line, the final one takes precedence. GNU ar also uses -U for this. PR: 196929 Sponsored by: The FreeBSD Foundation Changes: _U stable/10/ stable/10/usr.bin/ar/ar.1 stable/10/usr.bin/ar/ar.c
A commit references this bug: Author: emaste Date: Fri Sep 25 00:23:37 UTC 2015 New revision: 288202 URL: https://svnweb.freebsd.org/changeset/base/288202 Log: MFC r286010: ar: enable deterministic mode by default Ar cannot handle UIDs with more than 6 digits, and storing the mtime, uid, gid and mode provides little to negative value anyhow for ar's uses. Turn on deterministic (-D) mode by default; it can be disabled by the user with -U. Also MFC follow-on fixes in r286024 and r287324. PR: 196929 Relnotes: Yes Sponsored by: The FreeBSD Foundation Changes: _U stable/10/ stable/10/usr.bin/ar/ar.1 stable/10/usr.bin/ar/ar.c
Deterministic mode is now enabled by default in HEAD and stable/10.