Fix spelling s/ouput/output/
[samba.git] / nsswitch / wbinfo.c
index 80b245a7f5c34464a7e0757f8d18db65055f92be..1b58c73602a1d75fadf206fad6f4589534bdf5c3 100644 (file)
@@ -536,7 +536,26 @@ static bool wbinfo_list_domains(bool list_all_domains, bool verbose)
 
                switch(domain_list[i].trust_type) {
                case WBC_DOMINFO_TRUSTTYPE_NONE:
-                       d_printf("None        ");
+                       if (domain_list[i].trust_routing != NULL) {
+                               d_printf("%s\n", domain_list[i].trust_routing);
+                       } else {
+                               d_printf("None\n");
+                       }
+                       continue;
+               case WBC_DOMINFO_TRUSTTYPE_LOCAL:
+                       d_printf("Local\n");
+                       continue;
+               case WBC_DOMINFO_TRUSTTYPE_RWDC:
+                       d_printf("RWDC\n");
+                       continue;
+               case WBC_DOMINFO_TRUSTTYPE_RODC:
+                       d_printf("RODC\n");
+                       continue;
+               case WBC_DOMINFO_TRUSTTYPE_PDC:
+                       d_printf("PDC\n");
+                       continue;
+               case WBC_DOMINFO_TRUSTTYPE_WKSTA:
+                       d_printf("Workstation ");
                        break;
                case WBC_DOMINFO_TRUSTTYPE_FOREST:
                        d_printf("Forest      ");
@@ -621,7 +640,7 @@ static bool wbinfo_show_onlinestatus(const char *domain)
 
                d_printf("%s : %s\n",
                         domain_list[i].short_name,
-                        is_offline ? "offline" : "online" );
+                        is_offline ? "no active connection" : "active connection" );
        }
 
        wbcFreeMemory(domain_list);
@@ -1105,6 +1124,12 @@ static bool wbinfo_xids_to_sids(const char *arg)
 
        for (i=0; i<num_xids; i++) {
                char str[WBC_SID_STRING_BUFLEN];
+               struct wbcDomainSid null_sid = { 0 };
+
+               if (memcmp(&null_sid, &sids[i], sizeof(struct wbcDomainSid)) == 0) {
+                       d_printf("NOT MAPPED\n");
+                       continue;
+               }
                wbcSidToStringBuf(&sids[i], str, sizeof(str));
                d_printf("%s\n", str);
        }
@@ -1773,15 +1798,25 @@ static bool wbinfo_auth_crap(char *username, bool use_ntlmv2, bool use_lanman)
        if (use_ntlmv2) {
                DATA_BLOB server_chal;
                DATA_BLOB names_blob;
+               const char *netbios_name = NULL;
+               const char *domain = NULL;
+
+               netbios_name = get_winbind_netbios_name(),
+               domain = get_winbind_domain();
+               if (domain == NULL) {
+                       d_fprintf(stderr, "Failed to get domain from winbindd\n");
+                       return false;
+               }
 
                server_chal = data_blob(params.password.response.challenge, 8);
 
                /* Pretend this is a login to 'us', for blob purposes */
                names_blob = NTLMv2_generate_names_blob(NULL,
-                                               get_winbind_netbios_name(),
-                                               get_winbind_domain());
+                                                       netbios_name,
+                                                       domain);
 
-               if (!SMBNTLMv2encrypt(NULL, name_user, name_domain, pass,
+               if (pass != NULL &&
+                   !SMBNTLMv2encrypt(NULL, name_user, name_domain, pass,
                                      &server_chal,
                                      &names_blob,
                                      &lm, &nt, NULL, NULL)) {
@@ -1823,13 +1858,15 @@ static bool wbinfo_auth_crap(char *username, bool use_ntlmv2, bool use_lanman)
 
        if (wbc_status == WBC_ERR_AUTH_ERROR) {
                d_fprintf(stderr,
-                        "wbcAuthenticateUserEx(%s%c%s): error code was %s (0x%x)\n"
+                        "wbcAuthenticateUserEx(%s%c%s): error code was "
+                         "%s (0x%x, authoritative=%"PRIu8")\n"
                         "error message was: %s\n",
                         name_domain,
                         winbind_separator(),
                         name_user,
                         err->nt_string,
                         err->nt_status,
+                        err->authoritative,
                         err->display_string);
                wbcFreeMemory(err);
        } else if (WBC_ERROR_IS_OK(wbc_status)) {
@@ -2299,7 +2336,7 @@ int main(int argc, const 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, "Deprecated command, see --online-status" },
-               { "online-status", 0, POPT_ARG_NONE, 0, OPT_ONLINESTATUS, "Show whether domains are marked as online or offline"},
+               { "online-status", 0, POPT_ARG_NONE, 0, OPT_ONLINESTATUS, "Show whether domains maintain an active connection"},
                { "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" },