- (djm) OpenBSD CVS Sync
- deraadt@cvs.openbsd.org 2003/03/26 04:02:51 [sftp-server.c] one last fix to the tree: race fix broke stuff; pr 3169; srp@srparish.net, help from djm
This commit is contained in:
parent
68d893dfed
commit
b3207e8061
|
@ -1,3 +1,10 @@
|
||||||
|
20030326
|
||||||
|
- (djm) OpenBSD CVS Sync
|
||||||
|
- deraadt@cvs.openbsd.org 2003/03/26 04:02:51
|
||||||
|
[sftp-server.c]
|
||||||
|
one last fix to the tree: race fix broke stuff; pr 3169;
|
||||||
|
srp@srparish.net, help from djm
|
||||||
|
|
||||||
20030325
|
20030325
|
||||||
- (djm) Fix getpeerid support for 64 bit BE systems. From
|
- (djm) Fix getpeerid support for 64 bit BE systems. From
|
||||||
Arnd Bergmann <arndb@de.ibm.com>
|
Arnd Bergmann <arndb@de.ibm.com>
|
||||||
|
@ -1252,4 +1259,4 @@
|
||||||
save auth method before monitor_reset_key_state(); bugzilla bug #284;
|
save auth method before monitor_reset_key_state(); bugzilla bug #284;
|
||||||
ok provos@
|
ok provos@
|
||||||
|
|
||||||
$Id: ChangeLog,v 1.2641 2003/03/24 22:07:52 djm Exp $
|
$Id: ChangeLog,v 1.2642 2003/03/26 05:01:11 djm Exp $
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
RCSID("$OpenBSD: sftp-server.c,v 1.40 2003/03/05 22:33:43 markus Exp $");
|
RCSID("$OpenBSD: sftp-server.c,v 1.41 2003/03/26 04:02:51 deraadt Exp $");
|
||||||
|
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
#include "bufaux.h"
|
#include "bufaux.h"
|
||||||
|
@ -836,20 +836,31 @@ process_rename(void)
|
||||||
u_int32_t id;
|
u_int32_t id;
|
||||||
char *oldpath, *newpath;
|
char *oldpath, *newpath;
|
||||||
int status;
|
int status;
|
||||||
|
struct stat sb;
|
||||||
|
|
||||||
id = get_int();
|
id = get_int();
|
||||||
oldpath = get_string(NULL);
|
oldpath = get_string(NULL);
|
||||||
newpath = get_string(NULL);
|
newpath = get_string(NULL);
|
||||||
TRACE("rename id %u old %s new %s", id, oldpath, newpath);
|
TRACE("rename id %u old %s new %s", id, oldpath, newpath);
|
||||||
/* fail if 'newpath' exists */
|
status = SSH2_FX_FAILURE;
|
||||||
if (link(oldpath, newpath) == -1)
|
if (lstat(oldpath, &sb) == -1)
|
||||||
status = errno_to_portable(errno);
|
status = errno_to_portable(errno);
|
||||||
else if (unlink(oldpath) == -1) {
|
else if (S_ISREG(sb.st_mode)) {
|
||||||
status = errno_to_portable(errno);
|
/* Race-free rename of regular files */
|
||||||
/* clean spare link */
|
if (link(oldpath, newpath) == -1)
|
||||||
unlink(newpath);
|
status = errno_to_portable(errno);
|
||||||
} else
|
else if (unlink(oldpath) == -1) {
|
||||||
status = SSH2_FX_OK;
|
status = errno_to_portable(errno);
|
||||||
|
/* clean spare link */
|
||||||
|
unlink(newpath);
|
||||||
|
} else
|
||||||
|
status = SSH2_FX_OK;
|
||||||
|
} else if (stat(newpath, &sb) == -1) {
|
||||||
|
if (rename(oldpath, newpath) == -1)
|
||||||
|
status = errno_to_portable(errno);
|
||||||
|
else
|
||||||
|
status = SSH2_FX_OK;
|
||||||
|
}
|
||||||
send_status(id, status);
|
send_status(id, status);
|
||||||
xfree(oldpath);
|
xfree(oldpath);
|
||||||
xfree(newpath);
|
xfree(newpath);
|
||||||
|
|
Loading…
Reference in New Issue