This is a multi-part message in MIME format.
--------------050609020801050609090807
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Folks,

Metze and I discussed the sequence number stuff in Winbind
and both agree that the wbinfo --sequence call is fairly useless.

Attached are a pair of patches that xtend the struct wbcDOmainInfo
in the libwbclient API to include the OFFLINE status of domains.
This also includes a "wbinfo --online-status" command
and deprecates the "wbinfo --sequence" operation.

The only thing failing is that the main parent Winbind daemon
does not know the status of all domains. I could follow the
path that wmbcontrol did and use messages. I'm wondering if
we should store a online/offline record for each domain rather
than requiring each child process to figure it out. But this
is more work and too much for right now.

If ppl agree then I will find some existing way to actually
report the online/offline status in the next patch.

Please review. Thanks.




cheers, jerry
- --
================================================== ===================
Samba ------- http://www.samba.org
Likewise Software --------- http://www.likewisesoftware.com
"What man is a man who does not make the world better?" --Balian
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIDmDOIR7qMdg1EfYRApYjAJ92U5I7KoxWF+UJ/pBfzIYCaisE4QCbB+Ae
bPB6wLgHg2MERqPE6/86X5Q=
=7Vmk
-----END PGP SIGNATURE-----

--------------050609020801050609090807
Content-Type: text/x-diff;
name="0001-Rename-WBC_DOMAIN_XXX-domain-flags-to-WBC_DOMINFO_DO.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename*0="0001-Rename-WBC_DOMAIN_XXX-domain-flags-to-WBC_DOMINFO_DO.pa";
filename*1="tch"

>From 8eadd6d11a5b1fa5cc9539b21d7df12f5db244cd Mon Sep 17 00:00:00 2001

From: Gerald W. Carter
Date: Tue, 22 Apr 2008 12:22:59 -0500
Subject: [PATCH] Rename WBC_DOMAIN_XXX domain flags to WBC_DOMINFO_DOMAIN_XXX

Better consistency with the othre classes of WBC_DOMINDO_XXX_YYYY flags.
---
source/nsswitch/libwbclient/wbc_util.c | 6 +++---
source/nsswitch/libwbclient/wbclient.h | 8 ++++----
source/nsswitch/wbinfo.c | 6 +++---
3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/source/nsswitch/libwbclient/wbc_util.c b/source/nsswitch/libwbclient/wbc_util.c
index a1b6626..c1b3aff 100644
--- a/source/nsswitch/libwbclient/wbc_util.c
+++ b/source/nsswitch/libwbclient/wbc_util.c
@@ -170,11 +170,11 @@ wbcErr wbcDomainInfo(const char *domain, struct wbcDomainInfo **dinfo)
BAIL_ON_WBC_ERROR(wbc_status);

if (response.data.domain_info.native_mode)
- info->domain_flags |= WBC_DOMINFO_NATIVE;
+ info->domain_flags |= WBC_DOMINFO_DOMAIN_NATIVE;
if (response.data.domain_info.active_directory)
- info->domain_flags |= WBC_DOMINFO_AD;
+ info->domain_flags |= WBC_DOMINFO_DOMAIN_AD;
if (response.data.domain_info.primary)
- info->domain_flags |= WBC_DOMINFO_PRIMARY;
+ info->domain_flags |= WBC_DOMINFO_DOMAIN_PRIMARY;

*dinfo = info;

diff --git a/source/nsswitch/libwbclient/wbclient.h b/source/nsswitch/libwbclient/wbclient.h
index d73ea29..67fa256 100644
--- a/source/nsswitch/libwbclient/wbclient.h
+++ b/source/nsswitch/libwbclient/wbclient.h
@@ -135,10 +135,10 @@ struct wbcDomainInfo {

/* wbcDomainInfo->domain_flags */

-#define WBC_DOMINFO_UNKNOWN 0x00000000
-#define WBC_DOMINFO_NATIVE 0x00000001
-#define WBC_DOMINFO_AD 0x00000002
-#define WBC_DOMINFO_PRIMARY 0x00000004
+#define WBC_DOMINFO_DOMAIN_UNKNOWN 0x00000000
+#define WBC_DOMINFO_DOMAIN_NATIVE 0x00000001
+#define WBC_DOMINFO_DOMAIN_AD 0x00000002
+#define WBC_DOMINFO_DOMAIN_PRIMARY 0x00000004

/* wbcDomainInfo->trust_flags */

diff --git a/source/nsswitch/wbinfo.c b/source/nsswitch/wbinfo.c
index 8aa4e5f..d844e23 100644
--- a/source/nsswitch/wbinfo.c
+++ b/source/nsswitch/wbinfo.c
@@ -485,12 +485,12 @@ static bool wbinfo_domain_info(const char *domain)
d_printf("SID : %s\n", sid_str);

d_printf("Active Directory : %s\n",
- (dinfo->domain_flags & WBC_DOMINFO_AD) ? "Yes" : "No");
+ (dinfo->domain_flags & WBC_DOMINFO_DOMAIN_AD) ? "Yes" : "No");
d_printf("Native : %s\n",
- (dinfo->domain_flags & WBC_DOMINFO_NATIVE) ? "Yes" : "No");
+ (dinfo->domain_flags & WBC_DOMINFO_DOMAIN_NATIVE) ? "Yes" : "No");

d_printf("Primary : %s\n",
- (dinfo->domain_flags & WBC_DOMINFO_PRIMARY) ? "Yes" : "No");
+ (dinfo->domain_flags & WBC_DOMINFO_DOMAIN_PRIMARY) ? "Yes" : "No");

wbcFreeMemory(sid_str);
wbcFreeMemory(dinfo);
--
1.5.4.3


--------------050609020801050609090807
Content-Type: text/x-diff;
name="0002-Mark-a-domain-offline-in-the-wncDomainInfo-structure.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename*0="0002-Mark-a-domain-offline-in-the-wncDomainInfo-structure.pa";
filename*1="tch"

>From ce0a79c4c8face6fd1130bb87226b20b4969a1db Mon Sep 17 00:00:00 2001

From: Gerald W. Carter
Date: Tue, 22 Apr 2008 15:29:53 -0500
Subject: [PATCH] Mark a domain offline in the wncDomainInfo 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.
---
source/nsswitch/libwbclient/wbc_util.c | 15 ++++++++-
source/nsswitch/libwbclient/wbclient.h | 1 +
source/nsswitch/wbinfo.c | 58 +++++++++++++++++++------------
source/winbindd/winbindd_misc.c | 18 ++++++++--
4 files changed, 64 insertions(+), 28 deletions(-)

diff --git a/source/nsswitch/libwbclient/wbc_util.c b/source/nsswitch/libwbclient/wbc_util.c
index c1b3aff..3afd8a2 100644
--- a/source/nsswitch/libwbclient/wbc_util.c
+++ b/source/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/source/nsswitch/libwbclient/wbclient.h b/source/nsswitch/libwbclient/wbclient.h
index 67fa256..f236c43 100644
--- a/source/nsswitch/libwbclient/wbclient.h
+++ b/source/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/source/nsswitch/wbinfo.c b/source/nsswitch/wbinfo.c
index d844e23..7bb4abe 100644
--- a/source/nsswitch/wbinfo.c
+++ b/source/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 + 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");
diff --git a/source/winbindd/winbindd_misc.c b/source/winbindd/winbindd_misc.c
index bde2eaf..8933cf2 100644
--- a/source/winbindd/winbindd_misc.c
+++ b/source/winbindd/winbindd_misc.c
@@ -173,20 +173,29 @@ void winbindd_list_trusted_domains(struct winbindd_cli_state *state)
}

for ( i = 0; i < num_domains; i++ ) {
+ struct winbindd_domain *domain;
+ bool is_online = true;
+
d = &dom_list[i];
+ domain = find_domain_from_name_noinit(d->domain_name);
+ if (domain) {
+ is_online = domain->online;
+ }
+
if ( !extra_data ) {
extra_data = talloc_asprintf(state->mem_ctx,
- "%s\\%s\\%s\\%s\\%s\\%s\\%s",
+ "%s\\%s\\%s\\%s\\%s\\%s\\%s\\%s",
d->domain_name,
d->dns_name ? d->dns_name : d->domain_name,
sid_string_talloc(state->mem_ctx, &d->sid),
get_trust_type_string(d),
trust_is_transitive(d) ? "Yes" : "No",
trust_is_inbound(d) ? "Yes" : "No",
- trust_is_outbound(d) ? "Yes" : "No");
+ trust_is_outbound(d) ? "Yes" : "No",
+ is_online ? "Online" : "Offline" );
} else {
extra_data = talloc_asprintf(state->mem_ctx,
- "%s\n%s\\%s\\%s\\%s\\%s\\%s\\%s",
+ "%s\n%s\\%s\\%s\\%s\\%s\\%s\\%s\\%s",
extra_data,
d->domain_name,
d->dns_name ? d->dns_name : d->domain_name,
@@ -194,7 +203,8 @@ void winbindd_list_trusted_domains(struct winbindd_cli_state *state)
get_trust_type_string(d),
trust_is_transitive(d) ? "Yes" : "No",
trust_is_inbound(d) ? "Yes" : "No",
- trust_is_outbound(d) ? "Yes" : "No");
+ trust_is_outbound(d) ? "Yes" : "No",
+ is_online ? "Online" : "Offline" );
}
}

--
1.5.4.3


--------------050609020801050609090807--