diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/client/client.c | 4 | ||||
-rw-r--r-- | source3/client/clientutil.c | 4 | ||||
-rw-r--r-- | source3/include/nameserv.h | 9 | ||||
-rw-r--r-- | source3/include/proto.h | 3 | ||||
-rw-r--r-- | source3/include/smb.h | 4 | ||||
-rw-r--r-- | source3/lib/util.c | 5 | ||||
-rw-r--r-- | source3/nameannounce.c | 6 | ||||
-rw-r--r-- | source3/namedbwork.c | 2 | ||||
-rw-r--r-- | source3/param/loadparm.c | 152 | ||||
-rw-r--r-- | source3/smbd/ipc.c | 10 |
10 files changed, 164 insertions, 35 deletions
diff --git a/source3/client/client.c b/source3/client/client.c index 49804270e9..f9585c6de5 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -3311,7 +3311,7 @@ static BOOL send_login(char *inbuf,char *outbuf,BOOL start_session,BOOL use_setu if (doencrypt && *pass) { DEBUG(3,("Using encrypted passwords\n")); passlen = 24; - SMBencrypt(pass,cryptkey,pword); + SMBencrypt((uchar *)pass,(uchar *)cryptkey,(uchar *)pword); } #else doencrypt = False; @@ -3429,7 +3429,7 @@ static BOOL send_login(char *inbuf,char *outbuf,BOOL start_session,BOOL use_setu #ifdef SMB_PASSWD if (doencrypt && *pass) { passlen=24; - SMBencrypt(pass,cryptkey,pword); + SMBencrypt((uchar *)pass,(uchar *)cryptkey,(uchar *)pword); } #endif diff --git a/source3/client/clientutil.c b/source3/client/clientutil.c index d1407332ff..000cbba1a7 100644 --- a/source3/client/clientutil.c +++ b/source3/client/clientutil.c @@ -438,7 +438,7 @@ BOOL cli_send_login(char *inbuf, char *outbuf, BOOL start_session, BOOL use_setu if (doencrypt && *pass) { DEBUG(5,("Using encrypted passwords\n")); passlen = 24; - SMBencrypt(pass,cryptkey,pword); + SMBencrypt((uchar *)pass,(uchar *)cryptkey,(uchar *)pword); } #else doencrypt = False; @@ -556,7 +556,7 @@ BOOL cli_send_login(char *inbuf, char *outbuf, BOOL start_session, BOOL use_setu #ifdef SMB_PASSWD if (doencrypt && *pass) { passlen=24; - SMBencrypt(pass,cryptkey,pword); + SMBencrypt((uchar *)pass,(uchar *)cryptkey,(uchar *)pword); } #endif diff --git a/source3/include/nameserv.h b/source3/include/nameserv.h index 8482fa8d2c..83f3a3c524 100644 --- a/source3/include/nameserv.h +++ b/source3/include/nameserv.h @@ -408,11 +408,10 @@ struct packet_struct /* do all remote announcements this often */ #define REMOTE_ANNOUNCE_INTERVAL 180 -#define DFLT_SERVER_TYPE (SV_TYPE_WORKSTATION | SV_TYPE_SERVER | \ - (lp_time_server() ? SV_TYPE_TIME_SOURCE : 0) | \ - SV_TYPE_SERVER_UNIX | \ - SV_TYPE_PRINTQ_SERVER | SV_TYPE_SERVER_NT | \ - SV_TYPE_NT ) +/* Types of machine we can announce as */ +#define ANNOUNCE_AS_NT 1 +#define ANNOUNCE_AS_WIN95 2 +#define ANNOUNCE_AS_WFW 3 /* Macro's to enumerate subnets either with or without the WINS subnet. */ diff --git a/source3/include/proto.h b/source3/include/proto.h index 4b7b48f50b..23f7f191fb 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -267,6 +267,9 @@ BOOL lp_load(char *pszFname,BOOL global_only); int lp_numservices(void); void lp_dump(void); int lp_servicenumber(char *pszServiceName); +int lp_default_server_announce(void); +int lp_major_announce_version(void); +int lp_minor_announce_version(void); char *volume_label(int snum); /*The following definitions come from locking.c */ diff --git a/source3/include/smb.h b/source3/include/smb.h index c7ff549fe5..2b6888b8a7 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -844,8 +844,8 @@ char *Strstr(char *s, char *p); /* - Reappeared in 1.9.16p11 with fixed smbd services */ /* Version 4.20 - To indicate that nmbd and browsing now works better */ -#define MAJOR_VERSION 0x04 -#define MINOR_VERSION 0x02 +#define DEFAULT_MAJOR_VERSION 0x04 +#define DEFAULT_MINOR_VERSION 0x02 /* Browser Election Values */ #define BROWSER_ELECTION_VERSION 0x010f diff --git a/source3/lib/util.c b/source3/lib/util.c index cec25ef9b9..51bb2b4a16 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -77,10 +77,9 @@ fstring myworkgroup = ""; int smb_read_error = 0; -static char *filename_dos(char *path,char *buf); - static BOOL stdout_logging = False; +static char *filename_dos(char *path,char *buf); /******************************************************************* get ready for syslog stuff @@ -3742,5 +3741,3 @@ void file_unlock(int fd) #endif close(fd); } - - diff --git a/source3/nameannounce.c b/source3/nameannounce.c index a8fdde19bb..e92e989c31 100644 --- a/source3/nameannounce.c +++ b/source3/nameannounce.c @@ -165,8 +165,8 @@ void do_announce_host(int command, StrnCpy(p+5,server_name,16); strupper(p+5); - CVAL(p,21) = MAJOR_VERSION; /* major version */ - CVAL(p,22) = MINOR_VERSION; /* minor version */ + CVAL(p,21) = lp_major_announce_version(); /* major version */ + CVAL(p,22) = lp_minor_announce_version(); /* minor version */ SIVAL(p,23,server_type & ~SV_TYPE_LOCAL_LIST_ONLY); /* browse version: got from NT/AS 4.00 - Value defined in smb.h (JHT)*/ @@ -485,7 +485,7 @@ void announce_remote(time_t t) pstring s2; struct in_addr addr; char *comment,*workgroup; - int stype = DFLT_SERVER_TYPE; + int stype = lp_default_server_announce(); if (last_time && t < last_time + REMOTE_ANNOUNCE_INTERVAL) return; diff --git a/source3/namedbwork.c b/source3/namedbwork.c index 9b4b6a5300..2982ffd3e7 100644 --- a/source3/namedbwork.c +++ b/source3/namedbwork.c @@ -88,7 +88,7 @@ static struct work_record *make_workgroup(char *name) StrnCpy(work->work_group,name,sizeof(work->work_group)-1); work->serverlist = NULL; - work->ServerType = DFLT_SERVER_TYPE | (lp_local_master() ? + work->ServerType = lp_default_server_announce() | (lp_local_master() ? SV_TYPE_POTENTIAL_BROWSER : 0 ); work->RunningElection = False; work->ElectionCount = 0; diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index fd2797aadb..df6aff6f9c 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -135,6 +135,7 @@ typedef struct char *szRemoteAnnounce; char *szSocketAddress; char *szNISHomeMapName; + char *szAnnounceVersion; /* This is initialised in init_globals */ int max_log_size; int mangled_stack; int max_xmit; @@ -154,6 +155,7 @@ typedef struct int shmem_size; int shmem_hash_size; int client_code_page; + int announce_as; /* This is initialised in init_globals */ BOOL bDNSproxy; BOOL bWINSsupport; BOOL bWINSproxy; @@ -350,7 +352,7 @@ static int iNumServices = 0; static int iServiceIndex = 0; static BOOL bInGlobalSection = True; static BOOL bGlobalOnly = False; - +static int default_server_announce; #define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct)) @@ -363,6 +365,7 @@ static BOOL handle_security(char *pszParmValue,int *val); static BOOL handle_case(char *pszParmValue,int *val); static BOOL handle_printing(char *pszParmValue,int *val); static BOOL handle_character_set(char *pszParmValue,int *val); +static BOOL handle_announce_as(char *pszParmValue, int *val); #ifdef KANJI static BOOL handle_coding_system(char *pszParmValue,int *val); #endif /* KANJI */ @@ -385,6 +388,7 @@ struct parm_struct {"printing", P_INTEGER, P_GLOBAL, &Globals.printing,handle_printing}, {"max disk size", P_INTEGER, P_GLOBAL, &Globals.maxdisksize, NULL}, {"lpq cache time", P_INTEGER, P_GLOBAL, &Globals.lpqcachetime, NULL}, + {"announce as", P_INTEGER, P_GLOBAL, &Globals.announce_as, handle_announce_as}, {"encrypt passwords",P_BOOL, P_GLOBAL, &Globals.bEncryptPasswords, NULL}, {"getwd cache", P_BOOL, P_GLOBAL, &use_getwd_cache, NULL}, {"read prediction", P_BOOL, P_GLOBAL, &Globals.bReadPrediction, NULL}, @@ -430,6 +434,7 @@ struct parm_struct {"remote announce", P_STRING, P_GLOBAL, &Globals.szRemoteAnnounce, NULL}, {"socket address", P_STRING, P_GLOBAL, &Globals.szSocketAddress, NULL}, {"homedir map", P_STRING, P_GLOBAL, &Globals.szNISHomeMapName, NULL}, + {"announce version", P_STRING, P_GLOBAL, &Globals.szAnnounceVersion, NULL}, {"max log size", P_INTEGER, P_GLOBAL, &Globals.max_log_size, NULL}, {"mangled stack", P_INTEGER, P_GLOBAL, &Globals.mangled_stack, NULL}, {"max mux", P_INTEGER, P_GLOBAL, &Globals.max_mux, NULL}, @@ -602,6 +607,8 @@ static void init_globals(void) string_set(&Globals.szSocketAddress, "0.0.0.0"); sprintf(s,"Samba %s",VERSION); string_set(&Globals.szServerString,s); + sprintf(s,"%d.%d", DEFAULT_MAJOR_VERSION, DEFAULT_MINOR_VERSION); + string_set(&Globals.szAnnounceVersion,s); Globals.bLoadPrinters = True; Globals.bUseRhosts = False; Globals.max_packet = 65535; @@ -629,6 +636,7 @@ static void init_globals(void) Globals.ReadSize = 16*1024; Globals.shmem_size = SHMEM_SIZE; Globals.shmem_hash_size = SHMEM_HASH_SIZE; + Globals.announce_as = ANNOUNCE_AS_NT; Globals.bUnixRealname = False; #if (defined(NETGROUP) && defined(AUTOMOUNT)) Globals.bNISHomeMap = False; @@ -822,6 +830,7 @@ FN_GLOBAL_STRING(lp_wins_server,&Globals.szWINSserver) FN_GLOBAL_STRING(lp_interfaces,&Globals.szInterfaces) FN_GLOBAL_STRING(lp_socket_address,&Globals.szSocketAddress) FN_GLOBAL_STRING(lp_nis_home_map_name,&Globals.szNISHomeMapName) +FN_GLOBAL_STRING(lp_announce_version,&Globals.szAnnounceVersion) FN_GLOBAL_BOOL(lp_dns_proxy,&Globals.bDNSproxy) FN_GLOBAL_BOOL(lp_wins_support,&Globals.bWINSsupport) @@ -866,6 +875,7 @@ FN_GLOBAL_INTEGER(lp_maxdisksize,&Globals.maxdisksize) FN_GLOBAL_INTEGER(lp_lpqcachetime,&Globals.lpqcachetime) FN_GLOBAL_INTEGER(lp_syslog,&Globals.syslog) FN_GLOBAL_INTEGER(lp_client_code_page,&Globals.client_code_page) +FN_GLOBAL_INTEGER(lp_announce_as,&Globals.announce_as) FN_LOCAL_STRING(lp_preexec,szPreExec) FN_LOCAL_STRING(lp_postexec,szPostExec) @@ -1124,6 +1134,8 @@ BOOL lp_add_printer(char *pszPrintername, int iDefaultService) iSERVICE(i).bRead_only = False; /* No share modes on printer services. */ iSERVICE(i).bShareModes = False; + /* Printer services must be printable. */ + iSERVICE(i).bPrint_ok = True; DEBUG(3,("adding printer service %s\n",pszPrintername)); @@ -1433,9 +1445,9 @@ handle the interpretation of the default case ***************************************************************************/ static BOOL handle_case(char *pszParmValue,int *val) { - if (strequal(pszParmValue,"LOWER")) + if (strnequal(pszParmValue,"LOWER", 5)) *val = CASE_LOWER; - else if (strequal(pszParmValue,"UPPER")) + else if (strnequal(pszParmValue,"UPPER", 5)) *val = CASE_UPPER; return(True); } @@ -1445,24 +1457,38 @@ handle the interpretation of the printing system ***************************************************************************/ static BOOL handle_printing(char *pszParmValue,int *val) { - if (strequal(pszParmValue,"sysv")) + if (strnequal(pszParmValue,"sysv", 4)) *val = PRINT_SYSV; - else if (strequal(pszParmValue,"aix")) + else if (strnequal(pszParmValue,"aix", 3)) *val = PRINT_AIX; - else if (strequal(pszParmValue,"hpux")) + else if (strnequal(pszParmValue,"hpux", 4)) *val = PRINT_HPUX; - else if (strequal(pszParmValue,"bsd")) + else if (strnequal(pszParmValue,"bsd", 3)) *val = PRINT_BSD; - else if (strequal(pszParmValue,"qnx")) + else if (strnequal(pszParmValue,"qnx",3)) *val = PRINT_QNX; - else if (strequal(pszParmValue,"plp")) + else if (strnequal(pszParmValue,"plp", 3)) *val = PRINT_PLP; - else if (strequal(pszParmValue,"lprng")) + else if (strnequal(pszParmValue,"lprng", 5)) *val = PRINT_LPRNG; return(True); } /*************************************************************************** +handle the announce as parameter +***************************************************************************/ +static BOOL handle_announce_as(char *pszParmValue,int *val) +{ + if (strnequal(pszParmValue,"NT", 2)) + *val = ANNOUNCE_AS_NT; + else if (strnequal(pszParmValue,"win95", 5)) + *val = ANNOUNCE_AS_WIN95; + else if (strnequal(pszParmValue,"WfW", 3)) + *val = ANNOUNCE_AS_WFW; + return True; +} + +/*************************************************************************** handle the valid chars lines ***************************************************************************/ static BOOL handle_valid_chars(char *pszParmValue,char **ptr) @@ -1963,7 +1989,8 @@ BOOL lp_load(char *pszFname,BOOL global_only) { pstring n2; BOOL bRetval; - + static void set_default_server_announce_type(void); + add_to_file_list(pszFname); bRetval = False; @@ -1992,6 +2019,8 @@ BOOL lp_load(char *pszFname,BOOL global_only) lp_add_ipc(); + set_default_server_announce_type(); + bLoaded = True; return (bRetval); @@ -2058,3 +2087,104 @@ char *volume_label(int snum) if (!*ret) return(lp_servicename(snum)); return(ret); } + +#if 0 +/* + * nmbd only loads the global section. There seems to be no way to + * determine exactly is a service is printable by only looking at the + * [global] section so for now always announce as a print server. This + * will need looking at in the future. Jeremy (jallison@whistle.com). + */ +/******************************************************************* + Return true if any printer services are defined. + ******************************************************************/ +static BOOL lp_printer_services(void) +{ + int iService; + + for (iService = iNumServices - 1; iService >= 0; iService--) + if (VALID(iService) && iSERVICE(iService).bPrint_ok) + return True; + return False; +} +#endif + +/******************************************************************* + Set the server type we will announce as via nmbd. +********************************************************************/ +static void set_default_server_announce_type() +{ + default_server_announce = (SV_TYPE_WORKSTATION | SV_TYPE_SERVER | + SV_TYPE_SERVER_UNIX | SV_TYPE_PRINTQ_SERVER); + if(lp_announce_as() == ANNOUNCE_AS_NT) + default_server_announce |= (SV_TYPE_SERVER_NT | SV_TYPE_NT); + else if(lp_announce_as() == ANNOUNCE_AS_WIN95) + default_server_announce |= SV_TYPE_WIN95_PLUS; + else if(lp_announce_as() == ANNOUNCE_AS_WFW) + default_server_announce |= SV_TYPE_WFW; + default_server_announce |= (lp_time_server() ? SV_TYPE_TIME_SOURCE : 0); +/* + * nmbd only loads the [global] section. There seems to be no way to + * determine exactly if any service is printable by only looking at the + * [global] section so for now always announce as a print server. This + * will need looking at in the future. Jeremy (jallison@whistle.com). + */ +#if 0 + default_server_announce |= (lp_printer_services() ? SV_TYPE_PRINTQ_SERVER : 0); +#endif +} + +/******************************************************************* + Get the default server type we will announce as via nmbd. +********************************************************************/ +int lp_default_server_announce(void) +{ + return default_server_announce; +} + +/******************************************************************* + Split the announce version into major and minor numbers. +********************************************************************/ +int lp_major_announce_version(void) +{ + static BOOL got_major = False; + static int major_version = DEFAULT_MAJOR_VERSION; + char *vers; + char *p; + + if(got_major) + return major_version; + + got_major = True; + if((vers = lp_announce_version()) == NULL) + return major_version; + + if((p = strchr(vers, '.')) == 0) + return major_version; + + *p = '\0'; + major_version = atoi(vers); + return major_version; +} + +int lp_minor_announce_version(void) +{ + static BOOL got_minor = False; + static int minor_version = DEFAULT_MINOR_VERSION; + char *vers; + char *p; + + if(got_minor) + return minor_version; + + got_minor = True; + if((vers = lp_announce_version()) == NULL) + return minor_version; + + if((p = strchr(vers, '.')) == 0) + return minor_version; + + p++; + minor_version = atoi(p); + return minor_version; +} diff --git a/source3/smbd/ipc.c b/source3/smbd/ipc.c index 17bdd3ca66..89dd9f511b 100644 --- a/source3/smbd/ipc.c +++ b/source3/smbd/ipc.c @@ -1682,7 +1682,7 @@ static BOOL api_RNetServerGetInfo(int cnum,uint16 vuid, char *param,char *data, struct srv_info_struct *servers=NULL; int i,count; pstring comment; - uint32 servertype=DFLT_SERVER_TYPE; + uint32 servertype= lp_default_server_announce(); strcpy(comment,lp_serverstring()); @@ -1696,8 +1696,8 @@ static BOOL api_RNetServerGetInfo(int cnum,uint16 vuid, char *param,char *data, } if (servers) free(servers); - SCVAL(p,0,MAJOR_VERSION); - SCVAL(p,1,MINOR_VERSION); + SCVAL(p,0,lp_major_announce_version()); + SCVAL(p,1,lp_minor_announce_version()); SIVAL(p,2,servertype); if (mdrcnt == struct_len) { @@ -1777,8 +1777,8 @@ static BOOL api_NetWkstaGetInfo(int cnum,uint16 vuid, char *param,char *data, p2 = skip_string(p2,1); p += 4; - SCVAL(p,0,MAJOR_VERSION); /* system version - e.g 4 in 4.1 */ - SCVAL(p,1,MINOR_VERSION); /* system version - e.g .1 in 4.1 */ + SCVAL(p,0,lp_major_announce_version()); /* system version - e.g 4 in 4.1 */ + SCVAL(p,1,lp_minor_announce_version()); /* system version - e.g .1 in 4.1 */ p += 2; SIVAL(p,0,PTR_DIFF(p2,*rdata)); |