mirror of
https://github.com/samba-team/samba.git
synced 2025-01-22 22:04:08 +03:00
Adding the same change as was added to 1.9.18 branch to add the
"name resolve order" parameter. source/Makefile: Re-ordered link for name resolve order code. source/clientgen.c: source/clientutil.c: Added calls to resolve_name(). source/includes.h: Added HPUX zombie fix. source/loadparm.c: Added new name resolve order parameter. source/namequery.c: Re-wrote to include parsing of lmhosts file, new resolve_name() function requested by John. source/nmbd.c: Tell resolve_name not to do WINS lookups if we are the WINS server. source/nmbd_lmhosts.c: Call lmhosts parsing functions in namequery.c source/password.c: Call resolve_name() to lookup security=server name. source/reply.c: source/time.c: source/trans2.c: "fake directory create times" fix from Jim Hague - hague@research.canon.com.au. source/util.c: Removed isalnum() test in Get_Hostname() that seems to cause problems on many systems. Jeremy. (This used to be commit 7f118970da7c43eaddcf92dc056d3e849f1e7d5c)
This commit is contained in:
parent
14d6ee34de
commit
c54af0f8b2
@ -433,6 +433,8 @@ message command
|
||||
|
||||
min wins ttl
|
||||
|
||||
name resolve order
|
||||
|
||||
netbios aliases
|
||||
|
||||
netbios name
|
||||
@ -578,6 +580,8 @@ dos filetime resolution
|
||||
|
||||
exec
|
||||
|
||||
fake directory create times
|
||||
|
||||
fake oplocks
|
||||
|
||||
follow symlinks
|
||||
@ -1349,14 +1353,45 @@ the two timestamps to match, and Visual C++ is happy.
|
||||
.SS encrypt passwords (G)
|
||||
|
||||
This boolean controls whether encrypted passwords will be negotiated
|
||||
with the client. Note that this option has no effect if you haven't
|
||||
compiled in the necessary des libraries and encryption code. It
|
||||
defaults to no.
|
||||
with the client. Note that Windows NT 4.0 SP3 and above will by default
|
||||
expect encrypted passwords unless a registry entry is changed. To use
|
||||
encrypted passwords in Samba see the file docs/ENCRYPTION.txt.
|
||||
|
||||
.SS exec (S)
|
||||
|
||||
This is an alias for preexec
|
||||
|
||||
.SS fake directory create times (S)
|
||||
NTFS and Windows VFAT file systems keep a create time for all files
|
||||
and directories. This is not the same as the ctime - status change
|
||||
time - that Unix keeps, so Samba by default reports the earliest
|
||||
of the various times Unix does keep. Setting this parameter for a
|
||||
share causes Samba to always report midnight 1-1-1980 as
|
||||
the create time for directories.
|
||||
|
||||
This option is mainly used as a compatibility option for Visual C++
|
||||
when used against Samba shares. Visual C++ generated makefiles
|
||||
have the object directory as a dependency for each object file,
|
||||
and a make rule to create the directory. Also, when NMAKE
|
||||
compares timestamps it uses the creation time when examining
|
||||
a directory. Thus the object directory will be created if it does
|
||||
not exist, but once it does exist it will always have an earlier
|
||||
timestamp than the object files it contains.
|
||||
|
||||
However, Unix time semantics mean that the create time reported
|
||||
by Samba will be updated whenever a file is created or deleted
|
||||
in the directory. NMAKE therefore finds all object files in the
|
||||
object directory bar the last one built are out of date compared
|
||||
to the directory and rebuilds them. Enabling this option ensures
|
||||
directories always predate their contents and an NMAKE build will
|
||||
proceed as expected.
|
||||
|
||||
.B Default:
|
||||
fake directory create times = False
|
||||
|
||||
.B Example:
|
||||
fake directory create times = True
|
||||
|
||||
.SS fake oplocks (S)
|
||||
|
||||
Oplocks are the way that SMB clients get permission from a server to
|
||||
@ -2373,6 +2408,40 @@ The default is 6 hours (21600 seconds).
|
||||
.B Default:
|
||||
min wins ttl = 21600
|
||||
|
||||
.SS name resolve order (G)
|
||||
|
||||
This option is used by the programs smbd, nmbd and smbclient to determine
|
||||
what naming services and in what order to resolve host names to IP addresses.
|
||||
This option is most useful in smbclient. The option takes a space separated
|
||||
string of different name resolution options. These are "lmhosts", "host",
|
||||
"wins" and "bcast". They cause names to be resolved as follows :
|
||||
|
||||
lmhosts : Lookup an IP address in the Samba lmhosts file.
|
||||
host : Do a standard host name to IP address resolution, using the
|
||||
system /etc/hosts, NIS, or DNS lookups. This method of name
|
||||
resolution is operating system depended (for instance on Solaris
|
||||
this may be controlled by the /etc/nsswitch.conf file).
|
||||
wins : Query a name with the IP address listed in the "wins server ="
|
||||
parameter. If no WINS server has been specified this method will
|
||||
be ignored.
|
||||
bcast : Do a broadcast on each of the known local interfaces listed in
|
||||
the "interfaces =" parameter. This is the least reliable of the
|
||||
name resolution methods as it depends on the target host being
|
||||
on a locally connected subnet.
|
||||
|
||||
The default order is lmhosts, host, wins, bcast and these name resolution
|
||||
methods will be attempted in this order.
|
||||
|
||||
This option was first introduced in Samba 1.9.18p4.
|
||||
|
||||
.B Default:
|
||||
name resolve order = lmhosts host wins bcast
|
||||
|
||||
.Example:
|
||||
name resolve order = lmhosts bcast host
|
||||
|
||||
This will cause the local lmhosts file to be examined first, followed
|
||||
by a broadcast attempt, followed by a normal system hostname lookup.
|
||||
|
||||
.SS netbios aliases (G)
|
||||
|
||||
@ -2596,6 +2665,10 @@ netbios name, so if the machine's netbios name is different from its
|
||||
internet name then you may have to add its netbios name to
|
||||
/etc/hosts.
|
||||
|
||||
Note that with Samba 1.9.18p4 and above the name of the password
|
||||
server is looked up using the parameter "name resolve order=" and
|
||||
so may resolved by any method and order described in that parameter.
|
||||
|
||||
The password server much be a machine capable of using the "LM1.2X002"
|
||||
or the "LM NT 0.12" protocol, and it must be in user level security
|
||||
mode.
|
||||
@ -3869,6 +3942,7 @@ transferring data from clients.
|
||||
|
||||
.B Example:
|
||||
write raw = no
|
||||
|
||||
.SH NOTE ABOUT USERNAME/PASSWORD VALIDATION
|
||||
There are a number of ways in which a user can connect to a
|
||||
service. The server follows the following steps in determining if it
|
||||
|
@ -1,4 +1,4 @@
|
||||
.TH SMBCLIENT 1 "08 Jan 1998" "smbclient 1.9.18"
|
||||
.TH SMBCLIENT 1 "19 Feb 1998" "smbclient 1.9.18p3"
|
||||
.SH NAME
|
||||
smbclient \- ftp-like Lan Manager client program
|
||||
.SH SYNOPSIS
|
||||
@ -20,6 +20,9 @@ smbclient \- ftp-like Lan Manager client program
|
||||
.B \-I
|
||||
.I IP number
|
||||
] [
|
||||
.B \-R
|
||||
.I name resolve order
|
||||
] [
|
||||
.B \-N
|
||||
] [
|
||||
.B \-P
|
||||
@ -87,6 +90,11 @@ on the Lan Manager server "lanman", you would use the servicename
|
||||
Note that the server name required is NOT necessarily the host name of the
|
||||
server! The name required is a Lan Manager server name, which may or may not
|
||||
be the same as the hostname of the machine running the server.
|
||||
|
||||
With Samba 1.9.18p4 the server name is looked up according to the
|
||||
"name resolve order=" parameter in the smb.conf file, allowing an
|
||||
administrator to change the order and methods by which server names
|
||||
are looked up.
|
||||
.RE
|
||||
|
||||
.B password
|
||||
@ -114,6 +122,15 @@ rejected by these servers.
|
||||
Be cautious about including passwords in scripts.
|
||||
.RE
|
||||
|
||||
.B \-R name resolve order
|
||||
|
||||
.RS 3
|
||||
This parameter will override the default name resolution order of the
|
||||
server listed in the "name resolve order" parameter in smb.conf. This
|
||||
is useful to force name resolution to take place by a particular method.
|
||||
This command line parameter only exists in Samba 1.9.18p4 and above.
|
||||
.RE
|
||||
|
||||
.B \-A
|
||||
|
||||
.RS 3
|
||||
|
@ -3500,6 +3500,7 @@ static void usage(char *pname)
|
||||
DEBUG(0,("\t-m max protocol set the max protocol level\n"));
|
||||
DEBUG(0,("\t-L host get a list of shares available on a host\n"));
|
||||
DEBUG(0,("\t-I dest IP use this IP to connect to\n"));
|
||||
DEBUG(0,("\t-R name resolve order use these name resolution services only\n"));
|
||||
DEBUG(0,("\t-E write messages to stderr instead of stdout\n"));
|
||||
DEBUG(0,("\t-U username set the network username\n"));
|
||||
DEBUG(0,("\t-W workgroup set the workgroup name\n"));
|
||||
@ -3528,6 +3529,7 @@ static void usage(char *pname)
|
||||
extern char tar_type;
|
||||
static pstring servicesf = CONFIGFILE;
|
||||
pstring term_code;
|
||||
pstring new_name_resolve_order;
|
||||
char *p;
|
||||
|
||||
#ifdef KANJI
|
||||
@ -3539,6 +3541,8 @@ static void usage(char *pname)
|
||||
*query_host = 0;
|
||||
*base_directory = 0;
|
||||
|
||||
*new_name_resolve_order = 0;
|
||||
|
||||
DEBUGLEVEL = 2;
|
||||
|
||||
setup_logging(pname,True);
|
||||
@ -3624,7 +3628,7 @@ static void usage(char *pname)
|
||||
}
|
||||
|
||||
while ((opt =
|
||||
getopt(argc, argv,"s:B:O:M:S:i:Nn:d:Pp:l:hI:EB:U:L:t:m:W:T:D:c:")) != EOF)
|
||||
getopt(argc, argv,"s:B:O:R:M:S:i:Nn:d:Pp:l:hI:EB:U:L:t:m:W:T:D:c:")) != EOF)
|
||||
switch (opt)
|
||||
{
|
||||
case 'm':
|
||||
@ -3633,6 +3637,9 @@ static void usage(char *pname)
|
||||
case 'O':
|
||||
strcpy(user_socket_options,optarg);
|
||||
break;
|
||||
case 'R':
|
||||
pstrcpy(new_name_resolve_order, optarg);
|
||||
break;
|
||||
case 'S':
|
||||
strcpy(desthost,optarg);
|
||||
strupper(desthost);
|
||||
@ -3760,6 +3767,9 @@ static void usage(char *pname)
|
||||
get_myname((*myname)?NULL:myname,NULL);
|
||||
strupper(myname);
|
||||
|
||||
if(*new_name_resolve_order)
|
||||
lp_set_name_resolve_order(new_name_resolve_order);
|
||||
|
||||
if (tar_type) {
|
||||
recurse=True;
|
||||
|
||||
|
@ -29,8 +29,6 @@
|
||||
#define REGISTER 0
|
||||
#endif
|
||||
|
||||
#define USENMB
|
||||
|
||||
pstring service="";
|
||||
pstring desthost="";
|
||||
extern pstring myname;
|
||||
@ -863,7 +861,6 @@ BOOL cli_open_sockets(int port )
|
||||
char *host;
|
||||
pstring service2;
|
||||
extern int Client;
|
||||
BOOL failed = True;
|
||||
|
||||
if (port == 0) port=last_port;
|
||||
last_port=port;
|
||||
@ -894,37 +891,10 @@ BOOL cli_open_sockets(int port )
|
||||
|
||||
if (!have_ip)
|
||||
{
|
||||
struct hostent *hp;
|
||||
|
||||
if ((hp = Get_Hostbyname(host)))
|
||||
if(!resolve_name( host, &dest_ip))
|
||||
{
|
||||
putip((char *)&dest_ip,(char *)hp->h_addr);
|
||||
failed = False;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef USENMB
|
||||
/* Try and resolve the name with the netbios server */
|
||||
int bcast, count;
|
||||
struct in_addr *ip_list;
|
||||
|
||||
if ((bcast = open_socket_in(SOCK_DGRAM, 0, 3,
|
||||
interpret_addr(lp_socket_address()))) != -1) {
|
||||
set_socket_options(bcast, "SO_BROADCAST");
|
||||
|
||||
if ((ip_list = name_query(bcast, host, name_type, True, True, *iface_bcast(dest_ip),
|
||||
&count,0)) != NULL) {
|
||||
dest_ip = ip_list[0];
|
||||
free(ip_list);
|
||||
failed = False;
|
||||
}
|
||||
close (bcast);
|
||||
}
|
||||
#endif
|
||||
if (failed) {
|
||||
DEBUG(0,("Get_Hostbyname: Unknown host %s.\n",host));
|
||||
DEBUG(0,("cli_open_sockets: Unknown host %s.\n",host));
|
||||
return False;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -868,6 +868,7 @@ char *lp_auto_services(void);
|
||||
char *lp_passwd_program(void);
|
||||
char *lp_passwd_chat(void);
|
||||
char *lp_passwordserver(void);
|
||||
char *lp_name_resolve_order(void);
|
||||
char *lp_workgroup(void);
|
||||
char *lp_username_map(void);
|
||||
char *lp_character_set(void);
|
||||
@ -1007,6 +1008,7 @@ BOOL lp_fake_oplocks(int );
|
||||
BOOL lp_recursive_veto_delete(int );
|
||||
BOOL lp_dos_filetimes(int );
|
||||
BOOL lp_dos_filetime_resolution(int );
|
||||
BOOL lp_fake_dir_create_times(int );
|
||||
int lp_create_mode(int );
|
||||
int lp_force_create_mode(int );
|
||||
int lp_dir_mode(int );
|
||||
@ -1038,6 +1040,7 @@ void lp_copy_service(int snum, char *new_name);
|
||||
int lp_default_server_announce(void);
|
||||
int lp_major_announce_version(void);
|
||||
int lp_minor_announce_version(void);
|
||||
void lp_set_name_resolve_order(char *new_order);
|
||||
|
||||
/*The following definitions come from locking.c */
|
||||
|
||||
@ -1126,6 +1129,10 @@ BOOL name_status(int fd,char *name,int name_type,BOOL recurse,
|
||||
struct in_addr *name_query(int fd,char *name,int name_type,
|
||||
BOOL bcast,BOOL recurse,
|
||||
struct in_addr to_ip, int *count, void (*fn)());
|
||||
FILE *startlmhosts(char *fname);
|
||||
BOOL getlmhostsent( FILE *fp, char *name, int *name_type, struct in_addr *ipaddr);
|
||||
void endlmhosts(FILE *fp);
|
||||
BOOL resolve_name(char *name, struct in_addr *return_ip);
|
||||
|
||||
/*The following definitions come from nmbd.c */
|
||||
|
||||
@ -1725,7 +1732,7 @@ time_t make_unix_date2(void *date_ptr);
|
||||
time_t make_unix_date3(void *date_ptr);
|
||||
char *http_timestring(time_t t);
|
||||
char *timestring(void );
|
||||
time_t get_create_time(struct stat *st);
|
||||
time_t get_create_time(struct stat *st,BOOL fake_dirs);
|
||||
|
||||
/*The following definitions come from trans2.c */
|
||||
|
||||
|
@ -500,10 +500,15 @@ char *timestring(void )
|
||||
structure.
|
||||
****************************************************************************/
|
||||
|
||||
time_t get_create_time(struct stat *st)
|
||||
time_t get_create_time(struct stat *st,BOOL fake_dirs)
|
||||
{
|
||||
time_t ret = MIN(st->st_ctime, st->st_mtime);
|
||||
time_t ret1 = MIN(ret, st->st_atime);
|
||||
time_t ret, ret1;
|
||||
|
||||
if(S_ISDIR(st->st_mode) && fake_dirs)
|
||||
return (time_t)315493200L; /* 1/1/1980 */
|
||||
|
||||
ret = MIN(st->st_ctime, st->st_mtime);
|
||||
ret1 = MIN(ret, st->st_atime);
|
||||
|
||||
if(ret1 != (time_t)0)
|
||||
return ret1;
|
||||
|
@ -4047,11 +4047,20 @@ struct hostent *Get_Hostbyname(char *name)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This next test is redundent and causes some systems (with
|
||||
* broken isalnum() calls) problems.
|
||||
* JRA.
|
||||
*/
|
||||
|
||||
#if 0
|
||||
if (!isalnum(*name2))
|
||||
{
|
||||
free(name2);
|
||||
return(NULL);
|
||||
}
|
||||
#endif /* 0 */
|
||||
|
||||
ret = sys_gethostbyname(name2);
|
||||
if (ret != NULL)
|
||||
|
@ -1343,13 +1343,9 @@ BOOL cli_connect(struct cli_state *cli, char *host, struct in_addr *ip)
|
||||
fstrcpy(cli->desthost, host);
|
||||
|
||||
if (!ip) {
|
||||
struct hostent *hp;
|
||||
|
||||
if ((hp = Get_Hostbyname(cli->desthost)) == 0) {
|
||||
return False;
|
||||
}
|
||||
|
||||
putip((char *)&dest_ip,(char *)hp->h_addr);
|
||||
if(!resolve_name( cli->desthost, &dest_ip)) {
|
||||
return False;
|
||||
}
|
||||
} else {
|
||||
dest_ip = *ip;
|
||||
}
|
||||
|
@ -25,6 +25,8 @@
|
||||
extern pstring scope;
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
/* nmbd.c sets this to True. */
|
||||
BOOL global_in_nmbd = False;
|
||||
|
||||
/****************************************************************************
|
||||
interpret a node status response
|
||||
@ -303,3 +305,264 @@ struct in_addr *name_query(int fd,char *name,int name_type,
|
||||
|
||||
return ip_list;
|
||||
}
|
||||
|
||||
/********************************************************
|
||||
Start parsing the lmhosts file.
|
||||
*********************************************************/
|
||||
|
||||
FILE *startlmhosts(char *fname)
|
||||
{
|
||||
FILE *fp = fopen(fname,"r");
|
||||
if (!fp) {
|
||||
DEBUG(2,("startlmhosts: Can't open lmhosts file %s. Error was %s\n",
|
||||
fname, strerror(errno)));
|
||||
return NULL;
|
||||
}
|
||||
return fp;
|
||||
}
|
||||
|
||||
/********************************************************
|
||||
Parse the next line in the lmhosts file.
|
||||
*********************************************************/
|
||||
|
||||
BOOL getlmhostsent( FILE *fp, char *name, int *name_type, struct in_addr *ipaddr)
|
||||
{
|
||||
pstring line;
|
||||
|
||||
while(!feof(fp) && !ferror(fp)) {
|
||||
pstring ip,flags,extra;
|
||||
char *ptr;
|
||||
int count = 0;
|
||||
|
||||
*name_type = -1;
|
||||
|
||||
if (!fgets_slash(line,sizeof(pstring),fp))
|
||||
continue;
|
||||
|
||||
if (*line == '#')
|
||||
continue;
|
||||
|
||||
strcpy(ip,"");
|
||||
strcpy(name,"");
|
||||
strcpy(flags,"");
|
||||
|
||||
ptr = line;
|
||||
|
||||
if (next_token(&ptr,ip ,NULL))
|
||||
++count;
|
||||
if (next_token(&ptr,name ,NULL))
|
||||
++count;
|
||||
if (next_token(&ptr,flags,NULL))
|
||||
++count;
|
||||
if (next_token(&ptr,extra,NULL))
|
||||
++count;
|
||||
|
||||
if (count <= 0)
|
||||
continue;
|
||||
|
||||
if (count > 0 && count < 2)
|
||||
{
|
||||
DEBUG(0,("getlmhostsent: Ill formed hosts line [%s]\n",line));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (count >= 4)
|
||||
{
|
||||
DEBUG(0,("getlmhostsent: too many columns in lmhosts file (obsolete syntax)\n"));
|
||||
continue;
|
||||
}
|
||||
|
||||
DEBUG(4, ("getlmhostsent: lmhost entry: %s %s %s\n", ip, name, flags));
|
||||
|
||||
if (strchr(flags,'G') || strchr(flags,'S'))
|
||||
{
|
||||
DEBUG(0,("getlmhostsent: group flag in lmhosts ignored (obsolete)\n"));
|
||||
continue;
|
||||
}
|
||||
|
||||
*ipaddr = *interpret_addr2(ip);
|
||||
|
||||
/* Extra feature. If the name ends in '#XX', where XX is a hex number,
|
||||
then only add that name type. */
|
||||
if((ptr = strchr(name, '#')) != NULL)
|
||||
{
|
||||
char *endptr;
|
||||
|
||||
ptr++;
|
||||
*name_type = (int)strtol(ptr, &endptr,0);
|
||||
|
||||
if(!*ptr || (endptr == ptr))
|
||||
{
|
||||
DEBUG(0,("getlmhostsent: invalid name %s containing '#'.\n", name));
|
||||
continue;
|
||||
}
|
||||
|
||||
*(--ptr) = '\0'; /* Truncate at the '#' */
|
||||
}
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
return False;
|
||||
}
|
||||
|
||||
/********************************************************
|
||||
Finish parsing the lmhosts file.
|
||||
*********************************************************/
|
||||
|
||||
void endlmhosts(FILE *fp)
|
||||
{
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
/********************************************************
|
||||
Resolve a name into an IP address. Use this function if
|
||||
the string is either an IP address, DNS or host name
|
||||
or NetBIOS name. This uses the name switch in the
|
||||
smb.conf to determine the order of name resolution.
|
||||
*********************************************************/
|
||||
|
||||
BOOL resolve_name(char *name, struct in_addr *return_ip)
|
||||
{
|
||||
char *p;
|
||||
int i;
|
||||
BOOL pure_address = True;
|
||||
|
||||
if (strcmp(name,"0.0.0.0") == 0) {
|
||||
return_ip->s_addr = 0;
|
||||
return True;
|
||||
}
|
||||
if (strcmp(name,"255.255.255.255") == 0) {
|
||||
return_ip->s_addr = 0xFFFFFFFF;
|
||||
return True;
|
||||
}
|
||||
|
||||
for (i=0; pure_address && name[i]; i++)
|
||||
if (!(isdigit(name[i]) || name[i] == '.'))
|
||||
pure_address = False;
|
||||
|
||||
/* if it's in the form of an IP address then get the lib to interpret it */
|
||||
if (pure_address) {
|
||||
return_ip->s_addr = inet_addr(name);
|
||||
return True;
|
||||
}
|
||||
|
||||
for (p=strtok(lp_name_resolve_order(),LIST_SEP); p; p = strtok(NULL,LIST_SEP)) {
|
||||
if(strequal(p, "host") || strequal(p, "hosts")) {
|
||||
|
||||
/*
|
||||
* "host" means do a localhost, or dns lookup.
|
||||
*/
|
||||
|
||||
struct hostent *hp;
|
||||
|
||||
DEBUG(3,("resolve_name: Attempting host lookup for name %s\n"));
|
||||
|
||||
if (((hp = Get_Hostbyname(name)) != NULL) && (hp->h_addr != NULL)) {
|
||||
putip((char *)return_ip,(char *)hp->h_addr);
|
||||
return True;
|
||||
}
|
||||
|
||||
} else if(strequal( p, "lmhosts")) {
|
||||
|
||||
/*
|
||||
* "lmhosts" means parse the local lmhosts file.
|
||||
*/
|
||||
|
||||
FILE *fp;
|
||||
pstring lmhost_name;
|
||||
int name_type;
|
||||
|
||||
DEBUG(3,("resolve_name: Attempting lmhosts lookup for name %s\n"));
|
||||
|
||||
fp = startlmhosts( LMHOSTSFILE );
|
||||
if(fp) {
|
||||
while( getlmhostsent(fp, lmhost_name, &name_type, return_ip ) ) {
|
||||
if( strequal(name, lmhost_name )) {
|
||||
endlmhosts(fp);
|
||||
return True;
|
||||
}
|
||||
}
|
||||
endlmhosts(fp);
|
||||
}
|
||||
|
||||
} else if(strequal( p, "wins")) {
|
||||
|
||||
int sock;
|
||||
|
||||
/*
|
||||
* "wins" means do a unicast lookup to the WINS server.
|
||||
* Ignore if there is no WINS server specified or if the
|
||||
* WINS server is one of our interfaces (if we're being
|
||||
* called from within nmbd - we can't do this call as we
|
||||
* would then block).
|
||||
*/
|
||||
|
||||
DEBUG(3,("resolve_name: Attempting wins lookup for name %s\n"));
|
||||
|
||||
if(*lp_wins_server()) {
|
||||
struct in_addr wins_ip = *interpret_addr2(lp_wins_server());
|
||||
BOOL wins_ismyip = ismyip(wins_ip);
|
||||
|
||||
if((wins_ismyip && !global_in_nmbd) || !wins_ismyip) {
|
||||
sock = open_socket_in( SOCK_DGRAM, 0, 3,
|
||||
interpret_addr(lp_socket_address()) );
|
||||
|
||||
if (sock != -1) {
|
||||
struct in_addr *iplist = NULL;
|
||||
int count;
|
||||
iplist = name_query(sock, name, 0x20, False, True, wins_ip, &count, NULL);
|
||||
if(iplist != NULL) {
|
||||
*return_ip = iplist[0];
|
||||
free((char *)iplist);
|
||||
close(sock);
|
||||
return True;
|
||||
}
|
||||
close(sock);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
DEBUG(3,("resolve_name: WINS server resolution selected and no WINS server present.\n"));
|
||||
}
|
||||
} else if(strequal( p, "bcast")) {
|
||||
|
||||
int sock;
|
||||
|
||||
/*
|
||||
* "bcast" means do a broadcast lookup on all the local interfaces.
|
||||
*/
|
||||
|
||||
DEBUG(3,("resolve_name: Attempting broadcast lookup for name %s\n"));
|
||||
|
||||
sock = open_socket_in( SOCK_DGRAM, 0, 3,
|
||||
interpret_addr(lp_socket_address()) );
|
||||
|
||||
if (sock != -1) {
|
||||
struct in_addr *iplist = NULL;
|
||||
int count;
|
||||
int num_interfaces = iface_count();
|
||||
set_socket_options(sock,"SO_BROADCAST");
|
||||
/*
|
||||
* Lookup the name on all the interfaces, return on
|
||||
* the first successful match.
|
||||
*/
|
||||
for( i = 0; i < num_interfaces; i++) {
|
||||
struct in_addr sendto_ip = *iface_bcast(*iface_n_ip(i));
|
||||
iplist = name_query(sock, name, 0x20, True, False, sendto_ip, &count, NULL);
|
||||
if(iplist != NULL) {
|
||||
*return_ip = iplist[0];
|
||||
free((char *)iplist);
|
||||
close(sock);
|
||||
return True;
|
||||
}
|
||||
}
|
||||
close(sock);
|
||||
}
|
||||
|
||||
} else {
|
||||
DEBUG(0,("resolve_name: unknown name switch type %s\n", p));
|
||||
}
|
||||
}
|
||||
|
||||
return False;
|
||||
}
|
||||
|
@ -44,6 +44,8 @@ extern pstring myname;
|
||||
extern fstring myworkgroup;
|
||||
extern char **my_netbios_names;
|
||||
|
||||
extern BOOL global_in_nmbd;
|
||||
|
||||
/* are we running as a daemon ? */
|
||||
static BOOL is_daemon = False;
|
||||
|
||||
@ -552,6 +554,7 @@ int main(int argc,char *argv[])
|
||||
|
||||
global_nmb_port = NMB_PORT;
|
||||
*host_file = 0;
|
||||
global_in_nmbd = True;
|
||||
|
||||
StartupTime = time(NULL);
|
||||
|
||||
|
@ -33,88 +33,21 @@ Load a lmhosts file.
|
||||
****************************************************************************/
|
||||
void load_lmhosts_file(char *fname)
|
||||
{
|
||||
FILE *fp = fopen(fname,"r");
|
||||
pstring line;
|
||||
pstring name;
|
||||
int name_type;
|
||||
struct in_addr ipaddr;
|
||||
FILE *fp = startlmhosts( fname );
|
||||
|
||||
if (!fp) {
|
||||
DEBUG(2,("load_lmhosts_file: Can't open lmhosts file %s. Error was %s\n",
|
||||
fname, strerror(errno)));
|
||||
return;
|
||||
}
|
||||
|
||||
while (!feof(fp))
|
||||
while (getlmhostsent(fp, name, &name_type, &ipaddr) )
|
||||
{
|
||||
pstring ip,name,flags,extra;
|
||||
struct subnet_record *subrec = NULL;
|
||||
char *ptr;
|
||||
int count = 0;
|
||||
struct in_addr ipaddr;
|
||||
enum name_source source = LMHOSTS_NAME;
|
||||
int name_type = -1;
|
||||
|
||||
if (!fgets_slash(line,sizeof(pstring),fp))
|
||||
continue;
|
||||
|
||||
if (*line == '#')
|
||||
continue;
|
||||
|
||||
strcpy(ip,"");
|
||||
strcpy(name,"");
|
||||
strcpy(flags,"");
|
||||
|
||||
ptr = line;
|
||||
|
||||
if (next_token(&ptr,ip ,NULL))
|
||||
++count;
|
||||
if (next_token(&ptr,name ,NULL))
|
||||
++count;
|
||||
if (next_token(&ptr,flags,NULL))
|
||||
++count;
|
||||
if (next_token(&ptr,extra,NULL))
|
||||
++count;
|
||||
|
||||
if (count <= 0)
|
||||
continue;
|
||||
|
||||
if (count > 0 && count < 2)
|
||||
{
|
||||
DEBUG(0,("load_lmhosts_file: Ill formed hosts line [%s]\n",line));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (count >= 4)
|
||||
{
|
||||
DEBUG(0,("load_lmhosts_file: too many columns in lmhosts file %s (obsolete syntax)\n",
|
||||
fname));
|
||||
continue;
|
||||
}
|
||||
|
||||
DEBUG(4, ("load_lmhosts_file: lmhost entry: %s %s %s\n", ip, name, flags));
|
||||
|
||||
if (strchr(flags,'G') || strchr(flags,'S'))
|
||||
{
|
||||
DEBUG(0,("load_lmhosts_file: group flag in %s ignored (obsolete)\n",fname));
|
||||
continue;
|
||||
}
|
||||
|
||||
ipaddr = *interpret_addr2(ip);
|
||||
|
||||
/* Extra feature. If the name ends in '#XX', where XX is a hex number,
|
||||
then only add that name type. */
|
||||
if((ptr = strchr(name, '#')) != NULL)
|
||||
{
|
||||
char *endptr;
|
||||
|
||||
ptr++;
|
||||
name_type = (int)strtol(ptr, &endptr,0);
|
||||
|
||||
if(!*ptr || (endptr == ptr))
|
||||
{
|
||||
DEBUG(0,("load_lmhosts_file: invalid name %s containing '#'.\n", name));
|
||||
continue;
|
||||
}
|
||||
|
||||
*(--ptr) = '\0'; /* Truncate at the '#' */
|
||||
}
|
||||
|
||||
/* We find a relevent subnet to put this entry on, then add it. */
|
||||
/* Go through all the broadcast subnets and see if the mask matches. */
|
||||
@ -141,7 +74,7 @@ void load_lmhosts_file(char *fname)
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
endlmhosts(fp);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -143,6 +143,7 @@ typedef struct
|
||||
char *szDomainOtherSIDs;
|
||||
char *szDomainGroups;
|
||||
char *szDriverFile;
|
||||
char *szNameResolveOrder;
|
||||
int max_log_size;
|
||||
int mangled_stack;
|
||||
int max_xmit;
|
||||
@ -281,6 +282,7 @@ typedef struct
|
||||
BOOL bDeleteVetoFiles;
|
||||
BOOL bDosFiletimes;
|
||||
BOOL bDosFiletimeResolution;
|
||||
BOOL bFakeDirCreateTimes;
|
||||
char dummy[3]; /* for alignment */
|
||||
} service;
|
||||
|
||||
@ -368,6 +370,7 @@ static service sDefault =
|
||||
False, /* bDeleteVetoFiles */
|
||||
False, /* bDosFiletimes */
|
||||
False, /* bDosFiletimeResolution */
|
||||
False, /* bFakeDirCreateTimes */
|
||||
"" /* dummy */
|
||||
};
|
||||
|
||||
@ -495,6 +498,7 @@ static struct parm_struct parm_table[] =
|
||||
{"announce as", P_ENUM, P_GLOBAL, &Globals.announce_as, NULL, enum_announce_as, 0},
|
||||
{"max mux", P_INTEGER, P_GLOBAL, &Globals.max_mux, NULL, NULL, 0},
|
||||
{"max xmit", P_INTEGER, P_GLOBAL, &Globals.max_xmit, NULL, NULL, 0},
|
||||
{"name resolve order", P_STRING, P_GLOBAL, &Globals.szNameResolveOrder, NULL, NULL, 0},
|
||||
{"max packet", P_INTEGER, P_GLOBAL, &Globals.max_packet, NULL, NULL, 0},
|
||||
{"packet size", P_INTEGER, P_GLOBAL, &Globals.max_packet, NULL, NULL, 0},
|
||||
{"max ttl", P_INTEGER, P_GLOBAL, &Globals.max_ttl, NULL, NULL, 0},
|
||||
@ -642,7 +646,8 @@ static struct parm_struct parm_table[] =
|
||||
{"delete readonly", P_BOOL, P_LOCAL, &sDefault.bDeleteReadonly, NULL, NULL, FLAG_GLOBAL},
|
||||
{"dos filetimes", P_BOOL, P_LOCAL, &sDefault.bDosFiletimes, NULL, NULL, FLAG_GLOBAL},
|
||||
{"dos filetime resolution",P_BOOL,P_LOCAL,&sDefault.bDosFiletimeResolution, NULL, NULL, FLAG_GLOBAL},
|
||||
|
||||
|
||||
{"fake directory create times", P_BOOL,P_LOCAL, &sDefault.bFakeDirCreateTimes, NULL, NULL, FLAG_GLOBAL},
|
||||
{NULL, P_BOOL, P_NONE, NULL, NULL, NULL, 0}
|
||||
};
|
||||
|
||||
@ -696,6 +701,8 @@ static void init_globals(void)
|
||||
string_set(&Globals.szLogonHome, "\\\\%N\\%U");
|
||||
string_set(&Globals.szLogonPath, "\\\\%N\\%U\\profile");
|
||||
|
||||
string_set(&Globals.szNameResolveOrder, "lmhosts host wins bcast");
|
||||
|
||||
Globals.bLoadPrinters = True;
|
||||
Globals.bUseRhosts = False;
|
||||
Globals.max_packet = 65535;
|
||||
@ -906,6 +913,7 @@ FN_GLOBAL_STRING(lp_auto_services,&Globals.szAutoServices)
|
||||
FN_GLOBAL_STRING(lp_passwd_program,&Globals.szPasswdProgram)
|
||||
FN_GLOBAL_STRING(lp_passwd_chat,&Globals.szPasswdChat)
|
||||
FN_GLOBAL_STRING(lp_passwordserver,&Globals.szPasswordServer)
|
||||
FN_GLOBAL_STRING(lp_name_resolve_order,&Globals.szNameResolveOrder)
|
||||
FN_GLOBAL_STRING(lp_workgroup,&Globals.szWorkGroup)
|
||||
FN_GLOBAL_STRING(lp_username_map,&Globals.szUsernameMap)
|
||||
FN_GLOBAL_STRING(lp_character_set,&Globals.szCharacterSet)
|
||||
@ -1050,6 +1058,7 @@ FN_LOCAL_BOOL(lp_fake_oplocks,bFakeOplocks)
|
||||
FN_LOCAL_BOOL(lp_recursive_veto_delete,bDeleteVetoFiles)
|
||||
FN_LOCAL_BOOL(lp_dos_filetimes,bDosFiletimes)
|
||||
FN_LOCAL_BOOL(lp_dos_filetime_resolution,bDosFiletimeResolution)
|
||||
FN_LOCAL_BOOL(lp_fake_dir_create_times,bFakeDirCreateTimes)
|
||||
|
||||
FN_LOCAL_INTEGER(lp_create_mode,iCreate_mask)
|
||||
FN_LOCAL_INTEGER(lp_force_create_mode,iCreate_force_mode)
|
||||
@ -2478,3 +2487,11 @@ int lp_minor_announce_version(void)
|
||||
return minor_version;
|
||||
}
|
||||
|
||||
/***********************************************************
|
||||
Set the global name resolution order (used in smbclient).
|
||||
************************************************************/
|
||||
|
||||
void lp_set_name_resolve_order(char *new_order)
|
||||
{
|
||||
Globals.szNameResolveOrder = new_order;
|
||||
}
|
||||
|
@ -1689,11 +1689,10 @@ struct cli_state *server_cryptkey(void)
|
||||
standard_sub_basic(desthost);
|
||||
strupper(desthost);
|
||||
|
||||
dest_ip = *interpret_addr2(desthost);
|
||||
if (zero_ip(dest_ip)) {
|
||||
DEBUG(1,("Can't resolve address for %s\n",p));
|
||||
continue;
|
||||
}
|
||||
if(!resolve_name( desthost, &dest_ip)) {
|
||||
DEBUG(1,("server_cryptkey: Can't resolve address for %s\n",p));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ismyip(dest_ip)) {
|
||||
DEBUG(1,("Password server loop - disabling password server %s\n",p));
|
||||
|
@ -3965,7 +3965,7 @@ int reply_getattrE(char *inbuf,char *outbuf)
|
||||
/* Convert the times into dos times. Set create
|
||||
date to be last modify date as UNIX doesn't save
|
||||
this */
|
||||
put_dos_date2(outbuf,smb_vwv0,get_create_time(&sbuf));
|
||||
put_dos_date2(outbuf,smb_vwv0,get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(cnum))));
|
||||
put_dos_date2(outbuf,smb_vwv2,sbuf.st_atime);
|
||||
put_dos_date2(outbuf,smb_vwv4,sbuf.st_mtime);
|
||||
if (mode & aDIR)
|
||||
|
@ -385,7 +385,7 @@ static int get_lanman2_dir_entry(int cnum,char *path_mask,int dirtype,int info_l
|
||||
size = sbuf.st_size;
|
||||
mdate = sbuf.st_mtime;
|
||||
adate = sbuf.st_atime;
|
||||
cdate = get_create_time(&sbuf);
|
||||
cdate = get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(cnum)));
|
||||
if(mode & aDIR)
|
||||
size = 0;
|
||||
|
||||
@ -1204,7 +1204,7 @@ static int call_trans2qfilepathinfo(char *inbuf, char *outbuf, int length,
|
||||
case SMB_INFO_STANDARD:
|
||||
case SMB_INFO_QUERY_EA_SIZE:
|
||||
data_size = (info_level==1?22:26);
|
||||
put_dos_date2(pdata,l1_fdateCreation,get_create_time(&sbuf));
|
||||
put_dos_date2(pdata,l1_fdateCreation,get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(cnum))));
|
||||
put_dos_date2(pdata,l1_fdateLastAccess,sbuf.st_atime);
|
||||
put_dos_date2(pdata,l1_fdateLastWrite,sbuf.st_mtime); /* write time */
|
||||
SIVAL(pdata,l1_cbFile,size);
|
||||
@ -1215,7 +1215,7 @@ static int call_trans2qfilepathinfo(char *inbuf, char *outbuf, int length,
|
||||
|
||||
case SMB_INFO_QUERY_EAS_FROM_LIST:
|
||||
data_size = 24;
|
||||
put_dos_date2(pdata,0,get_create_time(&sbuf));
|
||||
put_dos_date2(pdata,0,get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(cnum))));
|
||||
put_dos_date2(pdata,4,sbuf.st_atime);
|
||||
put_dos_date2(pdata,8,sbuf.st_mtime);
|
||||
SIVAL(pdata,12,size);
|
||||
@ -1233,7 +1233,7 @@ static int call_trans2qfilepathinfo(char *inbuf, char *outbuf, int length,
|
||||
|
||||
case SMB_QUERY_FILE_BASIC_INFO:
|
||||
data_size = 36; /* w95 returns 40 bytes not 36 - why ?. */
|
||||
put_long_date(pdata,get_create_time(&sbuf));
|
||||
put_long_date(pdata,get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(cnum))));
|
||||
put_long_date(pdata+8,sbuf.st_atime);
|
||||
put_long_date(pdata+16,sbuf.st_mtime); /* write time */
|
||||
put_long_date(pdata+24,sbuf.st_mtime); /* change time */
|
||||
@ -1241,7 +1241,7 @@ static int call_trans2qfilepathinfo(char *inbuf, char *outbuf, int length,
|
||||
|
||||
DEBUG(5,("SMB_QFBI - "));
|
||||
{
|
||||
time_t create_time = get_create_time(&sbuf);
|
||||
time_t create_time = get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(cnum)));
|
||||
DEBUG(5,("create: %s ", ctime(&create_time)));
|
||||
}
|
||||
DEBUG(5,("access: %s ", ctime(&sbuf.st_atime)));
|
||||
@ -1297,7 +1297,7 @@ static int call_trans2qfilepathinfo(char *inbuf, char *outbuf, int length,
|
||||
break;
|
||||
|
||||
case SMB_QUERY_FILE_ALL_INFO:
|
||||
put_long_date(pdata,get_create_time(&sbuf));
|
||||
put_long_date(pdata,get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(cnum))));
|
||||
put_long_date(pdata+8,sbuf.st_atime);
|
||||
put_long_date(pdata+16,sbuf.st_mtime); /* write time */
|
||||
put_long_date(pdata+24,sbuf.st_mtime); /* change time */
|
||||
|
Loading…
x
Reference in New Issue
Block a user