[PATCH] Problems with rpcclient -c "shutdown -r" on (Free)BSD
Rudolf Cejka
cejkar at fit.vutbr.cz
Thu Nov 27 12:08:31 GMT 2003
Dear Samba team,
I had a problem with Samba 2.2.8a with issuing commad
rpcclient -Uadministrator -c "shutdown -r" <host>
on FreeBSD and I have found that there is a problem with two calls to
getopt() with different arguments in rpcclient (one for cmd args for
rpcclient, the second for cmd args for shutdown procedure).
Since 4.4BSD Lite, there is external variable optreset, which has
to be used for reset of processing arguments in getopt(), so I have
made patch, which solves my problem on FreeBSD - and I did not check
it on any real OpenBSD nor NetBSD, but I expect that on these systems
would be the same problem (manual pages know about optreset on all
three systems).
Original smaba 2.2.8a on FreeBSD:
# rpcclient -Uadministrator -c "shutdown -r" <host>
Password:
cmd = shutdown -r
... and computer is incorrectly shutted down.
Samba 2.2.8a on FreeBSD with my patch:
# rpcclient -Uadministrator -c "shutdown -r" <host>
Password:
cmd = shutdown -r
[-r]
... and computer is correctly rebooted
It would be great, if you incorporate this (or similar)
fix into next samba version, thanks.
--- 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)
{
--
Rudolf Cejka <cejkar at fit.vutbr.cz> http://www.fit.vutbr.cz/~cejkar
Brno University of Technology, Faculty of Information Technology
Bozetechova 2, 612 66 Brno, Czech Republic
More information about the samba-technical
mailing list