Unix SMB/Netbios implementation.
Version 1.9.
Samba utility functions
- Copyright (C) Andrew Tridgell 1992-1995
+ Copyright (C) Andrew Tridgell 1992-1997
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
pstring user_socket_options="";
pstring sesssetup_user="";
pstring myname = "";
+fstring myworkgroup = "";
int smb_read_error = 0;
connect_again:
ret = connect(res,(struct sockaddr *)&sock_out,sizeof(sock_out));
- if (ret < 0 && (errno == EINPROGRESS || errno == EALREADY) && loops--) {
+ /* Some systems return EAGAIN when they mean EINPROGRESS */
+ if (ret < 0 && (errno == EINPROGRESS || errno == EALREADY ||
+ errno == EAGAIN) && loops--) {
msleep(connect_loop);
goto connect_again;
}
- if (ret < 0 && (errno == EINPROGRESS || errno == EALREADY)) {
+ if (ret < 0 && (errno == EINPROGRESS || errno == EALREADY ||
+ errno == EAGAIN)) {
DEBUG(1,("timeout connecting to %s:%d\n",inet_ntoa(*addr),port));
close(res);
return -1;
}
-/* matchname - determine if host name matches IP address */
+/*******************************************************************
+ matchname - determine if host name matches IP address
+ ******************************************************************/
static BOOL matchname(char *remotehost,struct in_addr addr)
{
struct hostent *hp;
return False;
}
-/* return the DNS name of the client */
+/*******************************************************************
+ Reset the 'done' variables so after a client process is created
+ from a fork call these calls will be re-done. This should be
+ expanded if more variables need reseting.
+ ******************************************************************/
+
+static BOOL global_client_name_done = False;
+static BOOL global_client_addr_done = False;
+
+void reset_globals_after_fork()
+{
+ global_client_name_done = False;
+ global_client_addr_done = False;
+}
+
+/*******************************************************************
+ return the DNS name of the client
+ ******************************************************************/
char *client_name(void)
{
extern int Client;
struct sockaddr_in *sockin = (struct sockaddr_in *) (&sa);
int length = sizeof(sa);
static pstring name_buf;
- static BOOL done = False;
struct hostent *hp;
- if (done)
+ if (global_client_name_done)
return name_buf;
- done = True;
strcpy(name_buf,"UNKNOWN");
if (getpeername(Client, &sa, &length) < 0) {
DEBUG(0,("getpeername failed\n"));
- done = False;
return name_buf;
}
AF_INET)) == 0) {
DEBUG(1,("Gethostbyaddr failed for %s\n",client_addr()));
StrnCpy(name_buf,client_addr(),sizeof(name_buf) - 1);
- done = False;
} else {
StrnCpy(name_buf,(char *)hp->h_name,sizeof(name_buf) - 1);
if (!matchname(name_buf, sockin->sin_addr)) {
strcpy(name_buf,"UNKNOWN");
}
}
+ global_client_name_done = True;
return name_buf;
}
-/* return the IP addr of the client as a string */
+/*******************************************************************
+ return the IP addr of the client as a string
+ ******************************************************************/
char *client_addr(void)
{
extern int Client;
struct sockaddr_in *sockin = (struct sockaddr_in *) (&sa);
int length = sizeof(sa);
static fstring addr_buf;
- static BOOL done = False;
- if (done)
+ if (global_client_addr_done)
return addr_buf;
- done = True;
strcpy(addr_buf,"0.0.0.0");
if (getpeername(Client, &sa, &length) < 0) {
strcpy(addr_buf,(char *)inet_ntoa(sockin->sin_addr));
+ global_client_addr_done = True;
return addr_buf;
}
fstring s;
if (!tested) {
tested = True;
- sprintf(s,"/proc/%05d",getpid());
+ sprintf(s,"/proc/%05d",(int)getpid());
ok = file_exist(s,NULL);
}
if (ok) {
nameptr++;
continue;
}
- if(name_end = strchr(nameptr,'/'))
+ if((name_end = strchr(nameptr,'/'))!=NULL)
{
*name_end = 0;
}
return 0;
}
-BOOL is_vetoed_path(char *name)
+static BOOL is_in_path(char *name, char *namelist)
{
- char *namelist = lp_veto_files();
char *nameptr = namelist;
char *sub;
char *name_end;
nameptr++;
continue;
}
- if(name_end = strchr(nameptr,'/'))
+ if((name_end = strchr(nameptr,'/'))!=NULL)
{
*name_end = 0;
}
return 0;
}
+/****************************************************************************
+used to make files hidden, but still accessible
+****************************************************************************/
+BOOL is_hidden_path(char *path)
+{
+ return is_in_path(path, lp_hide_files());
+}
+
+/****************************************************************************
+used to make files _completely_ inaccessible
+****************************************************************************/
+BOOL is_vetoed_path(char *path)
+{
+ return is_in_path(path, lp_veto_files());
+}
+
/****************************************************************************
routine to do file locking
****************************************************************************/