Bug 73 - net does not work with # names.
net does not work with # names.
Status: CLOSED FIXED
Product: Samba 3.0
Classification: Unclassified
Component: net utility
3.0.0preX
Other other
: P3 normal
: none
Assigned To: Tim Potter
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2003-05-07 15:12 UTC by Marc Kaplan
Modified: 2005-08-24 10:26 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marc Kaplan 2003-05-07 15:12:29 UTC
I was trying to do a net rpc user as follows:


net rpc user -Uadministrator%password -S `net lookup host LOTHLORIEN 0x1b`




abartlet suggested that I use the following:


net rpc user -Uadministrator%password -S LOTHLORIEN#1b




However, the latter doesn't work. IMO, net should be able to resolve the # names 
since smbclient, nmblookup, and other programs that use libsmb can.
Comment 1 Gerald (Jerry) Carter 2003-05-08 15:31:33 UTC
changing priority
Comment 2 Tim Potter 2003-05-27 23:35:01 UTC
It's pretty easy to get net lookup host to take # names but that doesn't really
sound like something it should do, as a #1b name isn't a host name.

How about renaming net lookup host to net lookup netbios or something?

Also if you are looking up a #1c name then you are sometimes interested in
looking at the list of names returned.  Currently net lookup host foo#1c will
only display the first returned name.

While I'm on the subject of complaining (-: making up a new syntax for the name
type is pretty sucky.  Just stick with the defacto name#type as per the other
Samba tools.

Anyway here's a patch to save abartlet a bit of time:

*** net_lookup.c.~1.3.2.6.~	Thu Jan 30 15:40:12 2003
--- net_lookup.c	Wed May 28 16:32:41 2003
***************
*** 23,29 ****
  int net_lookup_usage(int argc, const char **argv)
  {
  	d_printf(
! "  net lookup host HOSTNAME <type>\n\tgives IP for a hostname\n\n"
  "  net lookup ldap [domain]\n\tgives IP of domain's ldap server\n\n"
  "  net lookup kdc [realm]\n\tgives IP of realm's kerberos KDC\n\n"
  "  net lookup dc [domain]\n\tgives IP of domains Domain Controllers\n\n"
--- 23,29 ----
  int net_lookup_usage(int argc, const char **argv)
  {
  	d_printf(
! "  net lookup host HOSTNAME[#<type>]\n\tgives IP for a hostname\n\n"
  "  net lookup ldap [domain]\n\tgives IP of domain's ldap server\n\n"
  "  net lookup kdc [realm]\n\tgives IP of realm's kerberos KDC\n\n"
  "  net lookup dc [domain]\n\tgives IP of domains Domain Controllers\n\n"
***************
*** 37,50 ****
  {
  	struct in_addr ip;
  	int name_type = 0x20;
  
! 	if (argc == 0) return net_lookup_usage(argc, argv);
! 	if (argc > 1) name_type = strtol(argv[1], NULL, 0);
  
! 	if (!resolve_name(argv[0], &ip, name_type)) {
  		/* we deliberately use DEBUG() here to send it to stderr 
  		   so scripts aren't mucked up */
! 		DEBUG(0,("Didn't find %s#%02x\n", argv[0], name_type));
  		return -1;
  	}
  
--- 37,58 ----
  {
  	struct in_addr ip;
  	int name_type = 0x20;
+ 	const char *name = argv[0];
+ 	char *p;
  
! 	if (argc == 0) 
! 		return net_lookup_usage(argc, argv);
  
! 	p = strchr_m(name,'#');
! 	if (p) {
! 		*p = '\0';
! 		sscanf(++p,"%x",&name_type);
! 	}
! 	
! 	if (!resolve_name(name, &ip, name_type)) {
  		/* we deliberately use DEBUG() here to send it to stderr 
  		   so scripts aren't mucked up */
! 		DEBUG(0,("Didn't find %s#%02x\n", name, name_type));
  		return -1;
  	}
  
Comment 3 Gerald (Jerry) Carter 2003-09-04 20:39:15 UTC
Tim, If this patch works for you, please apply it to the 3.0 tree.
Comment 4 Tim Potter 2003-09-04 21:40:42 UTC
Done!
Comment 5 Gerald (Jerry) Carter 2005-02-07 07:54:44 UTC
originally reported against 3.0alpha23.  Bugzilla spring cleaning.
Comment 6 Gerald (Jerry) Carter 2005-08-24 10:26:45 UTC
sorry for the same, cleaning up the database to prevent unecessary reopens of bugs.