History log of /freebsd-10.1-release/usr.bin/xinstall/xinstall.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 272461 02-Oct-2014 gjb

Copy stable/10@r272459 to releng/10.1 as part of
the 10.1-RELEASE process.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

# 256281 10-Oct-2013 gjb

Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


# 246147 31-Jan-2013 brooks

When in -U mode do avoid setting SUID bits, but do not modify the mode
variable so the intended mode can be logged correctly if -M is specified.

Sponsored by: DARPA, AFRL


# 245793 22-Jan-2013 brooks

Make "install -l s[ar]" act like "ln -sfh" as intended. This fixes
installation of symbolic links where the target is a link is to an
existing directory.


# 245617 18-Jan-2013 brooks

Introduce six new options from NetBSD:
* -M <metalog> Log metadata in mtree format.
* -D <destdir> Log paths relative to <destdir>.
* -h <hash> Log digest of type <hash>.
* -T <tags> Specify which mtree tags to log.
* -l <linkflag> Create hard or symbolic links (allows logging).
* -U Install without root privileges (owner, group, mode,
and flags can be logged via -M

NOTE: In the interest of compatibility with NetBSD and because it is the
obvious letter, the nearly useless -M option (disable mmap) has been
repurposed.

Sponsored by: DARPA, AFRL
Obtained from: NetBSD
Reviewed by: bz


# 245312 11-Jan-2013 brooks

Implement the -N <dbdir> option which allows an alternate passwd and
group file to be used. This is useful for installing on systems where
a user or group does not currently exist.

Sponsored by: DARPA, AFRL
Obtained from: NetBSD
MFC after: 5 days


# 237988 02-Jul-2012 kib

Issue proper diagnostic on the short writes, also consider the
case of write reporting 0 bytes as short write.

Reported and tested by: adreast
MFC after: 1 week


# 227202 06-Nov-2011 ed

Add missing static keywords to xinstall(1)


# 218940 22-Feb-2011 uqs

Teach tools/install.sh the -d directory mode.

Sync up with flags understood by install(1) [1], and make install(1)'s
usage output not hide the clearly documented -M flag.

PR: misc/154739 [1]
Submitted by: arundel


# 218909 21-Feb-2011 brucec

Fix typos - remove duplicate "the".

PR: bin/154928
Submitted by: Eitan Adler <lists at eitanadler.com>
MFC after: 3 days


# 216370 11-Dec-2010 joel

Remove the advertising clause from UCB copyrighted files in usr.bin. This
is in accordance with the information provided at
ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change

Also add $FreeBSD$ to a few files to keep svn happy.

Discussed with: imp, rwatson


# 204111 20-Feb-2010 uqs

Fix common misspelling of hierarchy

Pointed out by: bf1783 at gmail
Approved by: np (cxgb), kientzle (tar, etc.), philip (mentor)


# 200515 14-Dec-2009 delphij

Style improvements:

- Sort function prototypes;
- Apply static on all function bodies. To quote bde@:

> It is a good obfuscation to declare functions as static only in the
> prototype, so that you can't see the static for the actual function.
> The reverse obfuscation (with static only in the function definition)
> would make more sense, but is a constraint error.

Reviewed by: bde


# 200466 13-Dec-2009 delphij

xinstall.c does not require ctype functions, so ctype.h is not
necessary here.

Note: this would change the md5 checksum due to change caused
by different register layout.


# 200465 13-Dec-2009 delphij

Staticify internal functions and make usage() a prototype.


# 200462 13-Dec-2009 delphij

Revert most part of 200420 as requested, as more review and polish is
needed.


# 200420 11-Dec-2009 delphij

Remove unneeded header includes from usr.bin/ except contributed code.

Tested with: make universe


# 174587 14-Dec-2007 edwin

Give a better description when a install of multiple files fails
because of the absence of a destination directory or if the
"destination directory" is not a directory.

PR: bin/11826
Submitted by: Denis Eremenko <moonshade@pnhz.kz>
Approved by: grog@
X-MFC after: various freezes


# 156363 06-Mar-2006 obrien

Add an override (DONTSTRIP) so that one can easily install debugable
binaries when one cannot easily edit a package's Makefiles and/or
configure scripts.


# 140817 25-Jan-2005 ssouhlal

- Make WARNS?= 6 clean
- Add WARNS?= 6

Approved by: stefanf, grehan (mentor)


# 127112 17-Mar-2004 ru

Improved incorrect usage diagnostics.


# 127110 17-Mar-2004 ru

GC unnecessary include file.


# 125553 07-Feb-2004 ru

- Demangle usage().
- Require the "directory" argument with the -d option.


# 117455 11-Jul-2003 phk

Since (x)install is pretty unhelpfull and just spits out a Usage
for a lot of unrelated error conditions, at least report the line
number where it bailed.

Don't use multiline string literals for Usage, gcc 3.3 doesn't like them.


# 107428 30-Nov-2002 fenner

If both the unlink and the open fail, return the errno from the
unlink (very likely EPERM), since the errno from the open might
be a confusing ETXTBSY.

Approved by: re
MFC After: 1 week


# 107413 30-Nov-2002 bde

#include <sys/time.h> instead of depending on namespace pollution in
<sys/stat.h> for the declaration of struct timeval.

Approved by: re (rwatson)


# 106967 15-Nov-2002 peter

A little bit of anti-foot-shooting. Use utimes(2) rather than
the deprecated utime(3). utimes(2) uses timeval, but utime(3) uses
time_t's. If you do bad things (like I did) by mixing up include files
with libc, then install can do strange things if you mismatch the time_t
stuff. utime() is emulated entirely within libc.

Approved by: re (jhb)


# 106246 31-Oct-2002 ru

Do not change the target file's inode-change-time if -C is
specified, the target file already exists and the files are
the same, and the target's file flags and mode need not to
be changed.


# 102944 04-Sep-2002 dwmalone

ANSIify function definitions.
Add some constness to avoid some warnings.
Remove use register keyword.
Deal with missing/unneeded extern/prototypes.
Some minor type changes/casts to avoid warnings.

Reviewed by: md5


# 100870 29-Jul-2002 ru

Ignore -C, -p, and -S options of install(1) when used with the -d
option. Warn about COPY being phased out. Restore the old method
of always comparing before installing: INSTALL="install -C".

Requested by: bde


# 97876 05-Jun-2002 ru

Start the (overdue) de-orbit sequence for the -d -C combo,
as was promised in revision 1.43.

MFC after: 1 month


# 96674 15-May-2002 fanf

Report errors properly if wait() fails.

PR: 30543
Approved by: dwmalone (mentor)
MFC after: 3 weeks


# 96439 12-May-2002 bde

Fixed 5 style bugs in VCS ids.


# 96437 12-May-2002 bde

Fixed printing the the strip binary's name in error messages.


# 96416 11-May-2002 marcel

Add support for stripping non-native object files by using an
environment variable that specifies the name of the strip(1)
program to use. The envvar is "STRIPBIN". The more natural
choice would be "STRIP", but that one is taken already.


# 94276 09-Apr-2002 ru

No longer needed to #ifdef __FBSDID, this is now handled by Makefile.inc1.


# 92922 21-Mar-2002 imp

remove __P


# 92611 18-Mar-2002 des

Bump the cutoff mark for comparing files from 8 MB to 16 MB.


# 88179 19-Dec-2001 imp

xinstall is part of the upgrade path for 4.4-RELEASE as well.
Do the usualy ifdef trick here.

Reported by: dworkin muller <addr-removed> and faried nawaz <fn@hungry.com>


# 87724 12-Dec-2001 ru

More "const" poisoning, and only use NO_WERROR if we're bootstrapping.


# 87685 11-Dec-2001 markm

WARNS=2, use __FBSDID(), set NO_WERROR, as there are "dirty" files used
during the bootstrap phase.


# 79452 09-Jul-2001 brian

Fix the type of the NULL arg to execl()

Idea from: Theo de Raadt <deraadt@openbsd.org>


# 77472 30-May-2001 ru

Backout rev. 1.42 (relaxing the check for -d plus other flags).

Instead, issue a warning for now if -d and -C options are used
together. This will be turned into an error before 4.5-RELEASE.

Reviewed by: imp


# 77412 29-May-2001 imp

Use use ${INSTALL} -d in our build process. If INSTALL is set to
"install -C" then things will fail due to new checks. Relax the
checks so that install -C -d works again.


# 77345 28-May-2001 ru

Many new features and optimization improvements:

o New flags: -b and -B (backup)
o New flag: -S (safe copy; aka "atomic" install)
o The -c flag is now the default.
o The -D flag was withdrawn.

Reviewed by: bde (up to some point)
Obtained from: OpenBSD but heavily modified
MFC after: 1 month


# 66813 08-Oct-2000 bde

Use the correct timestamp for the -C -p case when the comparison fails.
A garbage timestamp was used for at least installing /dev/null with -C -p
when the target doesn't already exist.


# 61749 17-Jun-2000 joe

Switch over to using the new fflagstostr and strtofflags library calls.


# 56692 27-Jan-2000 joe

Historically file flags (schg, uschg, etc) have been converted from
string to u_long and back using two functions, flags_to_string and
string_to_flags, which co-existed with 'ls'. As time has progressed
more and more other tools have used these private functions to
manipulate the file flags.

Recently I moved these functions from /usr/src/bin/ls to libutil,
but after some discussion with bde it's been decided that they
really ought to go in libc.

There are two already existing libc functions for manipulating file
modes: setmode and getmode. In keeping with these flags_to_string
has been renamed getflags and string_to_flags to setflags.

The manual page could probably be improved upon ;)


# 54191 06-Dec-1999 obrien

Add "-v" to usage().


# 51705 26-Sep-1999 billf

-Wall fixes.

Submitted by: nrahlstr


# 50477 27-Aug-1999 peter

$Id$ -> $FreeBSD$


# 41847 16-Dec-1998 imp

Free memory from setmode.

Obtained from: OpenBSD


# 40301 13-Oct-1998 des

Calls one or more of malloc(), warn(), err(), syslog(), execlp() or
execvp() in the child branch of a vfork(). Changed to use fork()
instead.

Some of these (mv, find, apply, xargs) might benefit greatly from
being rewritten to use vfork() properly.

PR: Loosely related to bin/8252
Approved by: jkh and bde


# 36586 02-Jun-1998 peter

Treat an EOPNOTSUPP from fchflags() as a non-fatal case. Only warn about
it if flags were explicitly specified on the command line. Do not warn
if we were merely trying to preserve flags or remove UF_NODUMP. NFS does
not support flags.

I'm not sure that this is ideal, but it should do for now. Installing
a plain file onto a NFS server must work, we used to silently ignore the
attempt. Doing a binary install looses the flags anyway since cpio
doens't preserve them with the cdrom/network images.
XXX make world should not use flags or chown/chgrp in the obj/tmp area.

This is based on a suggestion from Ken Merry <ken@plutotech.com>.


# 32652 20-Jan-1998 bde

Converted to Lite2 mount interface - don't use numeric filesystem
types. The NetBSD compatibility cruft was more correct for -current
than FreeBSD's own code. It just used NetBSD #defines instead of
string literals for the filesystem names. NetBSD's MOUNT_UFS is
"ffs", so using a literal "ufs" gives wrong results, but this is
unimportant, especially for bootstrapping.

Fixed style bugs in trymmap().

Fixed some disordered declarations.


# 32490 13-Jan-1998 alex

Change MAP_FAILED to type void *.
Typo fix.


# 32429 11-Jan-1998 peter

Add an option (-M) to install to disable use of mmap(2). This is kinda
handy at the moment with -current's mmap+unlink interactions.. The
problems seem worst when using INSTALL="install -C" in /etc/make.conf.
This could well come in handy in the future too.


# 32360 09-Jan-1998 jb

Allow install to build from FreeBSD source using NetBSD tools and
headers during the port of FreeBSD to a NetBSD supported architecture.
FreeBSD needs to be able to install itself from very early on.


# 30809 28-Oct-1997 ache

1) Create intermediate directories with 755, not 777
2) Exit with error diagnostic if file exists but not a directory (-d)
3) Do chmod independently of chown (-d)


# 30795 27-Oct-1997 ache

1) Ignore -C with -d, not fail (for $(INSTALL) macro from /etc/make.conf)
2) When uid/gid not specified, not try to set 0:0 owner, just do nothing.
It makes possible to use install -d by users without setting
their uid:gid each time.
3) Be more specific where install_dir fails


# 29379 14-Sep-1997 peter

When calling strip, temporarily close the file, call strip and then
reopen it after strip has finished. This makes it work when
/usr/bin/strip replaces the file rather than doing an in-place edit
(such as the binutils-2.8 strip, which is a variation of objcopy).
This is necessary if install(1) and strip(1) are going to cooperate
on an ELF system.


# 28827 27-Aug-1997 charnier

Uncomment sccsid string and enclose it inside #if 0/#endif.
Cosmetic in man page.


# 26083 24-May-1997 peter

Bootstrap aid from older releases.. 'make world' can't build xinstall
until the includes are installed, and it doesn't install the includes until
xinstall is built (the previous xinstall binary may not have -C). As a
bandaid, define MAP_FAILED ourselves if <sys/mman.h> didn't. Perhaps it
would be safer to simply disable mmap if all the prerequisites are not
there.


# 24360 29-Mar-1997 imp

compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.


# 23012 22-Feb-1997 peter

Revert $FreeBSD$ to $Id$


# 21786 16-Jan-1997 alex

Sweep through the tree fixing mmap() usage:

- Use MAP_FAILED instead of the constant -1 to indicate
failure (required by POSIX).
- Removed flag arguments of '0' (required by POSIX).
- Fixed code which expected an error return of 0.
- Fixed code which thought any address with the high bit set
was an error.
- Check for failure where no checks were present.

Discussed with: bde


# 21673 14-Jan-1997 jkh

Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.


# 18611 01-Oct-1996 imp

Sync usage line to man page, per style(9).

Pointed out by: Bruce Evans <bde@zeta.org.au>


# 18572 29-Sep-1996 imp

Submitted by: Bruce Evans

Remove -S for the install usage message
Make the install usage message < 80 columns wide
Place the dodir declaration in order.


# 18551 29-Sep-1996 imp

Implement -d in install. Update the man page to reflect this change.


# 18525 28-Sep-1996 imp

Use EX_* exit values, from NetBSD


# 18489 24-Sep-1996 bde

Changed 'd' to 'D' in getopt arg too.


# 18482 24-Sep-1996 imp

Per discussions in -current
- Change the debug flag from -d to -D to avoid conflict with other
install programs.
- Update man page to reflect this
- Update usage string
-d meaning creat directory is specifically not implemented by these changes.


# 18040 05-Sep-1996 peter

Be more careful with mmap. If it fails, fall back to a plain compare or
copy.

Dont leave stray INS@xxxx temp files around, especially when installing
something less than 8MB and the destination runs out of space, etc.

It still doesn't clean up the temp files on SEGV or other signals etc.


# 18039 05-Sep-1996 peter

accidently removed the "dont compare > 8MB files hack".
didn't rewind the files after the read()s in the non-mmap compare.


# 18038 05-Sep-1996 peter

Only attempt to mmap() files from a ufs or cd9660 fs for comparing or
installing. mmap'ing stuff over a nfs mount took out my machine during
a 'make world' last night while I was asleep. I started out with a list
of fs's to avoid, when I realised that I really didn't know which ones
were safe with mmap, so I went for the ones I knew and implemented a
fallback compare.


# 17546 12-Aug-1996 peter

Add a simple -v (verbose) option that allows you to see when -C actually
installs something. This is not 100% right, since it has a false hit
when install -C snaps hard links.

Also, run strip(1) from the $PATH, otherwise you need a special version
of install to install (say) elf binaries which have a different strip.
With JDP's elfkit, the layout of the path determines which binary format
you are generating.


# 16611 23-Jun-1996 bde

Made strip failures fatal. This fixes PR 1328.


# 15144 08-Apr-1996 joerg

Don't reference NULL pointers if owner and/or group are omitted.

Pointed out by: somebody on the mailing list who's name i forgot


# 15069 05-Apr-1996 julian

Submitted by: archie@tribe.com

allow the user to install using a Numeric GID or UID.
this brings it in to line with chgrp and chown, ans is required
by some people using FreeBSD in a product.


# 13965 08-Feb-1996 pst

Kludge-fix for a specific instance of bin/517.
The real fix requires changes to getpwent(3) and friends and getgrent(3)
and friends.

Submitted by: Tim Wilkinson


# 11356 09-Oct-1995 bde

Add options -C (same as -c except for preserving the modification
time of the target if the target file is the same as the source),
-d (debug), and -p (same as -C except for preserving the modification
time of the source if the target doesn't exists or is different from
the source.

Use library err() functions instead of our own and pass them better
exit codes.

Submitted by: wollman (and changed a lot by me)


# 10346 27-Aug-1995 dg

Backed out change in rev 1.2.


# 9911 04-Aug-1995 joerg

Make install not remove the target file if -s has been specified but
stripping failed (since the file has been a shell script, for
example).

Closes PR # bin/645: "install -c -s" can't inst...

Submitted by: hohmuth@inf.tu-dresden.de (Michael Hohmuth)


# 1591 27-May-1994 rgrimes

This commit was generated by cvs2svn to compensate for changes in r1590,
which included commits to RCS files with non-trunk default branches.


# 1590 27-May-1994 rgrimes

BSD 4.4 Lite Usr.bin Sources