mirror of
https://github.com/samba-team/samba.git
synced 2025-02-26 21:57:41 +03:00
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)
This commit is contained in:
parent
5984097e09
commit
de154dcf92
@ -372,14 +372,27 @@ static wbcErr process_domain_info_string(TALLOC_CTX *ctx,
|
||||
}
|
||||
|
||||
/* Outgoing */
|
||||
r = s;
|
||||
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, "Yes") == 0) {
|
||||
info->trust_flags |= WBC_DOMINFO_TRUST_OUTGOING;
|
||||
if ( strcmp(r, "Offline") == 0) {
|
||||
info->domain_flags |= WBC_DOMINFO_DOMAIN_OFFLINE;
|
||||
}
|
||||
|
||||
wbc_status = WBC_ERR_SUCCESS;
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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 );
|
||||
|
||||
/* Send request */
|
||||
|
||||
if (winbindd_request_response(WINBINDD_SHOW_SEQUENCE, &request, &response) !=
|
||||
NSS_STATUS_SUCCESS)
|
||||
d_printf("This command has been deprecated. Please use the --online-status option instead.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Display response */
|
||||
/* 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;
|
||||
|
||||
wbc_status = wbcListTrusts(&domain_list, &num_domains);
|
||||
if (!WBC_ERROR_IS_OK(wbc_status)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
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 (!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");
|
||||
|
@ -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" );
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user