Commit Graph

137 Commits

Author SHA1 Message Date
Eitan Adler
dae3a64fb9 userland: Fix several typos and minor errors
- duplicate words
- typos
- references to old versions of FreeBSD

Reviewed by:	imp, benno
2017-12-27 03:23:01 +00:00
Pedro F. Giffuni
1de7b4b805 various: general adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.
2017-11-27 15:37:16 +00:00
Pedro F. Giffuni
df57947f08 spdx: initial adoption of licensing ID tags.
The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.

Initially, only tag files that use BSD 4-Clause "Original" license.

RelNotes:	yes
Differential Revision:	https://reviews.freebsd.org/D13133
2017-11-18 14:26:50 +00:00
Bryan Drewery
ea825d0274 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:07:04 +00:00
Xin LI
8a3cd533f1 Reduce code duplication in rpc.lockd.
Reuse create_service code instead of duplicating it in
lookup_addresses for kernel NLM.

As a (good) side effect this also fixed a few issues that were
already fixed in the former but never applied to the latter.

Reviewed by:	kevlo
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D11259
2017-06-21 06:34:06 +00:00
Bryan Drewery
c99b67a794 Utilize SYSROOT from r320119 in places where DESTDIR may be wanting WORLDTMP.
Since buildenv exports SYSROOT all of these uses will now look in
WORLDTMP by default.

sys/boot/efi/loader/Makefile
        A LIBSTAND hack is no longer required for buildenv.

MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2017-06-19 20:47:24 +00:00
Xin LI
df9abd97ac Check return value of seteuid() and bail out if we fail.
MFC after:	2 weeks
2017-06-19 07:02:52 +00:00
Xin LI
d5c2c66dba Fix buffer lengths.
After r319369, the RPC code validates caller supplied buffer length in
taddr2uaddr.  When no -h is specified, the sizeof(ai_addr) is used,
which is always smaller than the required size and therefore uaddr
would be NULL, causing the kernel to copyin() from userland NULL
and fail with EFAULT.

Reviewed by:	kevlo (via Telegram)
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D11151
2017-06-12 09:11:31 +00:00
Enji Cooper
f826cc0107 Use .ALLSRC instead of RPCSRC
This is a trivial simplification in the Makefile, meant to serve as
a good example for what to do with rules like this.

MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2017-03-01 04:12:24 +00:00
Enji Cooper
47c5f8f2fe Add missing break in lock_partialfilelock(..) with NFS_RESERR
This will help ensure that the right error is trickled up when the
function is called if the lock status is NFS_RESERR

Differential Revision: https://reviews.freebsd.org/D6622
Reviewed by: rmacklem
Approved by: re (gjb)
Tested with: fsx; svn info/svnversion (uses bdb locking); locktests from Bull http://nfsv4.bullopensource.org/tools/tests/locktest.php
MFC after: 2 weeks
Reported by: Coverity
CID: 1008161, 1304956
Sponsored by: EMC / Isilon Storage Division
2016-06-13 11:19:06 +00:00
Don Lewis
b6ecea3082 Actually use the loop interation limit so carefully computed on the
previous line to prevent buffer overflow.  This turns out to not be
important because the upstream xdr code already capped the object
size at the proper value.  Using the correct limit here looks a lot
less scary and should please Coverity.

Reported by:	Coverity
CID:		1199309, 1199310
MFC after:	1 week
2016-05-16 23:00:48 +00:00
Don Lewis
cec77ff4bf NULL releasedfl after calling deallocate_file_lock() which frees it
to avoid a use-after-free error in the debuglog() call at the top
of the loop.

Reported by:	Coverity
CID:		1006080
MFC after:	1 week
2016-05-16 05:17:43 +00:00
Bryan Drewery
bd18fd57db DIRDEPS_BUILD: Regenerate without local dependencies.
These are no longer needed after the recent 'beforebuild: depend' changes
and hooking DIRDEPS_BUILD into a subset of FAST_DEPEND which supports
skipping 'make depend'.

Sponsored by:	EMC / Isilon Storage Division
2016-02-24 17:20:11 +00:00
Ulrich Spörlein
c9e1c304c1 Fix type mismatches for malloc(3) and Co.
This is rather pedantic, as for most architectures it holds that
sizeof(type *) == sizeof(type **)

Found by:	clang static analyzer
Reviewed by:	ed
Differential Revision: https://reviews.freebsd.org/D4722
2015-12-29 11:24:41 +00:00
Simon J. Gerraty
ccfb965433 Add META_MODE support.
Off by default, build behaves normally.
WITH_META_MODE we get auto objdir creation, the ability to
start build from anywhere in the tree.

Still need to add real targets under targets/ to build packages.

Differential Revision:       D2796
Reviewed by: brooks imp
2015-06-13 19:20:56 +00:00
Simon J. Gerraty
44d314f704 dirdeps.mk now sets DEP_RELDIR 2015-06-08 23:35:17 +00:00
Simon J. Gerraty
98e0ffaefb Merge sync of head 2015-05-27 01:19:58 +00:00
Baptiste Daroussin
1e486a7e52 rpc.locked does not need to link to libutil 2015-04-09 21:48:17 +00:00
Ryan Stone
9745de4c2c When mountd is creating sockets, it iterates over all addresses specified
in the "hosts" array and eventually looks up the network address with
getaddrinfo(). At one point it checks for a numeric address and if it
sees one, it sets a hint parameter to force getaddrinfo to interpret the
host as a numeric address. However that hint is not cleared for subsequent
iterations of the loop and if any hosts seen after this point are host names,
getaddrinfo will fail on the name.  The result of this bug is that you cannot
pass a host name to the -h flag.

Unfortunately, the first iteration will either process ::1 or 127.0.0.1,
so the flag is set on the first iteration and all host names will fail
to be processed.

The same bug applies to rpc.lockd and rpc.statd, so fix them too.

Differential Revision:	https://reviews.freebsd.org/D1507
Reported by:	Dylan Martin
MFC after:	1 week
Sponsored by:	Sandvine Inc.
2015-01-19 00:33:32 +00:00
Baptiste Daroussin
c6db8143ed Convert usr.sbin to LIBADD
Reduce overlinking
2014-11-25 16:57:27 +00:00
Simon J. Gerraty
fae50821ae Updated dependencies 2014-05-16 14:09:51 +00:00
Simon J. Gerraty
76b28ad6ab Updated dependencies 2014-05-10 05:16:28 +00:00
Simon J. Gerraty
3b8f084595 Merge head 2014-04-28 07:50:45 +00:00
Eitan Adler
dda5b39711 multiple: Remove 3rd clause from BSD license where approved by the
regents and renumber.

This patch skips files in contrib/ and crypto/

Acked by:	imp
Discussed with:	emaste
2014-03-14 03:07:51 +00:00
Xin LI
146ff0f40f Make a copy instead using constant string directly when assigning to char *.
While I'm there also remove a few prototypes that are unused.
2014-01-04 01:12:28 +00:00
Xin LI
29df5733c2 Use prototype. 2014-01-04 01:08:10 +00:00
Simon J. Gerraty
7cf3a1c6b2 Updated dependencies 2013-03-11 17:21:52 +00:00
Simon J. Gerraty
f5f7c05209 Updated dependencies 2013-02-16 01:23:54 +00:00
Simon J. Gerraty
23090366f7 Sync from head 2012-11-04 02:52:03 +00:00
Kevin Lo
061c816530 Remove dead return code 2012-09-11 07:35:24 +00:00
Marcel Moolenaar
7750ad47a9 Sync FreeBSD's bmake branch with Juniper's internal bmake branch.
Requested by: Simon Gerraty <sjg@juniper.net>
2012-08-22 19:25:57 +00:00
Xin LI
64c06aeb8d Fix build:
- Use %ll instead of %q for explicit long long casts;
 - Use %j instead of %q in XFS and cast to intmax_t.

Tested with:	make universe
2012-05-23 06:49:50 +00:00
Dimitry Andric
5e0a19bdee Consistently set RPCGEN_CPP when running rpcgen, so the C preprocessor
set via ${CPP} is used, instead of always using hardcoded /usr/bin/cpp.

MFC after:	1 week
2012-02-07 09:27:07 +00:00
Ulrich Spörlein
3df5ecac8c Spelling fixes for usr.sbin/ 2011-12-30 10:58:14 +00:00
Rick Macklem
795b2dc06a Fix the nfs related daemons so that they don't intermittently
fail with "bind: address already in use". This problem was reported
to the freebsd-stable@ mailing list on Feb. 19 under the subject
heading "statd/lockd startup failure" by george+freebsd at m5p dot com.
The problem is that the first combination of {udp,tcp X ipv4,ipv6}
would select a port# dynamically, but one of the other three combinations
would have that port# already in use. The patch is somewhat involved
because it was requested by dougb@ that the four combinations use the
same port# wherever possible. The patch splits the create_service()
function into two functions. The first goes as far as bind(2) in a
loop for up to GETPORT_MAXTRY - 1 times, attempting to use the same port#
for all four cases. If these attempts fail, the last attempt allows
the 4 cases to use different port #s. After this function has succeeded,
the second function, called complete_service(), does the rest of what
create_service() did.
The three daemons mountd, rpc.lockd and rpc.statd all have a
create_service() function that is patched in a similar way. However,
create_service() has non-trivial differences for the three daemons
that made it impractical to share the same functions between them.

Reviewed by:	jhb
MFC after:	2 weeks
2011-06-02 19:49:47 +00:00
Ulrich Spörlein
091c4c86d1 rpc.lockd(8) WARNS cleanup
- Provide function prototype for nlm_syscall
- Don't assign a variable from the stack to a global var[1]
- Remove unused vars

Found by:	clang static analyser [1]
Reviewed by:	dfr
2010-12-20 21:12:18 +00:00
Rick Macklem
a37175df1d Fix the include path for nfs_lock.h.
MFC after:	2 weeks
2010-07-24 22:16:14 +00:00
Ed Schouten
71ccf09269 The last big commit: let usr.sbin/ use WARNS=6 by default. 2010-01-02 11:07:44 +00:00
Doug Rabson
0775314b63 Don't use sys/nfs/rpcv2.h - it is part of the old kernel RPC implementation
and will be removed.
2009-06-24 18:42:21 +00:00
Doug Rabson
c675522fc4 Re-implement the client side of rpc.lockd in the kernel. This implementation
provides the correct semantics for flock(2) style locks which are used by the
lockf(1) command line tool and the pidfile(3) library. It also implements
recovery from server restarts and ensures that dirty cache blocks are written
to the server before obtaining locks (allowing multiple clients to use file
locking to safely share data).

Sponsored by:	Isilon Systems
PR:		94256
MFC after:	2 weeks
2008-06-26 10:21:54 +00:00
Doug Rabson
bbf7dc4c6f Add a missing call to init_nsm().
MFC after:	1 week
2008-06-02 16:00:49 +00:00
Doug Rabson
3cba562fb9 If we can't find or load the kernel NLM support, don't just go ahead and
try to use it anyway.
2008-04-10 12:54:53 +00:00
Doug Rabson
0e7cce1381 Call listen(2) on bound tcp sockets before passing them to svc_tli_create. 2008-04-06 13:52:17 +00:00
Doug Rabson
3efa83dca3 Remove the '-k' option. 2008-03-27 15:11:02 +00:00
Doug Rabson
fa9d9930ca Add kernel module support for nfslockd and krpc. Use the module system
to detect (or load) kernel NLM support in rpc.lockd. Remove the '-k'
option to rpc.lockd and make kernel NLM the default. A user can still
force the use of the old user NLM by building a kernel without NFSLOCKD
and/or removing the nfslockd.ko module.
2008-03-27 11:54:20 +00:00
Doug Rabson
dfdcada31e Add the new kernel-mode NFS Lock Manager. To use it instead of the
user-mode lock manager, build a kernel with the NFSLOCKD option and
add '-k' to 'rpc_lockd_flags' in rc.conf.

Highlights include:

* Thread-safe kernel RPC client - many threads can use the same RPC
  client handle safely with replies being de-multiplexed at the socket
  upcall (typically driven directly by the NIC interrupt) and handed
  off to whichever thread matches the reply. For UDP sockets, many RPC
  clients can share the same socket. This allows the use of a single
  privileged UDP port number to talk to an arbitrary number of remote
  hosts.

* Single-threaded kernel RPC server. Adding support for multi-threaded
  server would be relatively straightforward and would follow
  approximately the Solaris KPI. A single thread should be sufficient
  for the NLM since it should rarely block in normal operation.

* Kernel mode NLM server supporting cancel requests and granted
  callbacks. I've tested the NLM server reasonably extensively - it
  passes both my own tests and the NFS Connectathon locking tests
  running on Solaris, Mac OS X and Ubuntu Linux.

* Userland NLM client supported. While the NLM server doesn't have
  support for the local NFS client's locking needs, it does have to
  field async replies and granted callbacks from remote NLMs that the
  local client has contacted. We relay these replies to the userland
  rpc.lockd over a local domain RPC socket.

* Robust deadlock detection for the local lock manager. In particular
  it will detect deadlocks caused by a lock request that covers more
  than one blocking request. As required by the NLM protocol, all
  deadlock detection happens synchronously - a user is guaranteed that
  if a lock request isn't rejected immediately, the lock will
  eventually be granted. The old system allowed for a 'deferred
  deadlock' condition where a blocked lock request could wake up and
  find that some other deadlock-causing lock owner had beaten them to
  the lock.

* Since both local and remote locks are managed by the same kernel
  locking code, local and remote processes can safely use file locks
  for mutual exclusion. Local processes have no fairness advantage
  compared to remote processes when contending to lock a region that
  has just been unlocked - the local lock manager enforces a strict
  first-come first-served model for both local and remote lockers.

Sponsored by:	Isilon Systems
PR:		95247 107555 115524 116679
MFC after:	2 weeks
2008-03-26 15:23:12 +00:00
Matteo Riondato
96e460ec53 Check the correct variables for malloc failures.
Submitted by:	Michiel Boland <michiel@boland.org>
2007-11-07 10:21:36 +00:00
Matteo Riondato
e56fbc5aad Add the -h <bindip> option to rpc.lockd, similar to the one in
nfsd(8), in mountd(8), and in rpc.statd(8)

-h bindip
Specify specific IP addresses to bind to for TCP and UDP requests.
This option may be specified multiple times.  If no -h option is
specified, rpc.lockd will bind to INADDR_ANY.  Note that when specifying
IP addresses with -h, rpc.lockd will automatically add 127.0.0.1 and
if IPv6 is enabled, ::1 to the list.

PR:		bin/98500
MFC after:	1 week
2007-11-02 14:51:53 +00:00
Jun Kuriyama
856f34f9e3 - Fix compilaton with DUMP_FILELOCK_VERBOSE.
- Use consistent "get_lock_matching_unlock" function name in
  debuglog().
2007-04-12 02:07:12 +00:00
Matteo Riondato
69f129c9f1 Add the "-p" option, which allows to specify a port which the daemon
should bind to.

PR:		bin/100969
Reviewed by:	alfred@
MFC after:	1 week
2007-04-03 20:58:28 +00:00