summaryrefslogtreecommitdiff
path: root/source3/nsswitch
diff options
context:
space:
mode:
authorSteven Danneman <steven.danneman@isilon.com>2008-03-25 16:58:40 -0700
committerGerald W. Carter <jerry@samba.org>2008-03-31 13:40:58 -0500
commit2b70174e1bcef3b34acb406c9f8d79b0ec0cacfa (patch)
tree9964645d38bf0190f8f6ec286faac5cae9e92e11 /source3/nsswitch
parent223071f01de8d85b594bab7c1f8514386da11281 (diff)
downloadsamba-2b70174e1bcef3b34acb406c9f8d79b0ec0cacfa.tar.gz
samba-2b70174e1bcef3b34acb406c9f8d79b0ec0cacfa.tar.bz2
samba-2b70174e1bcef3b34acb406c9f8d79b0ec0cacfa.zip
Augmented "wbinfo -m" to list additional information about the type, direction, and transitivty of trusts.
* added several helper functions to convert the trust_flags field in the winbindd_tdc_domain to more useful administrator ideas of trust type, trust direction, and trust transitivity. * converted winbindd_list_trusted_domains() to enumerate the trusted domain cache, instead of the domain list, and return additional trust information to the calling process * modified wbinfo to pretty print this additional trust information when a new --verbose switch is given with -m. Thus "wbinfo -m" and "wbinfo -all-domains" output as before, but "wbinfo --verbose -m" prints extra trust info. * updated some comments and fixed typos (This used to be commit e7827bb6afa264c12ecdc0858f49707ca3d6104f)
Diffstat (limited to 'source3/nsswitch')
-rw-r--r--source3/nsswitch/wbinfo.c93
1 files changed, 78 insertions, 15 deletions
diff --git a/source3/nsswitch/wbinfo.c b/source3/nsswitch/wbinfo.c
index 82d1061f6e..63748de016 100644
--- a/source3/nsswitch/wbinfo.c
+++ b/source3/nsswitch/wbinfo.c
@@ -83,7 +83,7 @@ static const char *get_winbind_domain(void)
if (!WBC_ERROR_IS_OK(wbc_status)) {
d_fprintf(stderr, "could not obtain winbind domain name!\n");
- /* HACK: (this module should not call lp_ funtions) */
+ /* HACK: (this module should not call lp_ functions) */
return lp_workgroup();
}
@@ -345,13 +345,15 @@ static bool wbinfo_wins_byip(char *ip)
return true;
}
-/* List trusted domains */
+/* List all/trusted domains */
-static bool wbinfo_list_domains(bool list_all_domains)
+static bool wbinfo_list_domains(bool list_all_domains, bool verbose)
{
struct winbindd_request request;
struct winbindd_response response;
+ bool print_all = !list_all_domains && verbose;
+
ZERO_STRUCT(request);
ZERO_STRUCT(response);
@@ -368,21 +370,72 @@ static bool wbinfo_list_domains(bool list_all_domains)
if (response.extra_data.data) {
const char *extra_data = (char *)response.extra_data.data;
char *name;
- char *p;
+ char *beg, *end;
TALLOC_CTX *frame = talloc_stackframe();
+ if (print_all) {
+ d_printf("%-34s%-12s%-12s%-10s%-10s\n",
+ "Domain Name", " Trust Type", "Transitive",
+ "Incoming", "Outgoing");
+ }
+
while(next_token_talloc(frame,&extra_data,&name,"\n")) {
- p = strchr(name, '\\');
- if (p == 0) {
- d_fprintf(stderr, "Got invalid response: %s\n",
- extra_data);
- TALLOC_FREE(frame);
- SAFE_FREE(response.extra_data.data);
- return false;
+ /* Print Domain Name */
+ if ((beg = strchr(name, '\\')) == NULL)
+ goto error;
+ *beg = 0;
+ beg++;
+ if ((end = strchr(beg, '\\')) == NULL)
+ goto error;
+ *end = 0;
+ if(*beg == 0)
+ d_printf("%-34s", name);
+ else
+ d_printf("%-34s", beg);
+
+ if (!print_all) {
+ d_printf("\n");
+ continue;
}
- *p = 0;
- d_printf("%s\n", name);
+
+ /* Skip SID */
+ beg = ++end;
+ if ((end = strchr(beg, '\\')) == NULL)
+ goto error;
+
+ /* Print Trust Type */
+ beg = ++end;
+ if ((end = strchr(beg, '\\')) == NULL)
+ goto error;
+ *end = 0;
+ d_printf(" %-12s", beg);
+
+ /* Print Transitive */
+ beg = ++end;
+ if ((end = strchr(beg, '\\')) == NULL)
+ goto error;
+ *end = 0;
+ d_printf("%-12s", beg);
+
+ /* Print Incoming */
+ beg = ++end;
+ if ((end = strchr(beg, '\\')) == NULL)
+ goto error;
+ *end = 0;
+ d_printf("%-10s", beg);
+
+ /* Print Outgoing */
+ beg = ++end;
+ d_printf("%-10s\n", beg);
}
+ goto out;
+
+error:
+ d_fprintf(stderr, "Got invalid response: %s\n", extra_data);
+ TALLOC_FREE(frame);
+ SAFE_FREE(response.extra_data.data);
+ return false;
+out:
TALLOC_FREE(frame);
SAFE_FREE(response.extra_data.data);
}
@@ -1278,6 +1331,7 @@ enum {
OPT_LIST_OWN_DOMAIN,
OPT_UID_INFO,
OPT_GROUP_INFO,
+ OPT_VERBOSE
};
int main(int argc, char **argv, char **envp)
@@ -1289,6 +1343,7 @@ int main(int argc, char **argv, char **envp)
static char *opt_domain_name;
static int int_arg;
int result = 1;
+ bool verbose = false;
struct poptOption long_options[] = {
POPT_AUTOHELP
@@ -1341,6 +1396,7 @@ int main(int argc, char **argv, char **envp)
/* "user%password,DOM\\user%password,user@EXAMPLE.COM,EXAMPLE.COM\\user%password" }, */
#endif
{ "separator", 0, POPT_ARG_NONE, 0, OPT_SEPARATOR, "Get the active winbind separator", NULL },
+ { "verbose", 0, POPT_ARG_NONE, 0, OPT_VERBOSE, "Print additional information per command", NULL },
POPT_COMMON_CONFIGFILE
POPT_COMMON_VERSION
POPT_TABLEEND
@@ -1363,6 +1419,11 @@ int main(int argc, char **argv, char **envp)
while((opt = poptGetNextOpt(pc)) != -1) {
/* get the generic configuration parameters like --domain */
+ switch (opt) {
+ case OPT_VERBOSE:
+ verbose = True;
+ break;
+ }
}
poptFreeContext(pc);
@@ -1471,7 +1532,7 @@ int main(int argc, char **argv, char **envp)
}
break;
case 'm':
- if (!wbinfo_list_domains(false)) {
+ if (!wbinfo_list_domains(false, verbose)) {
d_fprintf(stderr, "Could not list trusted domains\n");
goto done;
}
@@ -1601,7 +1662,7 @@ int main(int argc, char **argv, char **envp)
break;
}
case OPT_LIST_ALL_DOMAINS:
- if (!wbinfo_list_domains(true)) {
+ if (!wbinfo_list_domains(true, verbose)) {
goto done;
}
break;
@@ -1613,6 +1674,8 @@ int main(int argc, char **argv, char **envp)
/* generic configuration options */
case OPT_DOMAIN_NAME:
break;
+ case OPT_VERBOSE:
+ break;
default:
d_fprintf(stderr, "Invalid option\n");
poptPrintHelp(pc, stderr, 0);