static struct rpc_pipe_client *global_pipe_hnd;
static struct policy_handle pol;
static bool got_policy_hnd;
-static struct user_auth_info *smbcquotas_auth_info;
static struct cli_state *connect_one(const char *share);
NTSTATUS ret;
cli_ipc = connect_one("IPC$");
ret = cli_rpc_pipe_open_noauth(cli_ipc,
- &ndr_table_lsarpc.syntax_id,
+ &ndr_table_lsarpc,
&global_pipe_hnd);
if (!NT_STATUS_IS_OK(ret)) {
return False;
switch (todo) {
case PARSE_LIM:
- if (sscanf(p,"%"PRIu64"/%"PRIu64,&pqt->softlim,&pqt->hardlim)!=2) {
+ if (sscanf(p,"%"SCNu64"/%"SCNu64,&pqt->softlim,
+ &pqt->hardlim) != 2)
+ {
return -1;
}
{
const char *result;
- if (!_numeric&&special&&(val == SMB_NTQUOTAS_NO_LIMIT)) {
+ if (!_numeric && special && val == 0) {
return "NO LIMIT";
}
result = talloc_asprintf(talloc_tos(), "%"PRIu64, val);
static int do_quota(struct cli_state *cli,
enum SMB_QUOTA_TYPE qtype,
- uint16 cmd,
+ uint16_t cmd,
const char *username_str,
SMB_NTQUOTA_STRUCT *pqt)
{
- uint32 fs_attrs = 0;
+ uint32_t fs_attrs = 0;
uint16_t quota_fnum = 0;
SMB_NTQUOTA_LIST *qtl = NULL;
+ TALLOC_CTX *qtl_ctx = NULL;
SMB_NTQUOTA_STRUCT qt;
NTSTATUS status;
break;
case QUOTA_SETLIM:
pqt->sid = qt.sid;
+ if ((qtl_ctx = talloc_init(
+ "SMB_USER_QUOTA_SET")) ==
+ NULL) {
+ return -1;
+ }
+
+ if (!add_record_to_ntquota_list(
+ qtl_ctx, pqt, &qtl)) {
+ TALLOC_FREE(qtl_ctx);
+ return -1;
+ }
+
status = cli_set_user_quota(
- cli, quota_fnum, pqt);
+ cli, quota_fnum, qtl);
+ free_ntquota_list(&qtl);
if (!NT_STATUS_IS_OK(status)) {
d_printf("%s cli_set_user_quota %s\n",
nt_errstr(status),
status = cli_list_user_quota(
cli, quota_fnum, &qtl);
if (!NT_STATUS_IS_OK(status)) {
- d_printf("%s cli_set_user_quota %s\n",
- nt_errstr(status),
- username_str);
+ d_printf(
+ "%s cli_list_user_quota\n",
+ nt_errstr(status));
return -1;
}
dump_ntquota_list(&qtl,verbose,numeric,SidToString);
NTSTATUS nt_status;
uint32_t flags = 0;
- if (get_cmdline_auth_info_use_machine_account(smbcquotas_auth_info) &&
- !set_cmdline_auth_info_machine_account_creds(smbcquotas_auth_info)) {
- return NULL;
- }
-
- if (get_cmdline_auth_info_use_kerberos(smbcquotas_auth_info)) {
+ if (get_cmdline_auth_info_use_kerberos(popt_get_cmdline_auth_info())) {
flags |= CLI_FULL_CONNECTION_USE_KERBEROS |
CLI_FULL_CONNECTION_FALLBACK_AFTER_KERBEROS;
}
- set_cmdline_auth_info_getpass(smbcquotas_auth_info);
-
nt_status = cli_full_connection(&c, lp_netbios_name(), server,
NULL, 0,
share, "?????",
- get_cmdline_auth_info_username(smbcquotas_auth_info),
+ get_cmdline_auth_info_username(
+ popt_get_cmdline_auth_info()),
lp_workgroup(),
- get_cmdline_auth_info_password(smbcquotas_auth_info),
+ get_cmdline_auth_info_password(
+ popt_get_cmdline_auth_info()),
flags,
- get_cmdline_auth_info_signing_state(smbcquotas_auth_info));
+ get_cmdline_auth_info_signing_state(
+ popt_get_cmdline_auth_info()));
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0,("cli_full_connection failed! (%s)\n", nt_errstr(nt_status)));
return NULL;
}
- if (get_cmdline_auth_info_smb_encrypt(smbcquotas_auth_info)) {
+ if (get_cmdline_auth_info_smb_encrypt(popt_get_cmdline_auth_info())) {
nt_status = cli_cm_force_encryption(c,
- get_cmdline_auth_info_username(smbcquotas_auth_info),
- get_cmdline_auth_info_password(smbcquotas_auth_info),
+ get_cmdline_auth_info_username(
+ popt_get_cmdline_auth_info()),
+ get_cmdline_auth_info_password(
+ popt_get_cmdline_auth_info()),
lp_workgroup(),
share);
if (!NT_STATUS_IS_OK(nt_status)) {
/****************************************************************************
main program
****************************************************************************/
- int main(int argc, const char *argv[])
+int main(int argc, char *argv[])
{
+ const char **argv_const = discard_const_p(const char *, argv);
char *share;
int opt;
int result;
FSQFLAGS:QUOTA_ENABLED/DENY_DISK/LOG_SOFTLIMIT/LOG_HARD_LIMIT", "SETSTRING" },
{ "numeric", 'n', POPT_ARG_NONE, NULL, 'n', "Don't resolve sids or limits to names" },
{ "verbose", 'v', POPT_ARG_NONE, NULL, 'v', "be verbose" },
- { "test-args", 't', POPT_ARG_NONE, NULL, 'r', "Test arguments"},
+ { "test-args", 't', POPT_ARG_NONE, NULL, 't', "Test arguments"},
+ {"max-protocol", 'm', POPT_ARG_STRING, NULL, 'm',
+ "Set the max protocol level", "LEVEL"},
POPT_COMMON_SAMBA
POPT_COMMON_CREDENTIALS
{ NULL }
};
- load_case_tables();
+ smb_init_locale();
ZERO_STRUCT(qt);
fault_setup();
- lp_load_global(get_dyn_CONFIGFILE());
- load_interfaces();
-
- smbcquotas_auth_info = user_auth_info_init(frame);
- if (smbcquotas_auth_info == NULL) {
- exit(1);
- }
- popt_common_set_auth_info(smbcquotas_auth_info);
-
- pc = poptGetContext("smbcquotas", argc, argv, long_options, 0);
+ pc = poptGetContext("smbcquotas", argc, argv_const, long_options, 0);
poptSetOtherOptionHelp(pc, "//server1/share1");
}
todo = SET_QUOTA;
break;
+ case 'm':
+ lp_set_cmdline("client max protocol",
+ poptGetOptArg(pc));
+ break;
}
}
if (!fix_user) {
username_str = talloc_strdup(
- frame, get_cmdline_auth_info_username(smbcquotas_auth_info));
+ frame, get_cmdline_auth_info_username(
+ popt_get_cmdline_auth_info()));
if (!username_str) {
exit(EXIT_PARSE_ERROR);
}
exit(EXIT_FAILED);
}
} else {
+ popt_free_cmdline_auth_info();
exit(EXIT_OK);
}
break;
}
+ popt_free_cmdline_auth_info();
talloc_free(frame);
return result;