History log of /freebsd-current/usr.bin/rpcgen/rpc_main.c
Revision Date Author Comments
# 5b31cc94 23-Nov-2023 Warner Losh <imp@FreeBSD.org>

sccs: Manual changes

For the uncommon items: Go through the tree and remove sccs tags that
didn't fit any nice pattern. If in the neighborhood, other SCM tags were
removed when they were detritis of long-ago CVS somehow in the early
mists of the project. Some adjacent copyrights stringswere removed (they
duplicated the copyright notices in the file). This also removed
non-standard formations of omission of SCCS tags (usually by adding an
extra #if 0 somewhere.

After this commit, a number of strings tagged with the 'what' @(#)
prefix remain, but they are primarily copyright notices.

Sponsored by: Netflix


# bdcbfde3 23-Nov-2023 Warner Losh <imp@FreeBSD.org>

usr.bin: Remove ancient SCCS tags.

Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.

Sponsored by: Netflix


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 587458b7 13-Jul-2023 Jessica Clarke <jrtc27@FreeBSD.org>

rpcgen: Perform shell-style word expansion on RPCGEN_CPP

Up until recently, CPP has been a list of space-separated words, with no
quotes, backslashes or other characters with special meaning to a shell.
However, as of 8fad2cda93c7, (escaped) quotes appear in CPP, and the
rudimentary parser in rpcgen is insufficient, since it will leave the
escaped quotes as escaped rather than performing one level of expansion
as would be done by a shell (whether in a script or a Makefile).

Rather than hack around this in all the places RPCGEN_CPP gets set,
implement proper expansion inside rpcgen. Note that this only deals with
a subset of shell syntax, since we don't handle any of:

| & ; < > ( ) $ ` * ? [ # ˜ = %

having special meaning (with the exception of how a backslash behaves
inside double quotes, where \$ means a literal $ inside double quotes
but \a means a literal \a), instead using their literal value, but those
are all reasonable restrictions, and can be worked around by avoiding
their use; what's important is that we get the quoting and splitting
right.

This fixes -Winvalid-pp-token spew during build${libcompat}.

Reviewed by: brooks
Fixes: 8fad2cda93c7 ("bsd.compat.mk: Provide new CPP and sub-make variables")
Differential Revision: https://reviews.freebsd.org/D41013


# 9d843ba3 12-Jul-2023 Jessica Clarke <jrtc27@FreeBSD.org>

rpcgen: Clarify behaviour for idx

The re-initialisation of idx in the later else branch is a bit hidden,
and results in deviation from the earlier two paths. Use more consistent
code instead to make it abundantly clear what's going on.


# 1a7ac2bd 07-Jul-2023 Alfonso Gregory <gfunni234@gmail.com>

Mark usage function as __dead2 in programs where it does not return

In most cases, usage does not return, so mark them as __dead2. For the
cases where they do return, they have not been marked __dead2.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/735


# f0b58b19 04-Dec-2022 John Baldwin <jhb@FreeBSD.org>

rpcgen: Don't free() a pointer after realloc().

A successful realloc() already frees the old pointer.

Reported by: GCC -Wuse-after-free
Reviewed by: brooks, imp, emaste
Differential Revision: https://reviews.freebsd.org/D37540


# 7c8b268a 15-Oct-2019 Brooks Davis <brooks@FreeBSD.org>

rpcgen: make compiler arglist allocation dynamic

Limit argmax to an absurdly large value prevent overflow (no overflow
possible on FreeBSD due to ARG_MAX).

In CheriBSD we exceed the 19 non-NULL arguments in the static array. Add
a simple size doubling allocator and increase the default to 32.

GC remnants of support for fixed arguments.

Reviewed by: archardson (prior version), James Clarke (prior version)
MFC after: 1 week
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D21971


# 074170fb 27-Dec-2017 Warner Losh <imp@FreeBSD.org>

Free some variables before they go out of scope.

CID: 92074, 270099


# 4b61b26b 16-Aug-2016 Marcelo Araujo <araujo@FreeBSD.org>

Use nitems() from sys/param.h.

MFC after: 2 weeks.


# 7dbab955 18-Apr-2016 Marcelo Araujo <araujo@FreeBSD.org>

Use NULL for pointers.

strrchr(3) will return NULL if the character does not appears in
the string.

MFC after: 2 weeks.


# 80c7cc1c 15-Apr-2016 Pedro F. Giffuni <pfg@FreeBSD.org>

Cleanup unnecessary semicolons from utilities we all love.


# 36752498 06-Jun-2014 Bryan Drewery <bdrewery@FreeBSD.org>

Fix some rpcgen sample file issues.

* -Sc was generating code without a return type on main.
* -Sm was generating an unusable clean target due to undefined RM.
* -Sm was generating clean target with extra preceding space.

PR: 185582
Submitted by: Pawel Biernacki <pawel.biernacki@gmail.com>
MFC after: 1 week


# 7c31e86b 26-Dec-2013 Doug Rabson <dfr@FreeBSD.org>

Generate client sample code which compiles without warnings.
For 'rpcgen -a', generate a makefile where 'make clean all' works.


# bf70bece 19-Oct-2012 Ed Schouten <ed@FreeBSD.org>

More -Wmissing-variable-declarations fixes.

In addition to adding `static' where possible:

- bin/date: Move `retval' into extern.h to make it visible to date.c.
- bin/ed: Move globally used variables into ed.h.
- sbin/camcontrol: Move `verbose' into camcontrol.h and fix shadow warnings.
- usr.bin/calendar: Remove unneeded variables.
- usr.bin/chat: Make `line' local instead of global.
- usr.bin/elfdump: Comment out unneeded function.
- usr.bin/rlogin: Use _Noreturn instead of __dead2.
- usr.bin/tset: Pull `Ospeed' into extern.h.
- usr.sbin/mfiutil: Put global variables in mfiutil.h.
- usr.sbin/pkg: Remove unused `os_corres'.
- usr.sbin/quotaon, usr.sbin/repquota: Remove unused `qfname'.


# 005576f6 06-Feb-2012 Dimitry Andric <dim@FreeBSD.org>

In usr.bin/rpcgen/rpc_main.c, use execvp(3) instead of execv(3), so
rpcgen will search the current PATH for the preprocessor. This makes it
possible to run a preprocessor built during the cross-tools stage of
buildworld.

MFC after: 1 week


# ade215fd 05-Feb-2012 Dimitry Andric <dim@FreeBSD.org>

Amend r231079 by properly shifting up the existing arguments in
rpc_main.c's insarg() function. I had forgotten to put this in my patch
queue, sorry.

Pointy hat to: me
MFC after: 1 week


# 0dac0ed8 05-Feb-2012 Dimitry Andric <dim@FreeBSD.org>

Let rpcgen(1) support an environment variable RPCGEN_CPP to find the C
preprocessor to run. Previously, it always ran /usr/bin/cpp, unless you
used the -Y option, and even then you could not set the basename. It
also attempted to run /usr/ccs/lib/cpp for SVR4 compatibility, but this
is obsolete, and has been removed.

Note that setting RPCGEN_CPP to a command with arguments is supported,
though the command line parsing is simplistic. However, setting it to
e.g. "gcc46 -E" or "clang -E" will lead to problems, because both gcc
and clang in -E mode will consider files with unknown extensions (such
as .x) as object files, and attempt to link them.

This could be worked around by also adding "-x c", but it is much safer
to set RPCGEN_CPP to e.g. "cpp46" or "clang-cpp" instead.

MFC after: 1 week


# faabfb8a 05-Feb-2012 Dimitry Andric <dim@FreeBSD.org>

In usr.bin/rpcgen/rpc_main.c, properly check the return value of
strlcpy(), in addition to checking that of strlcat().

MFC after: 1 week


# b3608ae1 03-Jan-2012 Ed Schouten <ed@FreeBSD.org>

Replace index() and rindex() calls with strchr() and strrchr().

The index() and rindex() functions were marked LEGACY in the 2001
revision of POSIX and were subsequently removed from the 2008 revision.
The strchr() and strrchr() functions are part of the C standard.

This makes the source code a lot more consistent, as most of these C
files also call into other str*() routines. In fact, about a dozen
already perform strchr() calls.


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# ef636796 02-Jan-2010 Ed Schouten <ed@FreeBSD.org>

ANSIfy various tools in usr.bin/.

Most of these tools properly build at WARNS=6, except for their K&R
function declarations. Fix this, so we can bump WARNS as well.


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# f87730d4 23-Aug-2007 Xin LI <delphij@FreeBSD.org>

sysent.h is installed as sys/sysent.h, so reflect it.

Approved by: re (kensmith)
Spotted by: Changming Sun <changming at staff.sina.com.cn>
Sponsored by: SINA Corporation


# 8cb6926e 14-Nov-2005 Craig Rodrigues <rodrigc@FreeBSD.org>

Eliminate coredump problem introduced by last commit.

Noticed by: Guido van Rooij <guido at gvr dot org>


# 075775c9 13-Nov-2005 Craig Rodrigues <rodrigc@FreeBSD.org>

Eliminate build breakage due to warnings about const.


# e390e3af 13-Nov-2005 David Malone <dwmalone@FreeBSD.org>

Use ANSI definitions.
Avoid using extern by declaring shared functions in header files.
Const poision.


# 15df5e2d 02-Sep-2005 Stefan Farfeleder <stefanf@FreeBSD.org>

Don't generate K&R C code. The -C flag is kept for backwards compatibility.
Also remove the SIG_PF macro, there is no need to cast closedown.


# ec06b5e8 01-Sep-2005 Stefan Farfeleder <stefanf@FreeBSD.org>

Only write the dispatch table function prototypes to the header if the -h
flag was specified. If all files are generated at once, those functions are
static and shouldn't appear in the header.

PR: 84450
Reviewed by: alfred


# d0cc804b 31-Aug-2005 Stefan Farfeleder <stefanf@FreeBSD.org>

- Use prototypes in headers.
- Include rpc_scan.h before rpc_util.h for the tok_kind enum.
- Nuke unused declarations.


# 122562cd 31-Aug-2005 Stefan Farfeleder <stefanf@FreeBSD.org>

Rename the variable `inline' to `inline_size'.


# 63f17371 31-May-2005 Stefan Farfeleder <stefanf@FreeBSD.org>

Move #ident into #if 0.


# 4f83fd19 10-Feb-2005 Stefan Farfeleder <stefanf@FreeBSD.org>

Let the generated code include <string.h> instead of <memory.h>.


# 080f4020 02-May-2004 Sean Kelly <smkelly@FreeBSD.org>

- style(9) improvements courtesy of bde.
- Revise the former commit to behave nicer on filenames containing
multiple '.' characters.
- Prevent the generation of macros starting with "__".


# 10c546c4 01-May-2004 Sean Kelly <smkelly@FreeBSD.org>

Teach rpcgen to generate .h files properly when the input filename contains
characters that can't be used in preprocessor macros.

PR: bin/66156
Submitted by: K S Braunsdorf <rpc@ksb.npcguild.org>


# c5455e6d 19-Jun-2003 Martin Blapp <mbr@FreeBSD.org>

Fix broken -a functionality.

Reviewed by: phk
Submitted by: Martin Kammerhofer <mkamm@gmx.net>
PR: 53451

MFC: 1 week


# bcb53b16 16-Jan-2003 Martin Blapp <mbr@FreeBSD.org>

Implement nonblocking tpc-connections. rpcgen -m does still
produce backcompatible code.

Reviewed by: rwatson
Obtained from: NetBSD
MFC after: 1 day


# 75863a6d 20-Jul-2002 Philippe Charnier <charnier@FreeBSD.org>

Removal of spaces at EOL. Add __FBSDID. New function xmalloc, xrealloc,
xstrdup. There is a crash() function that do cleaning before exiting the
program. The new functions are wrappers that make use of crash() in case
of allocation failure. warn, exit -> err.

Reviewed by: alfred


# 40ad8885 14-Jul-2002 Alfred Perlstein <alfred@FreeBSD.org>

- TI-RPC is now the default again for code generation.

- As before, inetd support support is turned of per default.
Code for inetd can be made with -I.

- Support for ``transport monitors'' and the NLSPROVIDER env
variable is still there , even if their use is not clear in
non TLI stream based systems like Free-/NetBSD. It can be activated
with -P.

- There are a few corrections in rpcgen.1 and usage function to conform
to the code. Added and documented -P

- I removed the #ifdefs checks for Free-/NetBSD since we are the only
ones who use this code. MaxOS X may have the same limitations as
we have, so this code will correctly build for them.

- Generate correct cflags.

Submitted by: mbr, Jean-Luc Richier <Jean-Luc.Richier@imag.fr>
PR: bin/29175, misc/27816


# d3cb5ded 21-Mar-2002 Warner Losh <imp@FreeBSD.org>

remove __P


# a0b13740 20-Aug-2001 Kris Kennaway <kris@FreeBSD.org>

Don't overflow a buffer from command line arguments.

MFC after: 2 weeks


# f0cad56f 13-Apr-2001 Alfred Perlstein <alfred@FreeBSD.org>

Turn -b (BSD socket compat mode) back on by default, as we don't have TLI/XTI


# 8360efbd 18-Mar-2001 Alfred Perlstein <alfred@FreeBSD.org>

Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) and
associated changes that had to happen to make this possible as well as
bugs fixed along the way.

Bring in required TLI library routines to support this.

Since we don't support TLI we've essentially copied what NetBSD
has done, adding a thin layer to emulate direct the TLI calls
into BSD socket calls.

This is mostly from Sun's tirpc release that was made in 1994,
however some fixes were backported from the 1999 release (supposedly
only made available after this porting effort was underway).

The submitter has agreed to continue on and bring us up to the
1999 release.

Several key features are introduced with this update:
Client calls are thread safe. (1999 code has server side thread
safe)
Updated, a more modern interface.

Many userland updates were done to bring the code up to par with
the recent RPC API.

There is an update to the pthreads library, a function
pthread_main_np() was added to emulate a function of Sun's threads
library.

While we're at it, bring in NetBSD's lockd, it's been far too
long of a wait.

New rpcbind(8) replaces portmap(8) (supporting communication over
an authenticated Unix-domain socket, and by default only allowing
set and unset requests over that channel). It's much more secure
than the old portmapper.

Umount(8), mountd(8), mount_nfs(8), nfsd(8) have also been upgraded
to support TI-RPC and to support IPV6.

Umount(8) is also fixed to unmount pathnames longer than 80 chars,
which are currently truncated by the Kernel statfs structure.

Submitted by: Martin Blapp <mb@imp.ch>
Manpage review: ru
Secure RPC implemented by: wpaul


# f2912673 10-Jan-2001 David E. O'Brien <obrien@FreeBSD.org>

Have rpcgen actually tell us what cpp it is looking for (as it would if we
were SVR%).


# 89ea5c2a 09-Jan-2001 David E. O'Brien <obrien@FreeBSD.org>

Use /usr/bin/cpp as on NetBSD, not /usr/libexec/cpp.


# c3aac50f 27-Aug-1999 Peter Wemm <peter@FreeBSD.org>

$Id$ -> $FreeBSD$


# 35ab9586 25-Sep-1998 David E. O'Brien <obrien@FreeBSD.org>

include <pthread.h>

Submitted by: Alexander Leidinger <netchild@wurzelausix.CS.Uni-SB.DE>


# 36dbb7dd 06-Mar-1998 John Birrell <jb@FreeBSD.org>

Fix a #ifndef that became a #ifdef and changed the default
behaviour of rpcgen.

Noticed by: bde


# 02de434c 15-Jan-1998 John Birrell <jb@FreeBSD.org>

Add #ifdefs for __NetBSD__ in the rest of the places where __FreeBSD__
is defined so that this program behaves the same when built with
either set of tools. The only difference is where the pre-processor
is found. And that is a bug - it should check the CPP environment
variable and the path before just assuming that the compiled in
path is OK. I guess we should be using -Y ${WORLDPATH}/usr/bin/cpp
during a bootstrap build.


# d7c089b7 08-Jan-1998 John Birrell <jb@FreeBSD.org>

Add __NetBSD__ in a couple of places to allow this program to
compile under NetBSD, but behave like FreeBSD. For the time being,
look for NetBSD's cpp in /usr/bin.


# 0e76f40d 06-Aug-1997 Philippe Charnier <charnier@FreeBSD.org>

Use err(3), cosmetic in usage(), remove `cmdname'.


# 526195ad 12-Jul-1996 Jordan K. Hubbard <jkh@FreeBSD.org>

General -Wall warning cleanup, part I.
Submitted-By: Kent Vander Velden <graphix@iastate.edu>


# ff49530f 12-Dec-1995 Bill Paul <wpaul@FreeBSD.org>

Clean up. (I hope I'm doing this right.)

Update rpcgen with the one from the TI-RPC 2.3 distribution.

Note that when built for FreeBSD, this version of rpcgen assumes
backwards compatibility mode by default. This means that it will produce
ONCRPC 4.0 compatible code unless otherwise instructed, instead of the
other way around.

One incompatibility has also been worked around: this rpcgen normally
always emits an '#include <stropts.h>' directive whether you select
backwards compatibility mode or not. We don't have STREAMS, so this
behavior has been changed: now it will only emit this line if run in TI-RPC
mode.

The 'generate output files in current directory instead of the
directory where the protocol definition file lives' hack from the
original rpcgen has been preserved.

Notable new features:

- Can be used to generate RPC servers that can be launched
from port monitors such as inetd(5).

- Can generate ANSI C code.

- Can generate sample client and server top-level programs and
makefiles in addition to the usual client and server stubs.

- Can generate inline XDR routines.


# ee4f614e 12-Dec-1995 Bill Paul <wpaul@FreeBSD.org>

Import a newer and more functional version of rpcgen.

Obtained from: the Sun TI-RPC 2.3 source distribution


# 7799f52a 30-May-1995 Rodney W. Grimes <rgrimes@FreeBSD.org>

Remove trailing whitespace.


# 5ec07232 04-Mar-1995 Nate Williams <nate@FreeBSD.org>

Fix rpcgen so that generated files are written to the current working
directory (instead of the same directory as the source files) and that
#includes in those files do not contain the path to the source file.

Obtained from: J.T. Conklin via NetBSD


# 4e115012 07-Aug-1994 Garrett Wollman <wollman@FreeBSD.org>

Move RPC stub generator program over from 1.1.5.

Submitted by: Original work in 1.x by J. T. Conklin.