summaryrefslogtreecommitdiff
path: root/usr/src/cmd/fs.d
diff options
context:
space:
mode:
authorGordon Ross <gwr@nexenta.com>2018-04-08 10:09:12 -0400
committerGordon Ross <gwr@nexenta.com>2018-10-14 10:47:35 -0400
commita6d101109bfb442cf0db6d8ebb5fb7c32cb16d7e (patch)
tree872f4511663f1a3a203c28c4a70e888f0d77b495 /usr/src/cmd/fs.d
parent4226f635096bf9d814aa9fb335518c4855bbe3a3 (diff)
downloadillumos-joyent-a6d101109bfb442cf0db6d8ebb5fb7c32cb16d7e.tar.gz
9472 Add smbutil discon command
Reviewed by: Matt Barden <matt.barden@nexenta.com> Reviewed by: Evan Layton <evan.layton@nexenta.com> Reviewed by: Andy Fiddaman <andy@omniosce.org> Reviewed by: Ken Mays <kmays2000@gmail.com> Approved by: Dan McDonald <danmcd@joyent.com>
Diffstat (limited to 'usr/src/cmd/fs.d')
-rw-r--r--usr/src/cmd/fs.d/smbclnt/smbiod-svc/smbiod-svc.c4
-rw-r--r--usr/src/cmd/fs.d/smbclnt/smbutil/Makefile2
-rw-r--r--usr/src/cmd/fs.d/smbclnt/smbutil/common.h2
-rw-r--r--usr/src/cmd/fs.d/smbclnt/smbutil/discon.c110
-rw-r--r--usr/src/cmd/fs.d/smbclnt/smbutil/smbutil.c7
-rw-r--r--usr/src/cmd/fs.d/smbclnt/smbutil/view.c2
6 files changed, 121 insertions, 6 deletions
diff --git a/usr/src/cmd/fs.d/smbclnt/smbiod-svc/smbiod-svc.c b/usr/src/cmd/fs.d/smbclnt/smbiod-svc/smbiod-svc.c
index d99e04ba8d..23c0e4d1a0 100644
--- a/usr/src/cmd/fs.d/smbclnt/smbiod-svc/smbiod-svc.c
+++ b/usr/src/cmd/fs.d/smbclnt/smbiod-svc/smbiod-svc.c
@@ -560,14 +560,14 @@ child_gone(uid_t uid, pid_t pid, int status)
x = WEXITSTATUS(status);
if (x != 0) {
fprintf(stderr,
- "uid %d, pid %d exit %d",
+ "uid %d, pid %d exit %d\n",
uid, (int)pid, x);
}
}
if (WIFSIGNALED(status)) {
x = WTERMSIG(status);
fprintf(stderr,
- "uid %d, pid %d signal %d",
+ "uid %d, pid %d signal %d\n",
uid, (int)pid, x);
}
}
diff --git a/usr/src/cmd/fs.d/smbclnt/smbutil/Makefile b/usr/src/cmd/fs.d/smbclnt/smbutil/Makefile
index e20054c772..f15dcc8f67 100644
--- a/usr/src/cmd/fs.d/smbclnt/smbutil/Makefile
+++ b/usr/src/cmd/fs.d/smbclnt/smbutil/Makefile
@@ -32,7 +32,7 @@
PROG= smbutil
-OBJS= smbutil.o info.o login.o lookup.o print.o status.o view.o \
+OBJS= smbutil.o discon.o info.o login.o lookup.o print.o status.o view.o \
shares_rap.o shares_rpc.o srvsvc1_clnt.o srvsvc1_ndr.o
SRCS= $(OBJS:%.o=%.c)
diff --git a/usr/src/cmd/fs.d/smbclnt/smbutil/common.h b/usr/src/cmd/fs.d/smbclnt/smbutil/common.h
index aea093c0ea..74a8011f35 100644
--- a/usr/src/cmd/fs.d/smbclnt/smbutil/common.h
+++ b/usr/src/cmd/fs.d/smbclnt/smbutil/common.h
@@ -45,6 +45,7 @@ extern "C" {
#include <stdlib.h>
int cmd_crypt(int argc, char *argv[]);
+int cmd_discon(int argc, char *argv[]);
int cmd_help(int argc, char *argv[]);
int cmd_info(int argc, char *argv[]);
int cmd_login(int argc, char *argv[]);
@@ -56,6 +57,7 @@ int cmd_status(int argc, char *argv[]);
int cmd_view(int argc, char *argv[]);
void crypt_usage(void);
+void discon_usage(void);
void help_usage(void);
void info_usage(void);
void login_usage(void);
diff --git a/usr/src/cmd/fs.d/smbclnt/smbutil/discon.c b/usr/src/cmd/fs.d/smbclnt/smbutil/discon.c
new file mode 100644
index 0000000000..84b94a0332
--- /dev/null
+++ b/usr/src/cmd/fs.d/smbclnt/smbutil/discon.c
@@ -0,0 +1,110 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2018 Nexenta Systems, Inc. All rights reserved.
+ */
+
+/*
+ * smbutil "discon" sub-command to disconnect a session
+ * (mostly for usr/src/test/smbclient-tests)
+ */
+
+#include <sys/types.h>
+#include <errno.h>
+#include <stdio.h>
+#include <err.h>
+#include <unistd.h>
+#include <strings.h>
+#include <stdlib.h>
+#include <sysexits.h>
+#include <libintl.h>
+
+#include <netsmb/smb.h>
+#include <netsmb/smb_lib.h>
+#include "common.h"
+
+void
+discon_usage(void)
+{
+ printf(gettext("usage: smbutil discon [connection options] "
+ "//[workgroup;][user@]server\n"));
+ exit(1);
+}
+
+int
+cmd_discon(int argc, char *argv[])
+{
+ struct smb_ctx *ctx;
+ int error, opt;
+
+ if (argc < 2)
+ discon_usage();
+
+ error = smb_ctx_alloc(&ctx);
+ if (error != 0)
+ return (error);
+
+ error = smb_ctx_scan_argv(ctx, argc, argv,
+ SMBL_SERVER, SMBL_SERVER, USE_WILDCARD);
+ if (error != 0)
+ goto out;
+
+ error = smb_ctx_readrc(ctx);
+ if (error != 0)
+ goto out;
+
+ while ((opt = getopt(argc, argv, STDPARAM_OPT)) != EOF) {
+ if (opt == '?')
+ discon_usage();
+ error = smb_ctx_opt(ctx, opt, optarg);
+ if (error != 0)
+ goto out;
+ }
+
+ /*
+ * Resolve the server address,
+ * setup derived defaults.
+ */
+ error = smb_ctx_resolve(ctx);
+ if (error != 0)
+ goto out;
+
+ /*
+ * Have server, user, etc. from above:
+ * smb_ctx_scan_argv, option settings.
+ *
+ * Lookup a session without creating.
+ * (First part of smb_ctx_get_ssn)
+ * If we find the session, kill it.
+ */
+ error = smb_ctx_findvc(ctx);
+ if (error == ENOENT) {
+ /* Already gone. We're done. */
+ if (smb_debug)
+ fprintf(stderr, "session not found\n");
+ error = 0;
+ goto out;
+ }
+ if (error == 0) {
+ /* Found session. Kill it. */
+ error = smb_ctx_kill(ctx);
+ }
+
+ if (error != 0) {
+ smb_error(gettext("//%s: discon failed"),
+ error, ctx->ct_fullserver);
+ }
+
+out:
+ smb_ctx_free(ctx);
+ return (error);
+}
diff --git a/usr/src/cmd/fs.d/smbclnt/smbutil/smbutil.c b/usr/src/cmd/fs.d/smbclnt/smbutil/smbutil.c
index 9b09b87d64..aa10f999ee 100644
--- a/usr/src/cmd/fs.d/smbclnt/smbutil/smbutil.c
+++ b/usr/src/cmd/fs.d/smbclnt/smbutil/smbutil.c
@@ -70,6 +70,7 @@ static struct commands {
int flags;
} commands[] = {
{"crypt", cmd_crypt, NULL, CMDFL_NO_KMOD},
+ {"discon", cmd_discon, discon_usage, 0},
{"help", cmd_help, help_usage, CMDFL_NO_KMOD},
{"info", cmd_info, info_usage, 0},
{"login", cmd_login, login_usage, 0},
@@ -184,7 +185,8 @@ main(int argc, char *argv[])
}
static void
-help(void) {
+help(void)
+{
printf("\n");
printf(gettext("usage: %s [-hv] subcommand [args]\n"), __progname);
printf(gettext("where subcommands are:\n"
@@ -204,7 +206,8 @@ help(void) {
}
void
-help_usage(void) {
+help_usage(void)
+{
printf(gettext("usage: smbutil help command\n"));
exit(1);
}
diff --git a/usr/src/cmd/fs.d/smbclnt/smbutil/view.c b/usr/src/cmd/fs.d/smbclnt/smbutil/view.c
index 8622fb14be..bf3397c166 100644
--- a/usr/src/cmd/fs.d/smbclnt/smbutil/view.c
+++ b/usr/src/cmd/fs.d/smbclnt/smbutil/view.c
@@ -146,7 +146,7 @@ again:
out:
smb_ctx_free(ctx);
- return (0);
+ return (error);
}
#ifdef I18N /* not defined, put here so xgettext(1) can find strings */