Bug 210330 - "ar -s" not deterministic by default
Summary: "ar -s" not deterministic by default
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Ed Maste
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-06-16 17:42 UTC by Ed Maste
Modified: 2016-07-25 14:37 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Maste freebsd_committer freebsd_triage 2016-06-16 17:42:01 UTC
ar(1) produces deterministic output by default for the -q/-r options (append/replace), as described in the -D option:

     -D      When used in combination with the -r or -q option, insert 0's
             instead of the real mtime, uid and gid values and 0644 instead of
             file mode from the members named by arguments file ....  This
             ensures that checksums on the resulting archives are reproducible
             when member contents are identical.  This option is enabled by
             default.  If multiple -D and -U options are specified on the com‐
             mand line, the final one takes precedence.

It is not documented here, but this is also the case when ar is invoked as ranlib(1).

However, 'ar -s <file>' is supposed to be equivalent to ranlib:

     -s      Add an archive symbol table (see ar(5)) to the archive specified
             by argument archive.  Invoking ar with the -s option alone is
             equivalent to invoking ranlib.

but ar -s does not produce deterministic output by default.

In addition to -q/-r, ar -s (AR_S in ar.c) will write an archive symbol table if no mode is specified (-s with no other args), or in combination with -p/-t/-x (which are really read-options).
Comment 1 commit-hook freebsd_committer freebsd_triage 2016-06-16 21:22:46 UTC
A commit references this bug:

Author: emaste
Date: Thu Jun 16 21:22:27 UTC 2016
New revision: 301974
URL: https://svnweb.freebsd.org/changeset/base/301974

Log:
  ar: enable reproducible output by default when invoked as 'ar -s'

  ar output is already deterministic by default for ar -q and ar -r, and
  when invoked as ranlib. Make ar -s equivalent to ranlib and enable
  deterministic output by default in that case too.

  PR:		210330
  Reviewed by:	bdrewery
  Approved by:	re (gjb)
  MFC after:	1 week
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D6871

Changes:
  head/usr.bin/ar/ar.1
  head/usr.bin/ar/ar.c
Comment 2 commit-hook freebsd_committer freebsd_triage 2016-07-25 14:36:06 UTC
A commit references this bug:

Author: emaste
Date: Mon Jul 25 14:35:14 UTC 2016
New revision: 303295
URL: https://svnweb.freebsd.org/changeset/base/303295

Log:
  MFC r301974: ar: enable reproducible output by default when invoked as 'ar -s'

  ar output is already deterministic by default for ar -q and ar -r, and
  when invoked as ranlib. Make ar -s equivalent to ranlib and enable
  deterministic output by default in that case too.

  PR:		210330
  Sponsored by:	The FreeBSD Foundation

Changes:
_U  stable/10/
  stable/10/usr.bin/ar/ar.1
  stable/10/usr.bin/ar/ar.c