summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>1996-08-17 11:37:44 +0000
committerAndrew Tridgell <tridge@samba.org>1996-08-17 11:37:44 +0000
commit28177ca73bdbe3f8fb17a608db3df1a39e0e37a4 (patch)
treed921a3eecc5d2a521a8a79c2a7f3b62a53d51ef0
parent6afac1c3a6fe9530008b91867ff3d364ea415a43 (diff)
downloadsamba-28177ca73bdbe3f8fb17a608db3df1a39e0e37a4.tar.gz
samba-28177ca73bdbe3f8fb17a608db3df1a39e0e37a4.tar.bz2
samba-28177ca73bdbe3f8fb17a608db3df1a39e0e37a4.zip
- added support for Amiga-unix (based on BSD I think)
- changed the order of PROGS and SPROGS in Makefile (SPROGS first) - another 64 bit cleanup (for INADDR_NONE) - added paranoia code in DirCacheAdd() to detect looping - fixed important DirCache flush bug - rewrote the NetServerEnum code after I found it could return servers from multiple workgroups at once, and this could cause browsing havoc. Now a null workgroup query is equivalent to a query for the servers primary workgroup - got rid of my_workgroup() - got rid of "workgroup = *" comment in Makefile. We no longer support a workgroup of *, users must set the workgroup explicitly - the wins.dat file was being stored in a different format to what it was being loaded in - this could cause havoc. fixed. - uppercase our netbios name and the workgroup name at startup - if accept fails in main loop when running as a daemon then continue, don't just exit! - don't use ./ on smbclient in smbtar - better code to detect if a process exists (This used to be commit ec3d53963064b50ff33e8eff47812aac82f164ba)
-rw-r--r--source3/include/proto.h1
-rw-r--r--source3/lib/access.c2
-rw-r--r--source3/lib/util.c7
-rw-r--r--source3/namedbname.c55
-rw-r--r--source3/nameserv.c2
-rw-r--r--source3/nmbd/nmbd.c31
-rw-r--r--source3/param/loadparm.c13
-rw-r--r--source3/script/smbtar4
-rw-r--r--source3/smbd/dir.c9
-rw-r--r--source3/smbd/ipc.c145
-rw-r--r--source3/smbd/reply.c2
-rw-r--r--source3/smbd/server.c2
12 files changed, 88 insertions, 185 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index d3e9f42ae8..c1697dc641 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -249,7 +249,6 @@ BOOL lp_load(char *pszFname,BOOL global_only);
int lp_numservices(void);
void lp_dump(void);
int lp_servicenumber(char *pszServiceName);
-char *my_workgroup(void);
char *volume_label(int snum);
/*The following definitions come from locking.c */
diff --git a/source3/lib/access.c b/source3/lib/access.c
index 079253cdbd..8f57c37c26 100644
--- a/source3/lib/access.c
+++ b/source3/lib/access.c
@@ -15,7 +15,7 @@ should be sent to samba-bugs@samba.anu.edu.au
extern int DEBUGLEVEL;
#ifndef INADDR_NONE
-#define INADDR_NONE ((unsigned long)~0)
+#define INADDR_NONE ((uint32)~0)
#endif
diff --git a/source3/lib/util.c b/source3/lib/util.c
index aeaac29ae1..5ef1d21a7a 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -3089,11 +3089,8 @@ BOOL process_exists(int pid)
}
}
- /* a best guess for non root access */
- if (geteuid() != 0) return(True);
-
- /* otherwise use kill */
- return(pid == getpid() || kill(pid,0) == 0);
+ /* CGH 8/16/96 - added ESRCH test */
+ return(pid == getpid() || kill(pid,0) == 0 || errno != ESRCH);
#endif
}
diff --git a/source3/namedbname.c b/source3/namedbname.c
index 42ad9ad009..214926cfc9 100644
--- a/source3/namedbname.c
+++ b/source3/namedbname.c
@@ -230,17 +230,14 @@ void dump_names(void)
{
if (f && ip_equal(d->bcast_ip, ipgrp) && n->source == REGISTER)
{
- fstring data;
-
- /* XXXX i have little imagination as to how to output nb_flags as
- anything other than as a hexadecimal number :-) */
-
- sprintf(data, "%s#%02x %s %2x %ld",
- n->name.name,n->name.name_type, /* XXXX ignore scope for now */
- inet_ntoa(n->ip),
- n->nb_flags,
- n->death_time);
- fprintf(f, "%s\n", data);
+ /* XXXX i have little imagination as to how to output nb_flags as
+ anything other than as a hexadecimal number :-) */
+
+ fprintf(f, "%s#%02x %s %2x %ld\n",
+ n->name.name,n->name.name_type, /* XXXX ignore scope for now */
+ inet_ntoa(n->ip),
+ n->nb_flags,
+ n->death_time);
}
DEBUG(3,("%15s ", inet_ntoa(d->bcast_ip)));
@@ -294,12 +291,12 @@ void load_netbios_names(void)
int type = 0;
int nb_flags;
time_t ttd;
- struct in_addr ipaddr;
+ struct in_addr ipaddr;
- enum name_source source;
+ enum name_source source;
char *ptr;
- int count = 0;
+ int count = 0;
char *p;
@@ -307,24 +304,24 @@ void load_netbios_names(void)
if (*line == '#') continue;
- ptr = line;
-
- if (next_token(&ptr,name_str ,NULL)) ++count;
- if (next_token(&ptr,ip_str ,NULL)) ++count;
- if (next_token(&ptr,ttd_str ,NULL)) ++count;
- if (next_token(&ptr,nb_flags_str,NULL)) ++count;
-
- if (count <= 0) continue;
-
- if (count != 4) {
- DEBUG(0,("Ill formed wins line"));
- DEBUG(0,("[%s]: name#type ip nb_flags abs_time\n",line));
- continue;
- }
+ ptr = line;
+ if (next_token(&ptr,name_str ,NULL)) ++count;
+ if (next_token(&ptr,ip_str ,NULL)) ++count;
+ if (next_token(&ptr,nb_flags_str,NULL)) ++count;
+ if (next_token(&ptr,ttd_str ,NULL)) ++count;
+
+ if (count <= 0) continue;
+
+ if (count != 4) {
+ DEBUG(0,("Ill formed wins line"));
+ DEBUG(0,("[%s]: name#type ip nb_flags abs_time\n",line));
+ continue;
+ }
+
/* netbios name. # divides the name from the type (hex): netbios#xx */
strcpy(name,name_str);
-
+
p = strchr(name,'#');
if (p) {
diff --git a/source3/nameserv.c b/source3/nameserv.c
index 07b94ced5f..0297fee331 100644
--- a/source3/nameserv.c
+++ b/source3/nameserv.c
@@ -198,7 +198,7 @@ void add_my_names(void)
if (lp_domain_logons()) {
/* 0x1c is used to find logon servers for a domain */
- add_my_name_entry(d, my_workgroup(),0x1c,nb_type|NB_ACTIVE|NB_GROUP);
+ add_my_name_entry(d, lp_workgroup(),0x1c,nb_type|NB_ACTIVE|NB_GROUP);
}
}
if (lp_domain_master() && (d = find_subnet(ipgrp)))
diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c
index 1ee11edbcf..a4b303923d 100644
--- a/source3/nmbd/nmbd.c
+++ b/source3/nmbd/nmbd.c
@@ -376,6 +376,7 @@ static BOOL init_structs()
strcpy(myname,myhostname);
p = strchr(myname,'.');
if (p) *p = 0;
+ strupper(myname);
}
return True;
@@ -388,19 +389,14 @@ static void usage(char *pname)
{
DEBUG(0,("Incorrect program usage - is the command line correct?\n"));
- printf("Usage: %s [-n name] [-B bcast address] [-D] [-p port] [-d debuglevel] [-l log basename]\n",pname);
+ printf("Usage: %s [-n name] [-D] [-p port] [-d debuglevel] [-l log basename]\n",pname);
printf("Version %s\n",VERSION);
printf("\t-D become a daemon\n");
printf("\t-p port listen on the specified port\n");
printf("\t-d debuglevel set the debuglevel\n");
printf("\t-l log basename. Basename for log/debug files\n");
printf("\t-n netbiosname. the netbios name to advertise for this host\n");
- printf("\t-B broadcast address the address to use for broadcasts\n");
- printf("\t-N netmask the netmask to use for subnet determination\n");
printf("\t-H hosts file load a netbios hosts file\n");
- printf("\t-G group name add a group name to be part of\n");
- printf("\t-I ip-address override the IP address\n");
- printf("\t-C comment sets the machine comment that appears in browse lists\n");
printf("\n");
}
@@ -416,7 +412,6 @@ static void usage(char *pname)
extern char *optarg;
fstring group;
- *group = 0;
*host_file = 0;
StartupTime = time(NULL);
@@ -451,26 +446,19 @@ static void usage(char *pname)
case 's':
strcpy(servicesf,optarg);
break;
+ case 'N':
+ case 'B':
+ case 'I':
case 'C':
- strcpy(ServerComment,optarg);
- break;
case 'G':
- strcpy(group,optarg);
+ DEBUG(0,("Obsolete option '%c' used\n",opt));
break;
case 'H':
strcpy(host_file,optarg);
break;
- case 'I':
- iface_set_default(optarg,NULL,NULL);
- break;
- case 'B':
- iface_set_default(NULL,optarg,NULL);
- break;
- case 'N':
- iface_set_default(NULL,NULL,optarg);
- break;
case 'n':
strcpy(myname,optarg);
+ strupper(myname);
break;
case 'l':
sprintf(debugf,"%s.nmb",optarg);
@@ -540,6 +528,11 @@ static void usage(char *pname)
string_sub(ServerComment,"%h",myhostname);
add_my_names();
+
+ if (strequal(lp_workgroup(),"*")) {
+ DEBUG(0,("ERROR: a workgroup name of * is no longer supported\n"));
+ }
+
add_my_subnets(lp_workgroup());
DEBUG(3,("Checked names\n"));
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index d0df198a67..953613fd74 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -1920,19 +1920,6 @@ int lp_servicenumber(char *pszServiceName)
return (iService);
}
-
-
-
-/*******************************************************************
- get a workgroup - but map to standalone if '*'
- ******************************************************************/
-char *my_workgroup(void)
-{
- char *res = lp_workgroup();
- if (*res == '*') return("STANDALONE");
- return(res);
-}
-
/*******************************************************************
a useful volume label function
******************************************************************/
diff --git a/source3/script/smbtar b/source3/script/smbtar
index 156375ce9c..a947476dc6 100644
--- a/source3/script/smbtar
+++ b/source3/script/smbtar
@@ -11,8 +11,8 @@ case $0 in
# when called by absolute path, assume smbclient is in the same directory
/*)
SMBCLIENT="`dirname $0`/smbclient";;
- *) # edit this to show where your smbclient is
- SMBCLIENT="./smbclient";;
+ *) # you may need to edit this to show where your smbclient is
+ SMBCLIENT="smbclient";;
esac
# These are the default values. You could fill them in if you know what
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index 55a5983468..42bd54c270 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -631,6 +631,7 @@ add an entry to the directory cache
********************************************************************/
void DirCacheAdd(char *path,char *name,char *dname,int snum)
{
+ int count;
struct dir_cache *entry = (struct dir_cache *)malloc(sizeof(*entry));
if (!entry) return;
entry->path = strdup(path);
@@ -647,7 +648,12 @@ void DirCacheAdd(char *path,char *name,char *dname,int snum)
DEBUG(4,("Added dir cache entry %s %s -> %s\n",path,name,dname));
if (dir_cache_size == DIRCACHESIZE) {
- for (entry=dir_cache; entry->next; entry=entry->next) ;
+ for (entry=dir_cache, count=1;
+ entry->next && count < dir_cache_size;
+ entry=entry->next, count++) ;
+ if (entry->next || count != dir_cache_size) {
+ DEBUG(0,("DirCache bug - please report\n"));
+ }
free(entry->path);
free(entry->name);
free(entry->dname);
@@ -695,6 +701,7 @@ void DirCacheFlush(int snum)
if (entry->next) entry->next->prev = entry->prev;
if (dir_cache == entry) dir_cache = entry->next;
free(entry);
+ dir_cache_size--;
} else {
next = entry->next;
}
diff --git a/source3/smbd/ipc.c b/source3/smbd/ipc.c
index 39b8f3f089..78a9807769 100644
--- a/source3/smbd/ipc.c
+++ b/source3/smbd/ipc.c
@@ -748,78 +748,22 @@ static BOOL check_server_info(int uLevel, char* id)
return True;
}
-/* used for server information: client, nameserv and ipc */
struct srv_info_struct
{
fstring name;
uint32 type;
fstring comment;
- fstring domain; /* used ONLY in ipc.c NOT namework.c */
- BOOL server_added; /* used ONLY in ipc.c NOT namework.c */
+ fstring domain;
+ BOOL server_added;
};
-/*******************************************************************
- filter out unwanted server info
- ******************************************************************/
-static BOOL filter_server_info(struct srv_info_struct *server,
- BOOL domains,
- char *domain, uint32 request)
-{
- if (*domain == 0)
- {
- if (strequal(lp_workgroup(), server->domain)) {
- return True;
- }
- else if (domains)
- {
- DEBUG(4,("primary domain:reject %8x %s %s\n",request,server->name,server->domain));
- return False;
- }
- else if ((request & SV_TYPE_DOMAIN_ENUM) &&
- (server->type & SV_TYPE_DOMAIN_ENUM))
- {
- DEBUG(4,("rej:DOM %8x: %s %s\n",server->type,server->name,server->domain));
- return False;
- }
-
- return True;
- }
- else
- {
- if (strequal(domain, server->domain))
- {
- /*
- if (request == SV_TYPE_LOCAL_LIST_ONLY &&
- !(server->type & SV_TYPE_LOCAL_LIST_ONLY))
- {
- DEBUG(4,("rej:LOC %8x: ok %s %s\n",request,server->name,server->domain));
- return False;
- }
- */
- if ((request == (SV_TYPE_LOCAL_LIST_ONLY|SV_TYPE_DOMAIN_ENUM)) &&
- !(server->type&SV_TYPE_DOMAIN_ENUM))
- {
- DEBUG(4,("rej:LOCDOM %8x: ok %s %s\n",request,server->name,server->domain));
- return False;
- }
-
- return True;
- }
- else if (!domains)
- {
- DEBUG(4,("domain:%s %s %s\n",domain,server->name,server->domain));
- return False;
- }
- return True;
- }
-}
/*******************************************************************
get server info lists from the files saved by nmbd. Return the
number of entries
******************************************************************/
static int get_server_info(uint32 servertype,
- struct srv_info_struct **servers, BOOL domains,
+ struct srv_info_struct **servers,
char *domain)
{
FILE *f;
@@ -843,7 +787,7 @@ static int get_server_info(uint32 servertype,
/* request for everything is code for request all servers */
if (servertype == SV_TYPE_ALL) servertype &= ~SV_TYPE_DOMAIN_ENUM;
- DEBUG(4,("Servertype search: %8x domains:%s\n",servertype,BOOLSTR(domains)));
+ DEBUG(4,("Servertype search: %8x\n",servertype));
while (!feof(f))
{
@@ -870,7 +814,7 @@ static int get_server_info(uint32 servertype,
if (!next_token(&ptr,s->comment, NULL)) continue;
if (!next_token(&ptr,s->domain , NULL)) {
/* this allows us to cope with an old nmbd */
- strcpy(s->domain,my_workgroup());
+ strcpy(s->domain,lp_workgroup());
}
if (sscanf(stype,"%X",&s->type) != 1) {
@@ -884,20 +828,16 @@ static int get_server_info(uint32 servertype,
ok = False;
}
- if ((servertype == ~SV_TYPE_DOMAIN_ENUM) &&
+ if ((servertype & SV_TYPE_DOMAIN_ENUM) !=
(s->type & SV_TYPE_DOMAIN_ENUM))
{
- DEBUG(4,("s:all x dom "));
+ DEBUG(4,("s: dom mismatch "));
ok = False;
}
- if (domains && !(domain && *domain && strequal(domain, s->domain)))
+ if (!strequal(domain, s->domain) && !(servertype & SV_TYPE_DOMAIN_ENUM))
{
- if (!(s->type & SV_TYPE_DOMAIN_ENUM))
- {
- DEBUG(4,("r:dom enum "));
- ok = False;
- }
+ ok = False;
}
if (ok)
@@ -905,7 +845,6 @@ static int get_server_info(uint32 servertype,
DEBUG(4,("**SV** %20s %8x %25s %15s\n",
s->name, s->type, s->comment, s->domain));
- s->type |= SV_TYPE_LOCAL_LIST_ONLY;
s->server_added = True;
count++;
}
@@ -1026,16 +965,13 @@ static BOOL api_RNetServerEnum(int cnum, int uid, char *param, char *data,
int counted=0,total=0;
int i;
fstring domain;
- BOOL domains;
BOOL domain_request;
BOOL local_request = servertype & SV_TYPE_LOCAL_LIST_ONLY;
- /*if (servertype == SV_TYPE_ALL) servertype &= ~(SV_TYPE_DOMAIN_ENUM|SV_TYPE_LOCAL_LIST_ONLY);*/
if (servertype == SV_TYPE_ALL) servertype &= ~SV_TYPE_DOMAIN_ENUM;
- domain_request = servertype & SV_TYPE_DOMAIN_ENUM;
+ domain_request = ((servertype & SV_TYPE_DOMAIN_ENUM) != 0);
- domain[0] = 0;
p += 8;
if (!prefix_ok(str1,"WrLehD")) return False;
@@ -1045,20 +981,14 @@ static BOOL api_RNetServerEnum(int cnum, int uid, char *param, char *data,
DEBUG(4, ("domains_req:%s ", BOOLSTR(domain_request)));
DEBUG(4, ("local_only:%s\n", BOOLSTR(local_request)));
- if (strcmp(str1, "WrLehDO") == 0)
- {
- domains = False;
- }
- else if (strcmp(str1, "WrLehDz") == 0)
- {
- domains = True;
+ if (strcmp(str1, "WrLehDz") == 0) {
StrnCpy(domain, p, sizeof(fstring)-1);
+ } else {
+ StrnCpy(domain, lp_workgroup(), sizeof(fstring)-1);
}
if (lp_browse_list())
- {
- total = get_server_info(servertype,&servers,domains,domain);
- }
+ total = get_server_info(servertype,&servers,domain);
data_len = fixed_len = string_len = 0;
@@ -1070,21 +1000,17 @@ static BOOL api_RNetServerEnum(int cnum, int uid, char *param, char *data,
for (i=0;i<total;i++)
{
struct srv_info_struct *s = &servers[i];
- if (filter_server_info(s,domains,domain,
- local_request|domain_request))
+ if (lastname && strequal(lastname,s->name)) continue;
+ lastname = s->name;
+ data_len += fill_srv_info(s,uLevel,0,&f_len,0,&s_len,0);
+ DEBUG(4,("fill_srv_info %20s %8x %25s %15s\n",
+ s->name, s->type, s->comment, s->domain));
+
+ if (data_len <= buf_len)
{
- if (lastname && strequal(lastname,s->name)) continue;
- lastname = s->name;
- data_len += fill_srv_info(s,uLevel,0,&f_len,0,&s_len,0);
- DEBUG(4,("fill_srv_info %20s %8x %25s %15s\n",
- s->name, s->type, s->comment, s->domain));
-
- if (data_len <= buf_len)
- {
- counted++;
- fixed_len += f_len;
- string_len += s_len;
- }
+ counted++;
+ fixed_len += f_len;
+ string_len += s_len;
}
}
}
@@ -1104,15 +1030,12 @@ static BOOL api_RNetServerEnum(int cnum, int uid, char *param, char *data,
for (i = 0; i < total && count2;i++)
{
struct srv_info_struct *s = &servers[i];
- if (filter_server_info(s,domains,domain,local_request|domain_request))
- {
- if (lastname && strequal(lastname,s->name)) continue;
- lastname = s->name;
- fill_srv_info(s,uLevel,&p,&f_len,&p2,&s_len,*rdata);
- DEBUG(4,("fill_srv_info %20s %8x %25s %15s\n",
- s->name, s->type, s->comment, s->domain));
- count2--;
- }
+ if (lastname && strequal(lastname,s->name)) continue;
+ lastname = s->name;
+ fill_srv_info(s,uLevel,&p,&f_len,&p2,&s_len,*rdata);
+ DEBUG(4,("fill_srv_info %20s %8x %25s %15s\n",
+ s->name, s->type, s->comment, s->domain));
+ count2--;
}
}
@@ -1746,7 +1669,7 @@ static BOOL api_RNetServerGetInfo(int cnum,int uid, char *param,char *data,
strcpy(comment,lp_serverstring());
- if ((count=get_server_info(SV_TYPE_ALL,&servers,False,NULL))>0) {
+ if ((count=get_server_info(SV_TYPE_ALL,&servers,lp_workgroup()))>0) {
for (i=0;i<count;i++)
if (strequal(servers[i].name,local_machine)) {
servertype = servers[i].type;
@@ -1829,7 +1752,7 @@ static BOOL api_NetWkstaGetInfo(int cnum,int uid, char *param,char *data,
p += 4;
SIVAL(p,0,PTR_DIFF(p2,*rdata));
- strcpy(p2,my_workgroup());
+ strcpy(p2,lp_workgroup());
p2 = skip_string(p2,1);
p += 4;
@@ -1838,7 +1761,7 @@ static BOOL api_NetWkstaGetInfo(int cnum,int uid, char *param,char *data,
p += 2;
SIVAL(p,0,PTR_DIFF(p2,*rdata));
- strcpy(p2,my_workgroup()); /* login domain?? */
+ strcpy(p2,lp_workgroup()); /* login domain?? */
p2 = skip_string(p2,1);
p += 4;
@@ -2103,7 +2026,7 @@ static BOOL api_WWkstaUserLogon(int cnum,int uid, char *param,char *data,
strupper(mypath);
PACKS(&desc,"z",mypath); /* computer */
}
- PACKS(&desc,"z",my_workgroup());/* domain */
+ PACKS(&desc,"z",lp_workgroup());/* domain */
PACKS(&desc,"z",lp_logon_script()); /* script path */
PACKI(&desc,"D",0); /* reserved */
}
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index a97c8c9c9c..3c2e91d5f5 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -431,7 +431,7 @@ int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize)
p = smb_buf(outbuf);
strcpy(p,"Unix"); p = skip_string(p,1);
strcpy(p,"Samba "); strcat(p,VERSION); p = skip_string(p,1);
- strcpy(p,my_workgroup()); p = skip_string(p,1);
+ strcpy(p,lp_workgroup()); p = skip_string(p,1);
outsize = set_message(outbuf,3,PTR_DIFF(p,smb_buf(outbuf)),False);
/* perhaps grab OS version here?? */
}
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 170062a531..3889440975 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -1670,7 +1670,7 @@ static BOOL open_sockets(BOOL is_daemon,int port)
if (Client == -1)
{
DEBUG(0,("accept: %s",strerror(errno)));
- return False;
+ continue;
}
#ifdef NO_FORK_DEBUG