diff options
-rw-r--r-- | source3/nsswitch/wbinfo.c | 90 |
1 files changed, 49 insertions, 41 deletions
diff --git a/source3/nsswitch/wbinfo.c b/source3/nsswitch/wbinfo.c index aae76e4423..c55f4bb431 100644 --- a/source3/nsswitch/wbinfo.c +++ b/source3/nsswitch/wbinfo.c @@ -45,7 +45,7 @@ static char winbind_separator_int(BOOL strict) if (winbindd_request_response(WINBINDD_INFO, NULL, &response) != NSS_STATUS_SUCCESS) { - d_printf("could not obtain winbind separator!\n"); + d_fprintf(stderr, "could not obtain winbind separator!\n"); if (strict) { return -1; } @@ -57,7 +57,7 @@ static char winbind_separator_int(BOOL strict) got_sep = True; if (!sep) { - d_printf("winbind separator was NULL!\n"); + d_fprintf(stderr, "winbind separator was NULL!\n"); if (strict) { return -1; } @@ -84,7 +84,7 @@ static const char *get_winbind_domain(void) if (winbindd_request_response(WINBINDD_DOMAIN_NAME, NULL, &response) != NSS_STATUS_SUCCESS) { - d_printf("could not obtain winbind domain name!\n"); + d_fprintf(stderr, "could not obtain winbind domain name!\n"); /* HACK: (this module should not call lp_ funtions) */ return lp_workgroup(); @@ -199,7 +199,7 @@ static BOOL wbinfo_get_userdomgroups(const char *user_sid) return False; if (response.data.num_entries != 0) - printf("%s", (char *)response.extra_data); + d_printf("%s", (char *)response.extra_data); SAFE_FREE(response.extra_data); @@ -227,7 +227,7 @@ static BOOL wbinfo_wins_byname(char *name) /* Display response */ - printf("%s\n", response.data.winsresp); + d_printf("%s\n", response.data.winsresp); return True; } @@ -253,7 +253,7 @@ static BOOL wbinfo_wins_byip(char *ip) /* Display response */ - printf("%s\n", response.data.winsresp); + d_printf("%s\n", response.data.winsresp); return True; } @@ -282,7 +282,7 @@ static BOOL wbinfo_list_domains(void) while(next_token(&extra_data, name, "\n", sizeof(fstring))) { p = strchr(name, '\\'); if (p == 0) { - d_printf("Got invalid response: %s\n", + d_fprintf(stderr, "Got invalid response: %s\n", extra_data); return False; } @@ -379,7 +379,7 @@ static BOOL wbinfo_getdcname(const char *domain_name) if (winbindd_request_response(WINBINDD_GETDCNAME, &request, &response) != NSS_STATUS_SUCCESS) { - d_printf("Could not get dc name for %s\n", domain_name); + d_fprintf(stderr, "Could not get dc name for %s\n", domain_name); return False; } @@ -405,7 +405,7 @@ static BOOL wbinfo_check_secret(void) (result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed"); if (result != NSS_STATUS_SUCCESS) - d_printf("error code was %s (0x%x)\n", + d_fprintf(stderr, "error code was %s (0x%x)\n", response.data.auth.nt_status_string, response.data.auth.nt_status); @@ -607,7 +607,7 @@ static BOOL wbinfo_auth(char *username) (result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed"); if (response.data.auth.nt_status) - d_printf("error code was %s (0x%x)\nerror messsage was: %s\n", + d_fprintf(stderr, "error code was %s (0x%x)\nerror messsage was: %s\n", response.data.auth.nt_status_string, response.data.auth.nt_status, response.data.auth.error_string); @@ -707,7 +707,7 @@ static BOOL wbinfo_auth_crap(char *username) (result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed"); if (response.data.auth.nt_status) - d_printf("error code was %s (0x%x)\nerror messsage was: %s\n", + d_fprintf(stderr, "error code was %s (0x%x)\nerror messsage was: %s\n", response.data.auth.nt_status_string, response.data.auth.nt_status, response.data.auth.error_string); @@ -751,7 +751,7 @@ static BOOL wbinfo_klog(char *username) (result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed"); if (response.data.auth.nt_status) - d_printf("error code was %s (0x%x)\nerror messsage was: %s\n", + d_fprintf(stderr, "error code was %s (0x%x)\nerror messsage was: %s\n", response.data.auth.nt_status_string, response.data.auth.nt_status, response.data.auth.error_string); @@ -760,12 +760,12 @@ static BOOL wbinfo_klog(char *username) return False; if (response.extra_data == NULL) { - d_printf("Did not get token data\n"); + d_fprintf(stderr, "Did not get token data\n"); return False; } if (!afs_settoken_str((char *)response.extra_data)) { - d_printf("Could not set token\n"); + d_fprintf(stderr, "Could not set token\n"); return False; } @@ -1058,114 +1058,114 @@ int main(int argc, char **argv) switch (opt) { case 'u': if (!print_domain_users(opt_domain_name)) { - d_printf("Error looking up domain users\n"); + d_fprintf(stderr, "Error looking up domain users\n"); goto done; } break; case 'g': if (!print_domain_groups(opt_domain_name)) { - d_printf("Error looking up domain groups\n"); + d_fprintf(stderr, "Error looking up domain groups\n"); goto done; } break; case 's': if (!wbinfo_lookupsid(string_arg)) { - d_printf("Could not lookup sid %s\n", string_arg); + d_fprintf(stderr, "Could not lookup sid %s\n", string_arg); goto done; } break; case 'n': if (!wbinfo_lookupname(string_arg)) { - d_printf("Could not lookup name %s\n", string_arg); + d_fprintf(stderr, "Could not lookup name %s\n", string_arg); goto done; } break; case 'N': if (!wbinfo_wins_byname(string_arg)) { - d_printf("Could not lookup WINS by name %s\n", string_arg); + d_fprintf(stderr, "Could not lookup WINS by name %s\n", string_arg); goto done; } break; case 'I': if (!wbinfo_wins_byip(string_arg)) { - d_printf("Could not lookup WINS by IP %s\n", string_arg); + d_fprintf(stderr, "Could not lookup WINS by IP %s\n", string_arg); goto done; } break; case 'U': if (!wbinfo_uid_to_sid(int_arg)) { - d_printf("Could not convert uid %d to sid\n", int_arg); + d_fprintf(stderr, "Could not convert uid %d to sid\n", int_arg); goto done; } break; case 'G': if (!wbinfo_gid_to_sid(int_arg)) { - d_printf("Could not convert gid %d to sid\n", + d_fprintf(stderr, "Could not convert gid %d to sid\n", int_arg); goto done; } break; case 'S': if (!wbinfo_sid_to_uid(string_arg)) { - d_printf("Could not convert sid %s to uid\n", + d_fprintf(stderr, "Could not convert sid %s to uid\n", string_arg); goto done; } break; case 'Y': if (!wbinfo_sid_to_gid(string_arg)) { - d_printf("Could not convert sid %s to gid\n", + d_fprintf(stderr, "Could not convert sid %s to gid\n", string_arg); goto done; } break; case 'A': if (!wbinfo_allocate_rid()) { - d_printf("Could not allocate a RID\n"); + d_fprintf(stderr, "Could not allocate a RID\n"); goto done; } break; case 't': if (!wbinfo_check_secret()) { - d_printf("Could not check secret\n"); + d_fprintf(stderr, "Could not check secret\n"); goto done; } break; case 'm': if (!wbinfo_list_domains()) { - d_printf("Could not list trusted domains\n"); + d_fprintf(stderr, "Could not list trusted domains\n"); goto done; } break; case OPT_SEQUENCE: if (!wbinfo_show_sequence(opt_domain_name)) { - d_printf("Could not show sequence numbers\n"); + d_fprintf(stderr, "Could not show sequence numbers\n"); goto done; } break; case 'D': if (!wbinfo_domain_info(string_arg)) { - d_printf("Could not get domain info\n"); + d_fprintf(stderr, "Could not get domain info\n"); goto done; } break; case 'r': if (!wbinfo_get_usergroups(string_arg)) { - d_printf("Could not get groups for user %s\n", + d_fprintf(stderr, "Could not get groups for user %s\n", string_arg); goto done; } break; case OPT_USERSIDS: if (!wbinfo_get_usersids(string_arg)) { - d_printf("Could not get group SIDs for user SID %s\n", + d_fprintf(stderr, "Could not get group SIDs for user SID %s\n", string_arg); goto done; } break; case OPT_USERDOMGROUPS: if (!wbinfo_get_userdomgroups(string_arg)) { - d_printf("Could not get user's domain groups " + d_fprintf(stderr, "Could not get user's domain groups " "for user SID %s\n", string_arg); goto done; } @@ -1174,13 +1174,13 @@ int main(int argc, char **argv) BOOL got_error = False; if (!wbinfo_auth(string_arg)) { - d_printf("Could not authenticate user %s with " + d_fprintf(stderr, "Could not authenticate user %s with " "plaintext password\n", string_arg); got_error = True; } if (!wbinfo_auth_crap(string_arg)) { - d_printf("Could not authenticate user %s with " + d_fprintf(stderr, "Could not authenticate user %s with " "challenge/response\n", string_arg); got_error = True; } @@ -1191,29 +1191,37 @@ int main(int argc, char **argv) } case 'k': if (!wbinfo_klog(string_arg)) { - d_printf("Could not klog user\n"); + d_fprintf(stderr, "Could not klog user\n"); goto done; } break; case 'p': if (!wbinfo_ping()) { - d_printf("could not ping winbindd!\n"); + d_fprintf(stderr, "Could not ping winbindd!\n"); goto done; } break; case OPT_SET_AUTH_USER: - wbinfo_set_auth_user(string_arg); + if (!wbinfo_set_auth_user(string_arg)) { + goto done; + } break; case OPT_GET_AUTH_USER: wbinfo_get_auth_user(); break; case OPT_GETDCNAME: - wbinfo_getdcname(string_arg); + if (!wbinfo_getdcname(string_arg)) { + goto done; + } break; - case OPT_SEPARATOR: - d_printf("%c\n", winbind_separator_int(True)); + case OPT_SEPARATOR: { + const char sep = winbind_separator_int(True); + if (sep == -1) { + goto done; + } + d_printf("%c\n", sep); break; - + } /* generic configuration options */ case OPT_DOMAIN_NAME: break; |