|
|
bec77d |
diff --git a/Makefile.am b/Makefile.am
|
|
|
bec77d |
index 264ffa6..0cbea8c 100644
|
|
|
bec77d |
--- a/Makefile.am
|
|
|
bec77d |
+++ b/Makefile.am
|
|
|
bec77d |
@@ -15,6 +15,10 @@ AM_CPPFLAGS += -DRPCBIND_DEBUG -DSVC_RUN_DEBUG -DDEBUG_RMTCALL
|
|
|
bec77d |
AM_CPPFLAGS += -DND_DEBUG -DBIND_DEBUG
|
|
|
bec77d |
endif
|
|
|
bec77d |
|
|
|
bec77d |
+if LIBSETDEBUG
|
|
|
bec77d |
+AM_CPPFLAGS += -DLIB_SET_DEBUG
|
|
|
bec77d |
+endif
|
|
|
bec77d |
+
|
|
|
bec77d |
if WARMSTART
|
|
|
bec77d |
AM_CPPFLAGS += -DWARMSTART
|
|
|
bec77d |
endif
|
|
|
bec77d |
@@ -36,7 +40,8 @@ rpcbind_SOURCES = \
|
|
|
bec77d |
src/rpcbind.h \
|
|
|
bec77d |
src/security.c \
|
|
|
bec77d |
src/util.c \
|
|
|
bec77d |
- src/warmstart.c
|
|
|
bec77d |
+ src/warmstart.c \
|
|
|
bec77d |
+ src/xlog.c
|
|
|
bec77d |
rpcbind_LDADD = $(TIRPC_LIBS)
|
|
|
bec77d |
|
|
|
bec77d |
if SYSTEMD
|
|
|
bec77d |
diff --git a/configure.ac b/configure.ac
|
|
|
bec77d |
index b97b5a0..a260577 100644
|
|
|
bec77d |
--- a/configure.ac
|
|
|
bec77d |
+++ b/configure.ac
|
|
|
bec77d |
@@ -12,6 +12,10 @@ AM_CONDITIONAL(LIBWRAP, test x$enable_libwrap = xyes)
|
|
|
bec77d |
AC_ARG_ENABLE([debug],
|
|
|
bec77d |
AS_HELP_STRING([--enable-debug], [Turns on rpcbind debugging @<:@default=no@:>@]))
|
|
|
bec77d |
AM_CONDITIONAL(DEBUG, test x$enable_debug = xyes)
|
|
|
bec77d |
+if test x"$enable_debug" = xyes; then
|
|
|
bec77d |
+ AC_CHECK_LIB([tirpc], [libtirpc_set_debug], [lib_setdebug=yes])
|
|
|
bec77d |
+fi
|
|
|
bec77d |
+AM_CONDITIONAL(LIBSETDEBUG, test x$lib_setdebug = xyes)
|
|
|
bec77d |
|
|
|
bec77d |
AC_ARG_ENABLE([warmstarts],
|
|
|
bec77d |
AS_HELP_STRING([--enable-warmstarts], [Enables Warm Starts @<:@default=no@:>@]))
|
|
|
bec77d |
diff --git a/man/rpcbind.8 b/man/rpcbind.8
|
|
|
bec77d |
index da32701..af6200f 100644
|
|
|
bec77d |
--- a/man/rpcbind.8
|
|
|
bec77d |
+++ b/man/rpcbind.8
|
|
|
bec77d |
@@ -76,8 +76,8 @@ do an abort on errors.
|
|
|
bec77d |
Run in debug mode.
|
|
|
bec77d |
In this mode,
|
|
|
bec77d |
.Nm
|
|
|
bec77d |
-will not fork when it starts, will print additional information
|
|
|
bec77d |
-during operation, and will abort on certain errors if
|
|
|
bec77d |
+will log additional information during operation,
|
|
|
bec77d |
+and will abort on certain errors if
|
|
|
bec77d |
.Fl a
|
|
|
bec77d |
is also specified.
|
|
|
bec77d |
With this option, the name-to-address translation consistency
|
|
|
bec77d |
diff --git a/src/pmap_svc.c b/src/pmap_svc.c
|
|
|
bec77d |
index 337e64d..ad28b93 100644
|
|
|
bec77d |
--- a/src/pmap_svc.c
|
|
|
bec77d |
+++ b/src/pmap_svc.c
|
|
|
bec77d |
@@ -54,9 +54,11 @@ static char sccsid[] = "@(#)pmap_svc.c 1.23 89/04/05 Copyr 1984 Sun Micro";
|
|
|
bec77d |
#include <rpc/pmap_prot.h>
|
|
|
bec77d |
#include <rpc/rpcb_prot.h>
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
+#include <syslog.h>
|
|
|
bec77d |
#include <stdlib.h>
|
|
|
bec77d |
#endif
|
|
|
bec77d |
#include "rpcbind.h"
|
|
|
bec77d |
+#include "xlog.h"
|
|
|
bec77d |
#include <rpc/svc_soc.h> /* svc_getcaller routine definition */
|
|
|
bec77d |
static struct pmaplist *find_service_pmap __P((rpcprog_t, rpcvers_t,
|
|
|
bec77d |
rpcprot_t));
|
|
|
bec77d |
@@ -78,7 +80,7 @@ pmap_service(struct svc_req *rqstp, SVCXPRT *xprt)
|
|
|
bec77d |
*/
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr, "PMAPPROC_NULL\n");
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "PMAPPROC_NULL\n");
|
|
|
bec77d |
#endif
|
|
|
bec77d |
check_access(xprt, rqstp->rq_proc, 0, PMAPVERS);
|
|
|
bec77d |
if ((!svc_sendreply(xprt, (xdrproc_t) xdr_void, NULL)) &&
|
|
|
bec77d |
@@ -117,7 +119,7 @@ pmap_service(struct svc_req *rqstp, SVCXPRT *xprt)
|
|
|
bec77d |
*/
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr, "PMAPPROC_DUMP\n");
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "PMAPPROC_DUMP\n");
|
|
|
bec77d |
#endif
|
|
|
bec77d |
pmapproc_dump(rqstp, xprt);
|
|
|
bec77d |
break;
|
|
|
bec77d |
@@ -196,7 +198,7 @@ pmapproc_change(struct svc_req *rqstp /*__unused*/, SVCXPRT *xprt, unsigned long
|
|
|
bec77d |
}
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr, "%s request for (%lu, %lu) : ",
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "%s request for (%lu, %lu) : ",
|
|
|
bec77d |
op == PMAPPROC_SET ? "PMAP_SET" : "PMAP_UNSET",
|
|
|
bec77d |
reg.pm_prog, reg.pm_vers);
|
|
|
bec77d |
#endif
|
|
|
bec77d |
@@ -243,14 +245,14 @@ pmapproc_change(struct svc_req *rqstp /*__unused*/, SVCXPRT *xprt, unsigned long
|
|
|
bec77d |
done_change:
|
|
|
bec77d |
if ((!svc_sendreply(xprt, (xdrproc_t) xdr_long, (caddr_t) &ans)) &&
|
|
|
bec77d |
debugging) {
|
|
|
bec77d |
- fprintf(stderr, "portmap: svc_sendreply\n");
|
|
|
bec77d |
+ xlog(L_ERROR, "portmap: svc_sendreply failed!\n");
|
|
|
bec77d |
if (doabort) {
|
|
|
bec77d |
rpcbind_abort();
|
|
|
bec77d |
}
|
|
|
bec77d |
}
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr, "%s\n", ans == TRUE ? "succeeded" : "failed");
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "%s\n", ans == TRUE ? "succeeded" : "failed");
|
|
|
bec77d |
#endif
|
|
|
bec77d |
if (op == PMAPPROC_SET)
|
|
|
bec77d |
rpcbs_set(RPCBVERS_2_STAT, ans);
|
|
|
bec77d |
@@ -285,7 +287,7 @@ pmapproc_getport(struct svc_req *rqstp /*__unused*/, SVCXPRT *xprt)
|
|
|
bec77d |
if (debugging) {
|
|
|
bec77d |
uaddr = taddr2uaddr(rpcbind_get_conf(xprt->xp_netid),
|
|
|
bec77d |
svc_getrpccaller(xprt));
|
|
|
bec77d |
- fprintf(stderr, "PMAP_GETPORT req for (%lu, %lu, %s) from %s :",
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "PMAP_GETPORT req for (%lu, %lu, %s) from %s :",
|
|
|
bec77d |
reg.pm_prog, reg.pm_vers,
|
|
|
bec77d |
pmap_ipprot2netid(reg.pm_prot)?: "<invalid>",
|
|
|
bec77d |
uaddr);
|
|
|
bec77d |
@@ -315,14 +317,14 @@ pmapproc_getport(struct svc_req *rqstp /*__unused*/, SVCXPRT *xprt)
|
|
|
bec77d |
lport = port;
|
|
|
bec77d |
if ((!svc_sendreply(xprt, (xdrproc_t) xdr_long, (caddr_t)&lport)) &&
|
|
|
bec77d |
debugging) {
|
|
|
bec77d |
- (void) fprintf(stderr, "portmap: svc_sendreply\n");
|
|
|
bec77d |
+ xlog(L_ERROR, "portmap: svc_sendreply failed!\n");
|
|
|
bec77d |
if (doabort) {
|
|
|
bec77d |
rpcbind_abort();
|
|
|
bec77d |
}
|
|
|
bec77d |
}
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr, "port = %d\n", port);
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "port = %d\n", port);
|
|
|
bec77d |
#endif
|
|
|
bec77d |
rpcbs_getaddr(RPCBVERS_2_STAT, reg.pm_prog, reg.pm_vers,
|
|
|
bec77d |
pmap_ipprot2netid(reg.pm_prot) ?: "<unknown>",
|
|
|
bec77d |
@@ -347,8 +349,7 @@ pmapproc_dump(struct svc_req *rqstp /*__unused*/, SVCXPRT *xprt)
|
|
|
bec77d |
|
|
|
bec77d |
if ((!svc_sendreply(xprt, (xdrproc_t) xdr_pmaplist_ptr,
|
|
|
bec77d |
(caddr_t)&list_pml)) && debugging) {
|
|
|
bec77d |
- if (debugging)
|
|
|
bec77d |
- (void) fprintf(stderr, "portmap: svc_sendreply\n");
|
|
|
bec77d |
+ xlog(L_ERROR, "portmap: svc_sendreply failed!\n");
|
|
|
bec77d |
if (doabort) {
|
|
|
bec77d |
rpcbind_abort();
|
|
|
bec77d |
}
|
|
|
bec77d |
diff --git a/src/rpcb_svc.c b/src/rpcb_svc.c
|
|
|
bec77d |
index e350f85..92361a2 100644
|
|
|
bec77d |
--- a/src/rpcb_svc.c
|
|
|
bec77d |
+++ b/src/rpcb_svc.c
|
|
|
bec77d |
@@ -86,7 +86,7 @@ rpcb_service_3(struct svc_req *rqstp, SVCXPRT *transp)
|
|
|
bec77d |
*/
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr, "RPCBPROC_NULL\n");
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "RPCBPROC_NULL");
|
|
|
bec77d |
#endif
|
|
|
bec77d |
/* This call just logs, no actual checks */
|
|
|
bec77d |
check_access(transp, rqstp->rq_proc, 0, RPCBVERS);
|
|
|
bec77d |
@@ -114,7 +114,7 @@ rpcb_service_3(struct svc_req *rqstp, SVCXPRT *transp)
|
|
|
bec77d |
case RPCBPROC_DUMP:
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr, "RPCBPROC_DUMP\n");
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "RPCBPROC_DUMP");
|
|
|
bec77d |
#endif
|
|
|
bec77d |
xdr_argument = (xdrproc_t)xdr_void;
|
|
|
bec77d |
xdr_result = (xdrproc_t)xdr_rpcblist_ptr;
|
|
|
bec77d |
@@ -128,7 +128,7 @@ rpcb_service_3(struct svc_req *rqstp, SVCXPRT *transp)
|
|
|
bec77d |
case RPCBPROC_GETTIME:
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr, "RPCBPROC_GETTIME\n");
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "RPCBPROC_GETTIME");
|
|
|
bec77d |
#endif
|
|
|
bec77d |
xdr_argument = (xdrproc_t)xdr_void;
|
|
|
bec77d |
xdr_result = (xdrproc_t)xdr_u_long;
|
|
|
bec77d |
@@ -138,7 +138,7 @@ rpcb_service_3(struct svc_req *rqstp, SVCXPRT *transp)
|
|
|
bec77d |
case RPCBPROC_UADDR2TADDR:
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr, "RPCBPROC_UADDR2TADDR\n");
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "RPCBPROC_UADDR2TADDR");
|
|
|
bec77d |
#endif
|
|
|
bec77d |
xdr_argument = (xdrproc_t)xdr_wrapstring;
|
|
|
bec77d |
xdr_result = (xdrproc_t)xdr_netbuf;
|
|
|
bec77d |
@@ -148,7 +148,7 @@ rpcb_service_3(struct svc_req *rqstp, SVCXPRT *transp)
|
|
|
bec77d |
case RPCBPROC_TADDR2UADDR:
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr, "RPCBPROC_TADDR2UADDR\n");
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "RPCBPROC_TADDR2UADDR");
|
|
|
bec77d |
#endif
|
|
|
bec77d |
xdr_argument = (xdrproc_t)xdr_netbuf;
|
|
|
bec77d |
xdr_result = (xdrproc_t)xdr_wrapstring;
|
|
|
bec77d |
@@ -164,7 +164,7 @@ rpcb_service_3(struct svc_req *rqstp, SVCXPRT *transp)
|
|
|
bec77d |
(char *) &argument)) {
|
|
|
bec77d |
svcerr_decode(transp);
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- (void) fprintf(stderr, "rpcbind: could not decode\n");
|
|
|
bec77d |
+ (void) xlog(LOG_DEBUG, "rpcbind: could not decode");
|
|
|
bec77d |
return;
|
|
|
bec77d |
}
|
|
|
bec77d |
|
|
|
bec77d |
@@ -182,7 +182,7 @@ rpcb_service_3(struct svc_req *rqstp, SVCXPRT *transp)
|
|
|
bec77d |
result)) {
|
|
|
bec77d |
svcerr_systemerr(transp);
|
|
|
bec77d |
if (debugging) {
|
|
|
bec77d |
- (void) fprintf(stderr, "rpcbind: svc_sendreply\n");
|
|
|
bec77d |
+ (void) xlog(LOG_DEBUG, "rpcbind: svc_sendreply");
|
|
|
bec77d |
if (doabort) {
|
|
|
bec77d |
rpcbind_abort();
|
|
|
bec77d |
}
|
|
|
bec77d |
@@ -192,7 +192,7 @@ done:
|
|
|
bec77d |
if (!svc_freeargs(transp, (xdrproc_t)xdr_argument, (char *)
|
|
|
bec77d |
&argument)) {
|
|
|
bec77d |
if (debugging) {
|
|
|
bec77d |
- (void) fprintf(stderr, "unable to free arguments\n");
|
|
|
bec77d |
+ (void) xlog(LOG_DEBUG, "unable to free arguments");
|
|
|
bec77d |
if (doabort) {
|
|
|
bec77d |
rpcbind_abort();
|
|
|
bec77d |
}
|
|
|
bec77d |
@@ -220,7 +220,7 @@ rpcbproc_getaddr_3_local(void *arg, struct svc_req *rqstp /*__unused*/,
|
|
|
bec77d |
|
|
|
bec77d |
uaddr = taddr2uaddr(rpcbind_get_conf(transp->xp_netid),
|
|
|
bec77d |
svc_getrpccaller(transp));
|
|
|
bec77d |
- fprintf(stderr, "RPCB_GETADDR req for (%lu, %lu, %s) from %s: ",
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "RPCB_GETADDR req for (%lu, %lu, %s) from %s: ",
|
|
|
bec77d |
(unsigned long)regp->r_prog, (unsigned long)regp->r_vers,
|
|
|
bec77d |
regp->r_netid, uaddr);
|
|
|
bec77d |
free(uaddr);
|
|
|
bec77d |
diff --git a/src/rpcb_svc_4.c b/src/rpcb_svc_4.c
|
|
|
bec77d |
index 313e6d1..f1a72a6 100644
|
|
|
bec77d |
--- a/src/rpcb_svc_4.c
|
|
|
bec77d |
+++ b/src/rpcb_svc_4.c
|
|
|
bec77d |
@@ -89,7 +89,7 @@ rpcb_service_4(struct svc_req *rqstp, SVCXPRT *transp)
|
|
|
bec77d |
*/
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr, "RPCBPROC_NULL\n");
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "RPCBPROC_NULL\n");
|
|
|
bec77d |
#endif
|
|
|
bec77d |
check_access(transp, rqstp->rq_proc, 0, RPCBVERS4);
|
|
|
bec77d |
(void) svc_sendreply(transp, (xdrproc_t) xdr_void,
|
|
|
bec77d |
@@ -125,7 +125,7 @@ rpcb_service_4(struct svc_req *rqstp, SVCXPRT *transp)
|
|
|
bec77d |
case RPCBPROC_GETVERSADDR:
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr, "RPCBPROC_GETVERSADDR\n");
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "RPCBPROC_GETVERSADDR\n");
|
|
|
bec77d |
#endif
|
|
|
bec77d |
xdr_argument = (xdrproc_t)xdr_rpcb;
|
|
|
bec77d |
xdr_result = (xdrproc_t)xdr_wrapstring;
|
|
|
bec77d |
@@ -135,7 +135,7 @@ rpcb_service_4(struct svc_req *rqstp, SVCXPRT *transp)
|
|
|
bec77d |
case RPCBPROC_DUMP:
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr, "RPCBPROC_DUMP\n");
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "RPCBPROC_DUMP\n");
|
|
|
bec77d |
#endif
|
|
|
bec77d |
xdr_argument = (xdrproc_t)xdr_void;
|
|
|
bec77d |
xdr_result = (xdrproc_t)xdr_rpcblist_ptr;
|
|
|
bec77d |
@@ -145,7 +145,7 @@ rpcb_service_4(struct svc_req *rqstp, SVCXPRT *transp)
|
|
|
bec77d |
case RPCBPROC_INDIRECT:
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr, "RPCBPROC_INDIRECT\n");
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "RPCBPROC_INDIRECT\n");
|
|
|
bec77d |
#endif
|
|
|
bec77d |
rpcbproc_callit_com(rqstp, transp, rqstp->rq_proc, RPCBVERS4);
|
|
|
bec77d |
return;
|
|
|
bec77d |
@@ -154,7 +154,7 @@ rpcb_service_4(struct svc_req *rqstp, SVCXPRT *transp)
|
|
|
bec77d |
case RPCBPROC_BCAST:
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr, "RPCBPROC_BCAST\n");
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "RPCBPROC_BCAST\n");
|
|
|
bec77d |
#endif
|
|
|
bec77d |
rpcbproc_callit_com(rqstp, transp, rqstp->rq_proc, RPCBVERS4);
|
|
|
bec77d |
return;
|
|
|
bec77d |
@@ -162,7 +162,7 @@ rpcb_service_4(struct svc_req *rqstp, SVCXPRT *transp)
|
|
|
bec77d |
case RPCBPROC_GETTIME:
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr, "RPCBPROC_GETTIME\n");
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "RPCBPROC_GETTIME\n");
|
|
|
bec77d |
#endif
|
|
|
bec77d |
xdr_argument = (xdrproc_t)xdr_void;
|
|
|
bec77d |
xdr_result = (xdrproc_t)xdr_u_long;
|
|
|
bec77d |
@@ -172,7 +172,7 @@ rpcb_service_4(struct svc_req *rqstp, SVCXPRT *transp)
|
|
|
bec77d |
case RPCBPROC_UADDR2TADDR:
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr, "RPCBPROC_UADDR2TADDR\n");
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "RPCBPROC_UADDR2TADDR\n");
|
|
|
bec77d |
#endif
|
|
|
bec77d |
xdr_argument = (xdrproc_t)xdr_wrapstring;
|
|
|
bec77d |
xdr_result = (xdrproc_t)xdr_netbuf;
|
|
|
bec77d |
@@ -182,7 +182,7 @@ rpcb_service_4(struct svc_req *rqstp, SVCXPRT *transp)
|
|
|
bec77d |
case RPCBPROC_TADDR2UADDR:
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr, "RPCBPROC_TADDR2UADDR\n");
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "RPCBPROC_TADDR2UADDR\n");
|
|
|
bec77d |
#endif
|
|
|
bec77d |
xdr_argument = (xdrproc_t)xdr_netbuf;
|
|
|
bec77d |
xdr_result = (xdrproc_t)xdr_wrapstring;
|
|
|
bec77d |
@@ -192,7 +192,7 @@ rpcb_service_4(struct svc_req *rqstp, SVCXPRT *transp)
|
|
|
bec77d |
case RPCBPROC_GETADDRLIST:
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr, "RPCBPROC_GETADDRLIST\n");
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "RPCBPROC_GETADDRLIST\n");
|
|
|
bec77d |
#endif
|
|
|
bec77d |
xdr_argument = (xdrproc_t)xdr_rpcb;
|
|
|
bec77d |
xdr_result = (xdrproc_t)xdr_rpcb_entry_list_ptr;
|
|
|
bec77d |
@@ -202,7 +202,7 @@ rpcb_service_4(struct svc_req *rqstp, SVCXPRT *transp)
|
|
|
bec77d |
case RPCBPROC_GETSTAT:
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr, "RPCBPROC_GETSTAT\n");
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "RPCBPROC_GETSTAT\n");
|
|
|
bec77d |
#endif
|
|
|
bec77d |
xdr_argument = (xdrproc_t)xdr_void;
|
|
|
bec77d |
xdr_result = (xdrproc_t)xdr_rpcb_stat_byvers;
|
|
|
bec77d |
@@ -218,7 +218,7 @@ rpcb_service_4(struct svc_req *rqstp, SVCXPRT *transp)
|
|
|
bec77d |
(char *)&argument)) {
|
|
|
bec77d |
svcerr_decode(transp);
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- (void) fprintf(stderr, "rpcbind: could not decode\n");
|
|
|
bec77d |
+ (void) xlog(LOG_DEBUG, "rpcbind: could not decode\n");
|
|
|
bec77d |
return;
|
|
|
bec77d |
}
|
|
|
bec77d |
|
|
|
bec77d |
@@ -236,7 +236,7 @@ rpcb_service_4(struct svc_req *rqstp, SVCXPRT *transp)
|
|
|
bec77d |
result)) {
|
|
|
bec77d |
svcerr_systemerr(transp);
|
|
|
bec77d |
if (debugging) {
|
|
|
bec77d |
- (void) fprintf(stderr, "rpcbind: svc_sendreply\n");
|
|
|
bec77d |
+ (void) xlog(LOG_DEBUG, "rpcbind: svc_sendreply\n");
|
|
|
bec77d |
if (doabort) {
|
|
|
bec77d |
rpcbind_abort();
|
|
|
bec77d |
}
|
|
|
bec77d |
@@ -246,7 +246,7 @@ done:
|
|
|
bec77d |
if (!svc_freeargs(transp, (xdrproc_t) xdr_argument,
|
|
|
bec77d |
(char *)&argument)) {
|
|
|
bec77d |
if (debugging) {
|
|
|
bec77d |
- (void) fprintf(stderr, "unable to free arguments\n");
|
|
|
bec77d |
+ (void) xlog(LOG_DEBUG, "unable to free arguments\n");
|
|
|
bec77d |
if (doabort) {
|
|
|
bec77d |
rpcbind_abort();
|
|
|
bec77d |
}
|
|
|
bec77d |
@@ -277,7 +277,7 @@ rpcbproc_getaddr_4_local(void *arg, struct svc_req *rqstp, SVCXPRT *transp,
|
|
|
bec77d |
|
|
|
bec77d |
uaddr = taddr2uaddr(rpcbind_get_conf(transp->xp_netid),
|
|
|
bec77d |
svc_getrpccaller(transp));
|
|
|
bec77d |
- fprintf(stderr, "RPCB_GETADDR req for (%lu, %lu, %s) from %s: ",
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "RPCB_GETADDR req for (%lu, %lu, %s) from %s: ",
|
|
|
bec77d |
(unsigned long)regp->r_prog, (unsigned long)regp->r_vers,
|
|
|
bec77d |
regp->r_netid, uaddr);
|
|
|
bec77d |
free(uaddr);
|
|
|
bec77d |
@@ -307,7 +307,7 @@ rpcbproc_getversaddr_4_local(void *arg, struct svc_req *rqstp, SVCXPRT *transp,
|
|
|
bec77d |
|
|
|
bec77d |
uaddr = taddr2uaddr(rpcbind_get_conf(transp->xp_netid),
|
|
|
bec77d |
svc_getrpccaller(transp));
|
|
|
bec77d |
- fprintf(stderr, "RPCB_GETVERSADDR rqst for (%lu, %lu, %s)"
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "RPCB_GETVERSADDR rqst for (%lu, %lu, %s)"
|
|
|
bec77d |
" from %s : ",
|
|
|
bec77d |
(unsigned long)regp->r_prog, (unsigned long)regp->r_vers,
|
|
|
bec77d |
regp->r_netid, uaddr);
|
|
|
bec77d |
@@ -353,7 +353,7 @@ rpcbproc_getaddrlist_4_local(void *arg, struct svc_req *rqstp /*__unused*/,
|
|
|
bec77d |
}
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging) {
|
|
|
bec77d |
- fprintf(stderr, "r_addr: %s r_netid: %s nc_protofmly: %s\n",
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "r_addr: %s r_netid: %s nc_protofmly: %s\n",
|
|
|
bec77d |
regp->r_addr, regp->r_netid, reg_nconf->nc_protofmly);
|
|
|
bec77d |
}
|
|
|
bec77d |
#endif
|
|
|
bec77d |
@@ -369,20 +369,20 @@ rpcbproc_getaddrlist_4_local(void *arg, struct svc_req *rqstp /*__unused*/,
|
|
|
bec77d |
}
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr, "\tmerge with: %s\n",
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "\tmerge with: %s\n",
|
|
|
bec77d |
rbl->rpcb_map.r_addr);
|
|
|
bec77d |
#endif
|
|
|
bec77d |
if ((maddr = mergeaddr(transp, rbl->rpcb_map.r_netid,
|
|
|
bec77d |
rbl->rpcb_map.r_addr, saddr)) == NULL) {
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr, " FAILED\n");
|
|
|
bec77d |
+ xlog(LOG_DEBUG, " FAILED\n");
|
|
|
bec77d |
#endif
|
|
|
bec77d |
continue;
|
|
|
bec77d |
} else if (!maddr[0]) {
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr, " SUCCEEDED, but port died - maddr: nullstring\n");
|
|
|
bec77d |
+ xlog(LOG_DEBUG, " SUCCEEDED, but port died - maddr: nullstring\n");
|
|
|
bec77d |
#endif
|
|
|
bec77d |
/* The server died. Unset this combination */
|
|
|
bec77d |
delete_prog(regp->r_prog);
|
|
|
bec77d |
@@ -390,7 +390,7 @@ rpcbproc_getaddrlist_4_local(void *arg, struct svc_req *rqstp /*__unused*/,
|
|
|
bec77d |
}
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr, " SUCCEEDED maddr: %s\n", maddr);
|
|
|
bec77d |
+ xlog(LOG_DEBUG, " SUCCEEDED maddr: %s\n", maddr);
|
|
|
bec77d |
#endif
|
|
|
bec77d |
/*
|
|
|
bec77d |
* Add it to rlist.
|
|
|
bec77d |
@@ -418,7 +418,7 @@ rpcbproc_getaddrlist_4_local(void *arg, struct svc_req *rqstp /*__unused*/,
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging) {
|
|
|
bec77d |
for (rp = rlist; rp; rp = rp->rpcb_entry_next) {
|
|
|
bec77d |
- fprintf(stderr, "\t%s %s\n", rp->rpcb_entry_map.r_maddr,
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "\t%s %s\n", rp->rpcb_entry_map.r_maddr,
|
|
|
bec77d |
rp->rpcb_entry_map.r_nc_proto);
|
|
|
bec77d |
}
|
|
|
bec77d |
}
|
|
|
bec77d |
diff --git a/src/rpcb_svc_com.c b/src/rpcb_svc_com.c
|
|
|
bec77d |
index 69a6d2d..3716f04 100644
|
|
|
bec77d |
--- a/src/rpcb_svc_com.c
|
|
|
bec77d |
+++ b/src/rpcb_svc_com.c
|
|
|
bec77d |
@@ -137,14 +137,14 @@ rpcbproc_set_com(void *arg, struct svc_req *rqstp /*__unused*/, SVCXPRT *transp,
|
|
|
bec77d |
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr, "RPCB_SET request for (%lu, %lu, %s, %s) : ",
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "RPCB_SET request for (%lu, %lu, %s, %s) : ",
|
|
|
bec77d |
(unsigned long)regp->r_prog, (unsigned long)regp->r_vers,
|
|
|
bec77d |
regp->r_netid, regp->r_addr);
|
|
|
bec77d |
#endif
|
|
|
bec77d |
ans = map_set(regp, getowner(transp, owner, sizeof owner));
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr, "%s\n", ans == TRUE ? "succeeded" : "failed");
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "RPCB_SET: %s", ans == TRUE ? "succeeded" : "failed");
|
|
|
bec77d |
#endif
|
|
|
bec77d |
/* XXX: should have used some defined constant here */
|
|
|
bec77d |
rpcbs_set(rpcbversnum - 2, ans);
|
|
|
bec77d |
@@ -225,7 +225,7 @@ rpcbproc_unset_com(void *arg, struct svc_req *rqstp /*__unused*/, SVCXPRT *trans
|
|
|
bec77d |
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr, "RPCB_UNSET request for (%lu, %lu, %s) : ",
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "RPCB_UNSET request for (%lu, %lu, %s) : ",
|
|
|
bec77d |
(unsigned long)regp->r_prog, (unsigned long)regp->r_vers,
|
|
|
bec77d |
regp->r_netid);
|
|
|
bec77d |
#endif
|
|
|
bec77d |
@@ -233,7 +233,7 @@ rpcbproc_unset_com(void *arg, struct svc_req *rqstp /*__unused*/, SVCXPRT *trans
|
|
|
bec77d |
ans = map_unset(regp, getowner(transp, owner, sizeof owner));
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr, "%s\n", ans == TRUE ? "succeeded" : "failed");
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "RPCB_UNSET: %s", ans == TRUE ? "succeeded" : "failed");
|
|
|
bec77d |
#endif
|
|
|
bec77d |
/* XXX: should have used some defined constant here */
|
|
|
bec77d |
rpcbs_unset(rpcbversnum - 2, ans);
|
|
|
bec77d |
@@ -264,9 +264,9 @@ map_unset(RPCB *regp, char *owner)
|
|
|
bec77d |
* if superuser or the owner itself.
|
|
|
bec77d |
*/
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
- fprintf(stderr,"Suppression RPC_UNSET(map_unset)\n ");
|
|
|
bec77d |
- fprintf(stderr,"rbl->rpcb_map.r_owner=%s\n ",rbl->rpcb_map.r_owner);
|
|
|
bec77d |
- fprintf(stderr,"owner=%s\n ",owner);
|
|
|
bec77d |
+ xlog(LOG_DEBUG,"Suppression RPC_UNSET(map_unset) ");
|
|
|
bec77d |
+ xlog(LOG_DEBUG,"rbl->rpcb_map.r_owner=%s ",rbl->rpcb_map.r_owner);
|
|
|
bec77d |
+ xlog(LOG_DEBUG,"owner=%s ",owner);
|
|
|
bec77d |
#endif
|
|
|
bec77d |
if (strcmp(owner, "superuser") &&
|
|
|
bec77d |
strcmp(rbl->rpcb_map.r_owner, owner))
|
|
|
bec77d |
@@ -349,7 +349,7 @@ rpcbproc_getaddr_com(RPCB *regp, struct svc_req *rqstp /*__unused*/,
|
|
|
bec77d |
}
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr, "getaddr: %s\n", uaddr);
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "getaddr: %s", uaddr);
|
|
|
bec77d |
#endif
|
|
|
bec77d |
/* XXX: should have used some defined constant here */
|
|
|
bec77d |
rpcbs_getaddr(rpcbversnum - 2, regp->r_prog, regp->r_vers,
|
|
|
bec77d |
@@ -506,7 +506,7 @@ create_rmtcall_fd(struct netconfig *nconf)
|
|
|
bec77d |
|
|
|
bec77d |
if ((fd = __rpc_nconf2fd(nconf)) == -1) {
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr,
|
|
|
bec77d |
+ xlog(LOG_DEBUG,
|
|
|
bec77d |
"create_rmtcall_fd: couldn't open \"%s\" (errno %d)\n",
|
|
|
bec77d |
nconf->nc_device, errno);
|
|
|
bec77d |
return (-1);
|
|
|
bec77d |
@@ -514,7 +514,7 @@ create_rmtcall_fd(struct netconfig *nconf)
|
|
|
bec77d |
xprt = svc_tli_create(fd, 0, (struct t_bind *) 0, 0, 0);
|
|
|
bec77d |
if (xprt == NULL) {
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr,
|
|
|
bec77d |
+ xlog(LOG_DEBUG,
|
|
|
bec77d |
"create_rmtcall_fd: svc_tli_create failed\n");
|
|
|
bec77d |
return (-1);
|
|
|
bec77d |
}
|
|
|
bec77d |
@@ -656,7 +656,7 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
|
|
|
bec77d |
#endif /* notyet */
|
|
|
bec77d |
if (buf_alloc == NULL) {
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr,
|
|
|
bec77d |
+ xlog(LOG_DEBUG,
|
|
|
bec77d |
"rpcbproc_callit_com: No Memory!\n");
|
|
|
bec77d |
if (reply_type == RPCBPROC_INDIRECT)
|
|
|
bec77d |
svcerr_systemerr(transp);
|
|
|
bec77d |
@@ -672,7 +672,7 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
|
|
|
bec77d |
if (reply_type == RPCBPROC_INDIRECT)
|
|
|
bec77d |
svcerr_decode(transp);
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr,
|
|
|
bec77d |
+ xlog(LOG_DEBUG,
|
|
|
bec77d |
"rpcbproc_callit_com: svc_getargs failed\n");
|
|
|
bec77d |
goto error;
|
|
|
bec77d |
}
|
|
|
bec77d |
@@ -686,7 +686,7 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging) {
|
|
|
bec77d |
uaddr = taddr2uaddr(rpcbind_get_conf(transp->xp_netid), caller);
|
|
|
bec77d |
- fprintf(stderr, "%s %s req for (%lu, %lu, %lu, %s) from %s : ",
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "%s %s req for (%lu, %lu, %lu, %s) from %s : ",
|
|
|
bec77d |
versnum == PMAPVERS ? "pmap_rmtcall" :
|
|
|
bec77d |
versnum == RPCBVERS ? "rpcb_rmtcall" :
|
|
|
bec77d |
versnum == RPCBVERS4 ? "rpcb_indirect" : "unknown",
|
|
|
bec77d |
@@ -707,7 +707,7 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
|
|
|
bec77d |
if (rbl == (rpcblist_ptr)NULL) {
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr, "not found\n");
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "not found\n");
|
|
|
bec77d |
#endif
|
|
|
bec77d |
if (reply_type == RPCBPROC_INDIRECT)
|
|
|
bec77d |
svcerr_noprog(transp);
|
|
|
bec77d |
@@ -726,7 +726,7 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
|
|
|
bec77d |
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr, "found at uaddr %s\n", rbl->rpcb_map.r_addr);
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "found at uaddr %s\n", rbl->rpcb_map.r_addr);
|
|
|
bec77d |
#endif
|
|
|
bec77d |
/*
|
|
|
bec77d |
* Check whether this entry is valid and a server is present
|
|
|
bec77d |
@@ -750,14 +750,14 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
|
|
|
bec77d |
if (reply_type == RPCBPROC_INDIRECT)
|
|
|
bec77d |
svcerr_systemerr(transp);
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr,
|
|
|
bec77d |
+ xlog(LOG_DEBUG,
|
|
|
bec77d |
"rpcbproc_callit_com: rpcbind_get_conf failed\n");
|
|
|
bec77d |
goto error;
|
|
|
bec77d |
}
|
|
|
bec77d |
localsa = local_sa(((struct sockaddr *)caller->buf)->sa_family);
|
|
|
bec77d |
if (localsa == NULL) {
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr,
|
|
|
bec77d |
+ xlog(LOG_DEBUG,
|
|
|
bec77d |
"rpcbproc_callit_com: no local address\n");
|
|
|
bec77d |
goto error;
|
|
|
bec77d |
}
|
|
|
bec77d |
@@ -780,7 +780,7 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
|
|
|
bec77d |
nconf->nc_netid);
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr, "merged uaddr %s\n", m_uaddr);
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "merged uaddr %s\n", m_uaddr);
|
|
|
bec77d |
#endif
|
|
|
bec77d |
if ((fd = find_rmtcallfd_by_netid(nconf->nc_netid)) == -1) {
|
|
|
bec77d |
if (reply_type == RPCBPROC_INDIRECT)
|
|
|
bec77d |
@@ -800,20 +800,20 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
|
|
|
bec77d |
* beat on it any more.
|
|
|
bec77d |
*/
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr,
|
|
|
bec77d |
+ xlog(LOG_DEBUG,
|
|
|
bec77d |
"rpcbproc_callit_com: duplicate request\n");
|
|
|
bec77d |
goto error;
|
|
|
bec77d |
case -1:
|
|
|
bec77d |
/* forward_register failed. Perhaps no memory. */
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr,
|
|
|
bec77d |
+ xlog(LOG_DEBUG,
|
|
|
bec77d |
"rpcbproc_callit_com: forward_register failed\n");
|
|
|
bec77d |
goto error;
|
|
|
bec77d |
}
|
|
|
bec77d |
|
|
|
bec77d |
#ifdef DEBUG_RMTCALL
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr,
|
|
|
bec77d |
+ xlog(LOG_DEBUG,
|
|
|
bec77d |
"rpcbproc_callit_com: original XID %x, new XID %x\n",
|
|
|
bec77d |
*xidp, call_msg.rm_xid);
|
|
|
bec77d |
#endif
|
|
|
bec77d |
@@ -831,7 +831,7 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
|
|
|
bec77d |
if (reply_type == RPCBPROC_INDIRECT)
|
|
|
bec77d |
svcerr_systemerr(transp);
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr,
|
|
|
bec77d |
+ xlog(LOG_DEBUG,
|
|
|
bec77d |
"rpcbproc_callit_com: No memory!\n");
|
|
|
bec77d |
goto error;
|
|
|
bec77d |
}
|
|
|
bec77d |
@@ -843,7 +843,7 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
|
|
|
bec77d |
if (reply_type == RPCBPROC_INDIRECT)
|
|
|
bec77d |
svcerr_systemerr(transp);
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr,
|
|
|
bec77d |
+ xlog(LOG_DEBUG,
|
|
|
bec77d |
"rpcbproc_callit_com: xdr_callhdr failed\n");
|
|
|
bec77d |
goto error;
|
|
|
bec77d |
}
|
|
|
bec77d |
@@ -851,7 +851,7 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
|
|
|
bec77d |
if (reply_type == RPCBPROC_INDIRECT)
|
|
|
bec77d |
svcerr_systemerr(transp);
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr,
|
|
|
bec77d |
+ xlog(LOG_DEBUG,
|
|
|
bec77d |
"rpcbproc_callit_com: xdr_u_long failed\n");
|
|
|
bec77d |
goto error;
|
|
|
bec77d |
}
|
|
|
bec77d |
@@ -870,7 +870,7 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
|
|
|
bec77d |
} else {
|
|
|
bec77d |
/* we do not support any other authentication scheme */
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr,
|
|
|
bec77d |
+ xlog(LOG_DEBUG,
|
|
|
bec77d |
"rpcbproc_callit_com: oa_flavor != AUTH_NONE and oa_flavor != AUTH_SYS\n");
|
|
|
bec77d |
if (reply_type == RPCBPROC_INDIRECT)
|
|
|
bec77d |
svcerr_weakauth(transp); /* XXX too strong.. */
|
|
|
bec77d |
@@ -880,7 +880,7 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
|
|
|
bec77d |
if (reply_type == RPCBPROC_INDIRECT)
|
|
|
bec77d |
svcerr_systemerr(transp);
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr,
|
|
|
bec77d |
+ xlog(LOG_DEBUG,
|
|
|
bec77d |
"rpcbproc_callit_com: authwhatever_create returned NULL\n");
|
|
|
bec77d |
goto error;
|
|
|
bec77d |
}
|
|
|
bec77d |
@@ -889,7 +889,7 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
|
|
|
bec77d |
svcerr_systemerr(transp);
|
|
|
bec77d |
AUTH_DESTROY(auth);
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr,
|
|
|
bec77d |
+ xlog(LOG_DEBUG,
|
|
|
bec77d |
"rpcbproc_callit_com: AUTH_MARSHALL failed\n");
|
|
|
bec77d |
goto error;
|
|
|
bec77d |
}
|
|
|
bec77d |
@@ -898,7 +898,7 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
|
|
|
bec77d |
if (reply_type == RPCBPROC_INDIRECT)
|
|
|
bec77d |
svcerr_systemerr(transp);
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr,
|
|
|
bec77d |
+ xlog(LOG_DEBUG,
|
|
|
bec77d |
"rpcbproc_callit_com: xdr_opaque_parms failed\n");
|
|
|
bec77d |
goto error;
|
|
|
bec77d |
}
|
|
|
bec77d |
@@ -918,7 +918,7 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
|
|
|
bec77d |
if (sendto(fd, outbufp, outlen, 0, (struct sockaddr *)na->buf, na->len)
|
|
|
bec77d |
!= outlen) {
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr,
|
|
|
bec77d |
+ xlog(LOG_DEBUG,
|
|
|
bec77d |
"rpcbproc_callit_com: sendto failed: errno %d\n", errno);
|
|
|
bec77d |
if (reply_type == RPCBPROC_INDIRECT)
|
|
|
bec77d |
svcerr_systemerr(transp);
|
|
|
bec77d |
@@ -1123,15 +1123,7 @@ my_svc_run()
|
|
|
bec77d |
}
|
|
|
bec77d |
nfds = p - pollfds;
|
|
|
bec77d |
poll_ret = 0;
|
|
|
bec77d |
-#ifdef SVC_RUN_DEBUG
|
|
|
bec77d |
- if (debugging) {
|
|
|
bec77d |
- fprintf(stderr, "polling for read on fd < ");
|
|
|
bec77d |
- for (i = 0, p = pollfds; i < nfds; i++, p++)
|
|
|
bec77d |
- if (p->events)
|
|
|
bec77d |
- fprintf(stderr, "%d ", p->fd);
|
|
|
bec77d |
- fprintf(stderr, ">\n");
|
|
|
bec77d |
- }
|
|
|
bec77d |
-#endif
|
|
|
bec77d |
+
|
|
|
bec77d |
switch (poll_ret = poll(pollfds, nfds, 30 * 1000)) {
|
|
|
bec77d |
case -1:
|
|
|
bec77d |
/*
|
|
|
bec77d |
@@ -1144,15 +1136,6 @@ my_svc_run()
|
|
|
bec77d |
__svc_clean_idle(&cleanfds, 30, FALSE);
|
|
|
bec77d |
continue;
|
|
|
bec77d |
default:
|
|
|
bec77d |
-#ifdef SVC_RUN_DEBUG
|
|
|
bec77d |
- if (debugging) {
|
|
|
bec77d |
- fprintf(stderr, "poll returned read fds < ");
|
|
|
bec77d |
- for (i = 0, p = pollfds; i < nfds; i++, p++)
|
|
|
bec77d |
- if (p->revents)
|
|
|
bec77d |
- fprintf(stderr, "%d ", p->fd);
|
|
|
bec77d |
- fprintf(stderr, ">\n");
|
|
|
bec77d |
- }
|
|
|
bec77d |
-#endif
|
|
|
bec77d |
/*
|
|
|
bec77d |
* If we found as many replies on callback fds
|
|
|
bec77d |
* as the number of descriptors selectable which
|
|
|
bec77d |
@@ -1165,11 +1148,6 @@ my_svc_run()
|
|
|
bec77d |
continue;
|
|
|
bec77d |
svc_getreq_poll(pollfds, poll_ret-check_ret);
|
|
|
bec77d |
}
|
|
|
bec77d |
-#ifdef SVC_RUN_DEBUG
|
|
|
bec77d |
- if (debugging) {
|
|
|
bec77d |
- fprintf(stderr, "svc_maxfd now %u\n", svc_maxfd);
|
|
|
bec77d |
- }
|
|
|
bec77d |
-#endif
|
|
|
bec77d |
}
|
|
|
bec77d |
}
|
|
|
bec77d |
|
|
|
bec77d |
@@ -1189,7 +1167,7 @@ check_rmtcalls(struct pollfd *pfds, int nfds)
|
|
|
bec77d |
ncallbacks_found++;
|
|
|
bec77d |
#ifdef DEBUG_RMTCALL
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr,
|
|
|
bec77d |
+ xlog(LOG_DEBUG,
|
|
|
bec77d |
"my_svc_run: polled on forwarding fd %d, netid %s - calling handle_reply\n",
|
|
|
bec77d |
pfds[j].fd, xprt->xp_netid);
|
|
|
bec77d |
#endif
|
|
|
bec77d |
@@ -1274,7 +1252,7 @@ handle_reply(int fd, SVCXPRT *xprt)
|
|
|
bec77d |
} while (inlen < 0 && errno == EINTR);
|
|
|
bec77d |
if (inlen < 0) {
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr,
|
|
|
bec77d |
+ xlog(LOG_DEBUG,
|
|
|
bec77d |
"handle_reply: recvfrom returned %d, errno %d\n", inlen, errno);
|
|
|
bec77d |
goto done;
|
|
|
bec77d |
}
|
|
|
bec77d |
@@ -1286,14 +1264,14 @@ handle_reply(int fd, SVCXPRT *xprt)
|
|
|
bec77d |
xdrmem_create(&reply_xdrs, buffer, (u_int)inlen, XDR_DECODE);
|
|
|
bec77d |
if (!xdr_replymsg(&reply_xdrs, &reply_msg)) {
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- (void) fprintf(stderr,
|
|
|
bec77d |
+ (void) xlog(LOG_DEBUG,
|
|
|
bec77d |
"handle_reply: xdr_replymsg failed\n");
|
|
|
bec77d |
goto done;
|
|
|
bec77d |
}
|
|
|
bec77d |
fi = forward_find(reply_msg.rm_xid);
|
|
|
bec77d |
#ifdef SVC_RUN_DEBUG
|
|
|
bec77d |
if (debugging) {
|
|
|
bec77d |
- fprintf(stderr, "handle_reply: reply xid: %d fi addr: %p\n",
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "handle_reply: reply xid: %d fi addr: %p\n",
|
|
|
bec77d |
reply_msg.rm_xid, fi);
|
|
|
bec77d |
}
|
|
|
bec77d |
#endif
|
|
|
bec77d |
@@ -1303,7 +1281,7 @@ handle_reply(int fd, SVCXPRT *xprt)
|
|
|
bec77d |
_seterr_reply(&reply_msg, &reply_error);
|
|
|
bec77d |
if (reply_error.re_status != RPC_SUCCESS) {
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- (void) fprintf(stderr, "handle_reply: %s\n",
|
|
|
bec77d |
+ (void) xlog(LOG_DEBUG, "handle_reply: %s\n",
|
|
|
bec77d |
clnt_sperrno(reply_error.re_status));
|
|
|
bec77d |
send_svcsyserr(xprt, fi);
|
|
|
bec77d |
goto done;
|
|
|
bec77d |
@@ -1327,7 +1305,7 @@ done:
|
|
|
bec77d |
if (reply_msg.rm_xid == 0) {
|
|
|
bec77d |
#ifdef SVC_RUN_DEBUG
|
|
|
bec77d |
if (debugging) {
|
|
|
bec77d |
- fprintf(stderr, "handle_reply: NULL xid on exit!\n");
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "handle_reply: NULL xid on exit!\n");
|
|
|
bec77d |
}
|
|
|
bec77d |
#endif
|
|
|
bec77d |
} else
|
|
|
bec77d |
diff --git a/src/rpcbind.c b/src/rpcbind.c
|
|
|
bec77d |
index bf40807..2789baf 100644
|
|
|
bec77d |
--- a/src/rpcbind.c
|
|
|
bec77d |
+++ b/src/rpcbind.c
|
|
|
bec77d |
@@ -72,6 +72,7 @@
|
|
|
bec77d |
#include <errno.h>
|
|
|
bec77d |
#include <nss.h>
|
|
|
bec77d |
#include "rpcbind.h"
|
|
|
bec77d |
+#include "xlog.h"
|
|
|
bec77d |
|
|
|
bec77d |
/*#define RPCBIND_DEBUG*/
|
|
|
bec77d |
|
|
|
bec77d |
@@ -110,6 +111,9 @@ int nhosts = 0;
|
|
|
bec77d |
int on = 1;
|
|
|
bec77d |
int rpcbindlockfd;
|
|
|
bec77d |
|
|
|
bec77d |
+#ifdef LIB_SET_DEBUG
|
|
|
bec77d |
+void libtirpc_set_debug(char *name, int level, int use_stderr);
|
|
|
bec77d |
+#endif
|
|
|
bec77d |
#ifdef WARMSTART
|
|
|
bec77d |
/* Local Variable */
|
|
|
bec77d |
static int warmstart = 0; /* Grab an old copy of registrations. */
|
|
|
bec77d |
@@ -159,7 +163,7 @@ main(int argc, char *argv[])
|
|
|
bec77d |
rl.rlim_cur = 128;
|
|
|
bec77d |
setrlimit(RLIMIT_NOFILE, &rl);
|
|
|
bec77d |
}
|
|
|
bec77d |
- openlog("rpcbind", LOG_CONS, LOG_DAEMON);
|
|
|
bec77d |
+
|
|
|
bec77d |
if (geteuid()) { /* This command allowed only to root */
|
|
|
bec77d |
fprintf(stderr, "Sorry. You are not superuser\n");
|
|
|
bec77d |
exit(1);
|
|
|
bec77d |
@@ -184,7 +188,20 @@ main(int argc, char *argv[])
|
|
|
bec77d |
syslog(LOG_ERR, "%s: can't find local transport\n", argv[0]);
|
|
|
bec77d |
exit(1);
|
|
|
bec77d |
}
|
|
|
bec77d |
-
|
|
|
bec77d |
+ xlog_open("rpcbind");
|
|
|
bec77d |
+ if (dofork) {
|
|
|
bec77d |
+ xlog_syslog(TRUE);
|
|
|
bec77d |
+ xlog_stderr(FALSE);
|
|
|
bec77d |
+ } else {
|
|
|
bec77d |
+ xlog_syslog(FALSE);
|
|
|
bec77d |
+ xlog_stderr(TRUE);
|
|
|
bec77d |
+ }
|
|
|
bec77d |
+ if (debugging) {
|
|
|
bec77d |
+ xlog_config(D_ALL, 1);
|
|
|
bec77d |
+#ifdef LIB_SET_DEBUG
|
|
|
bec77d |
+ libtirpc_set_debug("rpcbind", debugging, (dofork == 0));
|
|
|
bec77d |
+#endif
|
|
|
bec77d |
+ }
|
|
|
bec77d |
rpc_control(RPC_SVC_CONNMAXREC_SET, &maxrec);
|
|
|
bec77d |
|
|
|
bec77d |
init_transport(nconf);
|
|
|
bec77d |
@@ -213,18 +230,16 @@ main(int argc, char *argv[])
|
|
|
bec77d |
(void) signal(SIGUSR1, SIG_IGN);
|
|
|
bec77d |
(void) signal(SIGUSR2, SIG_IGN);
|
|
|
bec77d |
|
|
|
bec77d |
- if (debugging) {
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
- printf("rpcbind debugging enabled.");
|
|
|
bec77d |
- if (doabort) {
|
|
|
bec77d |
- printf(" Will abort on errors!\n");
|
|
|
bec77d |
- } else {
|
|
|
bec77d |
- printf("\n");
|
|
|
bec77d |
- }
|
|
|
bec77d |
+ if (debugging) {
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "debugging enabled.");
|
|
|
bec77d |
+ if (doabort)
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "Will abort on errors!\n");
|
|
|
bec77d |
+ }
|
|
|
bec77d |
#endif
|
|
|
bec77d |
- } else if (dofork) {
|
|
|
bec77d |
+ if (dofork) {
|
|
|
bec77d |
if (daemon(0, 0))
|
|
|
bec77d |
- err(1, "fork failed");
|
|
|
bec77d |
+ err(1, "fork failed");
|
|
|
bec77d |
}
|
|
|
bec77d |
|
|
|
bec77d |
if (runasdaemon || rpcbinduser) {
|
|
|
bec77d |
@@ -306,11 +321,11 @@ init_transport(struct netconfig *nconf)
|
|
|
bec77d |
int i;
|
|
|
bec77d |
char **s;
|
|
|
bec77d |
|
|
|
bec77d |
- (void) fprintf(stderr, "%s: %ld lookup routines :\n",
|
|
|
bec77d |
+ (void) xlog(LOG_DEBUG, "%s: %ld lookup routines :\n",
|
|
|
bec77d |
nconf->nc_netid, nconf->nc_nlookups);
|
|
|
bec77d |
for (i = 0, s = nconf->nc_lookups; i < nconf->nc_nlookups;
|
|
|
bec77d |
i++, s++)
|
|
|
bec77d |
- fprintf(stderr, "[%d] - %s\n", i, *s);
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "[%d] - %s\n", i, *s);
|
|
|
bec77d |
}
|
|
|
bec77d |
#endif
|
|
|
bec77d |
if (!__rpc_nconf2sockinfo(nconf, &si)) {
|
|
|
bec77d |
@@ -540,7 +555,7 @@ init_transport(struct netconfig *nconf)
|
|
|
bec77d |
}
|
|
|
bec77d |
nb.len = nb.maxlen = sa_size;
|
|
|
bec77d |
uaddr = taddr2uaddr(nconf, &nb);
|
|
|
bec77d |
- (void) fprintf(stderr,
|
|
|
bec77d |
+ (void) xlog(LOG_DEBUG,
|
|
|
bec77d |
"rpcbind : my address is %s\n", uaddr);
|
|
|
bec77d |
(void) free(uaddr);
|
|
|
bec77d |
}
|
|
|
bec77d |
@@ -617,7 +632,7 @@ init_transport(struct netconfig *nconf)
|
|
|
bec77d |
}
|
|
|
bec77d |
nb.len = nb.maxlen = sa_size2;
|
|
|
bec77d |
uaddr = taddr2uaddr(nconf, &nb);
|
|
|
bec77d |
- (void) fprintf(stderr, "rpcbind : my address is %s\n",
|
|
|
bec77d |
+ (void) xlog(LOG_DEBUG, "rpcbind : my address is %s\n",
|
|
|
bec77d |
uaddr);
|
|
|
bec77d |
(void) free(uaddr);
|
|
|
bec77d |
}
|
|
|
bec77d |
@@ -724,13 +739,13 @@ got_socket:
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging) {
|
|
|
bec77d |
if (status < 0) {
|
|
|
bec77d |
- fprintf(stderr, "Error in finding bind status for %s\n",
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "Error in finding bind status for %s\n",
|
|
|
bec77d |
nconf->nc_netid);
|
|
|
bec77d |
} else if (status == 0) {
|
|
|
bec77d |
- fprintf(stderr, "check binding for %s\n",
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "check binding for %s\n",
|
|
|
bec77d |
nconf->nc_netid);
|
|
|
bec77d |
} else if (status > 0) {
|
|
|
bec77d |
- fprintf(stderr, "No check binding for %s\n",
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "No check binding for %s\n",
|
|
|
bec77d |
nconf->nc_netid);
|
|
|
bec77d |
}
|
|
|
bec77d |
}
|
|
|
bec77d |
@@ -744,11 +759,11 @@ got_socket:
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging) {
|
|
|
bec77d |
if (status < 0) {
|
|
|
bec77d |
- fprintf(stderr,
|
|
|
bec77d |
+ xlog(LOG_DEBUG,
|
|
|
bec77d |
"Could not create rmtcall fd for %s\n",
|
|
|
bec77d |
nconf->nc_netid);
|
|
|
bec77d |
} else {
|
|
|
bec77d |
- fprintf(stderr, "rmtcall fd for %s is %d\n",
|
|
|
bec77d |
+ xlog(LOG_DEBUG, "rmtcall fd for %s is %d\n",
|
|
|
bec77d |
nconf->nc_netid, status);
|
|
|
bec77d |
}
|
|
|
bec77d |
}
|
|
|
bec77d |
@@ -773,8 +788,8 @@ rbllist_add(rpcprog_t prog, rpcvers_t vers, struct netconfig *nconf,
|
|
|
bec77d |
}
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging){
|
|
|
bec77d |
- fprintf(stderr,"FUNCTION rbllist_add");
|
|
|
bec77d |
- fprintf(stderr,"Add the prog %lu vers %lu to the rpcbind list\n",
|
|
|
bec77d |
+ xlog(LOG_DEBUG,"FUNCTION rbllist_add");
|
|
|
bec77d |
+ xlog(LOG_DEBUG,"Add the prog %lu vers %lu to the rpcbind list",
|
|
|
bec77d |
(ulong)prog, (ulong)vers);
|
|
|
bec77d |
}
|
|
|
bec77d |
#endif
|
|
|
bec77d |
@@ -824,7 +839,7 @@ parseargs(int argc, char *argv[])
|
|
|
bec77d |
break; /* errors; for rpcbind developers */
|
|
|
bec77d |
/* only! */
|
|
|
bec77d |
case 'd':
|
|
|
bec77d |
- debugging = 1;
|
|
|
bec77d |
+ debugging++;
|
|
|
bec77d |
break;
|
|
|
bec77d |
case 'h':
|
|
|
bec77d |
++nhosts;
|
|
|
bec77d |
diff --git a/src/security.c b/src/security.c
|
|
|
bec77d |
index d272f74..70edef4 100644
|
|
|
bec77d |
--- a/src/security.c
|
|
|
bec77d |
+++ b/src/security.c
|
|
|
bec77d |
@@ -80,7 +80,7 @@ check_access(SVCXPRT *xprt, rpcproc_t proc, rpcprog_t prog, unsigned int rpcbver
|
|
|
bec77d |
if (!insecure && !is_loopback(caller)) {
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr, " declined (non-loopback sender) \n");
|
|
|
bec77d |
+ xlog(LOG_DEBUG, " declined (non-loopback sender) \n");
|
|
|
bec77d |
#endif
|
|
|
bec77d |
if (verboselog)
|
|
|
bec77d |
logit(log_severity, addr, proc, prog,
|
|
|
bec77d |
@@ -134,7 +134,7 @@ is_loopback(struct netbuf *nbuf)
|
|
|
bec77d |
sin = (struct sockaddr_in *)addr;
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr,
|
|
|
bec77d |
+ xlog(LOG_DEBUG,
|
|
|
bec77d |
"Checking caller's adress (port = %d)\n",
|
|
|
bec77d |
ntohs(sin->sin_port));
|
|
|
bec77d |
#endif
|
|
|
bec77d |
@@ -146,7 +146,7 @@ is_loopback(struct netbuf *nbuf)
|
|
|
bec77d |
sin6 = (struct sockaddr_in6 *)addr;
|
|
|
bec77d |
#ifdef RPCBIND_DEBUG
|
|
|
bec77d |
if (debugging)
|
|
|
bec77d |
- fprintf(stderr,
|
|
|
bec77d |
+ xlog(LOG_DEBUG,
|
|
|
bec77d |
"Checking caller's adress (port = %d)\n",
|
|
|
bec77d |
ntohs(sin6->sin6_port));
|
|
|
bec77d |
#endif
|
|
|
bec77d |
diff --git a/src/xlog.c b/src/xlog.c
|
|
|
bec77d |
new file mode 100644
|
|
|
bec77d |
index 0000000..ab6c717
|
|
|
bec77d |
--- /dev/null
|
|
|
bec77d |
+++ b/src/xlog.c
|
|
|
bec77d |
@@ -0,0 +1,234 @@
|
|
|
bec77d |
+/*
|
|
|
bec77d |
+ * support/nfs/xlog.c
|
|
|
bec77d |
+ *
|
|
|
bec77d |
+ * This module handles the logging of requests.
|
|
|
bec77d |
+ *
|
|
|
bec77d |
+ * TODO: Merge the two "XXX_log() calls.
|
|
|
bec77d |
+ *
|
|
|
bec77d |
+ * Authors: Donald J. Becker, <becker@super.org>
|
|
|
bec77d |
+ * Rick Sladkey, <jrs@world.std.com>
|
|
|
bec77d |
+ * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
|
|
|
bec77d |
+ * Olaf Kirch, <okir@monad.swb.de>
|
|
|
bec77d |
+ *
|
|
|
bec77d |
+ * This software maybe be used for any purpose provided
|
|
|
bec77d |
+ * the above copyright notice is retained. It is supplied
|
|
|
bec77d |
+ * as is, with no warranty expressed or implied.
|
|
|
bec77d |
+ */
|
|
|
bec77d |
+
|
|
|
bec77d |
+#ifdef HAVE_CONFIG_H
|
|
|
bec77d |
+#include <config.h>
|
|
|
bec77d |
+#endif
|
|
|
bec77d |
+
|
|
|
bec77d |
+#include <unistd.h>
|
|
|
bec77d |
+#include <signal.h>
|
|
|
bec77d |
+#include <time.h>
|
|
|
bec77d |
+#include <stdlib.h>
|
|
|
bec77d |
+#include <string.h>
|
|
|
bec77d |
+#include <stdio.h>
|
|
|
bec77d |
+#include <stdarg.h>
|
|
|
bec77d |
+#include <syslog.h>
|
|
|
bec77d |
+#include <errno.h>
|
|
|
bec77d |
+#include "xlog.h"
|
|
|
bec77d |
+
|
|
|
bec77d |
+#undef VERBOSE_PRINTF
|
|
|
bec77d |
+
|
|
|
bec77d |
+static int log_stderr = 1;
|
|
|
bec77d |
+static int log_syslog = 1;
|
|
|
bec77d |
+static int logging = 0; /* enable/disable DEBUG logs */
|
|
|
bec77d |
+static int logmask = 0; /* What will be logged */
|
|
|
bec77d |
+static char log_name[256]; /* name of this program */
|
|
|
bec77d |
+static int log_pid = -1; /* PID of this program */
|
|
|
bec77d |
+
|
|
|
bec77d |
+int export_errno = 0;
|
|
|
bec77d |
+
|
|
|
bec77d |
+static void xlog_toggle(int sig);
|
|
|
bec77d |
+static struct xlog_debugfac debugnames[] = {
|
|
|
bec77d |
+ { "general", D_GENERAL, },
|
|
|
bec77d |
+ { "call", D_CALL, },
|
|
|
bec77d |
+ { "auth", D_AUTH, },
|
|
|
bec77d |
+ { "parse", D_PARSE, },
|
|
|
bec77d |
+ { "all", D_ALL, },
|
|
|
bec77d |
+ { NULL, 0, },
|
|
|
bec77d |
+};
|
|
|
bec77d |
+
|
|
|
bec77d |
+void
|
|
|
bec77d |
+xlog_open(char *progname)
|
|
|
bec77d |
+{
|
|
|
bec77d |
+ openlog(progname, LOG_PID, LOG_DAEMON);
|
|
|
bec77d |
+
|
|
|
bec77d |
+ strncpy(log_name, progname, sizeof (log_name) - 1);
|
|
|
bec77d |
+ log_name [sizeof (log_name) - 1] = '\0';
|
|
|
bec77d |
+ log_pid = getpid();
|
|
|
bec77d |
+
|
|
|
bec77d |
+ signal(SIGUSR1, xlog_toggle);
|
|
|
bec77d |
+ signal(SIGUSR2, xlog_toggle);
|
|
|
bec77d |
+}
|
|
|
bec77d |
+
|
|
|
bec77d |
+void
|
|
|
bec77d |
+xlog_stderr(int on)
|
|
|
bec77d |
+{
|
|
|
bec77d |
+ log_stderr = on;
|
|
|
bec77d |
+}
|
|
|
bec77d |
+
|
|
|
bec77d |
+void
|
|
|
bec77d |
+xlog_syslog(int on)
|
|
|
bec77d |
+{
|
|
|
bec77d |
+ log_syslog = on;
|
|
|
bec77d |
+}
|
|
|
bec77d |
+
|
|
|
bec77d |
+static void
|
|
|
bec77d |
+xlog_toggle(int sig)
|
|
|
bec77d |
+{
|
|
|
bec77d |
+ unsigned int tmp, i;
|
|
|
bec77d |
+
|
|
|
bec77d |
+ if (sig == SIGUSR1) {
|
|
|
bec77d |
+ if ((logmask & D_ALL) && !logging) {
|
|
|
bec77d |
+ xlog(D_GENERAL, "turned on logging");
|
|
|
bec77d |
+ logging = 1;
|
|
|
bec77d |
+ return;
|
|
|
bec77d |
+ }
|
|
|
bec77d |
+ tmp = ~logmask;
|
|
|
bec77d |
+ logmask |= ((logmask & D_ALL) << 1) | D_GENERAL;
|
|
|
bec77d |
+ for (i = -1, tmp &= logmask; tmp; tmp >>= 1, i++)
|
|
|
bec77d |
+ if (tmp & 1)
|
|
|
bec77d |
+ xlog(D_GENERAL,
|
|
|
bec77d |
+ "turned on logging level %d", i);
|
|
|
bec77d |
+ } else {
|
|
|
bec77d |
+ xlog(D_GENERAL, "turned off logging");
|
|
|
bec77d |
+ logging = 0;
|
|
|
bec77d |
+ }
|
|
|
bec77d |
+ signal(sig, xlog_toggle);
|
|
|
bec77d |
+}
|
|
|
bec77d |
+
|
|
|
bec77d |
+void
|
|
|
bec77d |
+xlog_config(int fac, int on)
|
|
|
bec77d |
+{
|
|
|
bec77d |
+ if (on)
|
|
|
bec77d |
+ logmask |= fac;
|
|
|
bec77d |
+ else
|
|
|
bec77d |
+ logmask &= ~fac;
|
|
|
bec77d |
+ if (on)
|
|
|
bec77d |
+ logging = 1;
|
|
|
bec77d |
+}
|
|
|
bec77d |
+
|
|
|
bec77d |
+void
|
|
|
bec77d |
+xlog_sconfig(char *kind, int on)
|
|
|
bec77d |
+{
|
|
|
bec77d |
+ struct xlog_debugfac *tbl = debugnames;
|
|
|
bec77d |
+
|
|
|
bec77d |
+ while (tbl->df_name != NULL && strcasecmp(tbl->df_name, kind))
|
|
|
bec77d |
+ tbl++;
|
|
|
bec77d |
+ if (!tbl->df_name) {
|
|
|
bec77d |
+ xlog (L_WARNING, "Invalid debug facility: %s\n", kind);
|
|
|
bec77d |
+ return;
|
|
|
bec77d |
+ }
|
|
|
bec77d |
+ xlog_config(tbl->df_fac, on);
|
|
|
bec77d |
+}
|
|
|
bec77d |
+
|
|
|
bec77d |
+int
|
|
|
bec77d |
+xlog_enabled(int fac)
|
|
|
bec77d |
+{
|
|
|
bec77d |
+ return (logging && (fac & logmask));
|
|
|
bec77d |
+}
|
|
|
bec77d |
+
|
|
|
bec77d |
+
|
|
|
bec77d |
+/* Write something to the system logfile and/or stderr */
|
|
|
bec77d |
+void
|
|
|
bec77d |
+xlog_backend(int kind, const char *fmt, va_list args)
|
|
|
bec77d |
+{
|
|
|
bec77d |
+ va_list args2;
|
|
|
bec77d |
+
|
|
|
bec77d |
+ if (!(kind & (L_ALL)) && !(logging && (kind & logmask)))
|
|
|
bec77d |
+ return;
|
|
|
bec77d |
+
|
|
|
bec77d |
+ if (log_stderr)
|
|
|
bec77d |
+ va_copy(args2, args);
|
|
|
bec77d |
+
|
|
|
bec77d |
+ if (log_syslog) {
|
|
|
bec77d |
+ switch (kind) {
|
|
|
bec77d |
+ case L_FATAL:
|
|
|
bec77d |
+ vsyslog(LOG_ERR, fmt, args);
|
|
|
bec77d |
+ break;
|
|
|
bec77d |
+ case L_ERROR:
|
|
|
bec77d |
+ vsyslog(LOG_ERR, fmt, args);
|
|
|
bec77d |
+ break;
|
|
|
bec77d |
+ case L_WARNING:
|
|
|
bec77d |
+ vsyslog(LOG_WARNING, fmt, args);
|
|
|
bec77d |
+ break;
|
|
|
bec77d |
+ case L_NOTICE:
|
|
|
bec77d |
+ vsyslog(LOG_NOTICE, fmt, args);
|
|
|
bec77d |
+ break;
|
|
|
bec77d |
+ default:
|
|
|
bec77d |
+ if (!log_stderr)
|
|
|
bec77d |
+ vsyslog(LOG_INFO, fmt, args);
|
|
|
bec77d |
+ break;
|
|
|
bec77d |
+ }
|
|
|
bec77d |
+ }
|
|
|
bec77d |
+
|
|
|
bec77d |
+ if (log_stderr) {
|
|
|
bec77d |
+#ifdef VERBOSE_PRINTF
|
|
|
bec77d |
+ time_t now;
|
|
|
bec77d |
+ struct tm *tm;
|
|
|
bec77d |
+
|
|
|
bec77d |
+ time(&now;;
|
|
|
bec77d |
+ tm = localtime(&now;;
|
|
|
bec77d |
+ fprintf(stderr, "%s[%d] %04d-%02d-%02d %02d:%02d:%02d ",
|
|
|
bec77d |
+ log_name, log_pid,
|
|
|
bec77d |
+ tm->tm_year+1900, tm->tm_mon + 1, tm->tm_mday,
|
|
|
bec77d |
+ tm->tm_hour, tm->tm_min, tm->tm_sec);
|
|
|
bec77d |
+#else
|
|
|
bec77d |
+ fprintf(stderr, "%s: ", log_name);
|
|
|
bec77d |
+#endif
|
|
|
bec77d |
+ vfprintf(stderr, fmt, args2);
|
|
|
bec77d |
+ fprintf(stderr, "\n");
|
|
|
bec77d |
+ va_end(args2);
|
|
|
bec77d |
+ }
|
|
|
bec77d |
+
|
|
|
bec77d |
+ if (kind == L_FATAL)
|
|
|
bec77d |
+ exit(1);
|
|
|
bec77d |
+}
|
|
|
bec77d |
+
|
|
|
bec77d |
+void
|
|
|
bec77d |
+xlog(int kind, const char* fmt, ...)
|
|
|
bec77d |
+{
|
|
|
bec77d |
+ va_list args;
|
|
|
bec77d |
+
|
|
|
bec77d |
+ if (kind & (L_ERROR|D_GENERAL))
|
|
|
bec77d |
+ export_errno = 1;
|
|
|
bec77d |
+
|
|
|
bec77d |
+ va_start(args, fmt);
|
|
|
bec77d |
+ xlog_backend(kind, fmt, args);
|
|
|
bec77d |
+ va_end(args);
|
|
|
bec77d |
+}
|
|
|
bec77d |
+
|
|
|
bec77d |
+void
|
|
|
bec77d |
+xlog_warn(const char* fmt, ...)
|
|
|
bec77d |
+{
|
|
|
bec77d |
+ va_list args;
|
|
|
bec77d |
+
|
|
|
bec77d |
+ va_start(args, fmt);
|
|
|
bec77d |
+ xlog_backend(L_WARNING, fmt, args);
|
|
|
bec77d |
+ va_end(args);
|
|
|
bec77d |
+}
|
|
|
bec77d |
+
|
|
|
bec77d |
+
|
|
|
bec77d |
+void
|
|
|
bec77d |
+xlog_err(const char* fmt, ...)
|
|
|
bec77d |
+{
|
|
|
bec77d |
+ va_list args;
|
|
|
bec77d |
+
|
|
|
bec77d |
+ va_start(args, fmt);
|
|
|
bec77d |
+ xlog_backend(L_FATAL, fmt, args);
|
|
|
bec77d |
+ va_end(args);
|
|
|
bec77d |
+}
|
|
|
bec77d |
+
|
|
|
bec77d |
+void
|
|
|
bec77d |
+xlog_errno(int err, const char *fmt, ...)
|
|
|
bec77d |
+{
|
|
|
bec77d |
+ va_list args;
|
|
|
bec77d |
+
|
|
|
bec77d |
+ errno = err;
|
|
|
bec77d |
+ va_start(args, fmt);
|
|
|
bec77d |
+ xlog_backend(L_FATAL, fmt, args);
|
|
|
bec77d |
+ va_end(args);
|
|
|
bec77d |
+}
|
|
|
bec77d |
diff --git a/src/xlog.h b/src/xlog.h
|
|
|
bec77d |
new file mode 100644
|
|
|
bec77d |
index 0000000..a57b96c
|
|
|
bec77d |
--- /dev/null
|
|
|
bec77d |
+++ b/src/xlog.h
|
|
|
bec77d |
@@ -0,0 +1,52 @@
|
|
|
bec77d |
+/*
|
|
|
bec77d |
+ * xlog Logging functionality
|
|
|
bec77d |
+ *
|
|
|
bec77d |
+ * Copyright (C) 1995 Olaf Kirch <okir@monad.swb.de>
|
|
|
bec77d |
+ */
|
|
|
bec77d |
+
|
|
|
bec77d |
+#ifndef XLOG_H
|
|
|
bec77d |
+#define XLOG_H
|
|
|
bec77d |
+
|
|
|
bec77d |
+#include <stdarg.h>
|
|
|
bec77d |
+
|
|
|
bec77d |
+/* These are logged always. L_FATAL also does exit(1) */
|
|
|
bec77d |
+#define L_FATAL 0x0100
|
|
|
bec77d |
+#define L_ERROR 0x0200
|
|
|
bec77d |
+#define L_WARNING 0x0400
|
|
|
bec77d |
+#define L_NOTICE 0x0800
|
|
|
bec77d |
+#define L_ALL 0xFF00
|
|
|
bec77d |
+
|
|
|
bec77d |
+/* These are logged if enabled with xlog_[s]config */
|
|
|
bec77d |
+/* NB: code does not expect ORing together D_ and L_ */
|
|
|
bec77d |
+#define D_GENERAL 0x0001 /* general debug info */
|
|
|
bec77d |
+#define D_CALL 0x0002
|
|
|
bec77d |
+#define D_AUTH 0x0004
|
|
|
bec77d |
+#define D_FAC3 0x0008
|
|
|
bec77d |
+#define D_FAC4 0x0010
|
|
|
bec77d |
+#define D_FAC5 0x0020
|
|
|
bec77d |
+#define D_PARSE 0x0040
|
|
|
bec77d |
+#define D_FAC7 0x0080
|
|
|
bec77d |
+#define D_ALL 0x00FF
|
|
|
bec77d |
+
|
|
|
bec77d |
+/* This can be used to define symbolic log names that can be passed to
|
|
|
bec77d |
+ * xlog_config.
|
|
|
bec77d |
+ */
|
|
|
bec77d |
+struct xlog_debugfac {
|
|
|
bec77d |
+ char *df_name;
|
|
|
bec77d |
+ int df_fac;
|
|
|
bec77d |
+};
|
|
|
bec77d |
+
|
|
|
bec77d |
+extern int export_errno;
|
|
|
bec77d |
+void xlog_open(char *progname);
|
|
|
bec77d |
+void xlog_stderr(int on);
|
|
|
bec77d |
+void xlog_syslog(int on);
|
|
|
bec77d |
+void xlog_config(int fac, int on);
|
|
|
bec77d |
+void xlog_sconfig(char *, int on);
|
|
|
bec77d |
+int xlog_enabled(int fac);
|
|
|
bec77d |
+void xlog(int fac, const char *fmt, ...);
|
|
|
bec77d |
+void xlog_warn(const char *fmt, ...);
|
|
|
bec77d |
+void xlog_err(const char *fmt, ...);
|
|
|
bec77d |
+void xlog_errno(int err, const char *fmt, ...);
|
|
|
bec77d |
+void xlog_backend(int fac, const char *fmt, va_list args);
|
|
|
bec77d |
+
|
|
|
bec77d |
+#endif /* XLOG_H */
|