summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-12-14 22:24:56 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:07:26 -0500
commit707d1808982fa3788156999016904475eef26ffe (patch)
tree00793f6cc510dc6271adef2c201730ab60b14ad3 /source4
parent113cacf94cda313840ae714c9b8137c0a17cf23c (diff)
downloadsamba-707d1808982fa3788156999016904475eef26ffe.tar.gz
samba-707d1808982fa3788156999016904475eef26ffe.tar.bz2
samba-707d1808982fa3788156999016904475eef26ffe.zip
r4207: remove "lookupname" and "lookupsid", and instead have a single "lookup" command that
takes a name or sid. I think in general its better to make smbclient automatically work out the type from the format (I did the same with the privileges commands) (This used to be commit bbf482e13ab973a67e9b2c0e0e40c2afff073c63)
Diffstat (limited to 'source4')
-rw-r--r--source4/client/client.c65
1 files changed, 24 insertions, 41 deletions
diff --git a/source4/client/client.c b/source4/client/client.c
index b234a47e2c..a83ff6d29e 100644
--- a/source4/client/client.c
+++ b/source4/client/client.c
@@ -1837,60 +1837,44 @@ done:
}
/****************************************************************************
-lookup a sid
+lookup a name or sid
****************************************************************************/
-static int cmd_lookupsid(const char **cmd_ptr)
+static int cmd_lookup(const char **cmd_ptr)
{
fstring buf;
TALLOC_CTX *mem_ctx = talloc(NULL, 0);
NTSTATUS status;
- const char *name;
+ struct dom_sid *sid;
if (!next_token(cmd_ptr,buf,NULL,sizeof(buf))) {
- d_printf("lookupsid <sid>\n");
- talloc_free(mem_ctx);
- return 1;
- }
-
- status = smblsa_lookup_sid(cli, buf, mem_ctx, &name);
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("lsa_LookupSids - %s\n", nt_errstr(status));
+ d_printf("lookup <name|sid>\n");
talloc_free(mem_ctx);
return 1;
}
- d_printf("%s\n", name);
-
- talloc_free(mem_ctx);
-
- return 0;
-}
-
-/****************************************************************************
-lookup a name, showing sid
-****************************************************************************/
-static int cmd_lookupname(const char **cmd_ptr)
-{
- fstring buf;
- TALLOC_CTX *mem_ctx = talloc(NULL, 0);
- NTSTATUS status;
- const char *sid;
+ sid = dom_sid_parse_talloc(mem_ctx, buf);
+ if (sid == NULL) {
+ const char *sidstr;
+ status = smblsa_lookup_name(cli, buf, mem_ctx, &sidstr);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("lsa_LookupNames - %s\n", nt_errstr(status));
+ talloc_free(mem_ctx);
+ return 1;
+ }
- if (!next_token(cmd_ptr,buf,NULL,sizeof(buf))) {
- d_printf("lookupname <name>\n");
- talloc_free(mem_ctx);
- return 1;
- }
+ d_printf("%s\n", sidstr);
+ } else {
+ const char *name;
+ status = smblsa_lookup_sid(cli, buf, mem_ctx, &name);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("lsa_LookupSids - %s\n", nt_errstr(status));
+ talloc_free(mem_ctx);
+ return 1;
+ }
- status = smblsa_lookup_name(cli, buf, mem_ctx, &sid);
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("lsa_LookupNames - %s\n", nt_errstr(status));
- talloc_free(mem_ctx);
- return 1;
+ d_printf("%s\n", name);
}
- d_printf("%s\n", sid);
-
talloc_free(mem_ctx);
return 0;
@@ -2613,8 +2597,7 @@ static struct
{"history",cmd_history,"displays the command history",{COMPL_NONE,COMPL_NONE}},
{"lcd",cmd_lcd,"[directory] change/report the local current working directory",{COMPL_LOCAL,COMPL_NONE}},
{"link",cmd_link,"<src> <dest> create a UNIX hard link",{COMPL_REMOTE,COMPL_REMOTE}},
- {"lookupname",cmd_lookupname,"<name> show SID for name",{COMPL_NONE,COMPL_NONE}},
- {"lookupsid",cmd_lookupsid,"<sid> show name for SID",{COMPL_NONE,COMPL_NONE}},
+ {"lookup",cmd_lookup,"<name|sid> show SID for name or name for SID",{COMPL_NONE,COMPL_NONE}},
{"lowercase",cmd_lowercase,"toggle lowercasing of filenames for get",{COMPL_NONE,COMPL_NONE}},
{"ls",cmd_dir,"<mask> list the contents of the current directory",{COMPL_REMOTE,COMPL_NONE}},
{"mask",cmd_select,"<mask> mask all filenames against this",{COMPL_REMOTE,COMPL_NONE}},