From 5b51fc4f065e9e68eefb530eb99ad8da9f4e5d28 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 11 Apr 2003 23:32:00 +0000 Subject: smbcquota patch from metze (This used to be commit 74fab8f0d24004b1dfd5ce0fd7402895652f941f) --- source3/utils/smbcquotas.c | 545 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 545 insertions(+) create mode 100644 source3/utils/smbcquotas.c (limited to 'source3/utils/smbcquotas.c') diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c new file mode 100644 index 0000000000..c5d0aa869b --- /dev/null +++ b/source3/utils/smbcquotas.c @@ -0,0 +1,545 @@ +/* + Unix SMB/CIFS implementation. + QUOTA get/set utility + + Copyright (C) Andrew Tridgell 2000 + Copyright (C) Tim Potter 2000 + Copyright (C) Jeremy Allison 2000 + Copyright (C) Stefan (metze) Metzmacher 2003 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +static pstring server; + +/* numeric is set when the user wants numeric SIDs and ACEs rather + than going via LSA calls to resolve them */ +static BOOL numeric; +static BOOL verbose; + +enum todo_values {NOOP_QUOTA=0,FS_QUOTA,USER_QUOTA,LIST_QUOTA,SET_QUOTA}; +enum exit_values {EXIT_OK, EXIT_FAILED, EXIT_PARSE_ERROR}; + +static struct cli_state *cli_ipc = NULL; +static POLICY_HND pol; +static BOOL got_policy_hnd; + +static struct cli_state *connect_one(const char *share); + +/* Open cli connection and policy handle */ + +static BOOL cli_open_policy_hnd(void) +{ + /* Initialise cli LSA connection */ + + if (!cli_ipc) { + cli_ipc = connect_one("IPC$"); + if (!cli_nt_session_open (cli_ipc, PI_LSARPC)) { + return False; + } + } + + /* Open policy handle */ + + if (!got_policy_hnd) { + + /* Some systems don't support SEC_RIGHTS_MAXIMUM_ALLOWED, + but NT sends 0x2000000 so we might as well do it too. */ + + if (!NT_STATUS_IS_OK(cli_lsa_open_policy(cli_ipc, cli_ipc->mem_ctx, True, + GENERIC_EXECUTE_ACCESS, &pol))) { + return False; + } + + got_policy_hnd = True; + } + + return True; +} + +/* convert a SID to a string, either numeric or username/group */ +static void SidToString(fstring str, DOM_SID *sid, BOOL _numeric) +{ + char **domains = NULL; + char **names = NULL; + uint32 *types = NULL; + + sid_to_string(str, sid); + + if (_numeric) return; + + /* Ask LSA to convert the sid to a name */ + + if (!cli_open_policy_hnd() || + !NT_STATUS_IS_OK(cli_lsa_lookup_sids(cli_ipc, cli_ipc->mem_ctx, + &pol, 1, sid, &domains, + &names, &types)) || + !domains || !domains[0] || !names || !names[0]) { + return; + } + + /* Converted OK */ + + slprintf(str, sizeof(fstring) - 1, "%s%s%s", + domains[0], lp_winbind_separator(), + names[0]); + +} + +/* convert a string to a SID, either numeric or username/group */ +static BOOL StringToSid(DOM_SID *sid, const char *str) +{ + uint32 *types = NULL; + DOM_SID *sids = NULL; + BOOL result = True; + + if (strncmp(str, "S-", 2) == 0) { + return string_to_sid(sid, str); + } + + if (!cli_open_policy_hnd() || + !NT_STATUS_IS_OK(cli_lsa_lookup_names(cli_ipc, cli_ipc->mem_ctx, + &pol, 1, &str, &sids, + &types))) { + result = False; + goto done; + } + + sid_copy(sid, &sids[0]); + done: + + return result; +} + +#define QUOTA_GET 1 +#define QUOTA_SETLIM 2 +#define QUOTA_SETFLAGS 3 +#define QUOTA_LIST 4 + +enum {PARSE_FLAGS,PARSE_LIM}; + +static int parse_quota_set(pstring set_str, pstring username_str, enum SMB_QUOTA_TYPE *qtype, int *cmd, SMB_NTQUOTA_STRUCT *pqt) +{ + char *p = set_str,*p2; + int todo; + BOOL stop = False; + BOOL enable = False; + BOOL deny = False; + + if (strncasecmp(set_str,"UQLIM:",6)==0) { + p += 6; + *qtype = SMB_USER_QUOTA_TYPE; + *cmd = QUOTA_SETLIM; + todo = PARSE_LIM; + if ((p2=strstr(p,":"))==NULL) { + return -1; + } + + *p2 = '\0'; + p2++; + + fstrcpy(username_str,p); + p = p2; + } else if (strncasecmp(set_str,"FSQLIM:",7)==0) { + p +=7; + *qtype = SMB_USER_FS_QUOTA_TYPE; + *cmd = QUOTA_SETLIM; + todo = PARSE_LIM; + } else if (strncasecmp(set_str,"FSQFLAGS:",9)==0) { + p +=9; + todo = PARSE_FLAGS; + *qtype = SMB_USER_FS_QUOTA_TYPE; + *cmd = QUOTA_SETFLAGS; + } else { + return -1; + } + + switch (todo) { + case PARSE_LIM: +#if defined(HAVE_LONGLONG) + if (sscanf(p,"%llu/%llu",&pqt->softlim,&pqt->hardlim)!=2) { +#else + if (sscanf(p,"%lu/%lu",&pqt->softlim,&pqt->hardlim)!=2) { +#endif + return -1; + } + + break; + case PARSE_FLAGS: + while (!stop) { + + if ((p2=strstr(p,"/"))==NULL) { + stop = True; + } else { + *p2 = '\0'; + p2++; + } + + if (strncasecmp(p,"QUOTA_ENABLED",13)==0) { + enable = True; + } else if (strncasecmp(p,"DENY_DISK",9)==0) { + deny = True; + } else if (strncasecmp(p,"LOG_SOFTLIMIT",13)==0) { + pqt->qflags |= QUOTAS_LOG_THRESHOLD; + } else if (strncasecmp(p,"LOG_HARDLIMIT",13)==0) { + pqt->qflags |= QUOTAS_LOG_LIMIT; + } else { + return -1; + } + + p=p2; + } + + if (deny) { + pqt->qflags |= QUOTAS_DENY_DISK; + } else if (enable) { + pqt->qflags |= QUOTAS_ENABLED; + } + + break; + } + + return 0; +} + +static int do_quota(struct cli_state *cli, enum SMB_QUOTA_TYPE qtype, uint16 cmd, pstring username_str, SMB_NTQUOTA_STRUCT *pqt) +{ + uint32 fs_attrs = 0; + int quota_fnum = 0; + SMB_NTQUOTA_LIST *qtl = NULL; + SMB_NTQUOTA_STRUCT qt; + ZERO_STRUCT(qt); + + if (!cli_get_fs_attr_info(cli, &fs_attrs)) { + d_printf("Failed to get the filesystem attributes %s.\n", + cli_errstr(cli)); + return -1; + } + + if (!(fs_attrs & FILE_VOLUME_QUOTAS)) { + d_printf("Quotas are not supported by the server.\n"); + return 0; + } + + if (!cli_get_quota_handle(cli, "a_fnum)) { + d_printf("Failed to open \\%s %s.\n", + FAKE_FILE_NAME_QUOTA,cli_errstr(cli)); + return -1; + } + + switch(qtype) { + case SMB_USER_QUOTA_TYPE: + if (!StringToSid(&qt.sid, username_str)) { + d_printf("StringToSid() failed for [%s]\n",username_str); + return -1; + } + + switch(cmd) { + case QUOTA_GET: + if (!cli_get_user_quota(cli, quota_fnum, &qt)) { + d_printf("%s cli_get_user_quota %s\n", + cli_errstr(cli),username_str); + return -1; + } + dump_ntquota(&qt,verbose,numeric,SidToString); + break; + case QUOTA_SETLIM: + pqt->sid = qt.sid; + if (!cli_set_user_quota(cli, quota_fnum, pqt)) { + d_printf("%s cli_set_user_quota %s\n", + cli_errstr(cli),username_str); + return -1; + } + if (!cli_get_user_quota(cli, quota_fnum, &qt)) { + d_printf("%s cli_get_user_quota %s\n", + cli_errstr(cli),username_str); + return -1; + } + dump_ntquota(&qt,verbose,numeric,SidToString); + break; + case QUOTA_LIST: + if (!cli_list_user_quota(cli, quota_fnum, &qtl)) { + d_printf("%s cli_set_user_quota %s\n", + cli_errstr(cli),username_str); + return -1; + } + dump_ntquota_list(&qtl,verbose,numeric,SidToString); + free_ntquota_list(&qtl); + break; + default: + d_printf("Unknown Error\n"); + return -1; + } + break; + case SMB_USER_FS_QUOTA_TYPE: + switch(cmd) { + case QUOTA_GET: + if (!cli_get_fs_quota_info(cli, quota_fnum, &qt)) { + d_printf("%s cli_get_fs_quota_info\n", + cli_errstr(cli)); + return -1; + } + dump_ntquota(&qt,True,numeric,NULL); + break; + case QUOTA_SETLIM: + if (!cli_get_fs_quota_info(cli, quota_fnum, &qt)) { + d_printf("%s cli_get_fs_quota_info\n", + cli_errstr(cli)); + return -1; + } + qt.softlim = pqt->softlim; + qt.hardlim = pqt->hardlim; + if (!cli_set_fs_quota_info(cli, quota_fnum, &qt)) { + d_printf("%s cli_set_fs_quota_info\n", + cli_errstr(cli)); + return -1; + } + if (!cli_get_fs_quota_info(cli, quota_fnum, &qt)) { + d_printf("%s cli_get_fs_quota_info\n", + cli_errstr(cli)); + return -1; + } + dump_ntquota(&qt,True,numeric,NULL); + break; + case QUOTA_SETFLAGS: + if (!cli_get_fs_quota_info(cli, quota_fnum, &qt)) { + d_printf("%s cli_get_fs_quota_info\n", + cli_errstr(cli)); + return -1; + } + qt.qflags = pqt->qflags; + if (!cli_set_fs_quota_info(cli, quota_fnum, &qt)) { + d_printf("%s cli_set_fs_quota_info\n", + cli_errstr(cli)); + return -1; + } + if (!cli_get_fs_quota_info(cli, quota_fnum, &qt)) { + d_printf("%s cli_get_fs_quota_info\n", + cli_errstr(cli)); + return -1; + } + dump_ntquota(&qt,True,numeric,NULL); + break; + default: + d_printf("Unknown Error\n"); + return -1; + } + break; + default: + d_printf("Unknown Error\n"); + return -1; + } + + cli_close(cli, quota_fnum); + + return 0; +} + +/***************************************************** +return a connection to a server +*******************************************************/ +static struct cli_state *connect_one(const char *share) +{ + struct cli_state *c; + struct in_addr ip; + NTSTATUS nt_status; + zero_ip(&ip); + + if (!cmdline_auth_info.got_pass) { + char *pass = getpass("Password: "); + if (pass) { + pstrcpy(cmdline_auth_info.password, pass); + cmdline_auth_info.got_pass = True; + } + } + + if (NT_STATUS_IS_OK(nt_status = cli_full_connection(&c, global_myname(), server, + &ip, 0, + share, "?????", + cmdline_auth_info.username, lp_workgroup(), + cmdline_auth_info.password, 0, NULL))) { + return c; + } else { + DEBUG(0,("cli_full_connection failed! (%s)\n", nt_errstr(nt_status))); + return NULL; + } +} + +/**************************************************************************** + main program +****************************************************************************/ + int main(int argc, const char *argv[]) +{ + char *share; + int opt; + int result; + int todo = 0; + pstring username_str = {0}; + pstring path = {0}; + pstring set_str = {0}; + enum SMB_QUOTA_TYPE qtype; + int cmd = 0; + BOOL test_args = False; + struct cli_state *cli; + BOOL fix_user = False; + SMB_NTQUOTA_STRUCT qt; + poptContext pc; + struct poptOption long_options[] = { + POPT_AUTOHELP + { "user", 'u', POPT_ARG_STRING, NULL, 'u', "Show quotas for user", "user" }, + { "list", 'L', POPT_ARG_NONE, NULL, 'L', "List user quotas" }, + { "fs", 'F', POPT_ARG_NONE, NULL, 'F', "Show filesystem quotas" }, + { "set", 'S', POPT_ARG_STRING, NULL, 'S', "Set acls\n\ +SETSTRING:\n\ +UQLIM:// for user quotas\n\ +FSQLIM:/ for filesystem defaults\n\ +FSQFLAGS:QUOTA_ENABLED/DENY_DISK/LOG_SOFTLIMIT/LOG_HARD_LIMIT", "SETSTRING" }, + { "numeric", 'n', POPT_ARG_NONE, &numeric, True, "Don't resolve sids or limits to names" }, + { "verbose", 'v', POPT_ARG_NONE, &verbose, True, "be verbose" }, + { "test-args", 't', POPT_ARG_NONE, &test_args, True, "Test arguments"}, + POPT_COMMON_SAMBA + POPT_COMMON_CREDENTIALS + { NULL } + }; + + ZERO_STRUCT(qt); + + setlinebuf(stdout); + + dbf = x_stderr; + + fault_setup(NULL); + + setup_logging(argv[0],True); + + + lp_load(dyn_CONFIGFILE,True,False,False); + load_interfaces(); + + pc = poptGetContext("smbcquotas", argc, argv, long_options, 0); + + poptSetOtherOptionHelp(pc, "//server1/share1"); + + while ((opt = poptGetNextOpt(pc)) != -1) { + switch (opt) { + case 'L': + if (todo != 0) { + d_printf("Please specify only one option of <-L|-F|-S|-u>\n"); + exit(EXIT_PARSE_ERROR); + } + todo = LIST_QUOTA; + break; + + case 'F': + if (todo != 0) { + d_printf("Please specify only one option of <-L|-F|-S|-u>\n"); + exit(EXIT_PARSE_ERROR); + } + todo = FS_QUOTA; + break; + + case 'u': + if (todo != 0) { + d_printf("Please specify only one option of <-L|-F|-S|-u>\n"); + exit(EXIT_PARSE_ERROR); + } + pstrcpy(username_str,poptGetOptArg(pc)); + todo = USER_QUOTA; + fix_user = True; + break; + + case 'S': + if (todo != 0) { + d_printf("Please specify only one option of <-L|-F|-S|-u>\n"); + exit(EXIT_PARSE_ERROR); + } + pstrcpy(set_str,poptGetOptArg(pc)); + todo = SET_QUOTA; + break; + } + } + + if (todo == 0) + todo = USER_QUOTA; + + if (!fix_user) + pstrcpy(username_str,cmdline_auth_info.username); + + /* Make connection to server */ + if(!poptPeekArg(pc)) { + poptPrintUsage(pc, stderr, 0); + exit(EXIT_PARSE_ERROR); + } + + pstrcpy(path, poptGetArg(pc)); + + all_string_sub(path,"/","\\",0); + + pstrcpy(server,path+2); + share = strchr_m(server,'\\'); + if (!share) { + share = strchr_m(server,'/'); + if (!share) { + printf("Invalid argument: %s\n", share); + exit(EXIT_PARSE_ERROR); + } + } + + *share = 0; + share++; + + if (todo == SET_QUOTA) { + if (parse_quota_set(set_str, username_str, &qtype, &cmd, &qt)) { + printf("Invalid argument: -S %s\n", set_str); + exit(EXIT_PARSE_ERROR); + } + } + + if (!test_args) { + cli = connect_one(share); + if (!cli) { + exit(EXIT_FAILED); + } + } else { + exit(EXIT_OK); + } + + + /* Perform requested action */ + + switch (todo) { + case FS_QUOTA: + result = do_quota(cli,SMB_USER_FS_QUOTA_TYPE, QUOTA_GET, username_str, NULL); + break; + case LIST_QUOTA: + result = do_quota(cli,SMB_USER_QUOTA_TYPE, QUOTA_LIST, username_str, NULL); + break; + case USER_QUOTA: + result = do_quota(cli,SMB_USER_QUOTA_TYPE, QUOTA_GET, username_str, NULL); + break; + case SET_QUOTA: + result = do_quota(cli, qtype, cmd, username_str, &qt); + break; + default: + + result = EXIT_FAILED; + break; + } + + return result; +} + -- cgit From 11c453951a336969df3523779046fbd1380bcd64 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 23 Apr 2003 13:59:32 +0000 Subject: More fun with Sun CC needing constant initializers (This used to be commit ce3dd8fd69231798185e3e3bb988775e5671e070) --- source3/utils/smbcquotas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/utils/smbcquotas.c') diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c index c5d0aa869b..9c7379ca2a 100644 --- a/source3/utils/smbcquotas.c +++ b/source3/utils/smbcquotas.c @@ -393,7 +393,7 @@ static struct cli_state *connect_one(const char *share) pstring set_str = {0}; enum SMB_QUOTA_TYPE qtype; int cmd = 0; - BOOL test_args = False; + static BOOL test_args = False; struct cli_state *cli; BOOL fix_user = False; SMB_NTQUOTA_STRUCT qt; -- cgit From 4ea3cd2629592b5e306df64c998d220478d7f049 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 28 Apr 2003 05:18:30 +0000 Subject: Merge of const fixes from HEAD. (This used to be commit a847ebd82732cc2b430c58c3b287a46db0e35ba1) --- source3/utils/smbcquotas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/utils/smbcquotas.c') diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c index 9c7379ca2a..c5d0aa869b 100644 --- a/source3/utils/smbcquotas.c +++ b/source3/utils/smbcquotas.c @@ -393,7 +393,7 @@ static struct cli_state *connect_one(const char *share) pstring set_str = {0}; enum SMB_QUOTA_TYPE qtype; int cmd = 0; - static BOOL test_args = False; + BOOL test_args = False; struct cli_state *cli; BOOL fix_user = False; SMB_NTQUOTA_STRUCT qt; -- cgit From c6d511d8dde27d9369d1d314bf723b96ecda15a2 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 30 Apr 2003 14:25:13 +0000 Subject: Merge from HEAD - the usual popt-needs-static for Sun CC. (This used to be commit 2fabc356769477cc8bdbb23ecd8fee1e7d9fdb7d) --- source3/utils/smbcquotas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/utils/smbcquotas.c') diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c index c5d0aa869b..9c7379ca2a 100644 --- a/source3/utils/smbcquotas.c +++ b/source3/utils/smbcquotas.c @@ -393,7 +393,7 @@ static struct cli_state *connect_one(const char *share) pstring set_str = {0}; enum SMB_QUOTA_TYPE qtype; int cmd = 0; - BOOL test_args = False; + static BOOL test_args = False; struct cli_state *cli; BOOL fix_user = False; SMB_NTQUOTA_STRUCT qt; -- cgit From c507ebe56741d773bf6e7ad547863a2da1aee687 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 10 May 2003 10:53:48 +0000 Subject: Patch from metze and me that adds dummy smb_register_*() functions so that is now possible to, for example, load a module which contains an auth method into a binary without the auth/ subsystem built in. (This used to be commit 74d9ecfe2dd7364643d32acb62ade957bd71cd0d) --- source3/utils/smbcquotas.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/utils/smbcquotas.c') diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c index 9c7379ca2a..9ba243a4a5 100644 --- a/source3/utils/smbcquotas.c +++ b/source3/utils/smbcquotas.c @@ -24,6 +24,8 @@ #include "includes.h" +#include "module_dummy.h" + static pstring server; /* numeric is set when the user wants numeric SIDs and ACEs rather -- cgit From 0914e541f5480834c1b0ddc98b5f71f7f7abf9cb Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 10 May 2003 11:49:51 +0000 Subject: Reverse previous patch from Stefan and me after comments by Andrew Bartlett (This used to be commit d817eaf0ecca2d878ab1ffcf7a747a02d71c811e) --- source3/utils/smbcquotas.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/utils/smbcquotas.c') diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c index 9ba243a4a5..9c7379ca2a 100644 --- a/source3/utils/smbcquotas.c +++ b/source3/utils/smbcquotas.c @@ -24,8 +24,6 @@ #include "includes.h" -#include "module_dummy.h" - static pstring server; /* numeric is set when the user wants numeric SIDs and ACEs rather -- cgit From 29ca70cd34d3ba927ea1a9915ebd247f64965bd5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 30 Jul 2003 23:49:29 +0000 Subject: Add a command line option (-S on|off|required) to enable signing on client connections. Overrides smb.conf parameter if set. Jeremy. (This used to be commit 879309671df6b530e0bff69559422a417da4a307) --- source3/utils/smbcquotas.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/utils/smbcquotas.c') diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c index 9c7379ca2a..64321d5bfc 100644 --- a/source3/utils/smbcquotas.c +++ b/source3/utils/smbcquotas.c @@ -371,7 +371,8 @@ static struct cli_state *connect_one(const char *share) &ip, 0, share, "?????", cmdline_auth_info.username, lp_workgroup(), - cmdline_auth_info.password, 0, NULL))) { + cmdline_auth_info.password, 0, + cmdline_auth_info.signing_state, NULL))) { return c; } else { DEBUG(0,("cli_full_connection failed! (%s)\n", nt_errstr(nt_status))); -- cgit From bb0598faf58679a7ad26a1caab8eadb154a07ae2 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 22 Oct 2003 23:38:20 +0000 Subject: Put strcasecmp/strncasecmp on the banned list (except for needed calls in iconv.c and nsswitch/). Using them means you're not thinking about multibyte at all and I really want to discourage that. Jeremy. (This used to be commit d7e35dfb9283d560d0ed2ab231f36ed92767dace) --- source3/utils/smbcquotas.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'source3/utils/smbcquotas.c') diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c index 64321d5bfc..0bd8755420 100644 --- a/source3/utils/smbcquotas.c +++ b/source3/utils/smbcquotas.c @@ -140,7 +140,7 @@ static int parse_quota_set(pstring set_str, pstring username_str, enum SMB_QUOTA BOOL enable = False; BOOL deny = False; - if (strncasecmp(set_str,"UQLIM:",6)==0) { + if (strnequal(set_str,"UQLIM:",6)) { p += 6; *qtype = SMB_USER_QUOTA_TYPE; *cmd = QUOTA_SETLIM; @@ -154,12 +154,12 @@ static int parse_quota_set(pstring set_str, pstring username_str, enum SMB_QUOTA fstrcpy(username_str,p); p = p2; - } else if (strncasecmp(set_str,"FSQLIM:",7)==0) { + } else if (strnequal(set_str,"FSQLIM:",7)) { p +=7; *qtype = SMB_USER_FS_QUOTA_TYPE; *cmd = QUOTA_SETLIM; todo = PARSE_LIM; - } else if (strncasecmp(set_str,"FSQFLAGS:",9)==0) { + } else if (strnequal(set_str,"FSQFLAGS:",9)) { p +=9; todo = PARSE_FLAGS; *qtype = SMB_USER_FS_QUOTA_TYPE; @@ -189,13 +189,13 @@ static int parse_quota_set(pstring set_str, pstring username_str, enum SMB_QUOTA p2++; } - if (strncasecmp(p,"QUOTA_ENABLED",13)==0) { + if (strnequal(p,"QUOTA_ENABLED",13)) { enable = True; - } else if (strncasecmp(p,"DENY_DISK",9)==0) { + } else if (strnequal(p,"DENY_DISK",9)) { deny = True; - } else if (strncasecmp(p,"LOG_SOFTLIMIT",13)==0) { + } else if (strnequal(p,"LOG_SOFTLIMIT",13)) { pqt->qflags |= QUOTAS_LOG_THRESHOLD; - } else if (strncasecmp(p,"LOG_HARDLIMIT",13)==0) { + } else if (strnequal(p,"LOG_HARDLIMIT",13)) { pqt->qflags |= QUOTAS_LOG_LIMIT; } else { return -1; -- cgit From fe69a5e28dc24e97a1b601c49449beb3db6e4e6b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 15 Sep 2004 13:57:33 +0000 Subject: r2348: fix segmention faults in smbcquotas and smbcacls caused by setup_logging() (-r 1425) metze (This used to be commit 39f3f76ea2097c10799f0bef8717d3ac71cacaa8) --- source3/utils/smbcquotas.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'source3/utils/smbcquotas.c') diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c index 0bd8755420..98d214706a 100644 --- a/source3/utils/smbcquotas.c +++ b/source3/utils/smbcquotas.c @@ -419,14 +419,15 @@ FSQFLAGS:QUOTA_ENABLED/DENY_DISK/LOG_SOFTLIMIT/LOG_HARD_LIMIT", "SETSTRING" }, ZERO_STRUCT(qt); - setlinebuf(stdout); - + /* 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 ); - fault_setup(NULL); - - setup_logging(argv[0],True); + setlinebuf(stdout); + fault_setup(NULL); lp_load(dyn_CONFIGFILE,True,False,False); load_interfaces(); -- cgit From 10e4a96b5399a7ecbc893d2493a9ceb3ec66c8ed Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 17 Sep 2004 15:09:20 +0000 Subject: r2388: fix client quota support for the client we need the windows path and for server we need unix path metze (This used to be commit 54fd28f5e7b70ce2b192c2037ce28da3fea9ef92) --- source3/utils/smbcquotas.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source3/utils/smbcquotas.c') diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c index 98d214706a..81f7dd42bb 100644 --- a/source3/utils/smbcquotas.c +++ b/source3/utils/smbcquotas.c @@ -236,8 +236,9 @@ static int do_quota(struct cli_state *cli, enum SMB_QUOTA_TYPE qtype, uint16 cmd } if (!cli_get_quota_handle(cli, "a_fnum)) { - d_printf("Failed to open \\%s %s.\n", - FAKE_FILE_NAME_QUOTA,cli_errstr(cli)); + 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)); return -1; } -- cgit From 54abd2aa66069e6baf7769c496f46d9dba18db39 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 30 Sep 2005 17:13:37 +0000 Subject: r10656: BIG merge from trunk. Features not copied over * \PIPE\unixinfo * winbindd's {group,alias}membership new functions * winbindd's lookupsids() functionality * swat (trunk changes to be reverted as per discussion with Deryck) (This used to be commit 939c3cb5d78e3a2236209b296aa8aba8bdce32d3) --- source3/utils/smbcquotas.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'source3/utils/smbcquotas.c') diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c index 81f7dd42bb..c516fbb218 100644 --- a/source3/utils/smbcquotas.c +++ b/source3/utils/smbcquotas.c @@ -34,7 +34,8 @@ static BOOL verbose; enum todo_values {NOOP_QUOTA=0,FS_QUOTA,USER_QUOTA,LIST_QUOTA,SET_QUOTA}; enum exit_values {EXIT_OK, EXIT_FAILED, EXIT_PARSE_ERROR}; -static struct cli_state *cli_ipc = NULL; +static struct cli_state *cli_ipc; +static struct rpc_pipe_client *global_pipe_hnd; static POLICY_HND pol; static BOOL got_policy_hnd; @@ -47,8 +48,10 @@ static BOOL cli_open_policy_hnd(void) /* Initialise cli LSA connection */ if (!cli_ipc) { + NTSTATUS ret; cli_ipc = connect_one("IPC$"); - if (!cli_nt_session_open (cli_ipc, PI_LSARPC)) { + global_pipe_hnd = cli_rpc_pipe_open_noauth(cli_ipc, PI_LSARPC, &ret); + if (!global_pipe_hnd) { return False; } } @@ -60,7 +63,7 @@ static BOOL cli_open_policy_hnd(void) /* Some systems don't support SEC_RIGHTS_MAXIMUM_ALLOWED, but NT sends 0x2000000 so we might as well do it too. */ - if (!NT_STATUS_IS_OK(cli_lsa_open_policy(cli_ipc, cli_ipc->mem_ctx, True, + if (!NT_STATUS_IS_OK(rpccli_lsa_open_policy(global_pipe_hnd, cli_ipc->mem_ctx, True, GENERIC_EXECUTE_ACCESS, &pol))) { return False; } @@ -85,7 +88,7 @@ static void SidToString(fstring str, DOM_SID *sid, BOOL _numeric) /* Ask LSA to convert the sid to a name */ if (!cli_open_policy_hnd() || - !NT_STATUS_IS_OK(cli_lsa_lookup_sids(cli_ipc, cli_ipc->mem_ctx, + !NT_STATUS_IS_OK(rpccli_lsa_lookup_sids(global_pipe_hnd, cli_ipc->mem_ctx, &pol, 1, sid, &domains, &names, &types)) || !domains || !domains[0] || !names || !names[0]) { @@ -112,7 +115,7 @@ static BOOL StringToSid(DOM_SID *sid, const char *str) } if (!cli_open_policy_hnd() || - !NT_STATUS_IS_OK(cli_lsa_lookup_names(cli_ipc, cli_ipc->mem_ctx, + !NT_STATUS_IS_OK(rpccli_lsa_lookup_names(global_pipe_hnd, cli_ipc->mem_ctx, &pol, 1, &str, &sids, &types))) { result = False; -- cgit From a168730dda8f6917bf89d82824060cdd815c7297 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 3 Dec 2005 06:58:54 +0000 Subject: r12045: More warning fixes... Just a few more to go. Jeremy. (This used to be commit cd192ed79a531c6775cdbfb35f0eb2e0fa230ce9) --- source3/utils/smbcquotas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/utils/smbcquotas.c') diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c index c516fbb218..be7c2c64e6 100644 --- a/source3/utils/smbcquotas.c +++ b/source3/utils/smbcquotas.c @@ -396,7 +396,7 @@ static struct cli_state *connect_one(const char *share) pstring username_str = {0}; pstring path = {0}; pstring set_str = {0}; - enum SMB_QUOTA_TYPE qtype; + enum SMB_QUOTA_TYPE qtype = SMB_INVALID_QUOTA_TYPE; int cmd = 0; static BOOL test_args = False; struct cli_state *cli; -- cgit From c8f28c92a7a96e278031b85f04b4671206bf3502 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 28 Dec 2005 22:48:54 +0000 Subject: r12555: Fix more load_case_table swegfaults. Arggg. What I'd give for a global constructor... Jeremy. (This used to be commit c970d7d0a5ba225465dfb0980989b8817b17c643) --- source3/utils/smbcquotas.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/utils/smbcquotas.c') diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c index be7c2c64e6..f8e3313155 100644 --- a/source3/utils/smbcquotas.c +++ b/source3/utils/smbcquotas.c @@ -421,6 +421,8 @@ FSQFLAGS:QUOTA_ENABLED/DENY_DISK/LOG_SOFTLIMIT/LOG_HARD_LIMIT", "SETSTRING" }, { NULL } }; + load_case_tables(); + ZERO_STRUCT(qt); /* set default debug level to 1 regardless of what smb.conf sets */ -- cgit From 9c15bd311db76885b27f30ba92d885833f668550 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Sat, 28 Jan 2006 22:53:04 +0000 Subject: r13212: r12414@cabra: derrell | 2006-01-28 17:52:17 -0500 lp_load() could not be called multiple times to modify parameter settings based on reading from multiple configuration settings. Each time, it initialized all of the settings back to their defaults before reading the specified configuration file. This patch adds a parameter to lp_load() specifying whether the settings should be initialized. It does, however, still force the settings to be initialized the first time, even if the request was to not initialize them. (Not doing so could wreak havoc due to uninitialized values.) (This used to be commit f2a24de769d1b2266e576597c57a8e3b1e2a2b51) --- source3/utils/smbcquotas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/utils/smbcquotas.c') diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c index f8e3313155..b1a14685f5 100644 --- a/source3/utils/smbcquotas.c +++ b/source3/utils/smbcquotas.c @@ -435,7 +435,7 @@ FSQFLAGS:QUOTA_ENABLED/DENY_DISK/LOG_SOFTLIMIT/LOG_HARD_LIMIT", "SETSTRING" }, fault_setup(NULL); - lp_load(dyn_CONFIGFILE,True,False,False); + lp_load(dyn_CONFIGFILE,True,False,False,True); load_interfaces(); pc = poptGetContext("smbcquotas", argc, argv, long_options, 0); -- cgit From 0af1500fc0bafe61019f1b2ab1d9e1d369221240 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 3 Feb 2006 22:19:41 +0000 Subject: r13316: Let the carnage begin.... Sync with trunk as off r13315 (This used to be commit 17e63ac4ed8325c0d44fe62b2442449f3298559f) --- source3/utils/smbcquotas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/utils/smbcquotas.c') diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c index b1a14685f5..7b3268e783 100644 --- a/source3/utils/smbcquotas.c +++ b/source3/utils/smbcquotas.c @@ -116,7 +116,7 @@ static BOOL StringToSid(DOM_SID *sid, const char *str) if (!cli_open_policy_hnd() || !NT_STATUS_IS_OK(rpccli_lsa_lookup_names(global_pipe_hnd, cli_ipc->mem_ctx, - &pol, 1, &str, &sids, + &pol, 1, &str, NULL, &sids, &types))) { result = False; goto done; -- cgit From 2b8abc030b1eca43f7c0c05dc96eebeb6c492030 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 28 Jun 2006 21:30:21 +0000 Subject: r16644: Fix bug #3887 reported by jason@ncac.gwu.edu by converting the lookup_XX functions to correctly return SID_NAME_TYPE enums. Jeremy. (This used to be commit ee2b2d96b60c668e37592c79e86c2fd851e15f69) --- source3/utils/smbcquotas.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/utils/smbcquotas.c') diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c index 7b3268e783..6193395e7e 100644 --- a/source3/utils/smbcquotas.c +++ b/source3/utils/smbcquotas.c @@ -79,7 +79,7 @@ static void SidToString(fstring str, DOM_SID *sid, BOOL _numeric) { char **domains = NULL; char **names = NULL; - uint32 *types = NULL; + enum SID_NAME_USE *types = NULL; sid_to_string(str, sid); @@ -106,7 +106,7 @@ static void SidToString(fstring str, DOM_SID *sid, BOOL _numeric) /* convert a string to a SID, either numeric or username/group */ static BOOL StringToSid(DOM_SID *sid, const char *str) { - uint32 *types = NULL; + enum SID_NAME_USE *types = NULL; DOM_SID *sids = NULL; BOOL result = True; -- cgit From 2b27c93a9a8471693d7dcb5fdbe8afe65b22ff66 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 8 Sep 2006 14:28:06 +0000 Subject: r18271: Big change: * autogenerate lsa ndr code * rename 'enum SID_NAME_USE' to 'enum lsa_SidType' * merge a log more security descriptor functions from gen_ndr/ndr_security.c in SAMBA_4_0 The most embarassing thing is the "#define strlen_m strlen" We need a real implementation in SAMBA_3_0 which I'll work on after this code is in. (This used to be commit 3da9f80c28b1e75ef6d46d38fbb81ade6b9fa951) --- source3/utils/smbcquotas.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/utils/smbcquotas.c') diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c index 6193395e7e..40f4a86f96 100644 --- a/source3/utils/smbcquotas.c +++ b/source3/utils/smbcquotas.c @@ -79,7 +79,7 @@ static void SidToString(fstring str, DOM_SID *sid, BOOL _numeric) { char **domains = NULL; char **names = NULL; - enum SID_NAME_USE *types = NULL; + enum lsa_SidType *types = NULL; sid_to_string(str, sid); @@ -106,7 +106,7 @@ static void SidToString(fstring str, DOM_SID *sid, BOOL _numeric) /* convert a string to a SID, either numeric or username/group */ static BOOL StringToSid(DOM_SID *sid, const char *str) { - enum SID_NAME_USE *types = NULL; + enum lsa_SidType *types = NULL; DOM_SID *sids = NULL; BOOL result = True; -- cgit From e61f235796ff2da34fb207f48e2bba832c30740b Mon Sep 17 00:00:00 2001 From: James Peach Date: Sat, 19 May 2007 04:23:04 +0000 Subject: r23009: Both contains a strchr_m(server,'/') few lines after replacing all / with \. This patch removes this dead code. Patch from Pascal Terjan for bug #2313. (This used to be commit 04b84baef344206d97776e04a25f4bd214eea28f) --- source3/utils/smbcquotas.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'source3/utils/smbcquotas.c') diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c index 40f4a86f96..ae2e6a5956 100644 --- a/source3/utils/smbcquotas.c +++ b/source3/utils/smbcquotas.c @@ -500,11 +500,8 @@ FSQFLAGS:QUOTA_ENABLED/DENY_DISK/LOG_SOFTLIMIT/LOG_HARD_LIMIT", "SETSTRING" }, pstrcpy(server,path+2); share = strchr_m(server,'\\'); if (!share) { - share = strchr_m(server,'/'); - if (!share) { - printf("Invalid argument: %s\n", share); - exit(EXIT_PARSE_ERROR); - } + printf("Invalid argument: %s\n", share); + exit(EXIT_PARSE_ERROR); } *share = 0; -- cgit From 7eb828135bd7407851a10c32d57c404ecb030140 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 27 Jun 2007 11:42:17 +0000 Subject: r23627: Allow to pass down the lookup-level to rpccli_lsa_lookup_names(). Guenther (This used to be commit e9a7512a9f630340004913f1379452eea8a9b6ae) --- source3/utils/smbcquotas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/utils/smbcquotas.c') diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c index ae2e6a5956..bf05441c21 100644 --- a/source3/utils/smbcquotas.c +++ b/source3/utils/smbcquotas.c @@ -116,7 +116,7 @@ static BOOL StringToSid(DOM_SID *sid, const char *str) if (!cli_open_policy_hnd() || !NT_STATUS_IS_OK(rpccli_lsa_lookup_names(global_pipe_hnd, cli_ipc->mem_ctx, - &pol, 1, &str, NULL, &sids, + &pol, 1, &str, NULL, 1, &sids, &types))) { result = False; goto done; -- cgit From d824b98f80ba186030cbb70b3a1e5daf80469ecd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Jul 2007 19:25:36 +0000 Subject: r23779: Change from v2 or later to v3 or later. Jeremy. (This used to be commit 407e6e695b8366369b7c76af1ff76869b45347b3) --- source3/utils/smbcquotas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/utils/smbcquotas.c') diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c index bf05441c21..6aec07614d 100644 --- a/source3/utils/smbcquotas.c +++ b/source3/utils/smbcquotas.c @@ -9,7 +9,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, -- cgit From 5e54558c6dea67b56bbfaba5698f3a434d3dffb6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 00:52:41 +0000 Subject: r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text (This used to be commit b0132e94fc5fef936aa766fb99a306b3628e9f07) --- source3/utils/smbcquotas.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/utils/smbcquotas.c') diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c index 6aec07614d..70d28a7e4a 100644 --- a/source3/utils/smbcquotas.c +++ b/source3/utils/smbcquotas.c @@ -18,8 +18,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From faefb22c61568c678476b4dad36bdc5ce3afb499 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 4 Sep 2007 05:39:06 +0000 Subject: r24943: Some stackframes (This used to be commit cddb9f11d5fafcd3797cb242775c37f0c04d4f15) --- source3/utils/smbcquotas.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/utils/smbcquotas.c') diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c index 70d28a7e4a..8d954ac20a 100644 --- a/source3/utils/smbcquotas.c +++ b/source3/utils/smbcquotas.c @@ -401,6 +401,7 @@ static struct cli_state *connect_one(const char *share) struct cli_state *cli; BOOL fix_user = False; SMB_NTQUOTA_STRUCT qt; + TALLOC_CTX *frame = talloc_stackframe(); poptContext pc; struct poptOption long_options[] = { POPT_AUTOHELP @@ -544,6 +545,8 @@ FSQFLAGS:QUOTA_ENABLED/DENY_DISK/LOG_SOFTLIMIT/LOG_HARD_LIMIT", "SETSTRING" }, break; } + talloc_free(frame); + return result; } -- cgit From 8e54530b52fd256137740107e9fdf000f00a7a30 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 10 Oct 2007 18:25:16 -0700 Subject: Add start of IPv6 implementation. Currently most of this is avoiding IPv6 in winbindd, but moves most of the socket functions that were wrongly in lib/util.c into lib/util_sock.c and provides generic IPv4/6 independent versions of most things. Still lots of work to do, but now I can see how I'll fix the access check code. Nasty part that remains is the name resolution code which is used to returning arrays of in_addr structs. Jeremy. (This used to be commit 3f6bd0e1ec5cc6670f3d08f76fc2cd94c9cd1a08) --- source3/utils/smbcquotas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/utils/smbcquotas.c') diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c index 8d954ac20a..1f718b7cef 100644 --- a/source3/utils/smbcquotas.c +++ b/source3/utils/smbcquotas.c @@ -360,7 +360,7 @@ static struct cli_state *connect_one(const char *share) struct cli_state *c; struct in_addr ip; NTSTATUS nt_status; - zero_ip(&ip); + zero_ip_v4(&ip); if (!cmdline_auth_info.got_pass) { char *pass = getpass("Password: "); -- cgit From 30191d1a5704ad2b158386b511558972d539ce47 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 18 Oct 2007 17:40:25 -0700 Subject: RIP BOOL. Convert BOOL -> bool. I found a few interesting bugs in various places whilst doing this (places that assumed BOOL == int). I also need to fix the Samba4 pidl generation (next checkin). Jeremy. (This used to be commit f35a266b3cbb3e5fa6a86be60f34fe340a3ca71f) --- source3/utils/smbcquotas.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'source3/utils/smbcquotas.c') diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c index 1f718b7cef..387c296385 100644 --- a/source3/utils/smbcquotas.c +++ b/source3/utils/smbcquotas.c @@ -27,8 +27,8 @@ static pstring server; /* numeric is set when the user wants numeric SIDs and ACEs rather than going via LSA calls to resolve them */ -static BOOL numeric; -static BOOL verbose; +static bool numeric; +static bool verbose; enum todo_values {NOOP_QUOTA=0,FS_QUOTA,USER_QUOTA,LIST_QUOTA,SET_QUOTA}; enum exit_values {EXIT_OK, EXIT_FAILED, EXIT_PARSE_ERROR}; @@ -36,13 +36,13 @@ enum exit_values {EXIT_OK, EXIT_FAILED, EXIT_PARSE_ERROR}; static struct cli_state *cli_ipc; static struct rpc_pipe_client *global_pipe_hnd; static POLICY_HND pol; -static BOOL got_policy_hnd; +static bool got_policy_hnd; static struct cli_state *connect_one(const char *share); /* Open cli connection and policy handle */ -static BOOL cli_open_policy_hnd(void) +static bool cli_open_policy_hnd(void) { /* Initialise cli LSA connection */ @@ -74,7 +74,7 @@ static BOOL cli_open_policy_hnd(void) } /* 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, DOM_SID *sid, bool _numeric) { char **domains = NULL; char **names = NULL; @@ -103,11 +103,11 @@ static void SidToString(fstring str, DOM_SID *sid, BOOL _numeric) } /* convert a string to a SID, either numeric or username/group */ -static BOOL StringToSid(DOM_SID *sid, const char *str) +static bool StringToSid(DOM_SID *sid, const char *str) { enum lsa_SidType *types = NULL; DOM_SID *sids = NULL; - BOOL result = True; + bool result = True; if (strncmp(str, "S-", 2) == 0) { return string_to_sid(sid, str); @@ -138,9 +138,9 @@ static int parse_quota_set(pstring set_str, pstring username_str, enum SMB_QUOTA { char *p = set_str,*p2; int todo; - BOOL stop = False; - BOOL enable = False; - BOOL deny = False; + bool stop = False; + bool enable = False; + bool deny = False; if (strnequal(set_str,"UQLIM:",6)) { p += 6; @@ -397,9 +397,9 @@ static struct cli_state *connect_one(const char *share) pstring set_str = {0}; enum SMB_QUOTA_TYPE qtype = SMB_INVALID_QUOTA_TYPE; int cmd = 0; - static BOOL test_args = False; + static bool test_args = False; struct cli_state *cli; - BOOL fix_user = False; + bool fix_user = False; SMB_NTQUOTA_STRUCT qt; TALLOC_CTX *frame = talloc_stackframe(); poptContext pc; -- cgit From 9a85533914119fb995fb61555c9f6e0018d4d181 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 19 Oct 2007 11:38:36 -0700 Subject: Fix the popt / bool issues. Some places we used BOOL where we meant int. Fix this. Thanks to metze for pointing this out. Jeremy. (This used to be commit 793a9d24a163cb6cf5a3a0aa5ae30e9f8cf4744a) --- source3/utils/smbcquotas.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'source3/utils/smbcquotas.c') diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c index 387c296385..a3d90f823b 100644 --- a/source3/utils/smbcquotas.c +++ b/source3/utils/smbcquotas.c @@ -413,9 +413,9 @@ SETSTRING:\n\ UQLIM:// for user quotas\n\ FSQLIM:/ for filesystem defaults\n\ FSQFLAGS:QUOTA_ENABLED/DENY_DISK/LOG_SOFTLIMIT/LOG_HARD_LIMIT", "SETSTRING" }, - { "numeric", 'n', POPT_ARG_NONE, &numeric, True, "Don't resolve sids or limits to names" }, - { "verbose", 'v', POPT_ARG_NONE, &verbose, True, "be verbose" }, - { "test-args", 't', POPT_ARG_NONE, &test_args, True, "Test arguments"}, + { "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"}, POPT_COMMON_SAMBA POPT_COMMON_CREDENTIALS { NULL } @@ -444,6 +444,15 @@ FSQFLAGS:QUOTA_ENABLED/DENY_DISK/LOG_SOFTLIMIT/LOG_HARD_LIMIT", "SETSTRING" }, while ((opt = poptGetNextOpt(pc)) != -1) { switch (opt) { + case 'n': + numeric = true; + break; + case 'v': + verbose = true; + break; + case 't': + test_args = true; + break; case 'L': if (todo != 0) { d_printf("Please specify only one option of <-L|-F|-S|-u>\n"); -- cgit From f88b7a076be74a29a3bf876b4e2705f4a1ecf42b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 24 Oct 2007 14:16:54 -0700 Subject: This is a large patch (sorry). Migrate from struct in_addr to struct sockaddr_storage in most places that matter (ie. not the nmbd and NetBIOS lookups). This passes make test on an IPv4 box, but I'll have to do more work/testing on IPv6 enabled boxes. This should now give us a framework for testing and finishing the IPv6 migration. It's at the state where someone with a working IPv6 setup should (theorecically) be able to type : smbclient //ipv6-address/share and have it work. Jeremy. (This used to be commit 98e154c3125d5732c37a72d74b0eb5cd7b6155fd) --- source3/utils/smbcquotas.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'source3/utils/smbcquotas.c') diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c index a3d90f823b..f185caa50f 100644 --- a/source3/utils/smbcquotas.c +++ b/source3/utils/smbcquotas.c @@ -352,16 +352,17 @@ static int do_quota(struct cli_state *cli, enum SMB_QUOTA_TYPE qtype, uint16 cmd return 0; } -/***************************************************** -return a connection to a server +/***************************************************** + Return a connection to a server. *******************************************************/ + static struct cli_state *connect_one(const char *share) { struct cli_state *c; - struct in_addr ip; + struct sockaddr_storage ss; NTSTATUS nt_status; - zero_ip_v4(&ip); - + zero_addr(&ss, AF_INET); + if (!cmdline_auth_info.got_pass) { char *pass = getpass("Password: "); if (pass) { @@ -371,8 +372,8 @@ static struct cli_state *connect_one(const char *share) } if (NT_STATUS_IS_OK(nt_status = cli_full_connection(&c, global_myname(), server, - &ip, 0, - share, "?????", + &ss, 0, + share, "?????", cmdline_auth_info.username, lp_workgroup(), cmdline_auth_info.password, 0, cmdline_auth_info.signing_state, NULL))) { -- cgit From d4307679b95088d05f0abad440de5e961ee965df Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 27 Oct 2007 20:29:36 -0700 Subject: Change all occurrences of zero_addr(&ss,AF_INET) to zero_addr(&ss). All current uses were always of the AF_INET form, so simplify the call. If in the future we need to zero an addr to AF_INET6 this can be done separately. Jeremy. (This used to be commit 2e92418a138bf2738b77b7e0fcb2fa37ad84fc0c) --- source3/utils/smbcquotas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/utils/smbcquotas.c') diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c index f185caa50f..ae793c28f9 100644 --- a/source3/utils/smbcquotas.c +++ b/source3/utils/smbcquotas.c @@ -361,7 +361,7 @@ static struct cli_state *connect_one(const char *share) struct cli_state *c; struct sockaddr_storage ss; NTSTATUS nt_status; - zero_addr(&ss, AF_INET); + zero_addr(&ss); if (!cmdline_auth_info.got_pass) { char *pass = getpass("Password: "); -- cgit From d2cf97aeba14a4d336fb57b01f19bd5a08dcb003 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 29 Nov 2007 13:24:54 -0800 Subject: Remove the explicit TALLOC_CTX * from cli_struct. Make us very explicit about how long a talloc ctx should last. Jeremy. (This used to be commit ba9e2be2b5a59684e854609f9d82ea1633448c62) --- source3/utils/smbcquotas.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'source3/utils/smbcquotas.c') diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c index ae793c28f9..6ae63f4c68 100644 --- a/source3/utils/smbcquotas.c +++ b/source3/utils/smbcquotas.c @@ -62,7 +62,7 @@ static bool cli_open_policy_hnd(void) /* Some systems don't support SEC_RIGHTS_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, cli_ipc->mem_ctx, True, + if (!NT_STATUS_IS_OK(rpccli_lsa_open_policy(global_pipe_hnd, talloc_tos(), True, GENERIC_EXECUTE_ACCESS, &pol))) { return False; } @@ -87,7 +87,7 @@ static void SidToString(fstring str, DOM_SID *sid, bool _numeric) /* Ask LSA to convert the sid to a name */ if (!cli_open_policy_hnd() || - !NT_STATUS_IS_OK(rpccli_lsa_lookup_sids(global_pipe_hnd, cli_ipc->mem_ctx, + !NT_STATUS_IS_OK(rpccli_lsa_lookup_sids(global_pipe_hnd, talloc_tos(), &pol, 1, sid, &domains, &names, &types)) || !domains || !domains[0] || !names || !names[0]) { @@ -114,7 +114,7 @@ static bool StringToSid(DOM_SID *sid, const char *str) } if (!cli_open_policy_hnd() || - !NT_STATUS_IS_OK(rpccli_lsa_lookup_names(global_pipe_hnd, cli_ipc->mem_ctx, + !NT_STATUS_IS_OK(rpccli_lsa_lookup_names(global_pipe_hnd, talloc_tos(), &pol, 1, &str, NULL, 1, &sids, &types))) { result = False; @@ -559,4 +559,3 @@ FSQFLAGS:QUOTA_ENABLED/DENY_DISK/LOG_SOFTLIMIT/LOG_HARD_LIMIT", "SETSTRING" }, return result; } - -- cgit From adf6d848de8ae32a83c7271d8ccd24d2cf8b47f7 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 3 Dec 2007 18:48:41 -0800 Subject: Getting to the home stretch for elimination of pstrings... Jeremy. (This used to be commit 041163551194102ca67fef52c57d87020a1d09bc) --- source3/utils/smbcquotas.c | 92 ++++++++++++++++++++++++++++++---------------- 1 file changed, 60 insertions(+), 32 deletions(-) (limited to 'source3/utils/smbcquotas.c') diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c index 6ae63f4c68..3aa9e76a14 100644 --- a/source3/utils/smbcquotas.c +++ b/source3/utils/smbcquotas.c @@ -23,7 +23,7 @@ #include "includes.h" -static pstring server; +static char *server; /* numeric is set when the user wants numeric SIDs and ACEs rather than going via LSA calls to resolve them */ @@ -54,7 +54,7 @@ static bool cli_open_policy_hnd(void) return False; } } - + /* Open policy handle */ if (!got_policy_hnd) { @@ -134,14 +134,20 @@ static bool StringToSid(DOM_SID *sid, const char *str) enum {PARSE_FLAGS,PARSE_LIM}; -static int parse_quota_set(pstring set_str, pstring username_str, enum SMB_QUOTA_TYPE *qtype, int *cmd, SMB_NTQUOTA_STRUCT *pqt) +static int parse_quota_set(TALLOC_CTX *ctx, + char *set_str, + char **pp_username_str, + enum SMB_QUOTA_TYPE *qtype, + int *cmd, + SMB_NTQUOTA_STRUCT *pqt) { char *p = set_str,*p2; int todo; bool stop = False; bool enable = False; bool deny = False; - + + *pp_username_str = NULL; if (strnequal(set_str,"UQLIM:",6)) { p += 6; *qtype = SMB_USER_QUOTA_TYPE; @@ -150,11 +156,11 @@ static int parse_quota_set(pstring set_str, pstring username_str, enum SMB_QUOTA if ((p2=strstr(p,":"))==NULL) { return -1; } - + *p2 = '\0'; p2++; - - fstrcpy(username_str,p); + + *pp_username_str = talloc_strdup(ctx, p); p = p2; } else if (strnequal(set_str,"FSQLIM:",7)) { p +=7; @@ -179,7 +185,7 @@ static int parse_quota_set(pstring set_str, pstring username_str, enum SMB_QUOTA #endif return -1; } - + break; case PARSE_FLAGS: while (!stop) { @@ -211,14 +217,18 @@ static int parse_quota_set(pstring set_str, pstring username_str, enum SMB_QUOTA } else if (enable) { pqt->qflags |= QUOTAS_ENABLED; } - - break; + + break; } return 0; } -static int do_quota(struct cli_state *cli, enum SMB_QUOTA_TYPE qtype, uint16 cmd, pstring username_str, SMB_NTQUOTA_STRUCT *pqt) +static int do_quota(struct cli_state *cli, + enum SMB_QUOTA_TYPE qtype, + uint16 cmd, + const char *username_str, + SMB_NTQUOTA_STRUCT *pqt) { uint32 fs_attrs = 0; int quota_fnum = 0; @@ -234,7 +244,7 @@ static int do_quota(struct cli_state *cli, enum SMB_QUOTA_TYPE qtype, uint16 cmd if (!(fs_attrs & FILE_VOLUME_QUOTAS)) { d_printf("Quotas are not supported by the server.\n"); - return 0; + return 0; } if (!cli_get_quota_handle(cli, "a_fnum)) { @@ -250,7 +260,7 @@ static int do_quota(struct cli_state *cli, enum SMB_QUOTA_TYPE qtype, uint16 cmd d_printf("StringToSid() failed for [%s]\n",username_str); return -1; } - + switch(cmd) { case QUOTA_GET: if (!cli_get_user_quota(cli, quota_fnum, &qt)) { @@ -281,12 +291,12 @@ static int do_quota(struct cli_state *cli, enum SMB_QUOTA_TYPE qtype, uint16 cmd return -1; } dump_ntquota_list(&qtl,verbose,numeric,SidToString); - free_ntquota_list(&qtl); + free_ntquota_list(&qtl); break; default: d_printf("Unknown Error\n"); return -1; - } + } break; case SMB_USER_FS_QUOTA_TYPE: switch(cmd) { @@ -340,7 +350,7 @@ static int do_quota(struct cli_state *cli, enum SMB_QUOTA_TYPE qtype, uint16 cmd default: d_printf("Unknown Error\n"); return -1; - } + } break; default: d_printf("Unknown Error\n"); @@ -393,9 +403,9 @@ static struct cli_state *connect_one(const char *share) int opt; int result; int todo = 0; - pstring username_str = {0}; - pstring path = {0}; - pstring set_str = {0}; + char *username_str = NULL; + char *path = NULL; + char *set_str = NULL; enum SMB_QUOTA_TYPE qtype = SMB_INVALID_QUOTA_TYPE; int cmd = 0; static bool test_args = False; @@ -440,7 +450,7 @@ FSQFLAGS:QUOTA_ENABLED/DENY_DISK/LOG_SOFTLIMIT/LOG_HARD_LIMIT", "SETSTRING" }, load_interfaces(); pc = poptGetContext("smbcquotas", argc, argv, long_options, 0); - + poptSetOtherOptionHelp(pc, "//server1/share1"); while ((opt = poptGetNextOpt(pc)) != -1) { @@ -469,23 +479,29 @@ FSQFLAGS:QUOTA_ENABLED/DENY_DISK/LOG_SOFTLIMIT/LOG_HARD_LIMIT", "SETSTRING" }, } todo = FS_QUOTA; break; - + case 'u': if (todo != 0) { d_printf("Please specify only one option of <-L|-F|-S|-u>\n"); exit(EXIT_PARSE_ERROR); } - pstrcpy(username_str,poptGetOptArg(pc)); + username_str = talloc_strdup(frame, poptGetOptArg(pc)); + if (!username_str) { + exit(EXIT_PARSE_ERROR); + } todo = USER_QUOTA; fix_user = True; break; - + case 'S': if (todo != 0) { d_printf("Please specify only one option of <-L|-F|-S|-u>\n"); exit(EXIT_PARSE_ERROR); } - pstrcpy(set_str,poptGetOptArg(pc)); + set_str = talloc_strdup(frame, poptGetOptArg(pc)); + if (!set_str) { + exit(EXIT_PARSE_ERROR); + } todo = SET_QUOTA; break; } @@ -494,20 +510,32 @@ FSQFLAGS:QUOTA_ENABLED/DENY_DISK/LOG_SOFTLIMIT/LOG_HARD_LIMIT", "SETSTRING" }, if (todo == 0) todo = USER_QUOTA; - if (!fix_user) - pstrcpy(username_str,cmdline_auth_info.username); + if (!fix_user) { + username_str = talloc_strdup(frame, cmdline_auth_info.username); + if (!username_str) { + exit(EXIT_PARSE_ERROR); + } + } /* Make connection to server */ - if(!poptPeekArg(pc)) { + if(!poptPeekArg(pc)) { poptPrintUsage(pc, stderr, 0); exit(EXIT_PARSE_ERROR); } - - pstrcpy(path, poptGetArg(pc)); - all_string_sub(path,"/","\\",0); + path = talloc_strdup(frame, poptGetArg(pc)); + if (!path) { + printf("Out of memory\n"); + exit(EXIT_PARSE_ERROR); + } + + string_replace(path, '/', '\\'); - pstrcpy(server,path+2); + server = SMB_STRDUP(path+2); + if (!server) { + printf("Out of memory\n"); + exit(EXIT_PARSE_ERROR); + } share = strchr_m(server,'\\'); if (!share) { printf("Invalid argument: %s\n", share); @@ -518,7 +546,7 @@ FSQFLAGS:QUOTA_ENABLED/DENY_DISK/LOG_SOFTLIMIT/LOG_HARD_LIMIT", "SETSTRING" }, share++; if (todo == SET_QUOTA) { - if (parse_quota_set(set_str, username_str, &qtype, &cmd, &qt)) { + if (parse_quota_set(talloc_tos(), set_str, &username_str, &qtype, &cmd, &qt)) { printf("Invalid argument: -S %s\n", set_str); exit(EXIT_PARSE_ERROR); } -- cgit From e2ae63bcf72ac6a98d3b74281cba514b2e53f306 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 6 Dec 2007 18:58:01 -0800 Subject: Make all the tools use the proper accessor functions. Jeremy. (This used to be commit 6d61bb87975839adb25c304e5e5041f91b12d236) --- source3/utils/smbcquotas.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'source3/utils/smbcquotas.c') diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c index 3aa9e76a14..34a547d404 100644 --- a/source3/utils/smbcquotas.c +++ b/source3/utils/smbcquotas.c @@ -373,20 +373,22 @@ static struct cli_state *connect_one(const char *share) NTSTATUS nt_status; zero_addr(&ss); - if (!cmdline_auth_info.got_pass) { + if (!get_cmdline_auth_info_got_pass()) { char *pass = getpass("Password: "); if (pass) { - pstrcpy(cmdline_auth_info.password, pass); - cmdline_auth_info.got_pass = True; + set_cmdline_auth_info_password(pass); } } if (NT_STATUS_IS_OK(nt_status = cli_full_connection(&c, global_myname(), server, - &ss, 0, - share, "?????", - cmdline_auth_info.username, lp_workgroup(), - cmdline_auth_info.password, 0, - cmdline_auth_info.signing_state, NULL))) { + &ss, 0, + share, "?????", + get_cmdline_auth_info_username(), + lp_workgroup(), + get_cmdline_auth_info_password(), + 0, + get_cmdline_auth_info_signing_state(), + NULL))) { return c; } else { DEBUG(0,("cli_full_connection failed! (%s)\n", nt_errstr(nt_status))); @@ -511,7 +513,7 @@ FSQFLAGS:QUOTA_ENABLED/DENY_DISK/LOG_SOFTLIMIT/LOG_HARD_LIMIT", "SETSTRING" }, todo = USER_QUOTA; if (!fix_user) { - username_str = talloc_strdup(frame, cmdline_auth_info.username); + username_str = talloc_strdup(frame, get_cmdline_auth_info_username()); if (!username_str) { exit(EXIT_PARSE_ERROR); } -- cgit From 7faee02d0d351c5c039e8f1be7e82ce3a93cbe96 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 10 Dec 2007 11:30:37 -0800 Subject: Remove the char[1024] strings from dynconfig. Replace them with malloc'ing accessor functions. Should save a lot of static space :-). Jeremy. (This used to be commit 52dc5eaef2106015b3a8b659e818bdb15ad94b05) --- source3/utils/smbcquotas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/utils/smbcquotas.c') diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c index 34a547d404..08a3cc1806 100644 --- a/source3/utils/smbcquotas.c +++ b/source3/utils/smbcquotas.c @@ -448,7 +448,7 @@ FSQFLAGS:QUOTA_ENABLED/DENY_DISK/LOG_SOFTLIMIT/LOG_HARD_LIMIT", "SETSTRING" }, fault_setup(NULL); - lp_load(dyn_CONFIGFILE,True,False,False,True); + lp_load(get_dyn_CONFIGFILE(),True,False,False,True); load_interfaces(); pc = poptGetContext("smbcquotas", argc, argv, long_options, 0); -- cgit From 2e07c2ade89f4ff281c61f74cb88e09990cf5f46 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 15 Dec 2007 22:47:30 +0100 Subject: s/sid_to_string/sid_to_fstring/ least surprise for callers (This used to be commit eb523ba77697346a365589101aac379febecd546) --- source3/utils/smbcquotas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/utils/smbcquotas.c') diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c index 08a3cc1806..e6aa5e86cf 100644 --- a/source3/utils/smbcquotas.c +++ b/source3/utils/smbcquotas.c @@ -80,7 +80,7 @@ static void SidToString(fstring str, DOM_SID *sid, bool _numeric) char **names = NULL; enum lsa_SidType *types = NULL; - sid_to_string(str, sid); + sid_to_fstring(str, sid); if (_numeric) return; -- cgit From a41972e8012d5028ff19721a869a3c2322c48158 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 5 Jan 2008 00:50:03 -0800 Subject: Fix -e for smbcquotas. Jeremy. (This used to be commit f97b1247c1053f47aef64be95ab9b3c3d8702c8a) --- source3/utils/smbcquotas.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'source3/utils/smbcquotas.c') diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c index e6aa5e86cf..508a2dc8ca 100644 --- a/source3/utils/smbcquotas.c +++ b/source3/utils/smbcquotas.c @@ -380,20 +380,33 @@ static struct cli_state *connect_one(const char *share) } } - if (NT_STATUS_IS_OK(nt_status = cli_full_connection(&c, global_myname(), server, - &ss, 0, - share, "?????", - get_cmdline_auth_info_username(), - lp_workgroup(), - get_cmdline_auth_info_password(), - 0, - get_cmdline_auth_info_signing_state(), - NULL))) { - return c; - } else { + nt_status = cli_full_connection(&c, global_myname(), server, + &ss, 0, + share, "?????", + get_cmdline_auth_info_username(), + lp_workgroup(), + get_cmdline_auth_info_password(), + 0, + get_cmdline_auth_info_signing_state(), + NULL); + 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()) { + nt_status = cli_cm_force_encryption(c, + get_cmdline_auth_info_username(), + get_cmdline_auth_info_password(), + lp_workgroup(), + share); + if (!NT_STATUS_IS_OK(nt_status)) { + cli_shutdown(c); + return NULL; + } + } + + return c; } /**************************************************************************** -- cgit From 4d8836ab96889bcdc35e86bedffa6117f9c35095 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 5 May 2008 16:58:24 +0200 Subject: Fix client authentication with -P switch in client tools (Bug 5435). Guenther (This used to be commit d077ef64cd1d9bbaeb936566c2c70da508de829f) --- source3/utils/smbcquotas.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'source3/utils/smbcquotas.c') diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c index 508a2dc8ca..a73c3b49df 100644 --- a/source3/utils/smbcquotas.c +++ b/source3/utils/smbcquotas.c @@ -371,8 +371,21 @@ static struct cli_state *connect_one(const char *share) struct cli_state *c; struct sockaddr_storage ss; NTSTATUS nt_status; + uint32_t flags = 0; + zero_addr(&ss); + if (get_cmdline_auth_info_use_machine_account() && + !set_cmdline_auth_info_machine_account_creds()) { + return NULL; + } + + if (get_cmdline_auth_info_use_kerberos()) { + 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) { @@ -386,7 +399,7 @@ static struct cli_state *connect_one(const char *share) get_cmdline_auth_info_username(), lp_workgroup(), get_cmdline_auth_info_password(), - 0, + flags, get_cmdline_auth_info_signing_state(), NULL); if (!NT_STATUS_IS_OK(nt_status)) { -- cgit From 1335da2a7cc639310e5d389e8e8dbe67c4e7ca25 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 20 Jul 2008 11:04:31 +0200 Subject: Refactoring: Change calling conventions for cli_rpc_pipe_open_noauth Pass in ndr_syntax_id instead of pipe_idx, return NTSTATUS (This used to be commit 9abc9dc4dc13bd3e42f98eff64eacf24b51f5779) --- source3/utils/smbcquotas.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source3/utils/smbcquotas.c') diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c index a73c3b49df..11f8776a0e 100644 --- a/source3/utils/smbcquotas.c +++ b/source3/utils/smbcquotas.c @@ -49,8 +49,10 @@ static bool cli_open_policy_hnd(void) if (!cli_ipc) { NTSTATUS ret; cli_ipc = connect_one("IPC$"); - global_pipe_hnd = cli_rpc_pipe_open_noauth(cli_ipc, PI_LSARPC, &ret); - if (!global_pipe_hnd) { + ret = cli_rpc_pipe_open_noauth(cli_ipc, + &ndr_table_lsarpc.syntax_id, + &global_pipe_hnd); + if (!NT_STATUS_IS_OK(ret)) { return False; } } -- cgit