summaryrefslogtreecommitdiff
path: root/source3/utils/smbcacls.c
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2003-03-24 11:25:34 +0000
committerJelmer Vernooij <jelmer@samba.org>2003-03-24 11:25:34 +0000
commit11e9de855ca84af8d34a5f6459f304fcfa72dca3 (patch)
tree0eb5d0505a50136ed74a4207219c42b9d4996402 /source3/utils/smbcacls.c
parent223828642548c7e25f6189e274aa1edcdfe30c4f (diff)
downloadsamba-11e9de855ca84af8d34a5f6459f304fcfa72dca3.tar.gz
samba-11e9de855ca84af8d34a5f6459f304fcfa72dca3.tar.bz2
samba-11e9de855ca84af8d34a5f6459f304fcfa72dca3.zip
Patch from metze to generalise POPT_COMMON_SAMBA, with some minor changes
(This used to be commit 2ddfed298d7f0b6e690275725a39c3ef107077ae)
Diffstat (limited to 'source3/utils/smbcacls.c')
-rw-r--r--source3/utils/smbcacls.c45
1 files changed, 9 insertions, 36 deletions
diff --git a/source3/utils/smbcacls.c b/source3/utils/smbcacls.c
index af5bf09e48..ac15cf1aa0 100644
--- a/source3/utils/smbcacls.c
+++ b/source3/utils/smbcacls.c
@@ -24,11 +24,8 @@
#include "includes.h"
-static fstring password;
-static pstring username;
static pstring owner_username;
static fstring server;
-static int got_pass;
static int test_args = False;
static TALLOC_CTX *ctx;
@@ -716,19 +713,19 @@ static struct cli_state *connect_one(const char *share)
NTSTATUS nt_status;
zero_ip(&ip);
- if (!got_pass) {
+ if (!cmdline_auth_info.got_pass) {
char *pass = getpass("Password: ");
if (pass) {
- fstrcpy(password, pass);
- got_pass = True;
+ 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, "?????",
- username, lp_workgroup(),
- password, 0, NULL))) {
+ 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)));
@@ -743,7 +740,6 @@ static struct cli_state *connect_one(const char *share)
{
char *share;
int opt;
- char *p;
enum acl_mode mode = SMB_ACL_SET;
static char *the_acl = NULL;
enum chown_mode change_mode = REQUEST_NONE;
@@ -759,12 +755,10 @@ static struct cli_state *connect_one(const char *share)
{ "set", 'S', POPT_ARG_STRING, NULL, 'S', "Set acls", "ACLS" },
{ "chown", 'C', POPT_ARG_STRING, NULL, 'C', "Change ownership of a file", "USERNAME" },
{ "chgrp", 'G', POPT_ARG_STRING, NULL, 'G', "Change group ownership of a file", "GROUPNAME" },
- { "numeric", 'n', POPT_ARG_VAL, &numeric, True, "Don't resolve sids or masks to names" },
- { "test-args", 't', POPT_ARG_VAL, &test_args, True, "Test arguments"},
- { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug },
- { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version },
- { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile },
- {"username", 'U', POPT_ARG_STRING, NULL, 'U', "User to authenticate as", "user%password" },
+ { "numeric", 0, POPT_ARG_NONE, &numeric, True, "Don't resolve sids or masks to names" },
+ { "test-args", 't', POPT_ARG_NONE, &test_args, True, "Test arguments"},
+ POPT_COMMON_SAMBA
+ POPT_CREDENTIALS
{ NULL }
};
@@ -781,33 +775,12 @@ static struct cli_state *connect_one(const char *share)
lp_load(dyn_CONFIGFILE,True,False,False);
load_interfaces();
- if (getenv("USER")) {
- pstrcpy(username,getenv("USER"));
-
- if ((p=strchr_m(username,'%'))) {
- *p = 0;
- fstrcpy(password,p+1);
- got_pass = True;
- memset(strchr_m(getenv("USER"), '%') + 1, 'X',
- strlen(password));
- }
- }
pc = poptGetContext("smbcacls", argc, argv, long_options, 0);
poptSetOtherOptionHelp(pc, "//server1/share1 filename");
while ((opt = poptGetNextOpt(pc)) != -1) {
switch (opt) {
- case 'U':
- pstrcpy(username,poptGetOptArg(pc));
- p = strchr_m(username,'%');
- if (p) {
- *p = 0;
- fstrcpy(password, p+1);
- got_pass = 1;
- }
- break;
-
case 'S':
the_acl = smb_xstrdup(poptGetOptArg(pc));
mode = SMB_ACL_SET;