Accepting request 614102 from network
OBS-URL: https://build.opensuse.org/request/show/614102 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/rpcbind?expand=0&rev=57
This commit is contained in:
commit
872d4e27dd
@ -1,494 +0,0 @@
|
||||
From 5388d9b484838437c364aed925f3f6acb021264d Mon Sep 17 00:00:00 2001
|
||||
From: Olaf Kirch <okir@suse.de>
|
||||
Date: Tue, 20 Aug 2013 09:26:37 +0200
|
||||
Subject: [PATCH 08/24] First part of init_transport refactoring
|
||||
|
||||
This patch splits out the hostname resolution and socket creation/binding
|
||||
code into individual functions, and calls those from init_transport instead.
|
||||
|
||||
Signed-off-by: Olaf Kirch <okir@suse.de>
|
||||
---
|
||||
src/rpcbind.c | 407 +++++++++++++++++++++++++++++-----------------------------
|
||||
1 file changed, 201 insertions(+), 206 deletions(-)
|
||||
|
||||
diff --git a/src/rpcbind.c b/src/rpcbind.c
|
||||
index 896d509..a7dcc0e 100644
|
||||
--- a/src/rpcbind.c
|
||||
+++ b/src/rpcbind.c
|
||||
@@ -268,6 +268,186 @@ main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
/*
|
||||
+ * Helper function - maybe this should go elsewhere
|
||||
+ */
|
||||
+static void
|
||||
+sockaddr2netbuf(const struct sockaddr *sa, socklen_t alen, struct netbuf *abuf)
|
||||
+{
|
||||
+ abuf->len = abuf->maxlen = alen;
|
||||
+ abuf->buf = malloc(alen);
|
||||
+
|
||||
+ if (abuf->buf == NULL) {
|
||||
+ syslog(LOG_ERR, "not enough memory for address buffer (%u bytes)", alen);
|
||||
+ exit(1);
|
||||
+ }
|
||||
+
|
||||
+ memcpy(abuf->buf, sa, alen);
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * Perform hostname lookup
|
||||
+ */
|
||||
+static int
|
||||
+do_hostname_lookup(struct netconfig *nconf, const char *hostname, struct netbuf *abuf)
|
||||
+{
|
||||
+ struct addrinfo hints, *res = NULL;
|
||||
+ struct __rpc_sockinfo si;
|
||||
+ int aicode;
|
||||
+
|
||||
+ if (!__rpc_nconf2sockinfo(nconf, &si)) {
|
||||
+ syslog(LOG_ERR, "cannot get sockinfo for %s", nconf->nc_netid);
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ memset(&hints, 0, sizeof hints);
|
||||
+ hints.ai_flags = AI_PASSIVE;
|
||||
+ hints.ai_family = si.si_af;
|
||||
+ hints.ai_socktype = si.si_socktype;
|
||||
+ hints.ai_protocol = si.si_proto;
|
||||
+
|
||||
+ if (hostname == NULL) {
|
||||
+ /*
|
||||
+ * If no hosts were specified, just bind to INADDR_ANY
|
||||
+ */
|
||||
+ } else {
|
||||
+ u_int32_t host_addr[4]; /* IPv4 or IPv6 */
|
||||
+
|
||||
+ switch (hints.ai_family) {
|
||||
+ case AF_INET:
|
||||
+ if (inet_pton(AF_INET, hostname, host_addr) == 1)
|
||||
+ hints.ai_flags |= AI_NUMERICHOST;
|
||||
+ else if (inet_pton(AF_INET6, hostname, host_addr) == 1)
|
||||
+ return 0;
|
||||
+ break;
|
||||
+
|
||||
+ case AF_INET6:
|
||||
+ if (inet_pton(AF_INET6, hostname, host_addr) == 1)
|
||||
+ hints.ai_flags |= AI_NUMERICHOST;
|
||||
+ else if (inet_pton(AF_INET, hostname, host_addr) == 1)
|
||||
+ return 0;
|
||||
+ break;
|
||||
+
|
||||
+ default:
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if ((aicode = getaddrinfo(hostname, servname, &hints, &res)) != 0) {
|
||||
+ if ((aicode = getaddrinfo(hostname, "portmapper", &hints, &res)) != 0) {
|
||||
+ syslog(LOG_ERR,
|
||||
+ "cannot get %s address for %s: %s",
|
||||
+ nconf->nc_netid,
|
||||
+ hostname? hostname : "*",
|
||||
+ gai_strerror(aicode));
|
||||
+ return 0;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /* XXX: should we loop over all addresses returned? */
|
||||
+ sockaddr2netbuf(res->ai_addr, res->ai_addrlen, abuf);
|
||||
+ freeaddrinfo(res);
|
||||
+ return 1;
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+build_local_addr(const char *path, struct netbuf *abuf)
|
||||
+{
|
||||
+ struct sockaddr_un sun;
|
||||
+
|
||||
+ memset(&sun, 0, sizeof sun);
|
||||
+ sun.sun_family = AF_LOCAL;
|
||||
+ strcpy(sun.sun_path, path);
|
||||
+
|
||||
+ sockaddr2netbuf((struct sockaddr *) &sun, SUN_LEN(&sun), abuf);
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * Create a bound socket
|
||||
+ *
|
||||
+ * Return values:
|
||||
+ * -1 means error or problem with this netconfig entry.
|
||||
+ */
|
||||
+static int
|
||||
+create_transport_socket(struct netconfig *nconf, const char *hostname, struct netbuf *abuf, int *fdret)
|
||||
+{
|
||||
+ int fd = -1;
|
||||
+ int r;
|
||||
+ mode_t oldmask;
|
||||
+
|
||||
+ *fdret = -1;
|
||||
+
|
||||
+ if (strcmp(nconf->nc_netid, "local") == 0 || strcmp(nconf->nc_netid, "unix") == 0) {
|
||||
+ unlink(_PATH_RPCBINDSOCK);
|
||||
+ build_local_addr(_PATH_RPCBINDSOCK, abuf);
|
||||
+ } else {
|
||||
+ r = do_hostname_lookup(nconf, hostname, abuf);
|
||||
+ if (r <= 0)
|
||||
+ return r;
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
+ * XXX - using RPC library internal functions.
|
||||
+ */
|
||||
+ if ((fd = __rpc_nconf2fd(nconf)) < 0) {
|
||||
+ syslog(LOG_ERR, "cannot create socket for %s", nconf->nc_netid);
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ if (nconf->nc_semantics != NC_TPI_CLTS) {
|
||||
+ int on = 1;
|
||||
+
|
||||
+ /* For connection oriented sockets, always set REUSEADDR.
|
||||
+ * This allows us to restart the server even if there are
|
||||
+ * TCP sockets loitering around in TIME_WAIT */
|
||||
+ if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) != 0) {
|
||||
+ syslog(LOG_ERR, "cannot set SO_REUSEADDR on %s", nconf->nc_netid);
|
||||
+ return -1;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ oldmask = umask(S_IXUSR|S_IXGRP|S_IXOTH);
|
||||
+ if (bind(fd, (struct sockaddr *) abuf->buf, abuf->len) != 0) {
|
||||
+ syslog(LOG_ERR, "cannot bind %s on %s: %m",
|
||||
+ hostname? hostname : "*",
|
||||
+ nconf->nc_netid);
|
||||
+ (void) umask(oldmask);
|
||||
+ goto skip;
|
||||
+ }
|
||||
+ (void) umask(oldmask);
|
||||
+
|
||||
+ if (nconf->nc_semantics != NC_TPI_CLTS) {
|
||||
+ if (listen(fd, SOMAXCONN) < 0) {
|
||||
+ syslog(LOG_ERR, "unable to listen on %s socket: %m",
|
||||
+ nconf->nc_netid);
|
||||
+ return -1;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+#ifdef RPCBIND_DEBUG
|
||||
+ if (debugging) {
|
||||
+ /*
|
||||
+ * for debugging print out our universal
|
||||
+ * address
|
||||
+ */
|
||||
+ char *uaddr;
|
||||
+
|
||||
+ uaddr = taddr2uaddr(nconf, abuf);
|
||||
+ (void) fprintf(stderr, "rpcbind : my %s address is %s\n", nconf->nc_netid, uaddr);
|
||||
+ (void) free(uaddr);
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
+ *fdret = fd;
|
||||
+ return 1;
|
||||
+
|
||||
+skip:
|
||||
+ if (fd >= 0)
|
||||
+ close(fd);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
* Adds the entry into the rpcbind database.
|
||||
* If PORTMAP, then for UDP and TCP, it adds the entries for version 2 also
|
||||
* Returns 0 if succeeds, else fails
|
||||
@@ -277,20 +457,9 @@ init_transport(struct netconfig *nconf)
|
||||
{
|
||||
int fd = -1;
|
||||
struct t_bind taddr;
|
||||
- struct addrinfo hints, *res;
|
||||
struct __rpc_sockinfo si;
|
||||
SVCXPRT *my_xprt = NULL;
|
||||
int status; /* bound checking ? */
|
||||
- int aicode;
|
||||
- int addrlen = 0;
|
||||
- int nhostsbak;
|
||||
- int checkbind;
|
||||
- int on = 1;
|
||||
- struct sockaddr *sa = NULL;
|
||||
- u_int32_t host_addr[4]; /* IPv4 or IPv6 */
|
||||
- struct sockaddr_un sun;
|
||||
- mode_t oldmask;
|
||||
- res = NULL;
|
||||
|
||||
if ((nconf->nc_semantics != NC_TPI_CLTS) &&
|
||||
(nconf->nc_semantics != NC_TPI_COTS) &&
|
||||
@@ -315,24 +484,10 @@ init_transport(struct netconfig *nconf)
|
||||
return (1);
|
||||
}
|
||||
|
||||
- if ((strcmp(nconf->nc_netid, "local") == 0) ||
|
||||
- (strcmp(nconf->nc_netid, "unix") == 0)) {
|
||||
- memset(&sun, 0, sizeof sun);
|
||||
- sun.sun_family = AF_LOCAL;
|
||||
- unlink(_PATH_RPCBINDSOCK);
|
||||
- strcpy(sun.sun_path, _PATH_RPCBINDSOCK);
|
||||
- addrlen = SUN_LEN(&sun);
|
||||
- sa = (struct sockaddr *)&sun;
|
||||
- } else {
|
||||
- /* Get rpcbind's address on this transport */
|
||||
-
|
||||
- memset(&hints, 0, sizeof hints);
|
||||
- hints.ai_flags = AI_PASSIVE;
|
||||
- hints.ai_family = si.si_af;
|
||||
- hints.ai_socktype = si.si_socktype;
|
||||
- hints.ai_protocol = si.si_proto;
|
||||
- }
|
||||
if (nconf->nc_semantics == NC_TPI_CLTS) {
|
||||
+ int nhostsbak;
|
||||
+ int checkbind;
|
||||
+
|
||||
/*
|
||||
* If no hosts were specified, just bind to INADDR_ANY. Otherwise
|
||||
* make sure 127.0.0.1 is added to the list.
|
||||
@@ -343,9 +498,9 @@ init_transport(struct netconfig *nconf)
|
||||
if (nhostsbak == 1)
|
||||
hosts[0] = "*";
|
||||
else {
|
||||
- if (hints.ai_family == AF_INET) {
|
||||
+ if (si.si_af == AF_INET) {
|
||||
hosts[nhostsbak - 1] = "127.0.0.1";
|
||||
- } else if (hints.ai_family == AF_INET6) {
|
||||
+ } else if (si.si_af == AF_INET6) {
|
||||
hosts[nhostsbak - 1] = "::1";
|
||||
} else
|
||||
return 1;
|
||||
@@ -356,47 +511,9 @@ init_transport(struct netconfig *nconf)
|
||||
*/
|
||||
checkbind = 0;
|
||||
while (nhostsbak > 0) {
|
||||
- --nhostsbak;
|
||||
- /*
|
||||
- * XXX - using RPC library internal functions.
|
||||
- */
|
||||
- if ((fd = __rpc_nconf2fd(nconf)) < 0) {
|
||||
- syslog(LOG_ERR, "cannot create socket for %s",
|
||||
- nconf->nc_netid);
|
||||
- return (1);
|
||||
- }
|
||||
+ int r;
|
||||
|
||||
- hints.ai_flags &= ~AI_NUMERICHOST;
|
||||
- switch (hints.ai_family) {
|
||||
- case AF_INET:
|
||||
- if (inet_pton(AF_INET, hosts[nhostsbak],
|
||||
- host_addr) == 1) {
|
||||
- hints.ai_flags |= AI_NUMERICHOST;
|
||||
- } else {
|
||||
- /*
|
||||
- * Skip if we have an AF_INET6 adress.
|
||||
- */
|
||||
- if (inet_pton(AF_INET6,
|
||||
- hosts[nhostsbak], host_addr) == 1)
|
||||
- continue;
|
||||
- }
|
||||
- break;
|
||||
- case AF_INET6:
|
||||
- if (inet_pton(AF_INET6, hosts[nhostsbak],
|
||||
- host_addr) == 1) {
|
||||
- hints.ai_flags |= AI_NUMERICHOST;
|
||||
- } else {
|
||||
- /*
|
||||
- * Skip if we have an AF_INET adress.
|
||||
- */
|
||||
- if (inet_pton(AF_INET, hosts[nhostsbak],
|
||||
- host_addr) == 1)
|
||||
- continue;
|
||||
- }
|
||||
- break;
|
||||
- default:
|
||||
- break;
|
||||
- }
|
||||
+ --nhostsbak;
|
||||
|
||||
/*
|
||||
* If no hosts were specified, just bind to INADDR_ANY
|
||||
@@ -404,68 +521,14 @@ init_transport(struct netconfig *nconf)
|
||||
if (strcmp("*", hosts[nhostsbak]) == 0)
|
||||
hosts[nhostsbak] = NULL;
|
||||
|
||||
- if ((aicode = getaddrinfo(hosts[nhostsbak],
|
||||
- servname, &hints, &res)) != 0) {
|
||||
- if ((aicode = getaddrinfo(hosts[nhostsbak],
|
||||
- "portmapper", &hints, &res)) != 0) {
|
||||
- syslog(LOG_ERR,
|
||||
- "cannot get local address for %s: %s",
|
||||
- nconf->nc_netid, gai_strerror(aicode));
|
||||
- continue;
|
||||
- }
|
||||
- }
|
||||
- addrlen = res->ai_addrlen;
|
||||
- sa = (struct sockaddr *)res->ai_addr;
|
||||
- oldmask = umask(S_IXUSR|S_IXGRP|S_IXOTH);
|
||||
- if (bind(fd, sa, addrlen) != 0) {
|
||||
- syslog(LOG_ERR, "cannot bind %s on %s: %m",
|
||||
- (hosts[nhostsbak] == NULL) ? "*" :
|
||||
- hosts[nhostsbak], nconf->nc_netid);
|
||||
- if (res != NULL)
|
||||
- freeaddrinfo(res);
|
||||
+ memset(&taddr, 0, sizeof(taddr));
|
||||
+
|
||||
+ r = create_transport_socket(nconf, hosts[nhostsbak], &taddr.addr, &fd);
|
||||
+ if (r < 0)
|
||||
+ goto error;
|
||||
+ if (r == 0)
|
||||
continue;
|
||||
- } else
|
||||
- checkbind++;
|
||||
- (void) umask(oldmask);
|
||||
-
|
||||
- /* Copy the address */
|
||||
- taddr.addr.maxlen = taddr.addr.len = addrlen;
|
||||
- taddr.addr.buf = malloc(addrlen);
|
||||
- if (taddr.addr.buf == NULL) {
|
||||
- syslog(LOG_ERR,
|
||||
- "cannot allocate memory for %s address",
|
||||
- nconf->nc_netid);
|
||||
- if (res != NULL)
|
||||
- freeaddrinfo(res);
|
||||
- return 1;
|
||||
- }
|
||||
- memcpy(taddr.addr.buf, sa, addrlen);
|
||||
-#ifdef RPCBIND_DEBUG
|
||||
- if (debugging) {
|
||||
- /*
|
||||
- * for debugging print out our universal
|
||||
- * address
|
||||
- */
|
||||
- char *uaddr;
|
||||
- struct netbuf nb;
|
||||
- int sa_size = 0;
|
||||
-
|
||||
- nb.buf = sa;
|
||||
- switch( sa->sa_family){
|
||||
- case AF_INET:
|
||||
- sa_size = sizeof (struct sockaddr_in);
|
||||
- break;
|
||||
- case AF_INET6:
|
||||
- sa_size = sizeof (struct sockaddr_in6);
|
||||
- break;
|
||||
- }
|
||||
- nb.len = nb.maxlen = sa_size;
|
||||
- uaddr = taddr2uaddr(nconf, &nb);
|
||||
- (void) fprintf(stderr,
|
||||
- "rpcbind : my address is %s\n", uaddr);
|
||||
- (void) free(uaddr);
|
||||
- }
|
||||
-#endif
|
||||
+
|
||||
my_xprt = (SVCXPRT *)svc_tli_create(fd, nconf, &taddr,
|
||||
RPC_MAXDATASIZE, RPC_MAXDATASIZE);
|
||||
if (my_xprt == (SVCXPRT *)NULL) {
|
||||
@@ -473,84 +536,15 @@ init_transport(struct netconfig *nconf)
|
||||
nconf->nc_netid);
|
||||
goto error;
|
||||
}
|
||||
+ checkbind = 1;
|
||||
+ fd = -1;
|
||||
}
|
||||
if (!checkbind)
|
||||
return 1;
|
||||
} else { /* NC_TPI_COTS */
|
||||
- if ((fd = __rpc_nconf2fd(nconf)) < 0) {
|
||||
- syslog(LOG_ERR, "cannot create socket for %s",
|
||||
- nconf->nc_netid);
|
||||
- return (1);
|
||||
- }
|
||||
-
|
||||
- if ((strcmp(nconf->nc_netid, "local") != 0) &&
|
||||
- (strcmp(nconf->nc_netid, "unix") != 0)) {
|
||||
- if ((aicode = getaddrinfo(NULL, servname, &hints, &res))!= 0) {
|
||||
- if ((aicode = getaddrinfo(NULL, "portmapper", &hints, &res))!= 0) {
|
||||
- printf("cannot get local address for %s: %s", nconf->nc_netid, gai_strerror(aicode));
|
||||
- syslog(LOG_ERR,
|
||||
- "cannot get local address for %s: %s",
|
||||
- nconf->nc_netid, gai_strerror(aicode));
|
||||
- return 1;
|
||||
- }
|
||||
- }
|
||||
- addrlen = res->ai_addrlen;
|
||||
- sa = (struct sockaddr *)res->ai_addr;
|
||||
- }
|
||||
- oldmask = umask(S_IXUSR|S_IXGRP|S_IXOTH);
|
||||
- __rpc_fd2sockinfo(fd, &si);
|
||||
- if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on,
|
||||
- sizeof(on)) != 0) {
|
||||
- syslog(LOG_ERR, "cannot set SO_REUSEADDR on %s",
|
||||
- nconf->nc_netid);
|
||||
- if (res != NULL)
|
||||
- freeaddrinfo(res);
|
||||
- return 1;
|
||||
- }
|
||||
- if (bind(fd, sa, addrlen) < 0) {
|
||||
- syslog(LOG_ERR, "cannot bind %s: %m", nconf->nc_netid);
|
||||
- if (res != NULL)
|
||||
- freeaddrinfo(res);
|
||||
- return 1;
|
||||
- }
|
||||
- (void) umask(oldmask);
|
||||
-
|
||||
- /* Copy the address */
|
||||
- taddr.addr.len = taddr.addr.maxlen = addrlen;
|
||||
- taddr.addr.buf = malloc(addrlen);
|
||||
- if (taddr.addr.buf == NULL) {
|
||||
- syslog(LOG_ERR, "cannot allocate memory for %s address",
|
||||
- nconf->nc_netid);
|
||||
- if (res != NULL)
|
||||
- freeaddrinfo(res);
|
||||
- return 1;
|
||||
- }
|
||||
- memcpy(taddr.addr.buf, sa, addrlen);
|
||||
-#ifdef RPCBIND_DEBUG
|
||||
- if (debugging) {
|
||||
- /* for debugging print out our universal address */
|
||||
- char *uaddr;
|
||||
- struct netbuf nb;
|
||||
- int sa_size2 = 0;
|
||||
-
|
||||
- nb.buf = sa;
|
||||
- switch( sa->sa_family){
|
||||
- case AF_INET:
|
||||
- sa_size2 = sizeof (struct sockaddr_in);
|
||||
- break;
|
||||
- case AF_INET6:
|
||||
- sa_size2 = sizeof (struct sockaddr_in6);
|
||||
- break;
|
||||
- }
|
||||
- nb.len = nb.maxlen = sa_size2;
|
||||
- uaddr = taddr2uaddr(nconf, &nb);
|
||||
- (void) fprintf(stderr, "rpcbind : my address is %s\n",
|
||||
- uaddr);
|
||||
- (void) free(uaddr);
|
||||
- }
|
||||
-#endif
|
||||
-
|
||||
- listen(fd, SOMAXCONN);
|
||||
+ memset(&taddr, 0, sizeof(taddr));
|
||||
+ if (create_transport_socket(nconf, NULL, &taddr.addr, &fd) <= 0)
|
||||
+ goto error;
|
||||
|
||||
my_xprt = (SVCXPRT *)svc_tli_create(fd, nconf, &taddr, RPC_MAXDATASIZE, RPC_MAXDATASIZE);
|
||||
if (my_xprt == (SVCXPRT *)NULL) {
|
||||
@@ -682,7 +676,8 @@ init_transport(struct netconfig *nconf)
|
||||
}
|
||||
return (0);
|
||||
error:
|
||||
- close(fd);
|
||||
+ if (fd >= 0)
|
||||
+ close(fd);
|
||||
return (1);
|
||||
}
|
||||
|
||||
--
|
||||
1.7.12.4
|
||||
|
@ -1,249 +0,0 @@
|
||||
From bf8bb37d6265f986fed55afc3f15b9e526da2226 Mon Sep 17 00:00:00 2001
|
||||
From: Olaf Kirch <okir@suse.de>
|
||||
Date: Tue, 20 Aug 2013 09:49:15 +0200
|
||||
Subject: [PATCH 09/24] init_transport: move the registration code into a
|
||||
separate function
|
||||
|
||||
Signed-off-by: Olaf Kirch <okir@suse.de>
|
||||
---
|
||||
src/rpcbind.c | 216 +++++++++++++++++++++++++++++++---------------------------
|
||||
1 file changed, 116 insertions(+), 100 deletions(-)
|
||||
|
||||
diff --git a/src/rpcbind.c b/src/rpcbind.c
|
||||
index a7dcc0e..25d12c9 100644
|
||||
--- a/src/rpcbind.c
|
||||
+++ b/src/rpcbind.c
|
||||
@@ -447,6 +447,120 @@ skip:
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static int
|
||||
+rpcbind_register_transport(struct netconfig *nconf, SVCXPRT *xprt, struct netbuf *bind_addr)
|
||||
+{
|
||||
+ struct __rpc_sockinfo si;
|
||||
+ int status;
|
||||
+
|
||||
+ (void) __rpc_nconf2sockinfo(nconf, &si);
|
||||
+
|
||||
+#ifdef PORTMAP
|
||||
+ /*
|
||||
+ * Register both the versions for tcp/ip, udp/ip.
|
||||
+ */
|
||||
+ if (si.si_af == AF_INET &&
|
||||
+ (si.si_proto == IPPROTO_TCP || si.si_proto == IPPROTO_UDP)) {
|
||||
+ struct pmaplist *pml;
|
||||
+
|
||||
+ pml = malloc(sizeof (struct pmaplist));
|
||||
+ if (pml == NULL) {
|
||||
+ syslog(LOG_ERR, "no memory!");
|
||||
+ exit(1);
|
||||
+ }
|
||||
+ pml->pml_map.pm_prog = PMAPPROG;
|
||||
+ pml->pml_map.pm_vers = PMAPVERS;
|
||||
+ pml->pml_map.pm_port = PMAPPORT;
|
||||
+ pml->pml_map.pm_prot = si.si_proto;
|
||||
+
|
||||
+ switch (si.si_proto) {
|
||||
+ case IPPROTO_TCP:
|
||||
+ tcptrans = strdup(nconf->nc_netid);
|
||||
+ break;
|
||||
+ case IPPROTO_UDP:
|
||||
+ udptrans = strdup(nconf->nc_netid);
|
||||
+ break;
|
||||
+ }
|
||||
+ pml->pml_next = list_pml;
|
||||
+ list_pml = pml;
|
||||
+
|
||||
+ /* Add version 3 information */
|
||||
+ pml = malloc(sizeof (struct pmaplist));
|
||||
+ if (pml == NULL) {
|
||||
+ syslog(LOG_ERR, "no memory!");
|
||||
+ exit(1);
|
||||
+ }
|
||||
+ pml->pml_map = list_pml->pml_map;
|
||||
+ pml->pml_map.pm_vers = RPCBVERS;
|
||||
+ pml->pml_next = list_pml;
|
||||
+ list_pml = pml;
|
||||
+
|
||||
+ /* Add version 4 information */
|
||||
+ pml = malloc (sizeof (struct pmaplist));
|
||||
+ if (pml == NULL) {
|
||||
+ syslog(LOG_ERR, "no memory!");
|
||||
+ exit(1);
|
||||
+ }
|
||||
+ pml->pml_map = list_pml->pml_map;
|
||||
+ pml->pml_map.pm_vers = RPCBVERS4;
|
||||
+ pml->pml_next = list_pml;
|
||||
+ list_pml = pml;
|
||||
+
|
||||
+ /* Also add version 2 stuff to rpcbind list */
|
||||
+ rbllist_add(PMAPPROG, PMAPVERS, nconf, bind_addr);
|
||||
+ }
|
||||
+
|
||||
+ /* We need to support portmap over IPv4. It makes sense to
|
||||
+ * support it over AF_LOCAL as well, because that allows
|
||||
+ * rpcbind to identify the owner of a socket much better
|
||||
+ * than by relying on privileged ports to tell root from
|
||||
+ * non-root users. */
|
||||
+ if (si.si_af == AF_INET || si.si_af == AF_LOCAL) {
|
||||
+ if (!svc_register(xprt, PMAPPROG, PMAPVERS, pmap_service, 0)) {
|
||||
+ syslog(LOG_ERR, "could not register on %s",
|
||||
+ nconf->nc_netid);
|
||||
+ return 0;
|
||||
+ }
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
+ /* version 3 registration */
|
||||
+ if (!svc_reg(xprt, RPCBPROG, RPCBVERS, rpcb_service_3, NULL)) {
|
||||
+ syslog(LOG_ERR, "could not register %s version 3",
|
||||
+ nconf->nc_netid);
|
||||
+ return 0;
|
||||
+ }
|
||||
+ rbllist_add(RPCBPROG, RPCBVERS, nconf, bind_addr);
|
||||
+
|
||||
+ /* version 4 registration */
|
||||
+ if (!svc_reg(xprt, RPCBPROG, RPCBVERS4, rpcb_service_4, NULL)) {
|
||||
+ syslog(LOG_ERR, "could not register %s version 4",
|
||||
+ nconf->nc_netid);
|
||||
+ return 0;
|
||||
+ }
|
||||
+ rbllist_add(RPCBPROG, RPCBVERS4, nconf, bind_addr);
|
||||
+
|
||||
+ /* decide if bound checking works for this transport */
|
||||
+ status = add_bndlist(nconf, bind_addr);
|
||||
+
|
||||
+#ifdef RPCBIND_DEBUG
|
||||
+ if (debugging) {
|
||||
+ if (status < 0) {
|
||||
+ fprintf(stderr, "Error in finding bind status for %s\n",
|
||||
+ nconf->nc_netid);
|
||||
+ } else if (status == 0) {
|
||||
+ fprintf(stderr, "check binding for %s\n",
|
||||
+ nconf->nc_netid);
|
||||
+ } else if (status > 0) {
|
||||
+ fprintf(stderr, "No check binding for %s\n",
|
||||
+ nconf->nc_netid);
|
||||
+ }
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
+ return 1;
|
||||
+}
|
||||
+
|
||||
/*
|
||||
* Adds the entry into the rpcbind database.
|
||||
* If PORTMAP, then for UDP and TCP, it adds the entries for version 2 also
|
||||
@@ -554,107 +668,9 @@ init_transport(struct netconfig *nconf)
|
||||
}
|
||||
}
|
||||
|
||||
-#ifdef PORTMAP
|
||||
- /*
|
||||
- * Register both the versions for tcp/ip, udp/ip.
|
||||
- */
|
||||
- if (si.si_af == AF_INET &&
|
||||
- (si.si_proto == IPPROTO_TCP || si.si_proto == IPPROTO_UDP)) {
|
||||
- struct pmaplist *pml;
|
||||
-
|
||||
- pml = malloc(sizeof (struct pmaplist));
|
||||
- if (pml == NULL) {
|
||||
- syslog(LOG_ERR, "no memory!");
|
||||
- exit(1);
|
||||
- }
|
||||
- pml->pml_map.pm_prog = PMAPPROG;
|
||||
- pml->pml_map.pm_vers = PMAPVERS;
|
||||
- pml->pml_map.pm_port = PMAPPORT;
|
||||
- pml->pml_map.pm_prot = si.si_proto;
|
||||
-
|
||||
- switch (si.si_proto) {
|
||||
- case IPPROTO_TCP:
|
||||
- tcptrans = strdup(nconf->nc_netid);
|
||||
- break;
|
||||
- case IPPROTO_UDP:
|
||||
- udptrans = strdup(nconf->nc_netid);
|
||||
- break;
|
||||
- }
|
||||
- pml->pml_next = list_pml;
|
||||
- list_pml = pml;
|
||||
-
|
||||
- /* Add version 3 information */
|
||||
- pml = malloc(sizeof (struct pmaplist));
|
||||
- if (pml == NULL) {
|
||||
- syslog(LOG_ERR, "no memory!");
|
||||
- exit(1);
|
||||
- }
|
||||
- pml->pml_map = list_pml->pml_map;
|
||||
- pml->pml_map.pm_vers = RPCBVERS;
|
||||
- pml->pml_next = list_pml;
|
||||
- list_pml = pml;
|
||||
-
|
||||
- /* Add version 4 information */
|
||||
- pml = malloc (sizeof (struct pmaplist));
|
||||
- if (pml == NULL) {
|
||||
- syslog(LOG_ERR, "no memory!");
|
||||
- exit(1);
|
||||
- }
|
||||
- pml->pml_map = list_pml->pml_map;
|
||||
- pml->pml_map.pm_vers = RPCBVERS4;
|
||||
- pml->pml_next = list_pml;
|
||||
- list_pml = pml;
|
||||
-
|
||||
- /* Also add version 2 stuff to rpcbind list */
|
||||
- rbllist_add(PMAPPROG, PMAPVERS, nconf, &taddr.addr);
|
||||
- }
|
||||
-
|
||||
- /* We need to support portmap over IPv4. It makes sense to
|
||||
- * support it over AF_LOCAL as well, because that allows
|
||||
- * rpcbind to identify the owner of a socket much better
|
||||
- * than by relying on privileged ports to tell root from
|
||||
- * non-root users. */
|
||||
- if (si.si_af == AF_INET || si.si_af == AF_LOCAL) {
|
||||
- if (!svc_register(my_xprt, PMAPPROG, PMAPVERS, pmap_service, 0)) {
|
||||
- syslog(LOG_ERR, "could not register on %s",
|
||||
- nconf->nc_netid);
|
||||
- goto error;
|
||||
- }
|
||||
- }
|
||||
-#endif
|
||||
-
|
||||
- /* version 3 registration */
|
||||
- if (!svc_reg(my_xprt, RPCBPROG, RPCBVERS, rpcb_service_3, NULL)) {
|
||||
- syslog(LOG_ERR, "could not register %s version 3",
|
||||
- nconf->nc_netid);
|
||||
- goto error;
|
||||
- }
|
||||
- rbllist_add(RPCBPROG, RPCBVERS, nconf, &taddr.addr);
|
||||
-
|
||||
- /* version 4 registration */
|
||||
- if (!svc_reg(my_xprt, RPCBPROG, RPCBVERS4, rpcb_service_4, NULL)) {
|
||||
- syslog(LOG_ERR, "could not register %s version 4",
|
||||
- nconf->nc_netid);
|
||||
- goto error;
|
||||
- }
|
||||
- rbllist_add(RPCBPROG, RPCBVERS4, nconf, &taddr.addr);
|
||||
+ if (!rpcbind_register_transport(nconf, my_xprt, &taddr.addr))
|
||||
+ return (1);
|
||||
|
||||
- /* decide if bound checking works for this transport */
|
||||
- status = add_bndlist(nconf, &taddr.addr);
|
||||
-#ifdef RPCBIND_DEBUG
|
||||
- if (debugging) {
|
||||
- if (status < 0) {
|
||||
- fprintf(stderr, "Error in finding bind status for %s\n",
|
||||
- nconf->nc_netid);
|
||||
- } else if (status == 0) {
|
||||
- fprintf(stderr, "check binding for %s\n",
|
||||
- nconf->nc_netid);
|
||||
- } else if (status > 0) {
|
||||
- fprintf(stderr, "No check binding for %s\n",
|
||||
- nconf->nc_netid);
|
||||
- }
|
||||
- }
|
||||
-#endif
|
||||
/*
|
||||
* rmtcall only supported on CLTS transports for now.
|
||||
*/
|
||||
--
|
||||
1.7.12.4
|
||||
|
@ -1,141 +0,0 @@
|
||||
From 774ccd8224f8a6b76fce4204d3084ffb8cc09e5f Mon Sep 17 00:00:00 2001
|
||||
From: Olaf Kirch <okir@suse.de>
|
||||
Date: Tue, 20 Aug 2013 09:58:51 +0200
|
||||
Subject: [PATCH 10/24] Fix the behavior when specifying the -h option
|
||||
|
||||
Currently, when specifying the "-h" option, rpcbind will try to create
|
||||
sockets for all specified addresses, plus the loopback address. However,
|
||||
it will only register its programs on the last SVCXPRT created, which
|
||||
will usually be the first address specified via -h.
|
||||
|
||||
This patch fixes this problem by introducing a new function that creates
|
||||
the socket *and* registers all programs, and use that from the while
|
||||
loop.
|
||||
|
||||
Signed-off-by: Olaf Kirch <okir@suse.de>
|
||||
---
|
||||
src/rpcbind.c | 79 ++++++++++++++++++++++++++++++++---------------------------
|
||||
1 file changed, 43 insertions(+), 36 deletions(-)
|
||||
|
||||
diff --git a/src/rpcbind.c b/src/rpcbind.c
|
||||
index 25d12c9..c3679e2 100644
|
||||
--- a/src/rpcbind.c
|
||||
+++ b/src/rpcbind.c
|
||||
@@ -562,6 +562,43 @@ rpcbind_register_transport(struct netconfig *nconf, SVCXPRT *xprt, struct netbuf
|
||||
}
|
||||
|
||||
/*
|
||||
+ * This will create a server socket for the given netid, bound to the
|
||||
+ * address specified by @hostname
|
||||
+ *
|
||||
+ * Return value:
|
||||
+ * 1: success
|
||||
+ * 0: error - ignore this hostname
|
||||
+ * <0: error - ignore this netid
|
||||
+ */
|
||||
+static int
|
||||
+rpcbind_init_endpoint(struct netconfig *nconf, const char *hostname)
|
||||
+{
|
||||
+ struct t_bind taddr;
|
||||
+ SVCXPRT *my_xprt = NULL;
|
||||
+ int r, fd = -1;
|
||||
+
|
||||
+ memset(&taddr, 0, sizeof(taddr));
|
||||
+
|
||||
+ r = create_transport_socket(nconf, hostname, &taddr.addr, &fd);
|
||||
+ if (r <= 0)
|
||||
+ return r;
|
||||
+
|
||||
+ my_xprt = (SVCXPRT *)svc_tli_create(fd, nconf, &taddr, RPC_MAXDATASIZE, RPC_MAXDATASIZE);
|
||||
+ if (my_xprt == (SVCXPRT *)NULL) {
|
||||
+ syslog(LOG_ERR, "%s: could not create service", nconf->nc_netid);
|
||||
+ close(fd);
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ if (!rpcbind_register_transport(nconf, my_xprt, &taddr.addr)) {
|
||||
+ svc_destroy(my_xprt);
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ return 1;
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
* Adds the entry into the rpcbind database.
|
||||
* If PORTMAP, then for UDP and TCP, it adds the entries for version 2 also
|
||||
* Returns 0 if succeeds, else fails
|
||||
@@ -569,10 +606,7 @@ rpcbind_register_transport(struct netconfig *nconf, SVCXPRT *xprt, struct netbuf
|
||||
static int
|
||||
init_transport(struct netconfig *nconf)
|
||||
{
|
||||
- int fd = -1;
|
||||
- struct t_bind taddr;
|
||||
struct __rpc_sockinfo si;
|
||||
- SVCXPRT *my_xprt = NULL;
|
||||
int status; /* bound checking ? */
|
||||
|
||||
if ((nconf->nc_semantics != NC_TPI_CLTS) &&
|
||||
@@ -635,42 +669,19 @@ init_transport(struct netconfig *nconf)
|
||||
if (strcmp("*", hosts[nhostsbak]) == 0)
|
||||
hosts[nhostsbak] = NULL;
|
||||
|
||||
- memset(&taddr, 0, sizeof(taddr));
|
||||
-
|
||||
- r = create_transport_socket(nconf, hosts[nhostsbak], &taddr.addr, &fd);
|
||||
+ r = rpcbind_init_endpoint(nconf, hosts[nhostsbak]);
|
||||
if (r < 0)
|
||||
- goto error;
|
||||
- if (r == 0)
|
||||
- continue;
|
||||
-
|
||||
- my_xprt = (SVCXPRT *)svc_tli_create(fd, nconf, &taddr,
|
||||
- RPC_MAXDATASIZE, RPC_MAXDATASIZE);
|
||||
- if (my_xprt == (SVCXPRT *)NULL) {
|
||||
- syslog(LOG_ERR, "%s: could not create service",
|
||||
- nconf->nc_netid);
|
||||
- goto error;
|
||||
- }
|
||||
- checkbind = 1;
|
||||
- fd = -1;
|
||||
+ return 1;
|
||||
+ if (r > 0)
|
||||
+ checkbind = 1;
|
||||
}
|
||||
if (!checkbind)
|
||||
return 1;
|
||||
} else { /* NC_TPI_COTS */
|
||||
- memset(&taddr, 0, sizeof(taddr));
|
||||
- if (create_transport_socket(nconf, NULL, &taddr.addr, &fd) <= 0)
|
||||
- goto error;
|
||||
-
|
||||
- my_xprt = (SVCXPRT *)svc_tli_create(fd, nconf, &taddr, RPC_MAXDATASIZE, RPC_MAXDATASIZE);
|
||||
- if (my_xprt == (SVCXPRT *)NULL) {
|
||||
- syslog(LOG_ERR, "%s: could not create service",
|
||||
- nconf->nc_netid);
|
||||
- goto error;
|
||||
- }
|
||||
+ if (rpcbind_init_endpoint(nconf, NULL) <= 0)
|
||||
+ return 1;
|
||||
}
|
||||
|
||||
- if (!rpcbind_register_transport(nconf, my_xprt, &taddr.addr))
|
||||
- return (1);
|
||||
-
|
||||
/*
|
||||
* rmtcall only supported on CLTS transports for now.
|
||||
*/
|
||||
@@ -691,10 +702,6 @@ init_transport(struct netconfig *nconf)
|
||||
#endif
|
||||
}
|
||||
return (0);
|
||||
-error:
|
||||
- if (fd >= 0)
|
||||
- close(fd);
|
||||
- return (1);
|
||||
}
|
||||
|
||||
static void
|
||||
--
|
||||
1.7.12.4
|
||||
|
@ -1,104 +0,0 @@
|
||||
From 038db9589e4cf64b0a7307132d08bfa4547d59b1 Mon Sep 17 00:00:00 2001
|
||||
From: Olaf Kirch <okir@suse.de>
|
||||
Date: Tue, 20 Aug 2013 10:10:41 +0200
|
||||
Subject: [PATCH 11/24] Clean up the way we handle the -h option in
|
||||
init_transport
|
||||
|
||||
There's some odd realloc()ing going on, which is plain ugly.
|
||||
Make the code a little more readable.
|
||||
|
||||
Signed-off-by: Olaf Kirch <okir@suse.de>
|
||||
---
|
||||
src/rpcbind.c | 66 +++++++++++++++++++++++++++--------------------------------
|
||||
1 file changed, 30 insertions(+), 36 deletions(-)
|
||||
|
||||
diff --git a/src/rpcbind.c b/src/rpcbind.c
|
||||
index c3679e2..3b753c6 100644
|
||||
--- a/src/rpcbind.c
|
||||
+++ b/src/rpcbind.c
|
||||
@@ -632,52 +632,46 @@ init_transport(struct netconfig *nconf)
|
||||
return (1);
|
||||
}
|
||||
|
||||
- if (nconf->nc_semantics == NC_TPI_CLTS) {
|
||||
- int nhostsbak;
|
||||
- int checkbind;
|
||||
+ /* Check if the -h option was used to specify addresses to bind to.
|
||||
+ * The original purpose was to allow multihomed hosts to function
|
||||
+ * properly, making the reply originate from the same IP address
|
||||
+ * that it was sent to. We're solving this differently in the meantime
|
||||
+ * (using PKTINFO magic in libtirpc), but there may be other uses for
|
||||
+ * this option, like restricting rpcbind to certain "public" interfaces
|
||||
+ */
|
||||
+ if (nhosts != 0 && nconf->nc_semantics == NC_TPI_CLTS) {
|
||||
+ int numbound = 0, n, r;
|
||||
|
||||
- /*
|
||||
- * If no hosts were specified, just bind to INADDR_ANY. Otherwise
|
||||
- * make sure 127.0.0.1 is added to the list.
|
||||
- */
|
||||
- nhostsbak = nhosts;
|
||||
- nhostsbak++;
|
||||
- hosts = realloc(hosts, nhostsbak * sizeof(char *));
|
||||
- if (nhostsbak == 1)
|
||||
- hosts[0] = "*";
|
||||
- else {
|
||||
- if (si.si_af == AF_INET) {
|
||||
- hosts[nhostsbak - 1] = "127.0.0.1";
|
||||
- } else if (si.si_af == AF_INET6) {
|
||||
- hosts[nhostsbak - 1] = "::1";
|
||||
- } else
|
||||
- return 1;
|
||||
- }
|
||||
+ /* Ensure that we always bind to loopback */
|
||||
+ switch (si.si_af) {
|
||||
+ case AF_INET:
|
||||
+ if (rpcbind_init_endpoint(nconf, "127.0.0.1") > 0)
|
||||
+ numbound++;
|
||||
+ break;
|
||||
|
||||
- /*
|
||||
- * Bind to specific IPs if asked to
|
||||
- */
|
||||
- checkbind = 0;
|
||||
- while (nhostsbak > 0) {
|
||||
- int r;
|
||||
+ case AF_INET6:
|
||||
+ if (rpcbind_init_endpoint(nconf, "::1") > 0)
|
||||
+ numbound++;
|
||||
+ break;
|
||||
+ }
|
||||
|
||||
- --nhostsbak;
|
||||
+ for (n = 0; n < nhosts; ++n) {
|
||||
+ const char *hostname = hosts[n];
|
||||
|
||||
- /*
|
||||
- * If no hosts were specified, just bind to INADDR_ANY
|
||||
- */
|
||||
- if (strcmp("*", hosts[nhostsbak]) == 0)
|
||||
- hosts[nhostsbak] = NULL;
|
||||
+ /* In case someone gets the idea to specify "-h '*'" */
|
||||
+ if (strcmp("*", hostname) == 0)
|
||||
+ hostname = NULL;
|
||||
|
||||
- r = rpcbind_init_endpoint(nconf, hosts[nhostsbak]);
|
||||
+ r = rpcbind_init_endpoint(nconf, hostname);
|
||||
if (r < 0)
|
||||
return 1;
|
||||
if (r > 0)
|
||||
- checkbind = 1;
|
||||
+ numbound++;
|
||||
}
|
||||
- if (!checkbind)
|
||||
+
|
||||
+ if (numbound == 0)
|
||||
return 1;
|
||||
- } else { /* NC_TPI_COTS */
|
||||
+ } else {
|
||||
if (rpcbind_init_endpoint(nconf, NULL) <= 0)
|
||||
return 1;
|
||||
}
|
||||
--
|
||||
1.7.12.4
|
||||
|
@ -1,540 +0,0 @@
|
||||
From 3ac02ec367c314770774c4c9f82e8c2c75c7a28c Mon Sep 17 00:00:00 2001
|
||||
From: Olaf Kirch <okir@suse.de>
|
||||
Date: Tue, 20 Aug 2013 15:59:17 +0200
|
||||
Subject: [PATCH 14/24] When using systemd, redirect syslog() calls to the
|
||||
systemd journal
|
||||
|
||||
Signed-off-by: Olaf Kirch <okir@suse.de>
|
||||
---
|
||||
Makefile.am | 4 +--
|
||||
configure.ac | 1 +
|
||||
src/check_bound.c | 4 +--
|
||||
src/rpcb_svc.c | 1 -
|
||||
src/rpcb_svc_4.c | 1 -
|
||||
src/rpcb_svc_com.c | 5 ++-
|
||||
src/rpcbind.c | 100 +++++++++++++++++++++++++++++++++++------------------
|
||||
src/rpcbind.h | 3 ++
|
||||
src/security.c | 2 +-
|
||||
src/warmstart.c | 13 ++++---
|
||||
10 files changed, 83 insertions(+), 51 deletions(-)
|
||||
|
||||
diff --git a/Makefile.am b/Makefile.am
|
||||
index df755dd..6f7474f 100644
|
||||
--- a/Makefile.am
|
||||
+++ b/Makefile.am
|
||||
@@ -39,9 +39,9 @@ rpcbind_SOURCES = \
|
||||
rpcbind_LDADD = $(TIRPC_LIBS)
|
||||
|
||||
if SYSTEMD
|
||||
-AM_CPPFLAGS += $(SYSTEMD_CFLAGS) -DSYSTEMD
|
||||
+AM_CPPFLAGS += $(SYSTEMD_CFLAGS) $(SYSTEMD_JOURNAL_CFLAGS) -DSYSTEMD
|
||||
|
||||
-rpcbind_LDADD += $(SYSTEMD_LIBS)
|
||||
+rpcbind_LDADD += $(SYSTEMD_LIBS) $(SYSTEMD_JOURNAL_LIBS)
|
||||
|
||||
systemd/rpcbind.service: systemd/rpcbind.service.in Makefile
|
||||
sed -e 's,@bindir\@,$(bindir),g' \
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index a94933b..6d91dcd 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -36,6 +36,7 @@ AC_ARG_WITH([systemdsystemunitdir],
|
||||
if test "x$with_systemdsystemunitdir" != xno -a "x$with_systemdsystemunitdir" != "x"; then
|
||||
AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
|
||||
PKG_CHECK_MODULES([SYSTEMD], [libsystemd-daemon])
|
||||
+ PKG_CHECK_MODULES([SYSTEMD_JOURNAL], [libsystemd-journal])
|
||||
fi
|
||||
AM_CONDITIONAL(SYSTEMD, [test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ])
|
||||
|
||||
diff --git a/src/check_bound.c b/src/check_bound.c
|
||||
index c70b845..82d84b9 100644
|
||||
--- a/src/check_bound.c
|
||||
+++ b/src/check_bound.c
|
||||
@@ -119,7 +119,7 @@ add_bndlist(struct netconfig *nconf, struct netbuf *baddr /*__unused*/)
|
||||
fdl = malloc(sizeof (struct fdlist));
|
||||
if (fdl == NULL) {
|
||||
freenetconfigent(newnconf);
|
||||
- syslog(LOG_ERR, "no memory!");
|
||||
+ rpcbind_log_error("no memory!");
|
||||
return (-1);
|
||||
}
|
||||
fdl->nconf = newnconf;
|
||||
@@ -179,7 +179,7 @@ mergeaddr(SVCXPRT *xprt, char *netid, char *uaddr, char *saddr)
|
||||
} else {
|
||||
c_uaddr = taddr2uaddr(fdl->nconf, svc_getrpccaller(xprt));
|
||||
if (c_uaddr == NULL) {
|
||||
- syslog(LOG_ERR, "taddr2uaddr failed for %s",
|
||||
+ rpcbind_log_error("taddr2uaddr failed for %s",
|
||||
fdl->nconf->nc_netid);
|
||||
return (NULL);
|
||||
}
|
||||
diff --git a/src/rpcb_svc.c b/src/rpcb_svc.c
|
||||
index e350f85..c26b5be 100644
|
||||
--- a/src/rpcb_svc.c
|
||||
+++ b/src/rpcb_svc.c
|
||||
@@ -45,7 +45,6 @@
|
||||
#include <rpc/rpc.h>
|
||||
#include <rpc/rpcb_prot.h>
|
||||
#include <netconfig.h>
|
||||
-#include <syslog.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
diff --git a/src/rpcb_svc_4.c b/src/rpcb_svc_4.c
|
||||
index 313e6d1..6858095 100644
|
||||
--- a/src/rpcb_svc_4.c
|
||||
+++ b/src/rpcb_svc_4.c
|
||||
@@ -48,7 +48,6 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <netconfig.h>
|
||||
-#include <syslog.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "rpcbind.h"
|
||||
diff --git a/src/rpcb_svc_com.c b/src/rpcb_svc_com.c
|
||||
index f6bd6bd..1a4ad84 100644
|
||||
--- a/src/rpcb_svc_com.c
|
||||
+++ b/src/rpcb_svc_com.c
|
||||
@@ -50,7 +50,6 @@
|
||||
#include <rpc/svc_dg.h>
|
||||
#include <netconfig.h>
|
||||
#include <errno.h>
|
||||
-#include <syslog.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
@@ -520,7 +519,7 @@ create_rmtcall_fd(struct netconfig *nconf)
|
||||
}
|
||||
rmt = malloc(sizeof (struct rmtcallfd_list));
|
||||
if (rmt == NULL) {
|
||||
- syslog(LOG_ERR, "create_rmtcall_fd: no memory!");
|
||||
+ rpcbind_log_error("create_rmtcall_fd: no memory!");
|
||||
return (-1);
|
||||
}
|
||||
rmt->xprt = xprt;
|
||||
@@ -1438,7 +1437,7 @@ add_pmaplist(RPCB *arg)
|
||||
*/
|
||||
pml = malloc(sizeof (struct pmaplist));
|
||||
if (pml == NULL) {
|
||||
- (void) syslog(LOG_ERR, "rpcbind: no memory!\n");
|
||||
+ (void) rpcbind_log_error("rpcbind: no memory!\n");
|
||||
return (1);
|
||||
}
|
||||
pml->pml_map = pmap;
|
||||
diff --git a/src/rpcbind.c b/src/rpcbind.c
|
||||
index aec0510..50c042c 100644
|
||||
--- a/src/rpcbind.c
|
||||
+++ b/src/rpcbind.c
|
||||
@@ -59,18 +59,20 @@
|
||||
#include <arpa/inet.h>
|
||||
#ifdef SYSTEMD
|
||||
#include <systemd/sd-daemon.h>
|
||||
+#include <systemd/sd-journal.h>
|
||||
#endif
|
||||
+#include <syslog.h>
|
||||
#include <fcntl.h>
|
||||
#include <netdb.h>
|
||||
#include <stdio.h>
|
||||
#include <netconfig.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
-#include <syslog.h>
|
||||
#include <err.h>
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
#include <string.h>
|
||||
+#include <stdarg.h>
|
||||
#include <errno.h>
|
||||
#ifdef HAVE_NSS_H
|
||||
#include <nss.h>
|
||||
@@ -234,19 +236,19 @@ main(int argc, char *argv[])
|
||||
__nss_configure_lookup("passwd", "files");
|
||||
|
||||
if((p = getpwnam(id)) == NULL) {
|
||||
- syslog(LOG_ERR, "cannot get uid of '%s': %m", id);
|
||||
+ rpcbind_log_error("cannot get uid of '%s': %m", id);
|
||||
exit(1);
|
||||
}
|
||||
if (setgid(p->pw_gid) == -1) {
|
||||
- syslog(LOG_ERR, "setgid to '%s' (%d) failed: %m", id, p->pw_gid);
|
||||
+ rpcbind_log_error("setgid to '%s' (%d) failed: %m", id, p->pw_gid);
|
||||
exit(1);
|
||||
}
|
||||
if (setgroups(0, NULL) == -1) {
|
||||
- syslog(LOG_ERR, "dropping supplemental groups failed: %m");
|
||||
+ rpcbind_log_error("dropping supplemental groups failed: %m");
|
||||
exit(1);
|
||||
}
|
||||
if (setuid(p->pw_uid) == -1) {
|
||||
- syslog(LOG_ERR, "setuid to '%s' (%d) failed: %m", id, p->pw_uid);
|
||||
+ rpcbind_log_error("setuid to '%s' (%d) failed: %m", id, p->pw_uid);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
@@ -260,7 +262,7 @@ main(int argc, char *argv[])
|
||||
network_init();
|
||||
|
||||
my_svc_run();
|
||||
- syslog(LOG_ERR, "svc_run returned unexpectedly");
|
||||
+ rpcbind_log_error("svc_run returned unexpectedly");
|
||||
rpcbind_abort();
|
||||
/* NOTREACHED */
|
||||
|
||||
@@ -277,7 +279,7 @@ sockaddr2netbuf(const struct sockaddr *sa, socklen_t alen, struct netbuf *abuf)
|
||||
abuf->buf = malloc(alen);
|
||||
|
||||
if (abuf->buf == NULL) {
|
||||
- syslog(LOG_ERR, "not enough memory for address buffer (%u bytes)", alen);
|
||||
+ rpcbind_log_error("not enough memory for address buffer (%u bytes)", alen);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -295,7 +297,7 @@ do_hostname_lookup(struct netconfig *nconf, const char *hostname, struct netbuf
|
||||
int aicode;
|
||||
|
||||
if (!__rpc_nconf2sockinfo(nconf, &si)) {
|
||||
- syslog(LOG_ERR, "cannot get sockinfo for %s", nconf->nc_netid);
|
||||
+ rpcbind_log_error("cannot get sockinfo for %s", nconf->nc_netid);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -334,7 +336,7 @@ do_hostname_lookup(struct netconfig *nconf, const char *hostname, struct netbuf
|
||||
|
||||
if ((aicode = getaddrinfo(hostname, servname, &hints, &res)) != 0) {
|
||||
if ((aicode = getaddrinfo(hostname, "portmapper", &hints, &res)) != 0) {
|
||||
- syslog(LOG_ERR,
|
||||
+ rpcbind_log_error(
|
||||
"cannot get %s address for %s: %s",
|
||||
nconf->nc_netid,
|
||||
hostname? hostname : "*",
|
||||
@@ -389,7 +391,7 @@ create_transport_socket(struct netconfig *nconf, const char *hostname, struct ne
|
||||
* XXX - using RPC library internal functions.
|
||||
*/
|
||||
if ((fd = __rpc_nconf2fd(nconf)) < 0) {
|
||||
- syslog(LOG_ERR, "cannot create socket for %s", nconf->nc_netid);
|
||||
+ rpcbind_log_error("cannot create socket for %s", nconf->nc_netid);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -400,14 +402,14 @@ create_transport_socket(struct netconfig *nconf, const char *hostname, struct ne
|
||||
* This allows us to restart the server even if there are
|
||||
* TCP sockets loitering around in TIME_WAIT */
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) != 0) {
|
||||
- syslog(LOG_ERR, "cannot set SO_REUSEADDR on %s", nconf->nc_netid);
|
||||
+ rpcbind_log_error("cannot set SO_REUSEADDR on %s", nconf->nc_netid);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
oldmask = umask(S_IXUSR|S_IXGRP|S_IXOTH);
|
||||
if (bind(fd, (struct sockaddr *) abuf->buf, abuf->len) != 0) {
|
||||
- syslog(LOG_ERR, "cannot bind %s on %s: %m",
|
||||
+ rpcbind_log_error("cannot bind %s on %s: %m",
|
||||
hostname? hostname : "*",
|
||||
nconf->nc_netid);
|
||||
(void) umask(oldmask);
|
||||
@@ -417,7 +419,7 @@ create_transport_socket(struct netconfig *nconf, const char *hostname, struct ne
|
||||
|
||||
if (nconf->nc_semantics != NC_TPI_CLTS) {
|
||||
if (listen(fd, SOMAXCONN) < 0) {
|
||||
- syslog(LOG_ERR, "unable to listen on %s socket: %m",
|
||||
+ rpcbind_log_error("unable to listen on %s socket: %m",
|
||||
nconf->nc_netid);
|
||||
return -1;
|
||||
}
|
||||
@@ -465,7 +467,7 @@ rpcbind_register_transport(struct netconfig *nconf, SVCXPRT *xprt, struct netbuf
|
||||
|
||||
pml = malloc(sizeof (struct pmaplist));
|
||||
if (pml == NULL) {
|
||||
- syslog(LOG_ERR, "no memory!");
|
||||
+ rpcbind_log_error("no memory!");
|
||||
exit(1);
|
||||
}
|
||||
pml->pml_map.pm_prog = PMAPPROG;
|
||||
@@ -487,7 +489,7 @@ rpcbind_register_transport(struct netconfig *nconf, SVCXPRT *xprt, struct netbuf
|
||||
/* Add version 3 information */
|
||||
pml = malloc(sizeof (struct pmaplist));
|
||||
if (pml == NULL) {
|
||||
- syslog(LOG_ERR, "no memory!");
|
||||
+ rpcbind_log_error("no memory!");
|
||||
exit(1);
|
||||
}
|
||||
pml->pml_map = list_pml->pml_map;
|
||||
@@ -498,7 +500,7 @@ rpcbind_register_transport(struct netconfig *nconf, SVCXPRT *xprt, struct netbuf
|
||||
/* Add version 4 information */
|
||||
pml = malloc (sizeof (struct pmaplist));
|
||||
if (pml == NULL) {
|
||||
- syslog(LOG_ERR, "no memory!");
|
||||
+ rpcbind_log_error("no memory!");
|
||||
exit(1);
|
||||
}
|
||||
pml->pml_map = list_pml->pml_map;
|
||||
@@ -517,7 +519,7 @@ rpcbind_register_transport(struct netconfig *nconf, SVCXPRT *xprt, struct netbuf
|
||||
* non-root users. */
|
||||
if (si.si_af == AF_INET || si.si_af == AF_LOCAL) {
|
||||
if (!svc_register(xprt, PMAPPROG, PMAPVERS, pmap_service, 0)) {
|
||||
- syslog(LOG_ERR, "could not register on %s",
|
||||
+ rpcbind_log_error("could not register on %s",
|
||||
nconf->nc_netid);
|
||||
return 0;
|
||||
}
|
||||
@@ -526,7 +528,7 @@ rpcbind_register_transport(struct netconfig *nconf, SVCXPRT *xprt, struct netbuf
|
||||
|
||||
/* version 3 registration */
|
||||
if (!svc_reg(xprt, RPCBPROG, RPCBVERS, rpcb_service_3, NULL)) {
|
||||
- syslog(LOG_ERR, "could not register %s version 3",
|
||||
+ rpcbind_log_error("could not register %s version 3",
|
||||
nconf->nc_netid);
|
||||
return 0;
|
||||
}
|
||||
@@ -534,7 +536,7 @@ rpcbind_register_transport(struct netconfig *nconf, SVCXPRT *xprt, struct netbuf
|
||||
|
||||
/* version 4 registration */
|
||||
if (!svc_reg(xprt, RPCBPROG, RPCBVERS4, rpcb_service_4, NULL)) {
|
||||
- syslog(LOG_ERR, "could not register %s version 4",
|
||||
+ rpcbind_log_error("could not register %s version 4",
|
||||
nconf->nc_netid);
|
||||
return 0;
|
||||
}
|
||||
@@ -574,15 +576,15 @@ handle_ipv6_socket(int fd)
|
||||
socklen_t len = sizeof(opt);
|
||||
|
||||
if (getsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &opt, &len)) {
|
||||
- syslog(LOG_ERR, "failed to get ipv6 socket opts: %m");
|
||||
+ rpcbind_log_error("failed to get ipv6 socket opts: %m");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (opt) /* socket is already in V6ONLY mode */
|
||||
return 0;
|
||||
|
||||
- syslog(LOG_ERR, "systemd has passed an IPv4/IPv6 dual-mode socket.");
|
||||
- syslog(LOG_ERR, "Please fix your systemd config by specifying IPv4 and IPv6 sockets separately and using BindIPv6Only=ipv6-only.");
|
||||
+ rpcbind_log_error("systemd has passed an IPv4/IPv6 dual-mode socket.");
|
||||
+ rpcbind_log_error("Please fix your systemd config by specifying IPv4 and IPv6 sockets separately and using BindIPv6Only=ipv6-only.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -613,7 +615,7 @@ rpcbind_init_endpoint(struct netconfig *nconf, const char *hostname, int fd)
|
||||
socklen_t alen = sizeof(addr);
|
||||
|
||||
if (getsockname(fd, (struct sockaddr *) &addr, &alen) < 0) {
|
||||
- syslog(LOG_ERR, "cannot get address for socket fd %d", fd);
|
||||
+ rpcbind_log_error("cannot get address for socket fd %d", fd);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -625,7 +627,7 @@ rpcbind_init_endpoint(struct netconfig *nconf, const char *hostname, int fd)
|
||||
|
||||
my_xprt = (SVCXPRT *)svc_tli_create(fd, nconf, &taddr, RPC_MAXDATASIZE, RPC_MAXDATASIZE);
|
||||
if (my_xprt == (SVCXPRT *)NULL) {
|
||||
- syslog(LOG_ERR, "%s: could not create service", nconf->nc_netid);
|
||||
+ rpcbind_log_error("%s: could not create service", nconf->nc_netid);
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
@@ -667,7 +669,7 @@ init_transport(struct netconfig *nconf)
|
||||
#endif
|
||||
|
||||
if (!__rpc_nconf2sockinfo(nconf, &si)) {
|
||||
- syslog(LOG_ERR, "cannot get information for %s",
|
||||
+ rpcbind_log_error("cannot get information for %s",
|
||||
nconf->nc_netid);
|
||||
return (1);
|
||||
}
|
||||
@@ -746,7 +748,7 @@ init_transports_daemon(void)
|
||||
|
||||
nc_handle = setnetconfig(); /* open netconfig file */
|
||||
if (nc_handle == NULL) {
|
||||
- syslog(LOG_ERR, "could not read /etc/netconfig");
|
||||
+ rpcbind_log_error("could not read /etc/netconfig");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -754,7 +756,7 @@ init_transports_daemon(void)
|
||||
if (nconf == NULL)
|
||||
nconf = getnetconfigent("unix");
|
||||
if (nconf == NULL) {
|
||||
- syslog(LOG_ERR, "rpcbind: can't find local transport\n");
|
||||
+ rpcbind_log_error("rpcbind: can't find local transport\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -798,11 +800,11 @@ init_transports_systemd()
|
||||
int nfds, n;
|
||||
|
||||
if ((nfds = sd_listen_fds(0)) < 0) {
|
||||
- syslog(LOG_ERR, "failed to acquire systemd sockets: %s", strerror(-nfds));
|
||||
+ rpcbind_log_error("failed to acquire systemd sockets: %s", strerror(-nfds));
|
||||
exit(1);
|
||||
}
|
||||
if (nfds >= 16) {
|
||||
- syslog(LOG_ERR, "too many sockets passed by systemd (%u)", nfds);
|
||||
+ rpcbind_log_error("too many sockets passed by systemd (%u)", nfds);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -814,18 +816,18 @@ init_transports_systemd()
|
||||
fd = SD_LISTEN_FDS_START + n;
|
||||
|
||||
if (!__rpc_fd2sockinfo(fd, &si)) {
|
||||
- syslog(LOG_ERR, "cannot get socket information for fd %d", fd);
|
||||
+ rpcbind_log_error("cannot get socket information for fd %d", fd);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Now find the netconfig entry matching this transport */
|
||||
if ((nconf = sockinfo2nconf(&nc_handle, &si)) == NULL) {
|
||||
- syslog(LOG_ERR, "not netconfig for socket fd %d", fd);
|
||||
+ rpcbind_log_error("not netconfig for socket fd %d", fd);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (rpcbind_init_endpoint(nconf, NULL, fd) <= 0) {
|
||||
- syslog(LOG_ERR, "unable to create transport for socket fd %d", fd);
|
||||
+ rpcbind_log_error("unable to create transport for socket fd %d", fd);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
@@ -843,7 +845,7 @@ rbllist_add(rpcprog_t prog, rpcvers_t vers, struct netconfig *nconf,
|
||||
|
||||
rbl = malloc(sizeof (rpcblist));
|
||||
if (rbl == NULL) {
|
||||
- syslog(LOG_ERR, "no memory!");
|
||||
+ rpcbind_log_error("no memory!");
|
||||
exit(1);
|
||||
}
|
||||
#ifdef RPCBIND_DEBUG
|
||||
@@ -872,7 +874,7 @@ terminate(int dummy /*__unused*/)
|
||||
unlink(_PATH_RPCBINDSOCK);
|
||||
unlink(RPCBINDDLOCK);
|
||||
#ifdef WARMSTART
|
||||
- syslog(LOG_ERR,
|
||||
+ rpcbind_log_error(
|
||||
"rpcbind terminating on signal. Restart with \"rpcbind -w\"");
|
||||
write_warmstart(); /* Dump yourself */
|
||||
#endif
|
||||
@@ -956,3 +958,33 @@ toggle_verboselog(int dummy /*__unused*/)
|
||||
{
|
||||
verboselog = !verboselog;
|
||||
}
|
||||
+
|
||||
+void
|
||||
+rpcbind_log_error(const char *fmt, ...)
|
||||
+{
|
||||
+ va_list ap;
|
||||
+
|
||||
+ va_start(ap, fmt);
|
||||
+#ifdef SYSTEMD
|
||||
+ if (systemd_activation)
|
||||
+ sd_journal_printv(LOG_ERR, fmt, ap);
|
||||
+ else
|
||||
+#endif
|
||||
+ vsyslog(LOG_ERR, fmt, ap);
|
||||
+ va_end(ap);
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+rpcbind_log(int severity, const char *fmt, ...)
|
||||
+{
|
||||
+ va_list ap;
|
||||
+
|
||||
+ va_start(ap, fmt);
|
||||
+#ifdef SYSTEMD
|
||||
+ if (systemd_activation)
|
||||
+ sd_journal_printv(severity, fmt, ap);
|
||||
+ else
|
||||
+#endif
|
||||
+ vsyslog(severity, fmt, ap);
|
||||
+ va_end(ap);
|
||||
+}
|
||||
diff --git a/src/rpcbind.h b/src/rpcbind.h
|
||||
index 74f9591..bbdbd35 100644
|
||||
--- a/src/rpcbind.h
|
||||
+++ b/src/rpcbind.h
|
||||
@@ -136,6 +136,9 @@ char *addrmerge(struct netbuf *caller, char *serv_uaddr, char *clnt_uaddr, char
|
||||
void network_init(void);
|
||||
struct sockaddr *local_sa(int);
|
||||
|
||||
+void rpcbind_log_error(const char *, ...);
|
||||
+void rpcbind_log(int, const char *, ...);
|
||||
+
|
||||
/* For different getaddr semantics */
|
||||
#define RPCB_ALLVERS 0
|
||||
#define RPCB_ONEVERS 1
|
||||
diff --git a/src/security.c b/src/security.c
|
||||
index d272f74..3b768c0 100644
|
||||
--- a/src/security.c
|
||||
+++ b/src/security.c
|
||||
@@ -274,7 +274,7 @@ logit(int severity, struct sockaddr *addr, rpcproc_t procnum, rpcprog_t prognum,
|
||||
}
|
||||
getnameinfo(addr,size , fromname, sizeof fromname, NULL, 0, NI_NUMERICHOST);
|
||||
}
|
||||
- syslog(severity, "connect from %s to %s(%s)%s",
|
||||
+ rpcbind_log(severity, "connect from %s to %s(%s)%s",
|
||||
fromname, procname, progname, text);
|
||||
_exit(0);
|
||||
}
|
||||
diff --git a/src/warmstart.c b/src/warmstart.c
|
||||
index d1bb971..16eed3e 100644
|
||||
--- a/src/warmstart.c
|
||||
+++ b/src/warmstart.c
|
||||
@@ -42,7 +42,6 @@
|
||||
#include <netinet/in.h>
|
||||
#include <rpc/pmap_prot.h>
|
||||
#endif
|
||||
-#include <syslog.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
@@ -77,9 +76,9 @@ write_struct(char *filename, xdrproc_t structproc, void *list)
|
||||
close(i);
|
||||
fp = fopen(filename, "w");
|
||||
if (fp == NULL) {
|
||||
- syslog(LOG_ERR,
|
||||
+ rpcbind_log_error(
|
||||
"cannot open file = %s for writing", filename);
|
||||
- syslog(LOG_ERR, "cannot save any registration");
|
||||
+ rpcbind_log_error("cannot save any registration");
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
@@ -87,7 +86,7 @@ write_struct(char *filename, xdrproc_t structproc, void *list)
|
||||
xdrstdio_create(&xdrs, fp, XDR_ENCODE);
|
||||
|
||||
if (structproc(&xdrs, list) == FALSE) {
|
||||
- syslog(LOG_ERR, "xdr_%s: failed", filename);
|
||||
+ rpcbind_log_error("xdr_%s: failed", filename);
|
||||
fclose(fp);
|
||||
return (FALSE);
|
||||
}
|
||||
@@ -106,7 +105,7 @@ read_struct(char *filename, xdrproc_t structproc, void *list)
|
||||
fprintf(stderr, "rpcbind: using '%s' startup file\n", filename);
|
||||
|
||||
if ((fp = fopen(filename, "r")) == NULL) {
|
||||
- syslog(LOG_ERR,
|
||||
+ rpcbind_log_error(
|
||||
"Cannot open '%s' file for reading, errno %d (%s)",
|
||||
filename, errno, strerror(errno));
|
||||
goto error;
|
||||
@@ -122,14 +121,14 @@ read_struct(char *filename, xdrproc_t structproc, void *list)
|
||||
|
||||
fclose(fp);
|
||||
if (unlink(filename) < 0) {
|
||||
- syslog(LOG_ERR, "Cannot unlink '%s', errno %d (%s)",
|
||||
+ rpcbind_log_error("Cannot unlink '%s', errno %d (%s)",
|
||||
filename, errno, strerror(errno));
|
||||
}
|
||||
return (TRUE);
|
||||
|
||||
error:
|
||||
if (errno != ENOENT && unlink(filename) < 0) {
|
||||
- syslog(LOG_ERR, "Cannot unlink '%s', errno %d (%s)",
|
||||
+ rpcbind_log_error("Cannot unlink '%s', errno %d (%s)",
|
||||
filename, errno, strerror(errno));
|
||||
}
|
||||
if (debugging)
|
||||
--
|
||||
1.7.12.4
|
||||
|
@ -1,21 +0,0 @@
|
||||
The init_transport changes broke rmtcall forwarding. Fix it.
|
||||
|
||||
---
|
||||
src/rpcbind.c | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
Index: rpcbind-0.2.1_rc4/src/rpcbind.c
|
||||
===================================================================
|
||||
--- rpcbind-0.2.1_rc4.orig/src/rpcbind.c
|
||||
+++ rpcbind-0.2.1_rc4/src/rpcbind.c
|
||||
@@ -837,6 +837,10 @@ init_transports_systemd()
|
||||
rpcbind_log_error("unable to create transport for socket fd %d", fd);
|
||||
exit(1);
|
||||
}
|
||||
+
|
||||
+ if (nconf->nc_semantics == NC_TPI_CLTS && create_rmtcall_fd(nconf) < 0) {
|
||||
+ rpcbind_log_error("unable to create rmtcall fd for %s", nconf->nc_netid);
|
||||
+ }
|
||||
}
|
||||
|
||||
if (nc_handle)
|
@ -1,3 +1,20 @@
|
||||
-------------------------------------------------------------------
|
||||
Mon Jun 4 19:42:29 UTC 2018 - tchvatal@suse.com
|
||||
|
||||
- Drop all commented out patches (4 years now):
|
||||
* 0008-First-part-of-init_transport-refactoring.patch
|
||||
* 0009-init_transport-move-the-registration-code-into-a-sep.patch
|
||||
* 0010-Fix-the-behavior-when-specifying-the-h-option.patch
|
||||
* 0011-Clean-up-the-way-we-handle-the-h-option-in-init_tran.patch
|
||||
* 0014-When-using-systemd-redirect-syslog-calls-to-the-syst.patch
|
||||
* 0030-systemd-fix-rmtcall.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Jun 4 19:34:14 UTC 2018 - tchvatal@suse.com
|
||||
|
||||
- Say goodbye to omc files fate#301838
|
||||
- Format with spec-cleaner
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Apr 3 12:06:36 UTC 2018 - dimstar@opensuse.org
|
||||
|
||||
|
26
rpcbind.spec
26
rpcbind.spec
@ -27,18 +27,11 @@ Summary: Transport independent RPC portmapper
|
||||
# Git-Web: http://git.linux-nfs.org/?p=steved/rpcbind.git;a=summary
|
||||
License: BSD-4-Clause
|
||||
Group: Productivity/Networking/System
|
||||
Url: http://rpcbind.sourceforge.net
|
||||
URL: http://rpcbind.sourceforge.net
|
||||
Source: https://downloads.sourceforge.net/sourceforge/%{name}/%{name}-%{version}.tar.bz2
|
||||
Source2: sysconfig.rpcbind
|
||||
Source3: rpcbind.xml
|
||||
Source4: pmap_set.c
|
||||
Patch1: 0001-systemd-unit-files.patch
|
||||
Patch8: 0008-First-part-of-init_transport-refactoring.patch
|
||||
Patch9: 0009-init_transport-move-the-registration-code-into-a-sep.patch
|
||||
Patch10: 0010-Fix-the-behavior-when-specifying-the-h-option.patch
|
||||
Patch11: 0011-Clean-up-the-way-we-handle-the-h-option-in-init_tran.patch
|
||||
Patch14: 0014-When-using-systemd-redirect-syslog-calls-to-the-syst.patch
|
||||
Patch30: 0030-systemd-fix-rmtcall.patch
|
||||
Patch31: 0031-rpcbind-manpage.patch
|
||||
Patch32: svc-freeargs.patch
|
||||
BuildRequires: libtirpc-devel >= 1.0.1
|
||||
@ -47,14 +40,12 @@ BuildRequires: pkgconfig
|
||||
BuildRequires: systemd-rpm-macros
|
||||
BuildRequires: tcpd-devel
|
||||
BuildRequires: pkgconfig(libsystemd)
|
||||
PreReq: %fillup_prereq
|
||||
Requires(pre): %{_sbindir}/useradd
|
||||
Requires(post): %fillup_prereq
|
||||
Requires(pre): shadow
|
||||
Provides: portmap
|
||||
%{?systemd_requires}
|
||||
%if 0%{?suse_version} >= 1330
|
||||
BuildRequires: libnsl-devel
|
||||
%endif
|
||||
%if 0%{?suse_version} >= 1330
|
||||
Requires(pre): group(nobody)
|
||||
%endif
|
||||
|
||||
@ -69,12 +60,6 @@ regards to portmap.
|
||||
%setup -q
|
||||
cp %{SOURCE4} .
|
||||
%patch1 -p1
|
||||
#%patch8 -p1
|
||||
#%patch9 -p1
|
||||
#%patch10 -p1
|
||||
#%patch11 -p1
|
||||
#%patch14 -p1
|
||||
#%patch30 -p1
|
||||
%patch31 -p1
|
||||
%patch32 -p1
|
||||
|
||||
@ -99,13 +84,11 @@ gcc -I/usr/include/tirpc -pie -fpie -fwhole-program -Wl,-z,relro,-z,now %{optfla
|
||||
# fillup template
|
||||
mkdir -p %{buildroot}%{_fillupdir}
|
||||
install -m 644 %{SOURCE2} %{buildroot}%{_fillupdir}/
|
||||
mkdir -p %{buildroot}%{_datadir}/omc/svcinfo.d
|
||||
install -m 644 %{SOURCE3} %{buildroot}%{_datadir}/omc/svcinfo.d/
|
||||
#
|
||||
install -m 755 pmap_set %{buildroot}/sbin/pmap_set2
|
||||
# create symlink for rcrpcbind
|
||||
mkdir -p %{buildroot}%{_sbindir}
|
||||
ln -s /sbin/service %{buildroot}%{_sbindir}/rc%{name}
|
||||
ln -s service %{buildroot}%{_sbindir}/rc%{name}
|
||||
|
||||
%pre
|
||||
%service_add_pre %{name}.service %{name}.socket
|
||||
@ -133,7 +116,6 @@ exit 0
|
||||
%{_sbindir}/rc%{name}
|
||||
%{_mandir}/*/*
|
||||
%{_fillupdir}/sysconfig.%{name}
|
||||
%{_datadir}/omc/svcinfo.d/%{name}.xml
|
||||
%{_unitdir}/%{name}.service
|
||||
%{_unitdir}/%{name}.socket
|
||||
|
||||
|
93
rpcbind.xml
93
rpcbind.xml
@ -1,93 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
Copyright (c) 2006 Novell, Inc. All rights reserved.
|
||||
|
||||
|
||||
Service Description XML Document for RPC Portmap.
|
||||
|
||||
This file should be placed in /etc/omc/svcinfo.d
|
||||
|
||||
Note: The name of the service is the name of this file without the .xml
|
||||
file extension.
|
||||
-->
|
||||
|
||||
<serviceDescription version="1.0">
|
||||
|
||||
<!-- Caption for display purposes -->
|
||||
<caption>Rpcbind</caption>
|
||||
|
||||
<!-- Description of this service -->
|
||||
<description>
|
||||
Transport independent RPC portmapping daemon
|
||||
</description>
|
||||
|
||||
|
||||
<!--
|
||||
The startCommand tag specifies the command line that will be
|
||||
invoked to start the service. The return code from this command
|
||||
must be as follows:
|
||||
0 - success
|
||||
1 - generic or unspecified error
|
||||
2 - invalid or excess argument(s)
|
||||
3 - unimplemented feature (e.g. "reload")
|
||||
4 - user had insufficient privileges
|
||||
5 - program is not installed
|
||||
6 - program is not configured
|
||||
7 - program is not running
|
||||
-->
|
||||
<startCommand>/sbin/rcrpcbind start</startCommand>
|
||||
|
||||
<!--
|
||||
The reStartCommand tag specifies the command line that will be
|
||||
invoked to restart the service. The return code from this command
|
||||
must be as specified in the startCommand tag.
|
||||
-->
|
||||
<reStartCommand>/sbin/rcrpcbind restart</reStartCommand>
|
||||
|
||||
<!--
|
||||
The stopCommand tag specifies the command line that will be
|
||||
invoked to stop the service. The return code from this command
|
||||
must be as specified in the startCommand tag.
|
||||
-->
|
||||
<stopCommand>/sbin/rcrpcbind stop</stopCommand>
|
||||
|
||||
<!--
|
||||
The statusCommand specifies the command line that can be run
|
||||
that will report on the status of the service. The return code
|
||||
from this command line should be as follows:
|
||||
0 - service up and running
|
||||
1 - service dead, but /var/run/ pid file exists
|
||||
2 - service dead, but /var/lock/ lock file exists
|
||||
3 - service not running (unused)
|
||||
4 - service status unknown :-(
|
||||
-->
|
||||
<statusCommand>/sbin/rcrpcbind status</statusCommand>
|
||||
<!--
|
||||
The processInformation tag allows the XML Service provider to
|
||||
identify the processes that belong to the service. This allows
|
||||
the ServiceProcess associations to be instrumented.
|
||||
If the process_information tag is not specifed, the will be no
|
||||
ServiceProcess association for the service.
|
||||
-->
|
||||
|
||||
|
||||
<processInformation>
|
||||
<name>rpcbind</name>
|
||||
<modulePath>/sbin/rpcbind</modulePath>
|
||||
</processInformation>
|
||||
|
||||
|
||||
|
||||
<!--
|
||||
Define the services that this service has a dependency on.
|
||||
There must be a corresponding Service Description XML file
|
||||
for the antecedent service in the /etc/omc/svcinfo.d directory.
|
||||
-->
|
||||
<dependsOn>
|
||||
<serviceName>network</serviceName>
|
||||
<serviceName>syslog</serviceName>
|
||||
</dependsOn>
|
||||
|
||||
|
||||
|
||||
</serviceDescription>
|
Loading…
Reference in New Issue
Block a user