diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/include/interfaces.h | 2 | ||||
-rw-r--r-- | source3/lib/interface.c | 2 | ||||
-rw-r--r-- | source3/lib/util.c | 41 | ||||
-rw-r--r-- | source3/rpc_parse/parse_spoolss.c | 8 | ||||
-rw-r--r-- | source3/rpc_server/srv_spoolss_nt.c | 21 |
5 files changed, 53 insertions, 21 deletions
diff --git a/source3/include/interfaces.h b/source3/include/interfaces.h index ae5905e682..3b786f1ebc 100644 --- a/source3/include/interfaces.h +++ b/source3/include/interfaces.h @@ -3,6 +3,8 @@ interfaces on the machine */ +#define MAX_INTERFACES 128 + struct iface_struct { char name[16]; struct in_addr ip; diff --git a/source3/lib/interface.c b/source3/lib/interface.c index a93390e643..08636fa306 100644 --- a/source3/lib/interface.c +++ b/source3/lib/interface.c @@ -21,8 +21,6 @@ #include "includes.h" -#define MAX_INTERFACES 128 - static struct iface_struct *probed_ifaces; static int total_probed; diff --git a/source3/lib/util.c b/source3/lib/util.c index 7bd2ed8441..ca99f985ed 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -1391,6 +1391,47 @@ BOOL is_myname(char *s) return(ret); } +BOOL is_myname_or_ipaddr(char *s) +{ + char **ptr; + + /* optimize for the common case */ + if (strequal(s, global_myname)) + return True; + + /* maybe its an IP address? */ + if (is_ipaddress(s)) + { + struct iface_struct nics[MAX_INTERFACES]; + int i, n; + uint32 ip; + + ip = interpret_addr(s); + if ((ip==0) || (ip==0xffffffff)) + return False; + + n = get_interfaces(nics, MAX_INTERFACES); + for (i=0; i<n; i++) { + if (ip == nics[i].ip.s_addr) + return True; + } + } + + /* check for an alias */ + ptr = lp_netbios_aliases(); + for ( ; *ptr; ptr++ ) + { + if (StrCaseCmp(s, *ptr) == 0) + return True; + } + + + /* no match */ + return False; + +} + + /******************************************************************* set the horrid remote_arch string based on an enum. ********************************************************************/ diff --git a/source3/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c index 76214c13f1..a376b19c98 100644 --- a/source3/rpc_parse/parse_spoolss.c +++ b/source3/rpc_parse/parse_spoolss.c @@ -4922,13 +4922,7 @@ BOOL make_spoolss_driver_info_3( /******************************************************************* make a BUFFER5 struct from a uint16* ******************************************************************/ - -BOOL make_spoolss_buffer5( - TALLOC_CTX *mem_ctx, - BUFFER5 *buf5, - uint32 len, - uint16 *src -) +BOOL make_spoolss_buffer5(TALLOC_CTX *mem_ctx, BUFFER5 *buf5, uint32 len, uint16 *src) { buf5->buf_len = len; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 71b776f80a..3b21726a0f 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2959,13 +2959,14 @@ static WERROR enum_all_printers_info_1_local(NEW_BUFFER *buffer, uint32 offered, *********************************************************************/ static WERROR enum_all_printers_info_1_name(fstring name, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { - fstring temp; + char *s = name; + DEBUG(4,("enum_all_printers_info_1_name\n")); - fstrcpy(temp, "\\\\"); - fstrcat(temp, global_myname); + if ((name[0] == '\\') && (name[1] == '\\')) + s = name + 2; - if (strequal(name, temp)) { + if (is_myname_or_ipaddr(s)) { return enum_all_printers_info_1(PRINTER_ENUM_ICON8, buffer, offered, needed, returned); } else @@ -3131,20 +3132,16 @@ static WERROR enumprinters_level2( uint32 flags, fstring servername, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { - fstring temp; - - fstrcpy(temp, "\\\\"); - fstrcat(temp, global_myname); + char *s = servername; if (flags & PRINTER_ENUM_LOCAL) { - if (strequal(servername, temp)) - return enum_all_printers_info_2(buffer, offered, needed, returned); - else return enum_all_printers_info_2(buffer, offered, needed, returned); } if (flags & PRINTER_ENUM_NAME) { - if (strequal(servername, temp)) + if ((servername[0] == '\\') && (servername[1] == '\\')) + s = servername + 2; + if (is_myname_or_ipaddr(s)) return enum_all_printers_info_2(buffer, offered, needed, returned); else return WERR_INVALID_NAME; |