summaryrefslogtreecommitdiff
path: root/source3/nsswitch
diff options
context:
space:
mode:
authorGerald W. Carter <jerry@samba.org>2008-04-22 15:29:53 -0500
committerGerald W. Carter <jerry@samba.org>2008-04-23 08:47:50 -0500
commitde154dcf92ebaed23a33b6849af8aa14dc767a7d (patch)
treeb2d3ef1f425cd3b33d6d709b27989c371bdcd8d0 /source3/nsswitch
parent5984097e0921996aacad0d6077e7f866f74d8c23 (diff)
downloadsamba-de154dcf92ebaed23a33b6849af8aa14dc767a7d.tar.gz
samba-de154dcf92ebaed23a33b6849af8aa14dc767a7d.tar.bz2
samba-de154dcf92ebaed23a33b6849af8aa14dc767a7d.zip
Mark a domain offline in the wbcDomainInfo structure using the domain_flags.
Use the existing domain_flags fiueld in wbcDomainInfo to set a bit if the domain is marked as offline by Winbind. (This used to be commit 59cfba2c3d6d4594f08cbe3b7295ab36a7cfb044)
Diffstat (limited to 'source3/nsswitch')
-rw-r--r--source3/nsswitch/libwbclient/wbc_util.c15
-rw-r--r--source3/nsswitch/libwbclient/wbclient.h1
-rw-r--r--source3/nsswitch/wbinfo.c58
3 files changed, 50 insertions, 24 deletions
diff --git a/source3/nsswitch/libwbclient/wbc_util.c b/source3/nsswitch/libwbclient/wbc_util.c
index c1b3affc72..3afd8a29d3 100644
--- a/source3/nsswitch/libwbclient/wbc_util.c
+++ b/source3/nsswitch/libwbclient/wbc_util.c
@@ -373,15 +373,28 @@ static wbcErr process_domain_info_string(TALLOC_CTX *ctx,
/* Outgoing */
r = s;
- if (r == NULL) {
+ if ((s = strchr(r, '\\')) == NULL) {
wbc_status = WBC_ERR_INVALID_RESPONSE;
BAIL_ON_WBC_ERROR(wbc_status);
}
+ *s = '\0';
+ s++;
if (strcmp(r, "Yes") == 0) {
info->trust_flags |= WBC_DOMINFO_TRUST_OUTGOING;
}
+ /* Online/Offline status */
+
+ r = s;
+ if (r == NULL) {
+ wbc_status = WBC_ERR_INVALID_RESPONSE;
+ BAIL_ON_WBC_ERROR(wbc_status);
+ }
+ if ( strcmp(r, "Offline") == 0) {
+ info->domain_flags |= WBC_DOMINFO_DOMAIN_OFFLINE;
+ }
+
wbc_status = WBC_ERR_SUCCESS;
done:
diff --git a/source3/nsswitch/libwbclient/wbclient.h b/source3/nsswitch/libwbclient/wbclient.h
index 67fa25691a..f236c43e11 100644
--- a/source3/nsswitch/libwbclient/wbclient.h
+++ b/source3/nsswitch/libwbclient/wbclient.h
@@ -139,6 +139,7 @@ struct wbcDomainInfo {
#define WBC_DOMINFO_DOMAIN_NATIVE 0x00000001
#define WBC_DOMINFO_DOMAIN_AD 0x00000002
#define WBC_DOMINFO_DOMAIN_PRIMARY 0x00000004
+#define WBC_DOMINFO_DOMAIN_OFFLINE 0x00000008
/* wbcDomainInfo->trust_flags */
diff --git a/source3/nsswitch/wbinfo.c b/source3/nsswitch/wbinfo.c
index d844e2385e..7bb4abe9b2 100644
--- a/source3/nsswitch/wbinfo.c
+++ b/source3/nsswitch/wbinfo.c
@@ -419,39 +419,43 @@ static bool wbinfo_list_own_domain(void)
/* show sequence numbers */
static bool wbinfo_show_sequence(const char *domain)
{
- struct winbindd_request request;
- struct winbindd_response response;
-
- ZERO_STRUCT(response);
- ZERO_STRUCT(request);
-
- if ( domain )
- fstrcpy( request.domain_name, domain );
+ d_printf("This command has been deprecated. Please use the --online-status option instead.\n");
+ return false;
+}
- /* Send request */
+/* show sequence numbers */
+static bool wbinfo_show_onlinestatus(const char *domain)
+{
+ struct wbcDomainInfo *domain_list = NULL;
+ size_t num_domains;
+ wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+ int i;
- if (winbindd_request_response(WINBINDD_SHOW_SEQUENCE, &request, &response) !=
- NSS_STATUS_SUCCESS)
+ wbc_status = wbcListTrusts(&domain_list, &num_domains);
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
return false;
+ }
- /* Display response */
+ for (i=0; i<num_domains; i++) {
+ bool is_offline;
- if (domain) {
- d_printf("%s : ", domain);
- if (response.data.sequence_number == (uint32_t)-1) {
- d_printf("DISCONNECTED\n");
- } else {
- d_printf("%d\n", response.data.sequence_number);
+ if (domain) {
+ if (!strequal(domain_list[i].short_name, domain)) {
+ continue;
+ }
}
- } else if (response.extra_data.data) {
- char *extra_data = (char *)response.extra_data.data;
- d_printf("%s", extra_data);
- SAFE_FREE(response.extra_data.data);
+
+ is_offline = (domain_list[i].domain_flags & WBC_DOMINFO_DOMAIN_OFFLINE);
+
+ d_printf("%s : %s\n",
+ domain_list[i].short_name,
+ is_offline ? "offline" : "online" );
}
return true;
}
+
/* Show domain info */
static bool wbinfo_domain_info(const char *domain)
@@ -1317,7 +1321,8 @@ enum {
OPT_LIST_OWN_DOMAIN,
OPT_UID_INFO,
OPT_GROUP_INFO,
- OPT_VERBOSE
+ OPT_VERBOSE,
+ OPT_ONLINESTATUS
};
int main(int argc, char **argv, char **envp)
@@ -1357,6 +1362,7 @@ int main(int argc, char **argv, char **envp)
{ "all-domains", 0, POPT_ARG_NONE, 0, OPT_LIST_ALL_DOMAINS, "List all domains (trusted and own domain)" },
{ "own-domain", 0, POPT_ARG_NONE, 0, OPT_LIST_OWN_DOMAIN, "List own domain" },
{ "sequence", 0, POPT_ARG_NONE, 0, OPT_SEQUENCE, "Show sequence numbers of all domains" },
+ { "online-status", 0, POPT_ARG_NONE, 0, OPT_ONLINESTATUS, "Show whether domains are marked as online or offline"},
{ "domain-info", 'D', POPT_ARG_STRING, &string_arg, 'D', "Show most of the info we have about the domain" },
{ "user-info", 'i', POPT_ARG_STRING, &string_arg, 'i', "Get user info", "USER" },
{ "uid-info", 0, POPT_ARG_INT, &int_arg, OPT_UID_INFO, "Get user info from uid", "UID" },
@@ -1529,6 +1535,12 @@ int main(int argc, char **argv, char **envp)
goto done;
}
break;
+ case OPT_ONLINESTATUS:
+ if (!wbinfo_show_onlinestatus(opt_domain_name)) {
+ d_fprintf(stderr, "Could not show online-status\n");
+ goto done;
+ }
+ break;
case 'D':
if (!wbinfo_domain_info(string_arg)) {
d_fprintf(stderr, "Could not get domain info\n");