Date: Thu, 30 Aug 2001 14:18:34 +0100 From: Rasputin <rara.rasputin@virgin.net> To: stable@freebsd.org Subject: Re: portmapper flags? Message-ID: <20010830141834.A4042@shaft.techsupport.co.uk> In-Reply-To: <20010829182507.P40625-100000@nohow.demon.co.uk>; from noway@nohow.demon.co.uk on Wed, Aug 29, 2001 at 06:31:18PM %2B0100 References: <20010828164720.A29316@shaft.techsupport.co.uk> <20010829182507.P40625-100000@nohow.demon.co.uk>
next in thread | previous in thread | raw e-mail | index | archive | help
--C7zPtVaVf+AK4Oqc Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Ok, if anyone needs it, can they try this patch out? It makes portmapper follow the manpage, i.e. it won't try to bind to UDP:127.0.0.1 twice and crash. It doesn't fix tcp yet, but the manpage doesn't say you can restrict tcp anyway, and for all I know there's a reason for that (no hablo NFS) Oh, and sorry if the code sucks. It works and compiles without bugs on this end, but I'm no code ninja. If anyone wants to a) let me know if it works for them b) laugh at it and suggest a neater/more secure way of doing it drop me a line. I'll hold back on a send-pr for a day or two. Cheers! -- Isn't it interesting that the same people who laugh at science fiction listen to weather forecasts and economists? -- Kelvin Throop III Rasputin :: Jack of All Trades - Master of Nuns :: --C7zPtVaVf+AK4Oqc Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="portmap.patch" --- portmap.c.orig Tue Apr 10 00:35:19 2001 +++ portmap.c Thu Aug 30 13:51:06 2001 @@ -159,12 +159,26 @@ * If no hosts were specified, just bind to INADDR_ANY. Otherwise * make sure 127.0.0.1 is added to the list. */ - ++nhosts; - hosts = realloc(hosts, nhosts * sizeof(char *)); - if (nhosts == 1) + if (nhosts == 0){ + ++nhosts; + hosts = realloc(hosts, nhosts * sizeof(char *)); hosts[0] = "0.0.0.0"; - else - hosts[nhosts - 1] = "127.0.0.1"; + } + else { + /* add localhost *if* it's not already there */ + + int n, lh_requested = 0; + + for(n=0;n<nhosts;n++) { + if(!strcmp(hosts[n],"127.0.0.1")) lh_requested = 1; + } + + if (!lh_requested) { + ++nhosts; + hosts = realloc(hosts, nhosts * sizeof(char *)); + hosts[nhosts - 1] = "127.0.0.1"; + } + } /* * Add UDP socket(s) - bind to specific IPs if asked to --C7zPtVaVf+AK4Oqc-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010830141834.A4042>