Ejemplo n.º 1
0
static int rap_session_info(struct net_context *c, int argc, const char **argv)
{
	const char *sessname;
	struct cli_state *cli;
	int ret;

	if (argc == 0 || c->display_usage)
                return net_rap_session_usage(c, argc, argv);

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

	sessname = argv[0];

	ret = cli_NetSessionGetInfo(cli, sessname, display_session_func);
	if (ret < 0) {
		cli_shutdown(cli);
                return ret;
	}

	d_printf(_("Share name     Type     # Opens\n-------------------------"
		   "-----------------------------------------------------\n"));
	ret = cli_NetConnectionEnum(cli, sessname, display_conns_func);
	cli_shutdown(cli);
	return ret;
}
Ejemplo n.º 2
0
static int rap_user_add(int argc, const char **argv)
{
	struct cli_state *cli;
	int ret;
	RAP_USER_INFO_1 userinfo;

	if (argc == 0) {
		d_printf("\n\nUser name not specified\n");
                return net_rap_user_usage(argc, argv);
	}

	if (!(cli = net_make_ipc_connection(0)))
                return -1;
			
	safe_strcpy(userinfo.user_name, argv[0], sizeof(userinfo.user_name)-1);
	if (opt_flags == -1) 
                opt_flags = 0x21; 
			
	userinfo.userflags = opt_flags;
	userinfo.reserved1 = '\0';
	userinfo.comment = smb_xstrdup(opt_comment);
	userinfo.priv = 1; 
	userinfo.home_dir = NULL;
	userinfo.logon_script = NULL;

	ret = cli_NetUserAdd(cli, &userinfo);

	cli_shutdown(cli);
	return ret;
}
Ejemplo n.º 3
0
static int rap_session_info(int argc, const char **argv)
{
	const char *sessname;
	struct cli_state *cli;
	int ret;
	
	if (!(cli = net_make_ipc_connection(0))) 
                return -1;

	if (argc == 0) 
                return net_rap_session_usage(argc, argv);

	sessname = argv[0];

	ret = cli_NetSessionGetInfo(cli, sessname, display_session_func);
	if (ret < 0) {
		cli_shutdown(cli);
                return ret;
	}

	d_printf("Share name     Type     # Opens\n-------------------------"\
		 "-----------------------------------------------------\n");
	ret = cli_NetConnectionEnum(cli, sessname, display_conns_func);
	cli_shutdown(cli);
	return ret;
}
Ejemplo n.º 4
0
int net_rap_share(int argc, const char **argv)
{
	struct functable func[] = {
		{"DELETE", rap_share_delete},
		{"CLOSE", rap_share_delete},
		{"ADD", rap_share_add},
		{NULL, NULL}
	};

	if (argc == 0) {
		struct cli_state *cli;
		int ret;
		
		if (!(cli = net_make_ipc_connection(0))) 
			return -1;
		
		if (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(argc, argv, func, net_rap_share_usage);
}
Ejemplo n.º 5
0
static int net_rap_server_name(struct net_context *c, int argc, const char *argv[])
{
	struct cli_state *cli;
	char *name;

	if (c->display_usage) {
		d_printf("%s\n%s",
			 _("Usage:"),
			 _("net rap server name\n"
			   "    Get the name of the server\n"));
		return 0;
	}

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

	if (!cli_get_server_name(NULL, cli, &name)) {
		d_fprintf(stderr, _("cli_get_server_name failed\n"));
		cli_shutdown(cli);
		return -1;
	}

	d_printf(_("Server name = %s\n"), name);

	TALLOC_FREE(name);
	cli_shutdown(cli);
	return 0;
}
Ejemplo n.º 6
0
int net_rap_file(int argc, const char **argv)
{
	struct functable func[] = {
		{"CLOSE", rap_file_close},
		{"USER", rap_file_user},
		{"INFO", rap_file_info},
		{NULL, NULL}
	};
	
	if (argc == 0) {
		struct cli_state *cli;
		int ret;
		
		if (!(cli = net_make_ipc_connection(0))) 
                        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);
		cli_shutdown(cli);
		return ret;
	}
	
	return net_run_function(argc, argv, func, net_rap_file_usage);
}
Ejemplo n.º 7
0
static int rap_user_add(struct net_context *c, int argc, const char **argv)
{
	struct cli_state *cli;
	int ret;
	struct rap_user_info_1 userinfo;

	if (argc == 0 || c->display_usage) {
                return net_rap_user_usage(c, argc, argv);
	}

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

	strlcpy((char *)userinfo.user_name, argv[0], sizeof(userinfo.user_name));
	if (c->opt_flags == 0)
                c->opt_flags = 0x21;

	userinfo.userflags = c->opt_flags;
	userinfo.reserved1 = '\0';
        userinfo.comment = smb_xstrdup(c->opt_comment ? c->opt_comment : "");
	userinfo.priv = 1;
	userinfo.home_dir = NULL;
	userinfo.logon_script = NULL;
	userinfo.passwrd[0] = '\0';

	ret = cli_NetUserAdd(cli, &userinfo);

	cli_shutdown(cli);
	return ret;
}
Ejemplo n.º 8
0
int net_rap_user(int argc, const char **argv)
{
	int ret = -1;
	struct functable func[] = {
		{"ADD", rap_user_add},
		{"INFO", rap_user_info},
		{"DELETE", rap_user_delete},
		{NULL, NULL}
	};

	if (argc == 0) {
		struct cli_state *cli;
		if (!(cli = net_make_ipc_connection(0)))
                        goto done;
		if (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(argc, argv, func, net_rap_user_usage);
 done:
	if (ret != 0) {
		DEBUG(1, ("Net user returned: %d\n", ret));
	}
	return ret;
}
Ejemplo n.º 9
0
int net_rap_server(int argc, const char **argv)
{
	struct cli_state *cli;
	int ret;

	if (argc > 0) {
		if (strequal(argv[0], "name")) {
			return net_rap_server_name(argc, argv);
		}
		/* smb4k uses 'net [rap|rpc] server domain' to query servers in a domain */
		/* Fall through for 'domain', any other forms will cause to show usage message */
		if (!strequal(argv[0], "domain")) {
			return net_rap_server_usage(argc-1, argv+1);
		}
	}

	if (!(cli = net_make_ipc_connection(0))) 
                return -1;

	d_printf("\nEnumerating servers in this domain or workgroup: \n\n"\
		 "\tServer name          Server description\n"\
		 "\t-------------        ----------------------------\n");

	ret = cli_NetServerEnum(cli, cli->server_domain, SV_TYPE_ALL, 
				display_server_func,NULL); 
	cli_shutdown(cli);
	return ret;	
}
Ejemplo n.º 10
0
int net_rap_group(int argc, const char **argv)
{
	struct functable func[] = {
		{"ADD", rap_group_add},
		{"DELETE", rap_group_delete},
		{NULL, NULL}
	};

	if (argc == 0) {
		struct cli_state *cli;
		int ret;
		if (!(cli = net_make_ipc_connection(0)))
                        return -1;
		if (opt_long_list_entries) {
			d_printf("Group name            Comment\n");
			d_printf("-----------------------------\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(argc, argv, func, net_rap_group_usage);
}
Ejemplo n.º 11
0
int net_rap_service(int argc, const char **argv)
{
	struct functable func[] = {
		{"START", rap_service_start},
		{"STOP", rap_service_stop},
		{NULL, NULL}
	};

	if (argc == 0) {
		struct cli_state *cli;
		int ret;
		if (!(cli = net_make_ipc_connection(0))) 
			return -1;

		if (opt_long_list_entries) {
			d_printf("Service name          Comment\n");
			d_printf("-----------------------------\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(argc, argv, func, net_rap_service_usage);
}
Ejemplo n.º 12
0
static int net_rap_server_domain(struct net_context *c, int argc,
				 const char **argv)
{
	struct cli_state *cli;
	int ret;

	if (c->display_usage) {
		d_printf("%s\n%s",
			 _("Usage:"),
			 _("net rap server domain\n"
			   "    Enumerate servers in this domain/workgroup\n"));
		return 0;
	}

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

	d_printf(_("\nEnumerating servers in this domain or workgroup: \n\n"
		   "\tServer name          Server description\n"
		   "\t-------------        ----------------------------\n"));

	ret = cli_NetServerEnum(cli, cli->server_domain, SV_TYPE_ALL,
				display_server_func,NULL);
	cli_shutdown(cli);
	return ret;
}
Ejemplo n.º 13
0
int net_rap_session(int argc, const char **argv)
{
	struct functable func[] = {
		{"INFO", rap_session_info},
		{"DELETE", rap_session_delete},
		{"CLOSE", rap_session_delete},
		{NULL, NULL}
	};

	if (argc == 0) {
		struct cli_state *cli;
		int ret;
		
		if (!(cli = net_make_ipc_connection(0))) 
			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(argc, argv, func, net_rap_session_usage);
}
Ejemplo n.º 14
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);
}
Ejemplo n.º 15
0
static int rap_file_info(int argc, const char **argv)
{
	struct cli_state *cli;
	int ret;
	if (argc == 0)
		return net_rap_file_usage(argc, argv);
	
	if (!(cli = net_make_ipc_connection(0))) 
                return -1;

	ret = cli_NetFileGetInfo(cli, atoi(argv[0]), one_file_fn);
	cli_shutdown(cli);
	return ret;
}
Ejemplo n.º 16
0
static int rap_file_info(struct net_context *c, int argc, const char **argv)
{
	struct cli_state *cli;
	int ret;
	if (argc == 0 || c->display_usage)
		return net_rap_file_usage(c, argc, argv);

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

	ret = cli_NetFileGetInfo(cli, atoi(argv[0]), one_file_fn);
	cli_shutdown(cli);
	return ret;
}
Ejemplo n.º 17
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);
}
Ejemplo n.º 18
0
static int rap_group_delete(struct net_context *c, int argc, const char **argv)
{
	struct cli_state *cli;
	int ret;
	if (argc == 0 || c->display_usage) {
                return net_rap_group_usage(c, argc, argv);
	}

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

	ret = cli_NetGroupDelete(cli, argv[0]);
	cli_shutdown(cli);
	return ret;
}
Ejemplo n.º 19
0
static int rap_printq_delete(int argc, const char **argv)
{
	struct cli_state *cli;
	int ret;
	
	if (argc == 0) 
                return net_rap_printq_usage(argc, argv);

	if (!(cli = net_make_ipc_connection(0))) 
                return -1;

	ret = cli_printjob_del(cli, atoi(argv[0]));
	cli_shutdown(cli);
	return ret;
}
Ejemplo n.º 20
0
static int rap_user_info(struct net_context *c, int argc, const char **argv)
{
	struct cli_state *cli;
	int ret;
	if (argc == 0 || c->display_usage) {
                return net_rap_user_usage(c, argc, argv);
	}

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

	ret = cli_NetUserGetGroups(cli, argv[0], group_member_fn, NULL);
	cli_shutdown(cli);
	return ret;
}
Ejemplo n.º 21
0
static int rap_printq_delete(struct net_context *c, int argc, const char **argv)
{
	struct cli_state *cli;
	int ret;

	if (argc == 0 || c->display_usage)
                return net_rap_printq_usage(c, argc, argv);

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

	ret = cli_printjob_del(cli, atoi(argv[0]));
	cli_shutdown(cli);
	return ret;
}
Ejemplo n.º 22
0
static int rap_session_delete(int argc, const char **argv)
{
	struct cli_state *cli;
	int ret;
	
	if (!(cli = net_make_ipc_connection(0))) 
                return -1;

	if (argc == 0) 
                return net_rap_session_usage(argc, argv);

	ret = cli_NetSessionDel(cli, argv[0]);
	cli_shutdown(cli);
	return ret;
}
Ejemplo n.º 23
0
static int rap_groupmember_add(struct net_context *c, int argc, const char **argv)
{
	struct cli_state *cli;
	int ret;
	if (argc != 2 || c->display_usage) {
                return net_rap_groupmember_usage(c, argc, argv);
	}

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

	ret = cli_NetGroupAddUser(cli, argv[0], argv[1]);
	cli_shutdown(cli);
	return ret;
}
Ejemplo n.º 24
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);
}
Ejemplo n.º 25
0
int net_rap_password(int argc, const char **argv)
{
	struct cli_state *cli;
	int ret;
	
	if (argc < 3) 
                return net_rap_password_usage(argc, argv);

	if (!(cli = net_make_ipc_connection(0))) 
                return -1;

	/* BB Add check for password lengths? */
	ret = cli_oem_change_password(cli, argv[0], argv[2], argv[1]);
	cli_shutdown(cli);
	return ret;
}
Ejemplo n.º 26
0
static int rap_printq_info(struct net_context *c, int argc, const char **argv)
{
	struct cli_state *cli;
	int ret;

	if (argc == 0 || c->display_usage)
                return net_rap_printq_usage(c, argc, argv);

	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_NetPrintQGetInfo(cli, argv[0], enum_queue, enum_jobs);
	cli_shutdown(cli);
	return ret;
}
Ejemplo n.º 27
0
static int rap_groupmember_list(int argc, const char **argv)
{
	struct cli_state *cli;
	int ret;
	if (argc == 0) {
		d_printf("\n\nGroup name not specified\n");
                return net_rap_groupmember_usage(argc, argv);
	}

	if (!(cli = net_make_ipc_connection(0)))
                return -1;

	ret = cli_NetGroupGetUsers(cli, argv[0], group_member_fn, NULL ); 
	cli_shutdown(cli);
	return ret;
}
Ejemplo n.º 28
0
static int rap_groupmember_delete(int argc, const char **argv)
{
	struct cli_state *cli;
	int ret;
	if (argc != 2) {
		d_printf("\n\nGroup or user name not specified\n");
                return net_rap_groupmember_usage(argc, argv);
	}
	
	if (!(cli = net_make_ipc_connection(0)))
                return -1;

	ret = cli_NetGroupDelUser(cli, argv[0], argv[1]);
	cli_shutdown(cli);
	return ret;
}
Ejemplo n.º 29
0
static int rap_printq_info(int argc, const char **argv)
{
	struct cli_state *cli;
	int ret;
	
	if (argc == 0) 
                return net_rap_printq_usage(argc, argv);

	if (!(cli = net_make_ipc_connection(0))) 
                return -1;

	d_printf(PRINTQ_ENUM_DISPLAY, cli->desthost); /* list header */
	ret = cli_NetPrintQGetInfo(cli, argv[0], enum_queue, enum_jobs);
	cli_shutdown(cli);
	return ret;
}
Ejemplo n.º 30
0
static int rap_file_close(int argc, const char **argv)
{
	struct cli_state *cli;
	int ret;
	if (argc == 0) {
		d_printf("\nMissing fileid of file to close\n\n");
		return net_rap_file_usage(argc, argv);
	}

	if (!(cli = net_make_ipc_connection(0))) 
                return -1;

	ret = cli_NetFileClose(cli, atoi(argv[0]));
	cli_shutdown(cli);
	return ret;
}