Example #1
0
int net_rap_session(struct net_context *c, int argc, const char **argv)
{
	struct functable func[] = {
		{
			"info",
			rap_session_info,
			NET_TRANSPORT_RAP,
			N_("Display information about session"),
			N_("net rap session info\n"
			   "    Display information about session")
		},
		{
			"delete",
			rap_session_delete,
			NET_TRANSPORT_RAP,
			N_("Close specified session"),
			N_("net rap session delete\n"
			   "    Close specified session\n"
			   "    Alias for net rap session close")
		},
		{
			"close",
			rap_session_delete,
			NET_TRANSPORT_RAP,
			N_("Close specified session"),
			N_("net rap session close\n"
			   "    Close specified session")
		},
		{NULL, NULL, 0, NULL, NULL}
	};

	if (argc == 0) {
		struct cli_state *cli;
		int ret;

		if (c->display_usage) {
			d_printf(_("Usage:\n"));
			d_printf(_("net rap session\n"
				   "    List all open sessions on remote "
				   "server\n"));
			net_display_usage_from_functable(func);
			return 0;
		}

		if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
			return -1;

		d_printf(_("Computer             User name            "
			   "Client Type        Opens Idle time\n"
			   "------------------------------------------"
			   "------------------------------------\n"));
		ret = cli_NetSessionEnum(cli, list_sessions_func);

		cli_shutdown(cli);
		return ret;
	}

	return net_run_function(c, argc, argv, "net rap session", func);
}
Example #2
0
int net_rap_group(struct net_context *c, int argc, const char **argv)
{
	struct functable func[] = {
		{
			"add",
			rap_group_add,
			NET_TRANSPORT_RAP,
			N_("Add specified group"),
			N_("net rap group add\n"
			   "    Add specified group")
		},
		{
			"delete",
			rap_group_delete,
			NET_TRANSPORT_RAP,
			N_("Delete specified group"),
			N_("net rap group delete\n"
			   "    Delete specified group")
		},
		{NULL, NULL, 0, NULL, NULL}
	};

	if (argc == 0) {
		struct cli_state *cli;
		int ret;
		if (c->display_usage) {
			d_printf(_("Usage:\n"));
			d_printf(_("net rap group\n"
				   "    List all groups\n"));
			net_display_usage_from_functable(func);
			return 0;
		}

		if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
                        return -1;
		if (c->opt_long_list_entries) {
			d_printf(_("Group name            Comment\n"
			           "-----------------------------\n"));
			ret = cli_RNetGroupEnum(cli, long_group_fn, NULL);
			cli_shutdown(cli);
			return ret;
		}
		ret = cli_RNetGroupEnum0(cli, group_fn, NULL);
		cli_shutdown(cli);
		return ret;
	}

	return net_run_function(c, argc, argv, "net rap group", func);
}
Example #3
0
int net_rap_service(struct net_context *c, int argc, const char **argv)
{
	struct functable func[] = {
		{
			"start",
			rap_service_start,
			NET_TRANSPORT_RAP,
			N_("Start service on remote server"),
			N_("net rap service start\n"
			   "    Start service on remote server")
		},
		{
			"stop",
			rap_service_stop,
			NET_TRANSPORT_RAP,
			N_("Stop named serve on remote server"),
			N_("net rap service stop\n"
			   "    Stop named serve on remote server")
		},
		{NULL, NULL, 0, NULL, NULL}
	};

	if (argc == 0) {
		struct cli_state *cli;
		int ret;
		if (c->display_usage) {
			d_printf(_("Usage:\n"));
			d_printf(_("net rap service\n"
				   "    List services on remote server\n"));
			net_display_usage_from_functable(func);
			return 0;
		}

		if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
			return -1;

		if (c->opt_long_list_entries) {
			d_printf(_("Service name          Comment\n"
		                   "-----------------------------\n"));
			ret = cli_RNetServiceEnum(cli, long_group_fn, NULL);
		}
		ret = cli_RNetServiceEnum(cli, service_fn, NULL);
		cli_shutdown(cli);
		return ret;
	}

	return net_run_function(c, argc, argv, "net rap service", func);
}
Example #4
0
int net_rap_printq(struct net_context *c, int argc, const char **argv)
{
	struct cli_state *cli;
	int ret;

	struct functable func[] = {
		{
			"info",
			rap_printq_info,
			NET_TRANSPORT_RAP,
			N_("Display info about print queues and jobs"),
			N_("net rap printq info [queue]\n"
			   "    Display info about print jobs in queue.\n"
			   "    If queue is not specified, all queues are "
			   "listed")
		},
		{
			"delete",
			rap_printq_delete,
			NET_TRANSPORT_RAP,
			N_("Delete print job(s)"),
			N_("net rap printq delete\n"
			   "    Delete print job(s)")
		},
		{NULL, NULL, 0, NULL, NULL}
	};

	if (argc == 0) {
		if (c->display_usage) {
			d_printf(_("Usage:\n"));
			d_printf(_("net rap printq\n"
				   "    List the print queue\n"));
			net_display_usage_from_functable(func);
			return 0;
		}

		if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
			return -1;

		d_printf(PRINTQ_ENUM_DISPLAY, smbXcli_conn_remote_name(cli->conn)); /* list header */
		ret = cli_NetPrintQEnum(cli, enum_queue, enum_jobs);
		cli_shutdown(cli);
		return ret;
	}

	return net_run_function(c, argc, argv, "net rap printq", func);
}
Example #5
0
/* display or set the time on a host */
int net_time(struct net_context *c, int argc, const char **argv)
{
	time_t t;
	struct functable func[] = {
		{
			"system",
			net_time_system,
			NET_TRANSPORT_LOCAL,
			N_("Display time ready for /bin/date"),
			N_("net time system\n"
			   "    Display time ready for /bin/date")
		},
		{
			"set",
			net_time_set,
			NET_TRANSPORT_LOCAL,
			N_("Set the system time from time server"),
			N_("net time set\n"
			   "    Set the system time from time server")
		},
		{
			"zone",
			net_time_zone,
			NET_TRANSPORT_LOCAL,
			N_("Display timezone offset from UTC"),
			N_("net time zone\n"
			   "    Display timezone offset from UTC")
		},
		{NULL, NULL, 0, NULL, NULL}
	};

	if (argc != 0) {
		return net_run_function(c, argc, argv, "net time", func);
	}

	if (c->display_usage) {
		d_printf(  "%s\n"
		           "net time\n"
			   "    %s\n",
			 _("Usage:"),
			 _("Display the remote time server's time"));
		net_display_usage_from_functable(func);
		return 0;
	}

	if (c->opt_host == NULL && !c->opt_have_ip) {
		bool ok;

		ok = find_master_ip(c->opt_target_workgroup, &c->opt_dest_ip);
		if (!ok) {
			d_fprintf(stderr,
				  _("Could not locate a time server.  "
				    "Try specifying a target host.\n"));
			net_time_usage(c, argc, argv);
			return -1;
		}
		c->opt_have_ip = true;
	}

	/* default - print the time */
	t = cli_servertime(c->opt_host,
			   c->opt_have_ip? &c->opt_dest_ip : NULL,
			   NULL);
	if (t == 0) return -1;

	d_printf("%s", ctime(&t));
	return 0;
}
Example #6
0
int net_rap_user(struct net_context *c, int argc, const char **argv)
{
	int ret = -1;
	struct functable func[] = {
		{
			"add",
			rap_user_add,
			NET_TRANSPORT_RAP,
			N_("Add specified user"),
			N_("net rap user add\n"
			   "    Add specified user")
		},
		{
			"info",
			rap_user_info,
			NET_TRANSPORT_RAP,
			N_("List domain groups of specified user"),
			N_("net rap user info\n"
			   "    List domain groups of specified user")

		},
		{
			"delete",
			rap_user_delete,
			NET_TRANSPORT_RAP,
			N_("Remove specified user"),
			N_("net rap user delete\n"
			   "    Remove specified user")
		},
		{NULL, NULL, 0, NULL, NULL}
	};

	if (argc == 0) {
		struct cli_state *cli;
		if (c->display_usage) {
			d_printf(_("Usage:\n"));
			d_printf(_("net rap user\n"
				   "    List all users\n"));
			net_display_usage_from_functable(func);
			return 0;
		}

		if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
                        goto done;
		if (c->opt_long_list_entries) {
			d_printf(_("\nUser name             Comment"
				   "\n-----------------------------\n"));
			ret = cli_RNetUserEnum(cli, long_user_fn, NULL);
			cli_shutdown(cli);
			goto done;
		}
		ret = cli_RNetUserEnum0(cli, user_fn, NULL);
		cli_shutdown(cli);
		goto done;
	}

	ret = net_run_function(c, argc, argv, "net rap user", func);
 done:
	if (ret != 0) {
		DEBUG(1, (_("Net user returned: %d\n"), ret));
	}
	return ret;
}
Example #7
0
int net_rap_share(struct net_context *c, int argc, const char **argv)
{
	struct functable func[] = {
		{
			"delete",
			rap_share_delete,
			NET_TRANSPORT_RAP,
			N_("Delete a share from server"),
			N_("net rap share delete\n"
			   "    Delete a share from server")
		},
		{
			"close",
			rap_share_delete,
			NET_TRANSPORT_RAP,
			N_("Delete a share from server"),
			N_("net rap share close\n"
			   "    Delete a share from server\n"
			   "    Alias for net rap share delete")
		},
		{
			"add",
			rap_share_add,
			NET_TRANSPORT_RAP,
			N_("Add a share to server"),
			N_("net rap share add\n"
			   "    Add a share to server")
		},
		{NULL, NULL, 0, NULL, NULL}
	};

	if (argc == 0) {
		struct cli_state *cli;
		int ret;

		if (c->display_usage) {
			d_printf(_("Usage:\n"));
			d_printf(_("net rap share\n"
				   "    List all shares on remote server\n"));
			net_display_usage_from_functable(func);
			return 0;
		}

		if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
			return -1;

		if (c->opt_long_list_entries) {
			d_printf(_(
	"\nEnumerating shared resources (exports) on remote server:\n\n"
	"\nShare name   Type     Description\n"
	"----------   ----     -----------\n"));
			ret = cli_RNetShareEnum(cli, long_share_fn, NULL);
		} else {
			ret = cli_RNetShareEnum(cli, share_fn, NULL);
		}
		cli_shutdown(cli);
		return ret;
	}

	return net_run_function(c, argc, argv, "net rap share", func);
}
Example #8
0
int net_rap_file(struct net_context *c, int argc, const char **argv)
{
	struct functable func[] = {
		{
			"close",
			rap_file_close,
			NET_TRANSPORT_RAP,
			N_("Close specified file on server"),
			N_("net rap file close\n"
			   "    Close specified file on server")
		},
		{
			"user",
			rap_file_user,
			NET_TRANSPORT_RAP,
			N_("List all files opened by username"),
			N_("net rap file user\n"
			   "    List all files opened by username")
		},
		{
			"info",
			rap_file_info,
			NET_TRANSPORT_RAP,
			N_("Display info about an opened file"),
			N_("net rap file info\n"
			   "    Display info about an opened file")
		},
		{NULL, NULL, 0, NULL, NULL}
	};

	if (argc == 0) {
		struct cli_state *cli;
		int ret;

		if (c->display_usage) {
			d_printf(_("Usage:\n"));
			d_printf(_("net rap file\n"
				   "    List all open files on rempte "
				   "server\n"));
			net_display_usage_from_functable(func);
			return 0;
		}

		if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
                        return -1;

		/* list open files */

		d_printf(_("\nEnumerating open files on remote server:\n\n"
			   "\nFileId  Opened by            Perms  Locks  Path\n"
			   "------  ---------            -----  -----  ----\n"));
		ret = cli_NetFileEnum(cli, NULL, NULL, file_fn);

		if (ret == -1)
			d_printf(_("\nOperation not supported by server!\n\n"));

		cli_shutdown(cli);
		return ret;
	}

	return net_run_function(c, argc, argv, "net rap file", func);
}