+#define OLD_NTDOMAIN 1
/*
Unix SMB/Netbios implementation.
Version 1.9.
#include "includes.h"
-#include "trans2.h"
-#include "nterr.h"
/* look in server.c for some explanation of these variables */
extern int Protocol;
int ret;
pstrcpy(add_script, lp_adduser_script());
+ if (! *add_script) return -1;
pstring_sub(add_script, "%u", unix_user);
ret = smbrun(add_script,NULL,False);
DEBUG(3,("smb_create_user: Running the command `%s' gave %d\n",add_script,ret));
int ret;
pstrcpy(del_script, lp_deluser_script());
+ if (! *del_script) return -1;
pstring_sub(del_script, "%u", unix_user);
ret = smbrun(del_script,NULL,False);
DEBUG(3,("smb_delete_user: Running the command `%s' gave %d\n",del_script,ret));
* level security as we never know if it was a failure
* due to a bad password, or the user really doesn't exist.
*/
- if(lp_adduser_script() && !Get_Pwnam(unix_user,True)) {
+ if(lp_adduser_script() && !smb_getpwnam(unix_user,True)) {
smb_create_user(unix_user);
}
}
* If the admin wants us to try and create a UNIX
* user on the fly, do so.
*/
- if(user_exists && lp_adduser_script() && !Get_Pwnam(unix_user,True)) {
+ if(user_exists && lp_adduser_script() && !smb_getpwnam(unix_user,True)) {
smb_create_user(unix_user);
}
} else {
* wants us to try and delete that UNIX user on the fly,
* do so.
*/
- if(!user_exists && lp_deluser_script() && Get_Pwnam(unix_user,True)) {
+ if(!user_exists && lp_deluser_script() && smb_getpwnam(unix_user,True)) {
smb_delete_user(unix_user);
}
}
strlower(user);
- /*
- * In share level security, only overwrite sesssetup_use if
- * it's a non null-session share. Helps keep %U and %G
- * working.
- */
-
- if((lp_security() != SEC_SHARE) || (*user && !guest))
- pstrcpy(sesssetup_user,user);
+ pstrcpy(sesssetup_user,user);
reload_services(True);
pstrcpy( orig_user, user);
+ /* if the username exists as a domain/username pair on the unix system then use
+ that */
+ if (!Get_Pwnam(user, False)) {
+ pstring user2;
+ slprintf(user2,sizeof(user2),"%s/%s", domain, user);
+ if (Get_Pwnam(user2, True)) {
+ DEBUG(3,("Using unix username %s\n", user2));
+ pstrcpy(user, user2);
+ }
+ }
+
/*
* Pass the user through the NT -> unix user mapping
* function.
/*
* Do any UNIX username case mangling.
*/
- (void)Get_Pwnam( user, True);
+ smb_getpwnam(user, True);
add_session_user(user);
if (lp_map_to_guest() == MAP_TO_GUEST_ON_BAD_USER)
{
- if (Get_Pwnam(user,True))
+ if (smb_getpwnam(user,True))
{
DEBUG(1,("Rejecting user '%s': bad password\n", user));
return bad_password_error(inbuf,outbuf);
*/
}
- if (*smb_apasswd || !Get_Pwnam(user,True))
+ if (*smb_apasswd || !smb_getpwnam(user,True))
pstrcpy(user,lp_guestaccount(-1));
DEBUG(3,("Registered username %s for guest access\n",user));
guest = True;
}
}
- if (!Get_Pwnam(user,True)) {
- DEBUG(3,("No such user %s - using guest account\n",user));
+ if (!smb_getpwnam(user,True)) {
+ DEBUG(3,("No such user %s [%s] - using guest account\n",user, domain));
pstrcpy(user,lp_guestaccount(-1));
guest = True;
}
user we should become.
*/
{
- const struct passwd *pw = Get_Pwnam(user,False);
+ const struct passwd *pw = smb_getpwnam(user,False);
if (!pw) {
DEBUG(1,("Username %s is invalid on this system\n",user));
return bad_password_error(inbuf,outbuf);
/* register the name and uid as being validated, so further connections
to a uid can get through without a password, on the same VC */
- sess_vuid = register_vuid(uid,gid,user,sesssetup_user,guest);
+ sess_vuid = register_vuid(uid,gid,user,sesssetup_user,domain,guest);
SSVAL(outbuf,smb_uid,sess_vuid);
SSVAL(inbuf,smb_uid,sess_vuid);
/* dirtype &= ~aDIR; */
- DEBUG(5,("reply_search: path=%s status_len=%d\n",path,status_len));
-
-
if (status_len == 0)
{
pstring dir2;
else
{
memcpy(status,smb_buf(inbuf) + 1 + strlen(path) + 4,21);
- memcpy(mask,status+1,11);
- mask[11] = 0;
dirtype = CVAL(status,0) & 0x1F;
conn->dirptr = dptr_fetch(status+12,&dptr_num);
if (!conn->dirptr)
goto SearchEmpty;
string_set(&conn->dirpath,dptr_path(dptr_num));
- if (!case_sensitive)
- strnorm(mask);
+ fstrcpy(mask, dptr_wcard(dptr_num));
}
- /* turn strings of spaces into a . */
- {
- trim_string(mask,NULL," ");
- if ((p = strrchr(mask,' ')))
- {
- fstring ext;
- fstrcpy(ext,p+1);
- *p = 0;
- trim_string(mask,NULL," ");
- pstrcat(mask,".");
- pstrcat(mask,ext);
- }
- }
-
- /* Convert the formatted mask. (This code lives in trans2.c) */
- mask_convert(mask);
-
- {
- int skip;
- p = mask;
- while(*p)
- {
- if((skip = get_character_len( *p )) != 0 )
- {
- p += skip;
- }
- else
- {
- if (*p != '?' && *p != '*' && !isdoschar(*p))
- {
- DEBUG(5,("Invalid char [%c] in search mask?\n",*p));
- *p = '?';
- }
- p++;
- }
- }
- }
-
- if (!strchr(mask,'.') && strlen(mask)>8)
- {
- fstring tmp;
- fstrcpy(tmp,&mask[8]);
- mask[8] = '.';
- mask[9] = 0;
- pstrcat(mask,tmp);
- }
-
- DEBUG(5,("mask=%s directory=%s\n",mask,directory));
-
if (can_open)
{
p = smb_buf(outbuf) + 3;
}
return(ERROR(ERRDOS,ERRnofids));
}
+ dptr_set_wcard(dptr_num, strdup(mask));
}
DEBUG(4,("dptr_num is %d\n",dptr_num));
make_dir_struct(p,mask,fname,size,mode,date);
dptr_fill(p+12,dptr_num);
numentries++;
- }
- p += DIR_STRUCT_SIZE;
+ }
+ p += DIR_STRUCT_SIZE;
}
}
} /* if (ok ) */
if (!rc && is_mangled(mask))
check_mangled_cache( mask );
- has_wild = strchr(mask,'*') || strchr(mask,'?');
+ has_wild = ms_has_wild(mask);
if (!has_wild) {
pstrcat(directory,"/");
pstring fname;
pstrcpy(fname,dname);
- if(!mask_match(fname, mask, case_sensitive, False)) continue;
+ if(!mask_match(fname, mask, case_sensitive)) continue;
error = ERRnoaccess;
slprintf(fname,sizeof(fname)-1, "%s/%s",directory,dname);
if ((lp_syncalways(SNUM(conn)) || write_through) &&
lp_strict_sync(SNUM(conn)))
- conn->vfs_ops.fsync(fsp->fd);
+ sync_file(conn,fsp);
DEBUG(3,("writebraw2 fnum=%d start=%.0f num=%d wrote=%d\n",
fsp->fnum, (double)startpos, (int)numtowrite,(int)total_written));
nwritten = write_file(fsp,data,startpos,numtowrite);
if (lp_syncalways(SNUM(conn)))
- conn->vfs_ops.fsync(fsp->fd);
+ sync_file(conn,fsp);
if(((nwritten == 0) && (numtowrite != 0))||(nwritten < 0))
return(UNIXERROR(ERRDOS,ERRnoaccess));
nwritten = write_file(fsp,data,startpos,numtowrite);
if (lp_syncalways(SNUM(conn)))
- conn->vfs_ops.fsync(fsp->fd);
+ sync_file(conn,fsp);
if(((nwritten == 0) && (numtowrite != 0))||(nwritten < 0))
return(UNIXERROR(ERRDOS,ERRnoaccess));
size_t numtowrite = SVAL(inbuf,smb_vwv10);
BOOL write_through = BITSETW(inbuf+smb_vwv7,0);
ssize_t nwritten = -1;
- int smb_doff = SVAL(inbuf,smb_vwv11);
+ unsigned int smb_doff = SVAL(inbuf,smb_vwv11);
char *data;
/* If it's an IPC, pass off the pipe handler. */
CHECK_WRITE(fsp);
CHECK_ERROR(fsp);
+ if(smb_doff > smb_len(inbuf))
+ return(ERROR(ERRDOS,ERRbadmem));
+
data = smb_base(inbuf) + smb_doff;
if(CVAL(inbuf,smb_wct) == 14) {
fsp->fnum, (int)numtowrite, (int)nwritten));
if (lp_syncalways(SNUM(conn)) || write_through)
- conn->vfs_ops.fsync(fsp->fd);
+ sync_file(conn,fsp);
return chain_reply(inbuf,outbuf,length,bufsize);
}
if (!fsp) {
file_sync_all(conn);
} else {
- conn->vfs_ops.fsync(fsp->fd);
+ sync_file(conn,fsp);
}
DEBUG(3,("flush\n"));
{
int smb_reverb = SVAL(inbuf,smb_vwv0);
int seq_num;
- int data_len = smb_buflen(inbuf);
+ unsigned int data_len = smb_buflen(inbuf);
int outsize = set_message(outbuf,1,data_len,True);
-
+
+ data_len = MIN(data_len, (sizeof(inbuf)-(smb_buf(inbuf)-inbuf)));
+
/* copy any incoming data back out */
if (data_len > 0)
memcpy(smb_buf(outbuf),smb_buf(inbuf),data_len);
if (!rc && is_mangled(mask))
check_mangled_cache( mask );
- has_wild = strchr(mask,'*') || strchr(mask,'?');
+ has_wild = ms_has_wild(mask);
if (!has_wild) {
/*
pstrcpy(fname,dname);
- if(!mask_match(fname, mask, case_sensitive, False))
+ if(!mask_match(fname, mask, case_sensitive))
continue;
error = ERRnoaccess;
if (!rc && is_mangled(mask))
check_mangled_cache( mask );
- has_wild = strchr(mask,'*') || strchr(mask,'?');
+ has_wild = ms_has_wild(mask);
if (!has_wild) {
pstrcat(directory,"/");
pstring fname;
pstrcpy(fname,dname);
- if(!mask_match(fname, mask, case_sensitive, False))
+ if(!mask_match(fname, mask, case_sensitive))
continue;
error = ERRnoaccess;
nwritten = write_file(fsp,data,startpos,numtowrite);
if(lp_syncalways(SNUM(conn)) || write_through)
- conn->vfs_ops.fsync(fsp->fd);
+ sync_file(conn,fsp);
if(nwritten < (ssize_t)numtowrite)
return(UNIXERROR(ERRHRD,ERRdiskfull));
nwritten = write_file(fsp,data,startpos,numtowrite);
if(lp_syncalways(SNUM(conn)) || write_through)
- conn->vfs_ops.fsync(fsp->fd);
+ sync_file(conn,fsp);
if (nwritten < (ssize_t)numtowrite)
{
return(outsize);
}
+#undef OLD_NTDOMAIN