static int rap_share_add(struct net_context *c, int argc, const char **argv) { struct cli_state *cli; int ret; struct rap_share_info_2 sinfo; char *p; char *sharename; if (argc == 0 || c->display_usage) { return net_rap_share_usage(c, argc, argv); } if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli))) return -1; sharename = SMB_STRDUP(argv[0]); p = strchr(sharename, '='); if (p == NULL) { d_printf(_("Server path not specified\n")); SAFE_FREE(sharename); return net_rap_share_usage(c, argc, argv); } *p = 0; strlcpy((char *)sinfo.share_name, sharename, sizeof(sinfo.share_name)); sinfo.reserved1 = '\0'; sinfo.share_type = 0; sinfo.comment = c->opt_comment ? smb_xstrdup(c->opt_comment) : ""; sinfo.perms = 0; sinfo.maximum_users = c->opt_maxusers; sinfo.active_users = 0; sinfo.path = p+1; memset(sinfo.password, '\0', sizeof(sinfo.password)); sinfo.reserved2 = '\0'; ret = cli_NetShareAdd(cli, &sinfo); cli_shutdown(cli); SAFE_FREE(sharename); return ret; }
static int rap_share_add(int argc, const char **argv) { struct cli_state *cli; int ret; RAP_SHARE_INFO_2 sinfo; char *p; char *sharename; if (argc == 0) { d_printf("\n\nShare name not specified\n"); return net_rap_share_usage(argc, argv); } if (!(cli = net_make_ipc_connection(0))) return -1; sharename = SMB_STRDUP(argv[0]); p = strchr(sharename, '='); if (p == NULL) { d_printf("Server path not specified\n"); return net_rap_share_usage(argc, argv); } *p = 0; strlcpy(sinfo.share_name, sharename, sizeof(sinfo.share_name)); sinfo.reserved1 = '\0'; sinfo.share_type = 0; sinfo.comment = smb_xstrdup(opt_comment); sinfo.perms = 0; sinfo.maximum_users = opt_maxusers; sinfo.active_users = 0; sinfo.path = p+1; memset(sinfo.password, '\0', sizeof(sinfo.password)); sinfo.reserved2 = '\0'; ret = cli_NetShareAdd(cli, &sinfo); cli_shutdown(cli); return ret; }