mirror of
https://github.com/samba-team/samba.git
synced 2025-01-13 13:18:06 +03:00
cli_open() wasn't handling DENY_FCB or O_WRONLY correctly.
After fixing that I needed to use O_RDWR instead of O_WRONLY in several places to avoid the silly bug in MS servers that doesn't allow getattrE on a file opened with O_WRONLY
This commit is contained in:
parent
2071105b43
commit
e21aa4cb08
@ -981,7 +981,7 @@ static void do_put(char *rname,char *lname)
|
||||
struct timeval tp_start;
|
||||
GetTimeOfDay(&tp_start);
|
||||
|
||||
fnum = cli_open(cli, rname, O_WRONLY|O_CREAT|O_TRUNC, DENY_NONE);
|
||||
fnum = cli_open(cli, rname, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE);
|
||||
|
||||
if (fnum == -1) {
|
||||
DEBUG(0,("%s opening remote file %s\n",cli_errstr(cli),rname));
|
||||
|
@ -994,7 +994,7 @@ static int get_file(file_info2 finfo)
|
||||
DEBUG(5, ("get_file: file: %s, size %i\n", finfo.name, (int)finfo.size));
|
||||
|
||||
if (ensurepath(finfo.name) &&
|
||||
(fnum=cli_open(cli, finfo.name, O_WRONLY|O_CREAT|O_TRUNC, DENY_NONE)) == -1) {
|
||||
(fnum=cli_open(cli, finfo.name, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE)) == -1) {
|
||||
DEBUG(0, ("abandoning restore\n"));
|
||||
return(False);
|
||||
}
|
||||
|
@ -328,7 +328,7 @@ smb_print(struct cli_state *cli, /* I - SMB connection */
|
||||
* Open the printer device...
|
||||
*/
|
||||
|
||||
if ((fnum = cli_open(cli, title, O_WRONLY | O_CREAT | O_TRUNC, DENY_NONE)) == -1)
|
||||
if ((fnum = cli_open(cli, title, O_RDWR | O_CREAT | O_TRUNC, DENY_NONE)) == -1)
|
||||
{
|
||||
fprintf(stderr, "ERROR: %s opening remote file %s\n",
|
||||
cli_errstr(cli), title);
|
||||
|
@ -1231,6 +1231,7 @@ int cli_nt_create(struct cli_state *cli, char *fname)
|
||||
|
||||
/****************************************************************************
|
||||
open a file
|
||||
WARNING: if you open with O_WRONLY then getattrE won't work!
|
||||
****************************************************************************/
|
||||
int cli_open(struct cli_state *cli, char *fname, int flags, int share_mode)
|
||||
{
|
||||
@ -1238,12 +1239,6 @@ int cli_open(struct cli_state *cli, char *fname, int flags, int share_mode)
|
||||
unsigned openfn=0;
|
||||
unsigned accessmode=0;
|
||||
|
||||
/* you must open for RW not just write - otherwise getattrE doesn't
|
||||
work! */
|
||||
if ((flags & O_ACCMODE) == O_WRONLY && strncmp(cli->dev, "LPT", 3)) {
|
||||
flags = (flags & ~O_ACCMODE) | O_RDWR;
|
||||
}
|
||||
|
||||
if (flags & O_CREAT)
|
||||
openfn |= (1<<4);
|
||||
if (!(flags & O_EXCL)) {
|
||||
@ -1267,6 +1262,10 @@ int cli_open(struct cli_state *cli, char *fname, int flags, int share_mode)
|
||||
}
|
||||
#endif /* O_SYNC */
|
||||
|
||||
if (share_mode == DENY_FCB) {
|
||||
accessmode = 0xFF;
|
||||
}
|
||||
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
memset(cli->inbuf,'\0',smb_size);
|
||||
|
||||
|
@ -749,7 +749,7 @@ static void run_denytest(int dummy)
|
||||
|
||||
cli_unlink(&cli1, fname);
|
||||
|
||||
fnum1 = cli_open(&cli1, fname, O_WRONLY|O_CREAT, DENY_NONE);
|
||||
fnum1 = cli_open(&cli1, fname, O_RDWR|O_CREAT, DENY_NONE);
|
||||
cli_write(&cli1, fnum1, 0, fname, 0, strlen(fname));
|
||||
cli_close(&cli1, fnum1);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user