History log of /openbsd-current/usr.bin/rdistd/server.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.49 26-Dec-2022 jmc

spelling fixes; from paul tagliamonte
amendments to his diff are noted on tech


Revision tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.48 28-Jan-2022 guenther

When it's the possessive of 'it', it's spelled "its", without the
apostrophe.


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.47 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.46 28-Jun-2019 deraadt

mkstemp() returns -1 on failure


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.45 21-Sep-2018 millert

Use password/group cache functions and avoid stashing a pointer to
the return value of getgrgid(3) or getgrnam(3) which relies on
undefined behavior. The rdist server will now use getgroups(2) to
determine group membership of the invoking user. In addition, there
is now one implementation of tilde expansion instead of two.
OK tb@ tim@


# 1.44 09-Sep-2018 millert

Fix a crash in rdistd triggered by the recent getpw{ent,nam,uid}
changes. This stems from rdist stashing a pointer to the static
area used by getpw{ent,nam,uid} and using it to avoid repeating
passwd lookups when pw->pw_name matches the user to be looked up.

This relied on undefined behavior, and with the recent passwd
changes, is no longer possible as the old pointer will be invalidated.
A better approach is to use the upcoming uid_from_user(3) functions.
Found by and fix OK tim@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.43 30-Aug-2017 otto

gid_t is unsigned, so < 0 test is always false, compare against (gid_t)-1
explicitly; ok millert@


Revision tags: OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.42 30-Mar-2016 millert

Avoid compiler warning about zero-length printf format strings.
Allow a NULL format in message() and switch the two calls to
error() and message() with an empty format string to using NULL.
OK deraadt@


# 1.41 30-Mar-2016 millert

The change to make mkstemp(3) require at least 6 trailing Xs broke
rdistd for directories that do not exist on the destination. Calling
mkstemp(3) twice with the same format (filled in by the first
mkstemp(3) call) is bogus so call chkparent() *before* mkstemp(3)
instead of only on error. This costs an extra lstat(2) in the case
where the directory already exists but simplifies the code and
doesn't rely on undefined behavior (namely, the state of the template
when mkstemp fails). OK tim@


Revision tags: OPENBSD_5_9_BASE
# 1.40 22-Dec-2015 mmcc

remove needless allocation casts


# 1.39 22-Dec-2015 mmcc

Remove a couple needless allocation casts. No binary change.


# 1.38 15-Nov-2015 guenther

Switch to linkat() to support hardlinked symlinks
Simplify chown logic by using fchownat()
Cache whether we're root instead of calling getuid() before each chown


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.37 21-Jan-2015 guenther

Assume NFS_CHECK and RO_CHECK are defined.
We only need the dev_t and not the entire struct stat in mntinfo.
Delete some superfluous casts.


# 1.36 21-Jan-2015 guenther

Reduce opt_t from long to int.
Debug message consistency: format opts with %#x and modes with %#04o


# 1.35 20-Jan-2015 guenther

Split out from rdist/defs.h the client-only and server-only bits into
rdist/client.h and rdistd/server.h
Only put #includes in .h files that are necessary for the .h to be used;
all other #includes go in the .c files
Move all extern variable declarations to the .h files, renaming local
variables to avoid shadowing
Replace me_type member of mntent_t with an "is NFS?" flag bit


# 1.34 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


Revision tags: OPENBSD_5_6_BASE
# 1.33 12-Jul-2014 guenther

Rename 'link' parameter to eliminate shadow warnings


# 1.32 12-Jul-2014 guenther

Yes, we have setproctitle(). Delete that and several unused HAVE_* #defines


# 1.31 05-Jul-2014 guenther

Assume POSIX: S_IFSOCK and S_IFIFO
Kill some 'notyet' code that will never be enabled


# 1.30 05-Jul-2014 guenther

Assume POSIX: lchown(), fchown(), fchmod(), fchmodat()
Assume we have rcmdsh()


# 1.29 05-Jul-2014 guenther

Assume POSIX: uid_t and gid_t
Add parens to quiet gcc on previous commit


# 1.28 05-Jul-2014 guenther

Assume POSIX: <dirent.h>, struct dirent


# 1.27 05-Jul-2014 guenther

Oops, fix both locations using D_NAMLEN()


# 1.26 05-Jul-2014 guenther

Stop using silly macro when checking for '.' and '..' directory entries


Revision tags: OPENBSD_5_5_BASE
# 1.25 27-Oct-2013 guenther

If a constant string needs a name, use a static const array instead of a
pointer or non-const array, as that minimizes the symbols, maximizes the
placement into read-only memory, and avoids warnings from gcc -Wformat=2
when they're used as format strings.

ok deraadt@


Revision tags: OPENBSD_5_4_BASE
# 1.24 16-Apr-2013 deraadt

remove casts to time_t * which are not needed


Revision tags: OPENBSD_5_3_BASE
# 1.23 12-Nov-2012 guenther

Fix various format string issues. Stop assuming time_t is long or smaller.
Enable warnings.

ok krw@, ian@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.22 10-Apr-2011 krw

Apply some tough type-love and give rdist a chance to handle files
larger than 2GB. Diff from Stephan R. Gerber via PR#6586, tweaks
by me.

ok deraadt@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.21 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


Revision tags: OPENBSD_4_6_BASE
# 1.20 28-Mar-2009 deraadt

pathnames with space, tab, newline, etc are encoded before being sent.
But they were not reliably being decoded, resulting in wrong naming
on the target machine. diff from Tim van der Molen


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.19 25-May-2008 millert

Fix breakage introduced in rev 1.8 wrt rdisting symlinks. Push the
mkstemp() down into recvfile() and use mktemp() for recvlink().
OK okan@


# 1.18 13-May-2008 ray

Change a mktemp(3) to mkstemp(3), preventing a race condition.
Improve error checking.

OK okan@


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.17 01-Feb-2006 otto

double semicolon; from Daniel Matic in PR 4929


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.16 07-Jul-2003 mpech

fix readlink() usage.

millert@ ok


# 1.15 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.14 14-May-2003 millert

o Sync w/ freerdist 0.92 minus the compress option
o KNF and ANSIfy the function headers

Sparse file support is currently a no-op since it didn't work.
Proper sparse file support will be added later.


# 1.13 19-Apr-2003 millert

strcpy/strcat/sprintf removal; krw@ OK


# 1.12 10-Apr-2003 millert

more POSIX chown


# 1.11 05-Apr-2003 deraadt

strings; ok miod ho krw


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.10 19-Nov-2001 mpech

kill more registers

millert@ ok


Revision tags: OPENBSD_3_0_BASE
# 1.9 19-Sep-2001 mpech

occured->occurred

idea from deraadt@ via NetBSD
millert@ ok

p.s. Next commit will fix a typo in the sys/


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.8 04-Feb-1999 millert

Fix a serious memory consumption problem when running over directories
that contain many hard-linked files; johnh@isi.edu
Also add an xstrdup() that behaves like xmalloc() on failure.


Revision tags: OPENBSD_2_4_BASE
# 1.7 26-Jun-1998 millert

rdist 6.1.4 + OpenBSD patches + some -Wall


# 1.6 18-May-1998 deraadt

readlink len-1


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE OPENBSD_2_2_BASE OPENBSD_2_3_BASE
# 1.5 25-Jul-1996 millert

Updated to rdist 6.1.3. Used real snprintf() (instead of string length
in the format) since we have it.


# 1.4 26-Jun-1996 deraadt

rcsid


# 1.3 25-Jun-1996 deraadt

open O_EXCL instead of creat; for writable rdist directories... still small DOS


# 1.2 05-Mar-1996 dm

rdist 6.1.2


# 1.1 03-Feb-1996 dm

rdist 6.1.1


# 1.48 28-Jan-2022 guenther

When it's the possessive of 'it', it's spelled "its", without the
apostrophe.


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.47 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.46 28-Jun-2019 deraadt

mkstemp() returns -1 on failure


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.45 21-Sep-2018 millert

Use password/group cache functions and avoid stashing a pointer to
the return value of getgrgid(3) or getgrnam(3) which relies on
undefined behavior. The rdist server will now use getgroups(2) to
determine group membership of the invoking user. In addition, there
is now one implementation of tilde expansion instead of two.
OK tb@ tim@


# 1.44 09-Sep-2018 millert

Fix a crash in rdistd triggered by the recent getpw{ent,nam,uid}
changes. This stems from rdist stashing a pointer to the static
area used by getpw{ent,nam,uid} and using it to avoid repeating
passwd lookups when pw->pw_name matches the user to be looked up.

This relied on undefined behavior, and with the recent passwd
changes, is no longer possible as the old pointer will be invalidated.
A better approach is to use the upcoming uid_from_user(3) functions.
Found by and fix OK tim@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.43 30-Aug-2017 otto

gid_t is unsigned, so < 0 test is always false, compare against (gid_t)-1
explicitly; ok millert@


Revision tags: OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.42 30-Mar-2016 millert

Avoid compiler warning about zero-length printf format strings.
Allow a NULL format in message() and switch the two calls to
error() and message() with an empty format string to using NULL.
OK deraadt@


# 1.41 30-Mar-2016 millert

The change to make mkstemp(3) require at least 6 trailing Xs broke
rdistd for directories that do not exist on the destination. Calling
mkstemp(3) twice with the same format (filled in by the first
mkstemp(3) call) is bogus so call chkparent() *before* mkstemp(3)
instead of only on error. This costs an extra lstat(2) in the case
where the directory already exists but simplifies the code and
doesn't rely on undefined behavior (namely, the state of the template
when mkstemp fails). OK tim@


Revision tags: OPENBSD_5_9_BASE
# 1.40 22-Dec-2015 mmcc

remove needless allocation casts


# 1.39 22-Dec-2015 mmcc

Remove a couple needless allocation casts. No binary change.


# 1.38 15-Nov-2015 guenther

Switch to linkat() to support hardlinked symlinks
Simplify chown logic by using fchownat()
Cache whether we're root instead of calling getuid() before each chown


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.37 21-Jan-2015 guenther

Assume NFS_CHECK and RO_CHECK are defined.
We only need the dev_t and not the entire struct stat in mntinfo.
Delete some superfluous casts.


# 1.36 21-Jan-2015 guenther

Reduce opt_t from long to int.
Debug message consistency: format opts with %#x and modes with %#04o


# 1.35 20-Jan-2015 guenther

Split out from rdist/defs.h the client-only and server-only bits into
rdist/client.h and rdistd/server.h
Only put #includes in .h files that are necessary for the .h to be used;
all other #includes go in the .c files
Move all extern variable declarations to the .h files, renaming local
variables to avoid shadowing
Replace me_type member of mntent_t with an "is NFS?" flag bit


# 1.34 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


Revision tags: OPENBSD_5_6_BASE
# 1.33 12-Jul-2014 guenther

Rename 'link' parameter to eliminate shadow warnings


# 1.32 12-Jul-2014 guenther

Yes, we have setproctitle(). Delete that and several unused HAVE_* #defines


# 1.31 05-Jul-2014 guenther

Assume POSIX: S_IFSOCK and S_IFIFO
Kill some 'notyet' code that will never be enabled


# 1.30 05-Jul-2014 guenther

Assume POSIX: lchown(), fchown(), fchmod(), fchmodat()
Assume we have rcmdsh()


# 1.29 05-Jul-2014 guenther

Assume POSIX: uid_t and gid_t
Add parens to quiet gcc on previous commit


# 1.28 05-Jul-2014 guenther

Assume POSIX: <dirent.h>, struct dirent


# 1.27 05-Jul-2014 guenther

Oops, fix both locations using D_NAMLEN()


# 1.26 05-Jul-2014 guenther

Stop using silly macro when checking for '.' and '..' directory entries


Revision tags: OPENBSD_5_5_BASE
# 1.25 27-Oct-2013 guenther

If a constant string needs a name, use a static const array instead of a
pointer or non-const array, as that minimizes the symbols, maximizes the
placement into read-only memory, and avoids warnings from gcc -Wformat=2
when they're used as format strings.

ok deraadt@


Revision tags: OPENBSD_5_4_BASE
# 1.24 16-Apr-2013 deraadt

remove casts to time_t * which are not needed


Revision tags: OPENBSD_5_3_BASE
# 1.23 12-Nov-2012 guenther

Fix various format string issues. Stop assuming time_t is long or smaller.
Enable warnings.

ok krw@, ian@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.22 10-Apr-2011 krw

Apply some tough type-love and give rdist a chance to handle files
larger than 2GB. Diff from Stephan R. Gerber via PR#6586, tweaks
by me.

ok deraadt@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.21 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


Revision tags: OPENBSD_4_6_BASE
# 1.20 28-Mar-2009 deraadt

pathnames with space, tab, newline, etc are encoded before being sent.
But they were not reliably being decoded, resulting in wrong naming
on the target machine. diff from Tim van der Molen


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.19 25-May-2008 millert

Fix breakage introduced in rev 1.8 wrt rdisting symlinks. Push the
mkstemp() down into recvfile() and use mktemp() for recvlink().
OK okan@


# 1.18 13-May-2008 ray

Change a mktemp(3) to mkstemp(3), preventing a race condition.
Improve error checking.

OK okan@


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.17 01-Feb-2006 otto

double semicolon; from Daniel Matic in PR 4929


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.16 07-Jul-2003 mpech

fix readlink() usage.

millert@ ok


# 1.15 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.14 14-May-2003 millert

o Sync w/ freerdist 0.92 minus the compress option
o KNF and ANSIfy the function headers

Sparse file support is currently a no-op since it didn't work.
Proper sparse file support will be added later.


# 1.13 19-Apr-2003 millert

strcpy/strcat/sprintf removal; krw@ OK


# 1.12 10-Apr-2003 millert

more POSIX chown


# 1.11 05-Apr-2003 deraadt

strings; ok miod ho krw


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.10 19-Nov-2001 mpech

kill more registers

millert@ ok


Revision tags: OPENBSD_3_0_BASE
# 1.9 19-Sep-2001 mpech

occured->occurred

idea from deraadt@ via NetBSD
millert@ ok

p.s. Next commit will fix a typo in the sys/


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.8 04-Feb-1999 millert

Fix a serious memory consumption problem when running over directories
that contain many hard-linked files; johnh@isi.edu
Also add an xstrdup() that behaves like xmalloc() on failure.


Revision tags: OPENBSD_2_4_BASE
# 1.7 26-Jun-1998 millert

rdist 6.1.4 + OpenBSD patches + some -Wall


# 1.6 18-May-1998 deraadt

readlink len-1


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE OPENBSD_2_2_BASE OPENBSD_2_3_BASE
# 1.5 25-Jul-1996 millert

Updated to rdist 6.1.3. Used real snprintf() (instead of string length
in the format) since we have it.


# 1.4 26-Jun-1996 deraadt

rcsid


# 1.3 25-Jun-1996 deraadt

open O_EXCL instead of creat; for writable rdist directories... still small DOS


# 1.2 05-Mar-1996 dm

rdist 6.1.2


# 1.1 03-Feb-1996 dm

rdist 6.1.1


# 1.47 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.46 28-Jun-2019 deraadt

mkstemp() returns -1 on failure


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.45 21-Sep-2018 millert

Use password/group cache functions and avoid stashing a pointer to
the return value of getgrgid(3) or getgrnam(3) which relies on
undefined behavior. The rdist server will now use getgroups(2) to
determine group membership of the invoking user. In addition, there
is now one implementation of tilde expansion instead of two.
OK tb@ tim@


# 1.44 09-Sep-2018 millert

Fix a crash in rdistd triggered by the recent getpw{ent,nam,uid}
changes. This stems from rdist stashing a pointer to the static
area used by getpw{ent,nam,uid} and using it to avoid repeating
passwd lookups when pw->pw_name matches the user to be looked up.

This relied on undefined behavior, and with the recent passwd
changes, is no longer possible as the old pointer will be invalidated.
A better approach is to use the upcoming uid_from_user(3) functions.
Found by and fix OK tim@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.43 30-Aug-2017 otto

gid_t is unsigned, so < 0 test is always false, compare against (gid_t)-1
explicitly; ok millert@


Revision tags: OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.42 30-Mar-2016 millert

Avoid compiler warning about zero-length printf format strings.
Allow a NULL format in message() and switch the two calls to
error() and message() with an empty format string to using NULL.
OK deraadt@


# 1.41 30-Mar-2016 millert

The change to make mkstemp(3) require at least 6 trailing Xs broke
rdistd for directories that do not exist on the destination. Calling
mkstemp(3) twice with the same format (filled in by the first
mkstemp(3) call) is bogus so call chkparent() *before* mkstemp(3)
instead of only on error. This costs an extra lstat(2) in the case
where the directory already exists but simplifies the code and
doesn't rely on undefined behavior (namely, the state of the template
when mkstemp fails). OK tim@


Revision tags: OPENBSD_5_9_BASE
# 1.40 22-Dec-2015 mmcc

remove needless allocation casts


# 1.39 22-Dec-2015 mmcc

Remove a couple needless allocation casts. No binary change.


# 1.38 15-Nov-2015 guenther

Switch to linkat() to support hardlinked symlinks
Simplify chown logic by using fchownat()
Cache whether we're root instead of calling getuid() before each chown


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.37 21-Jan-2015 guenther

Assume NFS_CHECK and RO_CHECK are defined.
We only need the dev_t and not the entire struct stat in mntinfo.
Delete some superfluous casts.


# 1.36 21-Jan-2015 guenther

Reduce opt_t from long to int.
Debug message consistency: format opts with %#x and modes with %#04o


# 1.35 20-Jan-2015 guenther

Split out from rdist/defs.h the client-only and server-only bits into
rdist/client.h and rdistd/server.h
Only put #includes in .h files that are necessary for the .h to be used;
all other #includes go in the .c files
Move all extern variable declarations to the .h files, renaming local
variables to avoid shadowing
Replace me_type member of mntent_t with an "is NFS?" flag bit


# 1.34 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


Revision tags: OPENBSD_5_6_BASE
# 1.33 12-Jul-2014 guenther

Rename 'link' parameter to eliminate shadow warnings


# 1.32 12-Jul-2014 guenther

Yes, we have setproctitle(). Delete that and several unused HAVE_* #defines


# 1.31 05-Jul-2014 guenther

Assume POSIX: S_IFSOCK and S_IFIFO
Kill some 'notyet' code that will never be enabled


# 1.30 05-Jul-2014 guenther

Assume POSIX: lchown(), fchown(), fchmod(), fchmodat()
Assume we have rcmdsh()


# 1.29 05-Jul-2014 guenther

Assume POSIX: uid_t and gid_t
Add parens to quiet gcc on previous commit


# 1.28 05-Jul-2014 guenther

Assume POSIX: <dirent.h>, struct dirent


# 1.27 05-Jul-2014 guenther

Oops, fix both locations using D_NAMLEN()


# 1.26 05-Jul-2014 guenther

Stop using silly macro when checking for '.' and '..' directory entries


Revision tags: OPENBSD_5_5_BASE
# 1.25 27-Oct-2013 guenther

If a constant string needs a name, use a static const array instead of a
pointer or non-const array, as that minimizes the symbols, maximizes the
placement into read-only memory, and avoids warnings from gcc -Wformat=2
when they're used as format strings.

ok deraadt@


Revision tags: OPENBSD_5_4_BASE
# 1.24 16-Apr-2013 deraadt

remove casts to time_t * which are not needed


Revision tags: OPENBSD_5_3_BASE
# 1.23 12-Nov-2012 guenther

Fix various format string issues. Stop assuming time_t is long or smaller.
Enable warnings.

ok krw@, ian@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.22 10-Apr-2011 krw

Apply some tough type-love and give rdist a chance to handle files
larger than 2GB. Diff from Stephan R. Gerber via PR#6586, tweaks
by me.

ok deraadt@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.21 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


Revision tags: OPENBSD_4_6_BASE
# 1.20 28-Mar-2009 deraadt

pathnames with space, tab, newline, etc are encoded before being sent.
But they were not reliably being decoded, resulting in wrong naming
on the target machine. diff from Tim van der Molen


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.19 25-May-2008 millert

Fix breakage introduced in rev 1.8 wrt rdisting symlinks. Push the
mkstemp() down into recvfile() and use mktemp() for recvlink().
OK okan@


# 1.18 13-May-2008 ray

Change a mktemp(3) to mkstemp(3), preventing a race condition.
Improve error checking.

OK okan@


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.17 01-Feb-2006 otto

double semicolon; from Daniel Matic in PR 4929


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.16 07-Jul-2003 mpech

fix readlink() usage.

millert@ ok


# 1.15 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.14 14-May-2003 millert

o Sync w/ freerdist 0.92 minus the compress option
o KNF and ANSIfy the function headers

Sparse file support is currently a no-op since it didn't work.
Proper sparse file support will be added later.


# 1.13 19-Apr-2003 millert

strcpy/strcat/sprintf removal; krw@ OK


# 1.12 10-Apr-2003 millert

more POSIX chown


# 1.11 05-Apr-2003 deraadt

strings; ok miod ho krw


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.10 19-Nov-2001 mpech

kill more registers

millert@ ok


Revision tags: OPENBSD_3_0_BASE
# 1.9 19-Sep-2001 mpech

occured->occurred

idea from deraadt@ via NetBSD
millert@ ok

p.s. Next commit will fix a typo in the sys/


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.8 04-Feb-1999 millert

Fix a serious memory consumption problem when running over directories
that contain many hard-linked files; johnh@isi.edu
Also add an xstrdup() that behaves like xmalloc() on failure.


Revision tags: OPENBSD_2_4_BASE
# 1.7 26-Jun-1998 millert

rdist 6.1.4 + OpenBSD patches + some -Wall


# 1.6 18-May-1998 deraadt

readlink len-1


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE OPENBSD_2_2_BASE OPENBSD_2_3_BASE
# 1.5 25-Jul-1996 millert

Updated to rdist 6.1.3. Used real snprintf() (instead of string length
in the format) since we have it.


# 1.4 26-Jun-1996 deraadt

rcsid


# 1.3 25-Jun-1996 deraadt

open O_EXCL instead of creat; for writable rdist directories... still small DOS


# 1.2 05-Mar-1996 dm

rdist 6.1.2


# 1.1 03-Feb-1996 dm

rdist 6.1.1


# 1.46 28-Jun-2019 deraadt

mkstemp() returns -1 on failure


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.45 21-Sep-2018 millert

Use password/group cache functions and avoid stashing a pointer to
the return value of getgrgid(3) or getgrnam(3) which relies on
undefined behavior. The rdist server will now use getgroups(2) to
determine group membership of the invoking user. In addition, there
is now one implementation of tilde expansion instead of two.
OK tb@ tim@


# 1.44 09-Sep-2018 millert

Fix a crash in rdistd triggered by the recent getpw{ent,nam,uid}
changes. This stems from rdist stashing a pointer to the static
area used by getpw{ent,nam,uid} and using it to avoid repeating
passwd lookups when pw->pw_name matches the user to be looked up.

This relied on undefined behavior, and with the recent passwd
changes, is no longer possible as the old pointer will be invalidated.
A better approach is to use the upcoming uid_from_user(3) functions.
Found by and fix OK tim@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.43 30-Aug-2017 otto

gid_t is unsigned, so < 0 test is always false, compare against (gid_t)-1
explicitly; ok millert@


Revision tags: OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.42 30-Mar-2016 millert

Avoid compiler warning about zero-length printf format strings.
Allow a NULL format in message() and switch the two calls to
error() and message() with an empty format string to using NULL.
OK deraadt@


# 1.41 30-Mar-2016 millert

The change to make mkstemp(3) require at least 6 trailing Xs broke
rdistd for directories that do not exist on the destination. Calling
mkstemp(3) twice with the same format (filled in by the first
mkstemp(3) call) is bogus so call chkparent() *before* mkstemp(3)
instead of only on error. This costs an extra lstat(2) in the case
where the directory already exists but simplifies the code and
doesn't rely on undefined behavior (namely, the state of the template
when mkstemp fails). OK tim@


Revision tags: OPENBSD_5_9_BASE
# 1.40 22-Dec-2015 mmcc

remove needless allocation casts


# 1.39 22-Dec-2015 mmcc

Remove a couple needless allocation casts. No binary change.


# 1.38 15-Nov-2015 guenther

Switch to linkat() to support hardlinked symlinks
Simplify chown logic by using fchownat()
Cache whether we're root instead of calling getuid() before each chown


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.37 21-Jan-2015 guenther

Assume NFS_CHECK and RO_CHECK are defined.
We only need the dev_t and not the entire struct stat in mntinfo.
Delete some superfluous casts.


# 1.36 21-Jan-2015 guenther

Reduce opt_t from long to int.
Debug message consistency: format opts with %#x and modes with %#04o


# 1.35 20-Jan-2015 guenther

Split out from rdist/defs.h the client-only and server-only bits into
rdist/client.h and rdistd/server.h
Only put #includes in .h files that are necessary for the .h to be used;
all other #includes go in the .c files
Move all extern variable declarations to the .h files, renaming local
variables to avoid shadowing
Replace me_type member of mntent_t with an "is NFS?" flag bit


# 1.34 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


Revision tags: OPENBSD_5_6_BASE
# 1.33 12-Jul-2014 guenther

Rename 'link' parameter to eliminate shadow warnings


# 1.32 12-Jul-2014 guenther

Yes, we have setproctitle(). Delete that and several unused HAVE_* #defines


# 1.31 05-Jul-2014 guenther

Assume POSIX: S_IFSOCK and S_IFIFO
Kill some 'notyet' code that will never be enabled


# 1.30 05-Jul-2014 guenther

Assume POSIX: lchown(), fchown(), fchmod(), fchmodat()
Assume we have rcmdsh()


# 1.29 05-Jul-2014 guenther

Assume POSIX: uid_t and gid_t
Add parens to quiet gcc on previous commit


# 1.28 05-Jul-2014 guenther

Assume POSIX: <dirent.h>, struct dirent


# 1.27 05-Jul-2014 guenther

Oops, fix both locations using D_NAMLEN()


# 1.26 05-Jul-2014 guenther

Stop using silly macro when checking for '.' and '..' directory entries


Revision tags: OPENBSD_5_5_BASE
# 1.25 27-Oct-2013 guenther

If a constant string needs a name, use a static const array instead of a
pointer or non-const array, as that minimizes the symbols, maximizes the
placement into read-only memory, and avoids warnings from gcc -Wformat=2
when they're used as format strings.

ok deraadt@


Revision tags: OPENBSD_5_4_BASE
# 1.24 16-Apr-2013 deraadt

remove casts to time_t * which are not needed


Revision tags: OPENBSD_5_3_BASE
# 1.23 12-Nov-2012 guenther

Fix various format string issues. Stop assuming time_t is long or smaller.
Enable warnings.

ok krw@, ian@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.22 10-Apr-2011 krw

Apply some tough type-love and give rdist a chance to handle files
larger than 2GB. Diff from Stephan R. Gerber via PR#6586, tweaks
by me.

ok deraadt@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.21 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


Revision tags: OPENBSD_4_6_BASE
# 1.20 28-Mar-2009 deraadt

pathnames with space, tab, newline, etc are encoded before being sent.
But they were not reliably being decoded, resulting in wrong naming
on the target machine. diff from Tim van der Molen


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.19 25-May-2008 millert

Fix breakage introduced in rev 1.8 wrt rdisting symlinks. Push the
mkstemp() down into recvfile() and use mktemp() for recvlink().
OK okan@


# 1.18 13-May-2008 ray

Change a mktemp(3) to mkstemp(3), preventing a race condition.
Improve error checking.

OK okan@


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.17 01-Feb-2006 otto

double semicolon; from Daniel Matic in PR 4929


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.16 07-Jul-2003 mpech

fix readlink() usage.

millert@ ok


# 1.15 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.14 14-May-2003 millert

o Sync w/ freerdist 0.92 minus the compress option
o KNF and ANSIfy the function headers

Sparse file support is currently a no-op since it didn't work.
Proper sparse file support will be added later.


# 1.13 19-Apr-2003 millert

strcpy/strcat/sprintf removal; krw@ OK


# 1.12 10-Apr-2003 millert

more POSIX chown


# 1.11 05-Apr-2003 deraadt

strings; ok miod ho krw


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.10 19-Nov-2001 mpech

kill more registers

millert@ ok


Revision tags: OPENBSD_3_0_BASE
# 1.9 19-Sep-2001 mpech

occured->occurred

idea from deraadt@ via NetBSD
millert@ ok

p.s. Next commit will fix a typo in the sys/


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.8 04-Feb-1999 millert

Fix a serious memory consumption problem when running over directories
that contain many hard-linked files; johnh@isi.edu
Also add an xstrdup() that behaves like xmalloc() on failure.


Revision tags: OPENBSD_2_4_BASE
# 1.7 26-Jun-1998 millert

rdist 6.1.4 + OpenBSD patches + some -Wall


# 1.6 18-May-1998 deraadt

readlink len-1


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE OPENBSD_2_2_BASE OPENBSD_2_3_BASE
# 1.5 25-Jul-1996 millert

Updated to rdist 6.1.3. Used real snprintf() (instead of string length
in the format) since we have it.


# 1.4 26-Jun-1996 deraadt

rcsid


# 1.3 25-Jun-1996 deraadt

open O_EXCL instead of creat; for writable rdist directories... still small DOS


# 1.2 05-Mar-1996 dm

rdist 6.1.2


# 1.1 03-Feb-1996 dm

rdist 6.1.1


# 1.45 21-Sep-2018 millert

Use password/group cache functions and avoid stashing a pointer to
the return value of getgrgid(3) or getgrnam(3) which relies on
undefined behavior. The rdist server will now use getgroups(2) to
determine group membership of the invoking user. In addition, there
is now one implementation of tilde expansion instead of two.
OK tb@ tim@


# 1.44 09-Sep-2018 millert

Fix a crash in rdistd triggered by the recent getpw{ent,nam,uid}
changes. This stems from rdist stashing a pointer to the static
area used by getpw{ent,nam,uid} and using it to avoid repeating
passwd lookups when pw->pw_name matches the user to be looked up.

This relied on undefined behavior, and with the recent passwd
changes, is no longer possible as the old pointer will be invalidated.
A better approach is to use the upcoming uid_from_user(3) functions.
Found by and fix OK tim@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.43 30-Aug-2017 otto

gid_t is unsigned, so < 0 test is always false, compare against (gid_t)-1
explicitly; ok millert@


Revision tags: OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.42 30-Mar-2016 millert

Avoid compiler warning about zero-length printf format strings.
Allow a NULL format in message() and switch the two calls to
error() and message() with an empty format string to using NULL.
OK deraadt@


# 1.41 30-Mar-2016 millert

The change to make mkstemp(3) require at least 6 trailing Xs broke
rdistd for directories that do not exist on the destination. Calling
mkstemp(3) twice with the same format (filled in by the first
mkstemp(3) call) is bogus so call chkparent() *before* mkstemp(3)
instead of only on error. This costs an extra lstat(2) in the case
where the directory already exists but simplifies the code and
doesn't rely on undefined behavior (namely, the state of the template
when mkstemp fails). OK tim@


Revision tags: OPENBSD_5_9_BASE
# 1.40 22-Dec-2015 mmcc

remove needless allocation casts


# 1.39 22-Dec-2015 mmcc

Remove a couple needless allocation casts. No binary change.


# 1.38 15-Nov-2015 guenther

Switch to linkat() to support hardlinked symlinks
Simplify chown logic by using fchownat()
Cache whether we're root instead of calling getuid() before each chown


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.37 21-Jan-2015 guenther

Assume NFS_CHECK and RO_CHECK are defined.
We only need the dev_t and not the entire struct stat in mntinfo.
Delete some superfluous casts.


# 1.36 21-Jan-2015 guenther

Reduce opt_t from long to int.
Debug message consistency: format opts with %#x and modes with %#04o


# 1.35 20-Jan-2015 guenther

Split out from rdist/defs.h the client-only and server-only bits into
rdist/client.h and rdistd/server.h
Only put #includes in .h files that are necessary for the .h to be used;
all other #includes go in the .c files
Move all extern variable declarations to the .h files, renaming local
variables to avoid shadowing
Replace me_type member of mntent_t with an "is NFS?" flag bit


# 1.34 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


Revision tags: OPENBSD_5_6_BASE
# 1.33 12-Jul-2014 guenther

Rename 'link' parameter to eliminate shadow warnings


# 1.32 12-Jul-2014 guenther

Yes, we have setproctitle(). Delete that and several unused HAVE_* #defines


# 1.31 05-Jul-2014 guenther

Assume POSIX: S_IFSOCK and S_IFIFO
Kill some 'notyet' code that will never be enabled


# 1.30 05-Jul-2014 guenther

Assume POSIX: lchown(), fchown(), fchmod(), fchmodat()
Assume we have rcmdsh()


# 1.29 05-Jul-2014 guenther

Assume POSIX: uid_t and gid_t
Add parens to quiet gcc on previous commit


# 1.28 05-Jul-2014 guenther

Assume POSIX: <dirent.h>, struct dirent


# 1.27 05-Jul-2014 guenther

Oops, fix both locations using D_NAMLEN()


# 1.26 05-Jul-2014 guenther

Stop using silly macro when checking for '.' and '..' directory entries


Revision tags: OPENBSD_5_5_BASE
# 1.25 27-Oct-2013 guenther

If a constant string needs a name, use a static const array instead of a
pointer or non-const array, as that minimizes the symbols, maximizes the
placement into read-only memory, and avoids warnings from gcc -Wformat=2
when they're used as format strings.

ok deraadt@


Revision tags: OPENBSD_5_4_BASE
# 1.24 16-Apr-2013 deraadt

remove casts to time_t * which are not needed


Revision tags: OPENBSD_5_3_BASE
# 1.23 12-Nov-2012 guenther

Fix various format string issues. Stop assuming time_t is long or smaller.
Enable warnings.

ok krw@, ian@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.22 10-Apr-2011 krw

Apply some tough type-love and give rdist a chance to handle files
larger than 2GB. Diff from Stephan R. Gerber via PR#6586, tweaks
by me.

ok deraadt@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.21 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


Revision tags: OPENBSD_4_6_BASE
# 1.20 28-Mar-2009 deraadt

pathnames with space, tab, newline, etc are encoded before being sent.
But they were not reliably being decoded, resulting in wrong naming
on the target machine. diff from Tim van der Molen


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.19 25-May-2008 millert

Fix breakage introduced in rev 1.8 wrt rdisting symlinks. Push the
mkstemp() down into recvfile() and use mktemp() for recvlink().
OK okan@


# 1.18 13-May-2008 ray

Change a mktemp(3) to mkstemp(3), preventing a race condition.
Improve error checking.

OK okan@


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.17 01-Feb-2006 otto

double semicolon; from Daniel Matic in PR 4929


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.16 07-Jul-2003 mpech

fix readlink() usage.

millert@ ok


# 1.15 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.14 14-May-2003 millert

o Sync w/ freerdist 0.92 minus the compress option
o KNF and ANSIfy the function headers

Sparse file support is currently a no-op since it didn't work.
Proper sparse file support will be added later.


# 1.13 19-Apr-2003 millert

strcpy/strcat/sprintf removal; krw@ OK


# 1.12 10-Apr-2003 millert

more POSIX chown


# 1.11 05-Apr-2003 deraadt

strings; ok miod ho krw


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.10 19-Nov-2001 mpech

kill more registers

millert@ ok


Revision tags: OPENBSD_3_0_BASE
# 1.9 19-Sep-2001 mpech

occured->occurred

idea from deraadt@ via NetBSD
millert@ ok

p.s. Next commit will fix a typo in the sys/


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.8 04-Feb-1999 millert

Fix a serious memory consumption problem when running over directories
that contain many hard-linked files; johnh@isi.edu
Also add an xstrdup() that behaves like xmalloc() on failure.


Revision tags: OPENBSD_2_4_BASE
# 1.7 26-Jun-1998 millert

rdist 6.1.4 + OpenBSD patches + some -Wall


# 1.6 18-May-1998 deraadt

readlink len-1


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE OPENBSD_2_2_BASE OPENBSD_2_3_BASE
# 1.5 25-Jul-1996 millert

Updated to rdist 6.1.3. Used real snprintf() (instead of string length
in the format) since we have it.


# 1.4 26-Jun-1996 deraadt

rcsid


# 1.3 25-Jun-1996 deraadt

open O_EXCL instead of creat; for writable rdist directories... still small DOS


# 1.2 05-Mar-1996 dm

rdist 6.1.2


# 1.1 03-Feb-1996 dm

rdist 6.1.1


Revision tags: OPENBSD_6_2_BASE
# 1.43 30-Aug-2017 otto

gid_t is unsigned, so < 0 test is always false, compare against (gid_t)-1
explicitly; ok millert@


Revision tags: OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.42 30-Mar-2016 millert

Avoid compiler warning about zero-length printf format strings.
Allow a NULL format in message() and switch the two calls to
error() and message() with an empty format string to using NULL.
OK deraadt@


# 1.41 30-Mar-2016 millert

The change to make mkstemp(3) require at least 6 trailing Xs broke
rdistd for directories that do not exist on the destination. Calling
mkstemp(3) twice with the same format (filled in by the first
mkstemp(3) call) is bogus so call chkparent() *before* mkstemp(3)
instead of only on error. This costs an extra lstat(2) in the case
where the directory already exists but simplifies the code and
doesn't rely on undefined behavior (namely, the state of the template
when mkstemp fails). OK tim@


Revision tags: OPENBSD_5_9_BASE
# 1.40 22-Dec-2015 mmcc

remove needless allocation casts


# 1.39 22-Dec-2015 mmcc

Remove a couple needless allocation casts. No binary change.


# 1.38 15-Nov-2015 guenther

Switch to linkat() to support hardlinked symlinks
Simplify chown logic by using fchownat()
Cache whether we're root instead of calling getuid() before each chown


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.37 21-Jan-2015 guenther

Assume NFS_CHECK and RO_CHECK are defined.
We only need the dev_t and not the entire struct stat in mntinfo.
Delete some superfluous casts.


# 1.36 21-Jan-2015 guenther

Reduce opt_t from long to int.
Debug message consistency: format opts with %#x and modes with %#04o


# 1.35 20-Jan-2015 guenther

Split out from rdist/defs.h the client-only and server-only bits into
rdist/client.h and rdistd/server.h
Only put #includes in .h files that are necessary for the .h to be used;
all other #includes go in the .c files
Move all extern variable declarations to the .h files, renaming local
variables to avoid shadowing
Replace me_type member of mntent_t with an "is NFS?" flag bit


# 1.34 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


Revision tags: OPENBSD_5_6_BASE
# 1.33 12-Jul-2014 guenther

Rename 'link' parameter to eliminate shadow warnings


# 1.32 12-Jul-2014 guenther

Yes, we have setproctitle(). Delete that and several unused HAVE_* #defines


# 1.31 05-Jul-2014 guenther

Assume POSIX: S_IFSOCK and S_IFIFO
Kill some 'notyet' code that will never be enabled


# 1.30 05-Jul-2014 guenther

Assume POSIX: lchown(), fchown(), fchmod(), fchmodat()
Assume we have rcmdsh()


# 1.29 05-Jul-2014 guenther

Assume POSIX: uid_t and gid_t
Add parens to quiet gcc on previous commit


# 1.28 05-Jul-2014 guenther

Assume POSIX: <dirent.h>, struct dirent


# 1.27 05-Jul-2014 guenther

Oops, fix both locations using D_NAMLEN()


# 1.26 05-Jul-2014 guenther

Stop using silly macro when checking for '.' and '..' directory entries


Revision tags: OPENBSD_5_5_BASE
# 1.25 27-Oct-2013 guenther

If a constant string needs a name, use a static const array instead of a
pointer or non-const array, as that minimizes the symbols, maximizes the
placement into read-only memory, and avoids warnings from gcc -Wformat=2
when they're used as format strings.

ok deraadt@


Revision tags: OPENBSD_5_4_BASE
# 1.24 16-Apr-2013 deraadt

remove casts to time_t * which are not needed


Revision tags: OPENBSD_5_3_BASE
# 1.23 12-Nov-2012 guenther

Fix various format string issues. Stop assuming time_t is long or smaller.
Enable warnings.

ok krw@, ian@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.22 10-Apr-2011 krw

Apply some tough type-love and give rdist a chance to handle files
larger than 2GB. Diff from Stephan R. Gerber via PR#6586, tweaks
by me.

ok deraadt@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.21 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


Revision tags: OPENBSD_4_6_BASE
# 1.20 28-Mar-2009 deraadt

pathnames with space, tab, newline, etc are encoded before being sent.
But they were not reliably being decoded, resulting in wrong naming
on the target machine. diff from Tim van der Molen


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.19 25-May-2008 millert

Fix breakage introduced in rev 1.8 wrt rdisting symlinks. Push the
mkstemp() down into recvfile() and use mktemp() for recvlink().
OK okan@


# 1.18 13-May-2008 ray

Change a mktemp(3) to mkstemp(3), preventing a race condition.
Improve error checking.

OK okan@


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.17 01-Feb-2006 otto

double semicolon; from Daniel Matic in PR 4929


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.16 07-Jul-2003 mpech

fix readlink() usage.

millert@ ok


# 1.15 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.14 14-May-2003 millert

o Sync w/ freerdist 0.92 minus the compress option
o KNF and ANSIfy the function headers

Sparse file support is currently a no-op since it didn't work.
Proper sparse file support will be added later.


# 1.13 19-Apr-2003 millert

strcpy/strcat/sprintf removal; krw@ OK


# 1.12 10-Apr-2003 millert

more POSIX chown


# 1.11 05-Apr-2003 deraadt

strings; ok miod ho krw


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.10 19-Nov-2001 mpech

kill more registers

millert@ ok


Revision tags: OPENBSD_3_0_BASE
# 1.9 19-Sep-2001 mpech

occured->occurred

idea from deraadt@ via NetBSD
millert@ ok

p.s. Next commit will fix a typo in the sys/


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.8 04-Feb-1999 millert

Fix a serious memory consumption problem when running over directories
that contain many hard-linked files; johnh@isi.edu
Also add an xstrdup() that behaves like xmalloc() on failure.


Revision tags: OPENBSD_2_4_BASE
# 1.7 26-Jun-1998 millert

rdist 6.1.4 + OpenBSD patches + some -Wall


# 1.6 18-May-1998 deraadt

readlink len-1


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE OPENBSD_2_2_BASE OPENBSD_2_3_BASE
# 1.5 25-Jul-1996 millert

Updated to rdist 6.1.3. Used real snprintf() (instead of string length
in the format) since we have it.


# 1.4 26-Jun-1996 deraadt

rcsid


# 1.3 25-Jun-1996 deraadt

open O_EXCL instead of creat; for writable rdist directories... still small DOS


# 1.2 05-Mar-1996 dm

rdist 6.1.2


# 1.1 03-Feb-1996 dm

rdist 6.1.1