Print this page
3328 smbutil view does't work with Win2008 and later
requires 1575 untangle libmlrpc ...


  16  * 4. Neither the name of the author nor the names of any co-contributors
  17  *    may be used to endorse or promote products derived from this software
  18  *    without specific prior written permission.
  19  *
  20  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30  * SUCH DAMAGE.
  31  */
  32 
  33 /*
  34  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  35  * Use is subject to license terms.


  36  */
  37 
  38 #include <sys/param.h>
  39 #include <sys/time.h>
  40 #include <stdio.h>
  41 #include <string.h>
  42 #include <unistd.h>
  43 #include <stdlib.h>
  44 #include <err.h>
  45 #include <sysexits.h>
  46 #include <locale.h>
  47 #include <libintl.h>
  48 
  49 #include <netsmb/smb_lib.h>
  50 
  51 #include "common.h"
  52 
  53 #ifndef EX_DATAERR
  54 #define EX_DATAERR 1
  55 #endif
  56 
  57 static void help(void);
  58 
  59 
  60 typedef int cmd_fn_t (int argc, char *argv[]);
  61 typedef void cmd_usage_t (void);
  62 
  63 #define CMDFL_NO_KMOD   0x0001
  64 
  65 static struct commands {
  66         const char      *name;
  67         cmd_fn_t        *fn;
  68         cmd_usage_t     *usage;
  69         int             flags;
  70 } commands[] = {
  71         {"crypt",       cmd_crypt,      NULL, CMDFL_NO_KMOD},
  72         {"help",        cmd_help,       help_usage, CMDFL_NO_KMOD},

  73         {"login",       cmd_login,      login_usage, 0},
  74         {"logout",      cmd_logout,     logout_usage, 0},
  75         {"logoutall",   cmd_logoutall,  logoutall_usage, 0},
  76         {"lookup",      cmd_lookup,     lookup_usage, CMDFL_NO_KMOD},
  77         {"print",       cmd_print,      print_usage, 0},
  78         {"status",      cmd_status,     status_usage, CMDFL_NO_KMOD},
  79         {"view",        cmd_view,       view_usage, 0},
  80         {NULL, NULL, NULL, 0}
  81 };
  82 
  83 static struct commands *
  84 lookupcmd(const char *name)
  85 {
  86         struct commands *cmd;
  87 
  88         for (cmd = commands; cmd->name; cmd++) {
  89                 if (strcmp(cmd->name, name) == 0)
  90                         return (cmd);
  91         }
  92         return (NULL);


 172                 errx(EX_DATAERR, gettext("unknown command %s"), cp);
 173 
 174         if ((cmd->flags & CMDFL_NO_KMOD) == 0 && smb_lib_init() != 0)
 175                 exit(1);
 176 
 177         argc -= optind;
 178         argv += optind;
 179         optind = 1;
 180         err = cmd->fn(argc, argv);
 181         return ((err) ? 1 : 0);
 182 }
 183 
 184 static void
 185 help(void) {
 186         printf("\n");
 187         printf(gettext("usage: %s [-hv] subcommand [args]\n"), __progname);
 188         printf(gettext("where subcommands are:\n"
 189         " crypt         slightly obscure password\n"
 190         " help          display help on specified subcommand\n"
 191         /* " lc                 display active connections\n" */

 192         " login         login to specified host\n"
 193         " logout        logout from specified host\n"
 194         " logoutall     logout all users (requires privilege)\n"
 195         " lookup        resolve NetBIOS name to IP address\n"
 196         " print         print file to the specified remote printer\n"
 197         " status        resolve IP address or DNS name to NetBIOS names\n"
 198         " view          list resources on specified host\n"
 199         "\n"));
 200         exit(1);
 201 }
 202 
 203 void
 204 help_usage(void) {
 205         printf(gettext("usage: smbutil help command\n"));
 206         exit(1);
 207 }


  16  * 4. Neither the name of the author nor the names of any co-contributors
  17  *    may be used to endorse or promote products derived from this software
  18  *    without specific prior written permission.
  19  *
  20  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30  * SUCH DAMAGE.
  31  */
  32 
  33 /*
  34  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  35  * Use is subject to license terms.
  36  *
  37  * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
  38  */
  39 
  40 #include <sys/param.h>
  41 #include <sys/time.h>
  42 #include <stdio.h>
  43 #include <string.h>
  44 #include <unistd.h>
  45 #include <stdlib.h>
  46 #include <err.h>
  47 #include <sysexits.h>
  48 #include <locale.h>
  49 #include <libintl.h>
  50 
  51 #include <netsmb/smb_lib.h>
  52 
  53 #include "common.h"
  54 
  55 #ifndef EX_DATAERR
  56 #define EX_DATAERR 1
  57 #endif
  58 
  59 static void help(void);
  60 
  61 
  62 typedef int cmd_fn_t (int argc, char *argv[]);
  63 typedef void cmd_usage_t (void);
  64 
  65 #define CMDFL_NO_KMOD   0x0001
  66 
  67 static struct commands {
  68         const char      *name;
  69         cmd_fn_t        *fn;
  70         cmd_usage_t     *usage;
  71         int             flags;
  72 } commands[] = {
  73         {"crypt",       cmd_crypt,      NULL, CMDFL_NO_KMOD},
  74         {"help",        cmd_help,       help_usage, CMDFL_NO_KMOD},
  75         {"info",        cmd_info,       info_usage, 0},
  76         {"login",       cmd_login,      login_usage, 0},
  77         {"logout",      cmd_logout,     logout_usage, 0},
  78         {"logoutall",   cmd_logoutall,  logoutall_usage, 0},
  79         {"lookup",      cmd_lookup,     lookup_usage, CMDFL_NO_KMOD},
  80         {"print",       cmd_print,      print_usage, 0},
  81         {"status",      cmd_status,     status_usage, CMDFL_NO_KMOD},
  82         {"view",        cmd_view,       view_usage, 0},
  83         {NULL, NULL, NULL, 0}
  84 };
  85 
  86 static struct commands *
  87 lookupcmd(const char *name)
  88 {
  89         struct commands *cmd;
  90 
  91         for (cmd = commands; cmd->name; cmd++) {
  92                 if (strcmp(cmd->name, name) == 0)
  93                         return (cmd);
  94         }
  95         return (NULL);


 175                 errx(EX_DATAERR, gettext("unknown command %s"), cp);
 176 
 177         if ((cmd->flags & CMDFL_NO_KMOD) == 0 && smb_lib_init() != 0)
 178                 exit(1);
 179 
 180         argc -= optind;
 181         argv += optind;
 182         optind = 1;
 183         err = cmd->fn(argc, argv);
 184         return ((err) ? 1 : 0);
 185 }
 186 
 187 static void
 188 help(void) {
 189         printf("\n");
 190         printf(gettext("usage: %s [-hv] subcommand [args]\n"), __progname);
 191         printf(gettext("where subcommands are:\n"
 192         " crypt         slightly obscure password\n"
 193         " help          display help on specified subcommand\n"
 194         /* " lc                 display active connections\n" */
 195         " info          display server type and version\n"
 196         " login         login to specified host\n"
 197         " logout        logout from specified host\n"
 198         " logoutall     logout all users (requires privilege)\n"
 199         " lookup        resolve NetBIOS name to IP address\n"
 200         " print         print file to the specified remote printer\n"
 201         " status        resolve IP address or DNS name to NetBIOS names\n"
 202         " view          list resources on specified host\n"
 203         "\n"));
 204         exit(1);
 205 }
 206 
 207 void
 208 help_usage(void) {
 209         printf(gettext("usage: smbutil help command\n"));
 210         exit(1);
 211 }