Problems with rpcclient on FreeBSD

Richard Sharpe rsharpe at richardsharpe.com
Mon May 17 17:29:14 GMT 2004


On Mon, 17 May 2004, Rudolf Cejka wrote:

> There is a comment about getopt() reinitialization in rpcclient/cmd_reg.c:
> /* TODO: test if this hack works on other systems too --simo */
> As far as I know, it does not work atleast on FreeBSD, where optreset
> has to be used instead of just setting optind. The same problem seems to
> be in 2.2.9 and in 3.0.4. Please apply following or similar patch in Samba,
> so that rpcclient -c "command -parameter" could work on FreeBSD. I think
> that other BSDs could have the same problem.

There are a couple of problems with this change.

1. rpcclient is kind of only semi-supported

2. Since it is likely that all of *BSD have this issue, we really should
have a configure test that tests for the presence of optreset. The #ifdefs
below then would be #ifdef HAVE_OPTRESET ...

> Thanks you very much.
>
> --- source/rpcclient/cmd_reg.c.orig	Thu Nov 27 12:17:08 2003
> +++ source/rpcclient/cmd_reg.c	Thu Nov 27 12:19:24 2003
> @@ -900,6 +900,9 @@
>  {
>  	extern char *optarg;
>  	extern int optind;
> +#if	defined(__FreeBSD__)
> +	extern int optreset;
> +#endif
>  	NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
>  	fstring msg;
>  	uint32 timeout = 20;
> @@ -907,7 +910,11 @@
>  	int opt;
>
>  	*msg = 0;
> +#if	defined(__FreeBSD__)
> +	optreset = optind = 1;
> +#else
>  	optind = 0; /* TODO: test if this hack works on other systems too --simo */
> +#endif
>
>  	while ((opt = getopt(argc, argv, "m:t:rf")) != EOF)
>  	{

Regards
-----
Richard Sharpe, rsharpe[at]richardsharpe.com, rsharpe[at]samba.org,
sharpe[at]ethereal.com, http://www.richardsharpe.com


More information about the samba-technical mailing list