*/
#include "includes.h"
+#include "popt_common.h"
+#include "../librpc/gen_ndr/ndr_lsa.h"
+#include "rpc_client/cli_lsarpc.h"
+#include "fake_file.h"
+#include "../libcli/security/security.h"
static char *server;
static struct cli_state *cli_ipc;
static struct rpc_pipe_client *global_pipe_hnd;
-static POLICY_HND pol;
+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);
if (!got_policy_hnd) {
- /* Some systems don't support SEC_RIGHTS_MAXIMUM_ALLOWED,
+ /* Some systems don't support SEC_FLAG_MAXIMUM_ALLOWED,
but NT sends 0x2000000 so we might as well do it too. */
if (!NT_STATUS_IS_OK(rpccli_lsa_open_policy(global_pipe_hnd, talloc_tos(), True,
}
/* convert a SID to a string, either numeric or username/group */
-static void SidToString(fstring str, DOM_SID *sid, bool _numeric)
+static void SidToString(fstring str, struct dom_sid *sid, bool _numeric)
{
char **domains = NULL;
char **names = NULL;
}
/* convert a string to a SID, either numeric or username/group */
-static bool StringToSid(DOM_SID *sid, const char *str)
+static bool StringToSid(struct dom_sid *sid, const char *str)
{
enum lsa_SidType *types = NULL;
- DOM_SID *sids = NULL;
+ struct dom_sid *sids = NULL;
bool result = True;
- if (strncmp(str, "S-", 2) == 0) {
- return string_to_sid(sid, str);
+ if (string_to_sid(sid, str)) {
+ return true;
}
if (!cli_open_policy_hnd() ||
SMB_NTQUOTA_STRUCT *pqt)
{
uint32 fs_attrs = 0;
- int quota_fnum = 0;
+ uint16_t quota_fnum = 0;
SMB_NTQUOTA_LIST *qtl = NULL;
SMB_NTQUOTA_STRUCT qt;
+ NTSTATUS status;
+
ZERO_STRUCT(qt);
- if (!cli_get_fs_attr_info(cli, &fs_attrs)) {
+ status = cli_get_fs_attr_info(cli, &fs_attrs);
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("Failed to get the filesystem attributes %s.\n",
- cli_errstr(cli));
+ nt_errstr(status));
return -1;
}
return 0;
}
- if (!cli_get_quota_handle(cli, "a_fnum)) {
+ status = cli_get_quota_handle(cli, "a_fnum);
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("Quotas are not enabled on this share.\n");
d_printf("Failed to open %s %s.\n",
- FAKE_FILE_NAME_QUOTA_WIN32,cli_errstr(cli));
+ FAKE_FILE_NAME_QUOTA_WIN32,
+ nt_errstr(status));
return -1;
}
NTSTATUS nt_status;
uint32_t flags = 0;
- zero_addr(&ss);
+ zero_sockaddr(&ss);
- if (get_cmdline_auth_info_use_machine_account() &&
- !set_cmdline_auth_info_machine_account_creds()) {
+ 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()) {
+ if (get_cmdline_auth_info_use_kerberos(smbcquotas_auth_info)) {
flags |= CLI_FULL_CONNECTION_USE_KERBEROS |
CLI_FULL_CONNECTION_FALLBACK_AFTER_KERBEROS;
}
- if (!get_cmdline_auth_info_got_pass()) {
- char *pass = getpass("Password: ");
- if (pass) {
- set_cmdline_auth_info_password(pass);
- }
- }
+ set_cmdline_auth_info_getpass(smbcquotas_auth_info);
nt_status = cli_full_connection(&c, global_myname(), server,
&ss, 0,
share, "?????",
- get_cmdline_auth_info_username(),
+ get_cmdline_auth_info_username(smbcquotas_auth_info),
lp_workgroup(),
- get_cmdline_auth_info_password(),
+ get_cmdline_auth_info_password(smbcquotas_auth_info),
flags,
- get_cmdline_auth_info_signing_state(),
- NULL);
+ get_cmdline_auth_info_signing_state(smbcquotas_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()) {
+ if (get_cmdline_auth_info_smb_encrypt(smbcquotas_auth_info)) {
nt_status = cli_cm_force_encryption(c,
- get_cmdline_auth_info_username(),
- get_cmdline_auth_info_password(),
+ get_cmdline_auth_info_username(smbcquotas_auth_info),
+ get_cmdline_auth_info_password(smbcquotas_auth_info),
lp_workgroup(),
share);
if (!NT_STATUS_IS_OK(nt_status)) {
ZERO_STRUCT(qt);
/* set default debug level to 1 regardless of what smb.conf sets */
- setup_logging( "smbcquotas", True );
- DEBUGLEVEL_CLASS[DBGC_ALL] = 1;
- dbf = x_stderr;
- x_setbuf( x_stderr, NULL );
+ setup_logging( "smbcquotas", DEBUG_STDERR);
+ lp_set_cmdline("log level", "1");
setlinebuf(stdout);
lp_load(get_dyn_CONFIGFILE(),True,False,False,True);
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);
poptSetOtherOptionHelp(pc, "//server1/share1");
todo = USER_QUOTA;
if (!fix_user) {
- username_str = talloc_strdup(frame, get_cmdline_auth_info_username());
+ username_str = talloc_strdup(
+ frame, get_cmdline_auth_info_username(smbcquotas_auth_info));
if (!username_str) {
exit(EXIT_PARSE_ERROR);
}