This helps to see compiled time options, e.g. remote calls enablement. $ ./rpcbind -v rpcbind 1.2.7 debug: no, libset debug: no, libwrap: no, nss modules: files, remote calls: no, statedir: /run/rpcbind, systemd: yes, user: root, warm start: no Signed-off-by: Petr Vorel <pvorel@xxxxxxx> --- man/rpcbind.8 | 6 +++- src/rpcbind.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 83 insertions(+), 4 deletions(-) diff --git a/man/rpcbind.8 b/man/rpcbind.8 index cd0f817..15b70f9 100644 --- a/man/rpcbind.8 +++ b/man/rpcbind.8 @@ -11,7 +11,7 @@ .Nd universal addresses to RPC program number mapper .Sh SYNOPSIS .Nm -.Op Fl adfhilsw +.Op Fl adfhilsvw .Sh DESCRIPTION The .Nm @@ -141,6 +141,10 @@ to use non-privileged ports for outgoing connections, preventing non-privileged clients from using .Nm to connect to services from a privileged port. +.It Fl v +Print +.Nm +version and builtin configuration and exit. .It Fl w Cause .Nm diff --git a/src/rpcbind.c b/src/rpcbind.c index 122ce6a..bf7b499 100644 --- a/src/rpcbind.c +++ b/src/rpcbind.c @@ -96,10 +96,11 @@ char *rpcbinduser = RPCBIND_USER; char *rpcbinduser = NULL; #endif +#define NSS_MODULES_DEFAULT "files" #ifdef NSS_MODULES char *nss_modules = NSS_MODULES; #else -char *nss_modules = "files"; +char *nss_modules = NSS_MODULES_DEFAULT; #endif /* who to suid to if -s is given */ @@ -143,6 +144,76 @@ static void rbllist_add(rpcprog_t, rpcvers_t, struct netconfig *, static void terminate(int); static void parseargs(int, char *[]); +static void version() +{ + fprintf(stderr, "%s\n", PACKAGE_STRING); + + fprintf(stderr, "debug: "); +#ifdef RPCBIND_DEBUG + fprintf(stderr, "yes"); +#else + fprintf(stderr, "no"); +#endif + + fprintf(stderr, ", libset debug: "); +#ifdef LIB_SET_DEBUG + fprintf(stderr, "yes"); +#else + fprintf(stderr, "no"); +#endif + + fprintf(stderr, ", libwrap: "); +#ifdef LIBWRAP + fprintf(stderr, "yes"); +#else + fprintf(stderr, "no"); +#endif + + fprintf(stderr, ", nss modules: "); +#ifdef NSS_MODULES + fprintf(stderr, "%s", NSS_MODULES); +#else + fprintf(stderr, "%s", NSS_MODULES_DEFAULT); +#endif + + fprintf(stderr, ", remote calls: "); +#ifdef RMTCALLS + fprintf(stderr, "yes"); +#else + fprintf(stderr, "no"); +#endif + + fprintf(stderr, ", statedir: "); +#ifdef RPCBIND_STATEDIR + fprintf(stderr, "%s", RPCBIND_STATEDIR); +#else + fprintf(stderr, ""); +#endif + + fprintf(stderr, ", systemd: "); +#ifdef SYSTEMD + fprintf(stderr, "yes"); +#else + fprintf(stderr, "no"); +#endif + + fprintf(stderr, ", user: "); +#ifdef RPCBIND_USER + fprintf(stderr, "%s", RPCBIND_USER); +#else + fprintf(stderr, ""); +#endif + + fprintf(stderr, ", warm start: "); +#ifdef WARMSTART + fprintf(stderr, "yes"); +#else + fprintf(stderr, "no"); +#endif + + fprintf(stderr, "\n"); +} + int main(int argc, char *argv[]) { @@ -888,7 +959,7 @@ parseargs(int argc, char *argv[]) { int c; oldstyle_local = 1; - while ((c = getopt(argc, argv, "adh:ilswf")) != -1) { + while ((c = getopt(argc, argv, "adfh:ilsvw")) != -1) { switch (c) { case 'a': doabort = 1; /* when debugging, do an abort on */ @@ -918,13 +989,17 @@ parseargs(int argc, char *argv[]) case 'f': dofork = 0; break; + case 'v': + version(); + exit(0); + break; #ifdef WARMSTART case 'w': warmstart = 1; break; #endif default: /* error */ - fprintf(stderr, "usage: rpcbind [-adhilswf]\n"); + fprintf(stderr, "usage: rpcbind [-adfhilsvw]\n"); exit (1); } } -- 2.49.0