Another variant of getservbyname_r.

Try the attached patch.
I can't compile it, I do not have an openbsd host.

If the patch works, we will have to fix the configure script to detect 
that variant and define GETSERVBYNAME_R4

Jean-Louis


On 01/08/17 06:17 PM, Eric Lovelace wrote:
> This seems to be the relevant part from the doc (located here: 
> https://man.openbsd.org/getservent.3 
> <https://man.openbsd.org/getservent.3>):
>
> int getservbyname_r(const char *name, const char *proto, struct 
> servent *servent, struct servent_data *servent_data);
>
> I checked out the line from the source (security-util.c line 3318)
> r = getservbyname_r(service, proto, &sp, buf, 2048, &result);
>
> So there definitely is a mismatch in parameters. It also looks like 
> that area of code already has some logic for switching between a 5 
> parameter call and a 6 parameter call; I guess when I sit back down in 
> front of the system in question I will see if I can get enough of a 
> handle on the code to write the 4 parameter call.
> ________________________________________
> From: Jean-Louis Martineau [jmartin...@carbonite.com]
> Sent: Tuesday, August 01, 2017 5:11 PM
> To: Eric Lovelace; amanda-users@amanda.org
> Subject: Re: Compiling 3.4.5 on OpenBSD 6.1
>
> How getservbyname_r is defined on OpenBSD 6.1
>
> Jean-Louis
>
> On 01/08/17 04:28 PM, Eric Lovelace wrote:
> > Hello,
> >
> > I would like to run Amanda on OpenBSD (Ideally with current versions of
> > each). From what I have found online, this was possible in previous
> > versions of both softwares but I canĀ¹t find any examples with more 
> recent
> > versions; is this setup still supported? I ran into an issue with the
> > default make command (that apparently the Makefile used some GNU make
> > exclusive features), but using gmake seemed to advance the progress a
> > little further. Has anyone encountered anything similar and been able to
> > get it working? Thanks in advance!
> >
> > The error from running gmake
> > ============================
> > libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../config -I../gnulib
> > -I../common-src -fno-strict-aliasing -D_GNU_SOURCE -I/usr/include 
> -pthread
> > -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include
> > -I/usr/local/include -Wall -Wextra -Wparentheses
> > -Wdeclaration-after-statement -Wmissing-prototypes -Wstrict-prototypes
> > -Wmissing-declarations -Wformat -Wformat-security -Wsign-compare
> > -Wfloat-equal -Wold-style-definition -Wno-strict-aliasing
> > -Wno-unknown-pragmas -Wno-deprecated-declarations
> > -DAMANDA_FILE=\"security-util.c\" -g -O2 -fno-strict-aliasing -MT
> > security-util.lo -MD -MP -MF .deps/security-util.Tpo -c security-util.c
> > -fPIC -DPIC -o .libs/security-util.o
> > security-util.c: In function 'find_port_for_service':
> > security-util.c:3318: warning: passing argument 4 of 'getservbyname_r'
> > from incompatible pointer type
> > security-util.c:3318: error: too many arguments to function
> > 'getservbyname_r'
> > gmake[3]: *** [Makefile:2479: security-util.lo] Error 1
> > gmake[3]: Leaving directory '/root/amanda-3.4.5/common-src'
> > gmake[2]: *** [Makefile:2123: all] Error 2
> > gmake[2]: Leaving directory '/root/amanda-3.4.5/common-src'
> > gmake[1]: *** [Makefile:1717: all-recursive] Error 1
> > gmake[1]: Leaving directory '/root/amanda-3.4.5'
> > gmake: *** [Makefile:1641: all] Error 2
> >
> >
> >
> >
> > The results from ./configure
> > ============================
> > Directories:
> > Application: /usr/local/libexec/amanda/application
> > Configuration: /usr/local/etc/amanda
> > GNU Tar lists: /usr/local/var/amanda/gnutar-lists
> > Perl modules (amperldir): /usr/local/libdata/perl5/site_perl
> > Template and example data files (amdatadir): /usr/local/share/amanda
> > Temporary: /tmp/amanda
> > WARNINGS:
> > no user specified (--with-user) -- using 'amanda'
> > no group specified (--with-group) -- using 'backup'
> > /bin/tar is not GNU tar, so it will not be used.
> > /usr/local/bin/smbclient does not seem to be smbclient.
> >
> >
>
This message is the property of CARBONITE, INC. and may contain confidential or 
privileged information.
If this message has been delivered to you by mistake, then do not copy or 
deliver this message to anyone.  Instead, destroy it and notify me by reply 
e-mail
diff --git a/common-src/security-util.c b/common-src/security-util.c
index 0058ab8..348f145 100644
--- a/common-src/security-util.c
+++ b/common-src/security-util.c
@@ -3302,10 +3302,11 @@ find_port_for_service(
     } else {
         struct servent *result;
 #ifdef HAVE_GETSERVBYNAME_R
-        struct servent sp;
-        char buf[2048];
 
+#define GETSERVBYNAME_R4
 #ifdef GETSERVBYNAME_R5
+        struct servent sp;
+        char buf[2048];
 	result = getservbyname_r(service, proto, &sp, buf, 2048);
 	if (result == 0) {
 	    assert(errno != ERANGE);
@@ -3314,6 +3315,19 @@ find_port_for_service(
 	    port = (in_port_t)(ntohs((in_port_t)sp.s_port));
 	}
 #else
+#ifdef GETSERVBYNAME_R4
+	struct servent_data servent_data;
+	int r;
+	memset(&servent_data, 0, sizeof(struct servent_data));
+	r = getservbyname_r(service, proto, &result, &servent_data);
+	if (r != 0) {
+	    port = 0;
+	} else {
+	    port = (in_port_t)(ntohs((in_port_t)result->s_port));
+	}
+#else
+        struct servent sp;
+        char buf[2048];
 	int r;
 	r = getservbyname_r(service, proto, &sp, buf, 2048, &result);
 	assert(r != ERANGE);
@@ -3323,6 +3337,7 @@ find_port_for_service(
 	    port = (in_port_t)(ntohs((in_port_t)sp.s_port));
 	}
 #endif
+#endif
 #else
 	if ((result = getservbyname(service, proto)) == NULL) {
 	    port = 0;

Reply via email to