diff options
author | Andrew Tridgell <tridge@samba.org> | 1996-05-04 10:48:19 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 1996-05-04 10:48:19 +0000 |
commit | b2a31c9e8118519b13c3625f6d1b46042bcb9501 (patch) | |
tree | 2ba3c5915acf19653c0bf0cb40d221957566000e /source3 | |
parent | 03aeb8af5d97c1be6122ea90d53fa386e22c3046 (diff) | |
download | samba-b2a31c9e8118519b13c3625f6d1b46042bcb9501.tar.gz samba-b2a31c9e8118519b13c3625f6d1b46042bcb9501.tar.xz samba-b2a31c9e8118519b13c3625f6d1b46042bcb9501.zip |
- use issafe()
- map the archive bit in a more robust manner. We now set it when we
first write to the file after opening it.
(This used to be commit d20627b378e41546f00e5aabc86a71889ebc236a)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/smbd/server.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 5d8facef33..605e98be0f 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -257,7 +257,7 @@ int dos_chmod(int cnum,char *fname,int dosmode,struct stat *st) unixmode &= ~(S_IWUSR|S_IWGRP|S_IWOTH); unixmode |= tmp; } - + return(chmod(fname,unixmode)); } @@ -410,8 +410,12 @@ BOOL unix_convert(char *name,int cnum) { if ((! *name) || strchr(name,'/') || !is_8_3(name)) { + char *s; fstring name2; sprintf(name2,"%.6s.XXXXXX",remote_machine); + /* sanitise the name */ + for (s=name2 ; *s ; s++) + if (!issafe(*s)) *s = '_'; strcpy(name,(char *)mktemp(name2)); } return(True); @@ -1227,16 +1231,6 @@ void close_file(int fnum) if (lp_share_modes(SNUM(cnum))) del_share_mode(fnum); - if (Files[fnum].modified) { - struct stat st; - if (fstat(Files[fnum].fd,&st) == 0) { - int dosmode = dos_mode(cnum,Files[fnum].name,&st); - if (!IS_DOS_ARCHIVE(dosmode)) { - dos_chmod(cnum,Files[fnum].name,dosmode | aARCH,&st); - } - } - } - close(Files[fnum].fd); /* NT uses smbclose to start a print - weird */ @@ -1609,7 +1603,16 @@ int write_file(int fnum,char *data,int n) return(0); } - Files[fnum].modified = True; + if (!Files[fnum].modified) { + struct stat st; + Files[fnum].modified = True; + if (fstat(Files[fnum].fd,&st) == 0) { + int dosmode = dos_mode(Files[fnum].cnum,Files[fnum].name,&st); + if (MAP_ARCHIVE(Files[fnum].cnum) && !IS_DOS_ARCHIVE(dosmode)) { + dos_chmod(Files[fnum].cnum,Files[fnum].name,dosmode | aARCH,&st); + } + } + } return(write_data(Files[fnum].fd,data,n)); } |