diff options
author | Herb Lewis <herb@samba.org> | 2002-01-15 01:46:24 +0000 |
---|---|---|
committer | Herb Lewis <herb@samba.org> | 2002-01-15 01:46:24 +0000 |
commit | ee3677d49e8db515e7750101c1d7b8ebf0dfffd2 (patch) | |
tree | 7d25606e3e4c9b6cd81f2b85af3963bcc4841f5a | |
parent | ac028ab7aa9f00cdcbc0e7ef67956fa99702bfad (diff) | |
download | samba-ee3677d49e8db515e7750101c1d7b8ebf0dfffd2.tar.gz samba-ee3677d49e8db515e7750101c1d7b8ebf0dfffd2.tar.xz samba-ee3677d49e8db515e7750101c1d7b8ebf0dfffd2.zip |
add wins commands to winbind
add wins test commands to wbinfo
-rw-r--r-- | source/nsswitch/wbinfo.c | 66 | ||||
-rw-r--r-- | source/nsswitch/winbindd.c | 5 | ||||
-rw-r--r-- | source/nsswitch/winbindd_nss.h | 5 | ||||
-rw-r--r-- | source/nsswitch/winbindd_proto.h | 6 |
4 files changed, 81 insertions, 1 deletions
diff --git a/source/nsswitch/wbinfo.c b/source/nsswitch/wbinfo.c index baa3f69e24f..fceb0e86342 100644 --- a/source/nsswitch/wbinfo.c +++ b/source/nsswitch/wbinfo.c @@ -59,6 +59,56 @@ static BOOL wbinfo_get_usergroups(char *user) return True; } +/* Convert NetBIOS name to IP */ + +static BOOL wbinfo_wins_byname(char *name) +{ + struct winbindd_request request; + struct winbindd_response response; + + ZERO_STRUCT(request); + ZERO_STRUCT(response); + + /* Send request */ + + fstrcpy(request.data.name, name); + if (winbindd_request(WINBINDD_WINS_BYNAME, &request, &response) != + NSS_STATUS_SUCCESS) { + return False; + } + + /* Display response */ + + printf("%s\n", response.data.name.name); + + return True; +} + +/* Convert IP to NetBIOS name */ + +static BOOL wbinfo_wins_byip(char *ip) +{ + struct winbindd_request request; + struct winbindd_response response; + + ZERO_STRUCT(request); + ZERO_STRUCT(response); + + /* Send request */ + + fstrcpy(request.data.name, ip); + if (winbindd_request(WINBINDD_WINS_BYIP, &request, &response) != + NSS_STATUS_SUCCESS) { + return False; + } + + /* Display response */ + + printf("%s\n", response.data.name.name); + + return True; +} + /* List trusted domains */ static BOOL wbinfo_list_domains(void) @@ -456,6 +506,8 @@ static void usage(void) "| -aA user%%password\n"); printf("\t-u\t\t\tlists all domain users\n"); printf("\t-g\t\t\tlists all domain groups\n"); + printf("\t-h name\t\t\tconverts NetBIOS hostname to IP\n"); + printf("\t-i ip\t\t\tconverts IP address to NetBIOS name\n"); printf("\t-n name\t\t\tconverts name to sid\n"); printf("\t-s sid\t\t\tconverts sid to name\n"); printf("\t-U uid\t\t\tconverts uid to sid\n"); @@ -508,7 +560,7 @@ int main(int argc, char **argv) return 1; } - while ((opt = getopt(argc, argv, "ugs:n:U:G:S:Y:tmr:a:A:")) != EOF) { + while ((opt = getopt(argc, argv, "h:i:ugs:n:U:G:S:Y:tmr:a:A:")) != EOF) { switch (opt) { case 'u': if (!print_domain_users()) { @@ -522,6 +574,18 @@ int main(int argc, char **argv) return 1; } break; + case 'h': + if (!wbinfo_wins_byname(optarg)) { + printf("Could not lookup WINS by hostname %s\n", optarg); + return 1; + } + break; + case 'i': + if (!wbinfo_wins_byip(optarg)) { + printf("Could not lookup WINS by IP %s\n", optarg); + return 1; + } + break; case 's': if (!wbinfo_lookupsid(optarg)) { printf("Could not lookup sid %s\n", optarg); diff --git a/source/nsswitch/winbindd.c b/source/nsswitch/winbindd.c index 2b52b64749f..d0343e744ee 100644 --- a/source/nsswitch/winbindd.c +++ b/source/nsswitch/winbindd.c @@ -332,6 +332,11 @@ static struct dispatch_table dispatch_table[] = { { WINBINDD_CHECK_MACHACC, winbindd_check_machine_acct, "CHECK_MACHACC" }, + /* WINS functions */ + + { WINBINDD_WINS_BYNAME, winbindd_wins_byname, "WINS_BYNAME" }, + { WINBINDD_WINS_BYIP, winbindd_wins_byip, "WINS_BYIP" }, + /* End of list */ { WINBINDD_NUM_CMDS, NULL, "NONE" } diff --git a/source/nsswitch/winbindd_nss.h b/source/nsswitch/winbindd_nss.h index 1a3a98e1b8a..255a14e3d62 100644 --- a/source/nsswitch/winbindd_nss.h +++ b/source/nsswitch/winbindd_nss.h @@ -84,6 +84,11 @@ enum winbindd_cmd { WINBINDD_CHECK_MACHACC, /* Check machine account pw works */ + /* WINS commands */ + + WINBINDD_WINS_BYIP, + WINBINDD_WINS_BYNAME, + /* Placeholder for end of cmd list */ WINBINDD_NUM_CMDS diff --git a/source/nsswitch/winbindd_proto.h b/source/nsswitch/winbindd_proto.h index 39b86afbc88..88d7d868918 100644 --- a/source/nsswitch/winbindd_proto.h +++ b/source/nsswitch/winbindd_proto.h @@ -55,6 +55,7 @@ void winbindd_cache_status(void); /*The following definitions come from nsswitch/winbindd_cm.c */ +void cm_init_creds(struct ntuser_creds *creds); CLI_POLICY_HND *cm_get_lsa_handle(char *domain); CLI_POLICY_HND *cm_get_sam_handle(char *domain); CLI_POLICY_HND *cm_get_sam_dom_handle(char *domain, DOM_SID *domain_sid); @@ -156,4 +157,9 @@ NTSTATUS winbindd_query_dispinfo(struct winbindd_domain *domain, uint32 *num_entries, SAM_DISPINFO_CTR *ctr); BOOL check_domain_env(char *domain_env, char *domain); BOOL parse_domain_user(char *domuser, fstring domain, fstring user); + +/*The following definitions come from nsswitch/winbindd_wins.c */ + +enum winbindd_result winbindd_wins_byip(struct winbindd_cli_state *state); +enum winbindd_result winbindd_wins_byname(struct winbindd_cli_state *state); #endif /* _PROTO_H_ */ |