diff options
-rw-r--r-- | source3/include/local.h | 2 | ||||
-rw-r--r-- | source3/include/proto.h | 1 | ||||
-rw-r--r-- | source3/include/smb.h | 4 | ||||
-rw-r--r-- | source3/lib/time.c | 5 | ||||
-rw-r--r-- | source3/lib/util.c | 32 | ||||
-rw-r--r-- | source3/param/loadparm.c | 4 | ||||
-rw-r--r-- | source3/smbd/reply.c | 2 | ||||
-rw-r--r-- | source3/smbd/server.c | 2 | ||||
-rw-r--r-- | source3/smbd/trans2.c | 30 | ||||
-rw-r--r-- | source3/smbd/uid.c | 8 |
10 files changed, 77 insertions, 13 deletions
diff --git a/source3/include/local.h b/source3/include/local.h index b2a8f5ec57..22862a9a1f 100644 --- a/source3/include/local.h +++ b/source3/include/local.h @@ -27,7 +27,7 @@ MAX_CONNECTIONS services, but any number of machines may connect at one time. */ #define MAX_CONNECTIONS 127 -#define MAX_OPEN_FILES 10 +#define MAX_OPEN_FILES 100 /* Default size of shared memory used for share mode locking */ #ifndef SHMEM_SIZE diff --git a/source3/include/proto.h b/source3/include/proto.h index 7f6321c869..306d3a42a0 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -280,6 +280,7 @@ BOOL lp_nis_home_map(void); BOOL lp_time_server(void); BOOL lp_bind_interfaces_only(void); BOOL lp_net_wksta_user_logon(void); +BOOL lp_win95_bug_compatibility(void); int lp_os_level(void); int lp_max_ttl(void); int lp_max_wins_ttl(void); diff --git a/source3/include/smb.h b/source3/include/smb.h index 9a7278069d..77f4006c4a 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -1366,7 +1366,7 @@ struct cli_state { struct current_user { - int cnum, id; + int cnum, vuid; int uid, gid; int ngroups; gid_t *groups; @@ -1424,7 +1424,7 @@ typedef struct int pos; uint32 size; int mode; - int uid; + int vuid; char *mmap_ptr; uint32 mmap_size; write_bmpx_struct *wbmpx_ptr; diff --git a/source3/lib/time.c b/source3/lib/time.c index 62a7016994..81e3dcfd8f 100644 --- a/source3/lib/time.c +++ b/source3/lib/time.c @@ -508,5 +508,8 @@ time_t get_create_time(struct stat *st) time_t get_access_time(struct stat *st) { - return st->st_atime; + if (lp_win95_bug_compatibility()) + return st->st_mtime; + else + return st->st_atime; } diff --git a/source3/lib/util.c b/source3/lib/util.c index 1d65269f95..3b30f1e6b5 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -3811,6 +3811,38 @@ void standard_sub_basic(char *str) case 'h' : string_sub(p,"%h", myhostname); break; case 'm' : string_sub(p,"%m", remote_machine); break; case 'v' : string_sub(p,"%v", VERSION); break; + case '$' : /* Expand environment variables */ + { + /* Contributed by Branko Cibej <branko.cibej@hermes.si> */ + fstring envname; + char *envval; + char *q, *r; + int copylen; + + if (*(p+2) != '(') { p+=2; break; } + if ((q = strchr(p,')')) == NULL) + { + DEBUG(0,("standard_sub_basic: Unterminated environment \ +variable [%s]\n", p)); + p+=2; break; + } + + r = p+3; + copylen = MIN((q-r),(sizeof(envname)-1)); + strncpy(envname,r,copylen); + envname[copylen] = '\0'; + if ((envval = getenv(envname)) == NULL) + { + DEBUG(0,("standard_sub_basic: Environment variable [%s] not set\n", + envname)); + p+=2; break; + } + copylen = MIN((q+1-p),(sizeof(envname)-1)); + strncpy(envname,p,copylen); + envname[copylen] = '\0'; + string_sub(p,envname,envval); + break; + } case '\0': p++; break; /* don't run off end if last character is % */ default : p+=2; break; } diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index 0e55bc4ac1..82a4851444 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -189,6 +189,7 @@ typedef struct BOOL bTimeServer; BOOL bBindInterfacesOnly; BOOL bNetWkstaUserLogon; + BOOL bWin95BugCompatibility; } global; static global Globals; @@ -530,6 +531,7 @@ static struct parm_struct {"unix realname", P_BOOL, P_GLOBAL, &Globals.bUnixRealname, NULL, NULL}, {"NIS homedir", P_BOOL, P_GLOBAL, &Globals.bNISHomeMap, NULL, NULL}, {"time server", P_BOOL, P_GLOBAL, &Globals.bTimeServer, NULL, NULL}, + {"win95 bug compatibility", P_BOOL, P_GLOBAL, &Globals.bWin95BugCompatibility,NULL, NULL}, {"printer driver file", P_STRING, P_GLOBAL, &Globals.szDriverFile, NULL, NULL}, {"-valid", P_BOOL, P_LOCAL, &sDefault.valid, NULL, NULL}, {"comment", P_STRING, P_LOCAL, &sDefault.comment, NULL, NULL}, @@ -723,6 +725,7 @@ static void init_globals(void) Globals.bTimeServer = False; Globals.bBindInterfacesOnly = False; Globals.bNetWkstaUserLogon = True; + Globals.bWin95BugCompatibility = False; /* these parameters are set to defaults that are more appropriate for the increasing samba install base: @@ -939,6 +942,7 @@ FN_GLOBAL_BOOL(lp_nis_home_map,&Globals.bNISHomeMap) FN_GLOBAL_BOOL(lp_time_server,&Globals.bTimeServer) FN_GLOBAL_BOOL(lp_bind_interfaces_only,&Globals.bBindInterfacesOnly) FN_GLOBAL_BOOL(lp_net_wksta_user_logon,&Globals.bNetWkstaUserLogon) +FN_GLOBAL_BOOL(lp_win95_bug_compatibility,&Globals.bWin95BugCompatibility) FN_GLOBAL_INTEGER(lp_os_level,&Globals.os_level) FN_GLOBAL_INTEGER(lp_max_ttl,&Globals.max_ttl) diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index db494d07db..93bb679289 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -1385,7 +1385,7 @@ int reply_ulogoffX(char *inbuf,char *outbuf,int length,int bufsize) if ((vuser != 0) && (lp_security() != SEC_SHARE)) { int i; for (i=0;i<MAX_OPEN_FILES;i++) - if (Files[i].uid == vuser->uid && Files[i].open) { + if ((Files[i].vuid == vuid) && Files[i].open) { close_file(i,False); } } diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 94360a4c37..0a6a05fdbf 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -1344,7 +1344,7 @@ static void open_file(int fnum,int cnum,char *fname1,int flags,int mode, struct Connections[cnum].num_files_open++; fsp->mode = sbuf->st_mode; GetTimeOfDay(&fsp->open_time); - fsp->uid = current_user.id; + fsp->vuid = current_user.vuid; fsp->size = 0; fsp->pos = -1; fsp->open = True; diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 825dd0a25e..2b5d5785fa 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -32,6 +32,7 @@ extern BOOL case_sensitive; extern int Client; extern int oplock_sock; extern int smb_read_error; +extern fstring local_machine; /**************************************************************************** Send the required number of replies back. @@ -940,7 +941,8 @@ static int call_trans2qfsinfo(char *inbuf, char *outbuf, int length, int bufsize int data_len; struct stat st; char *vname = volume_label(SNUM(cnum)); - + int snum = SNUM(cnum); + DEBUG(3,("call_trans2qfsinfo: cnum = %d, level = %d\n", cnum, info_level)); if(sys_stat(".",&st)!=0) { @@ -971,7 +973,11 @@ static int call_trans2qfsinfo(char *inbuf, char *outbuf, int length, int bufsize /* Return volume name */ int volname_len = MIN(strlen(vname),11); data_len = l2_vol_szVolLabel + volname_len + 1; - put_dos_date2(pdata,l2_vol_fdateCreation,st.st_ctime); + /* + * Add volume serial number - hash of a combination of + * the called hostname and the service name. + */ + SIVAL(pdata,0,str_checksum(lp_servicename(snum)) ^ str_checksum(local_machine) ); SCVAL(pdata,l2_vol_cch,volname_len); StrnCpy(pdata+l2_vol_szVolLabel,vname,volname_len); DEBUG(5,("call_trans2qfsinfo : time = %x, namelen = %d, name = %s\n",st.st_ctime, volname_len, @@ -992,6 +998,11 @@ static int call_trans2qfsinfo(char *inbuf, char *outbuf, int length, int bufsize break; case SMB_QUERY_FS_VOLUME_INFO: data_len = 18 + 2*strlen(vname); + /* + * Add volume serial number - hash of a combination of + * the called hostname and the service name. + */ + SIVAL(pdata,8,str_checksum(lp_servicename(snum)) ^ str_checksum(local_machine) ); SIVAL(pdata,12,2*strlen(vname)); PutUniCode(pdata+18,vname); DEBUG(5,("call_trans2qfsinfo : SMB_QUERY_FS_VOLUME_INFO namelen = %d, vol = %s\n", strlen(vname), @@ -1128,9 +1139,18 @@ 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_fdateLastAccess,get_access_time(&sbuf)); - put_dos_date2(pdata,l1_fdateLastWrite,sbuf.st_mtime); /* write time */ + if( lp_win95_bug_compatibility()) + { + put_dos_date(pdata,l1_fdateCreation,get_create_time(&sbuf)); + put_dos_date(pdata,l1_fdateLastAccess,get_access_time(&sbuf)); + put_dos_date(pdata,l1_fdateLastWrite,sbuf.st_mtime); /* write time */ + } + else + { + put_dos_date2(pdata,l1_fdateCreation,get_create_time(&sbuf)); + put_dos_date2(pdata,l1_fdateLastAccess,get_access_time(&sbuf)); + put_dos_date2(pdata,l1_fdateLastWrite,sbuf.st_mtime); /* write time */ + } SIVAL(pdata,l1_cbFile,size); SIVAL(pdata,l1_cbFileAlloc,ROUNDUP(size,1024)); SSVAL(pdata,l1_attrFile,mode); diff --git a/source3/smbd/uid.c b/source3/smbd/uid.c index 176f6ca240..14b0000f59 100644 --- a/source3/smbd/uid.c +++ b/source3/smbd/uid.c @@ -53,6 +53,7 @@ void init_uid(void) initial_gid = getegid(); current_user.cnum = -1; + current_user.vuid = UID_FIELD_INVALID; ChDir(OriginalDir); } @@ -174,6 +175,7 @@ BOOL become_guest(void) DEBUG(1,("Failed to become guest. Invalid guest account?\n")); current_user.cnum = -2; + current_user.vuid = UID_FIELD_INVALID; return(ret); } @@ -208,7 +210,8 @@ BOOL become_user(connection_struct *conn, int cnum, uint16 vuid) int snum,gid; int uid; - if (current_user.cnum == cnum && vuser != 0 && current_user.id == vuser->uid) { + if ((current_user.cnum == cnum) && (vuser != 0) && (current_user.vuid == vuid) && + (current_user.uid == vuser->uid)) { DEBUG(4,("Skipping become_user - already user\n")); return(True); } @@ -272,7 +275,7 @@ BOOL become_user(connection_struct *conn, int cnum, uint16 vuid) } current_user.cnum = cnum; - current_user.id = uid; + current_user.vuid = vuid; DEBUG(5,("become_user uid=(%d,%d) gid=(%d,%d)\n", getuid(),geteuid(),getgid(),getegid())); @@ -333,6 +336,7 @@ BOOL unbecome_user(void ) getuid(),geteuid(),getgid(),getegid())); current_user.cnum = -1; + current_user.vuid = UID_FIELD_INVALID; return(True); } |