mirror of
https://github.com/upa/mscp.git
synced 2026-02-15 17:54:43 +08:00
chmod after truncate and setutimes on the remote side.
When the source file permission is r--r--r--, truncate and setutimes AFTER chmod fail due to permission deined. So, do chmod after truncate and setutimes.
This commit is contained in:
@@ -323,12 +323,14 @@ int mscp_setstat(const char *path, struct stat *st, bool preserve_ts, sftp_sessi
|
||||
ret = sftp_setstat(sftp, path, &attr);
|
||||
sftp_err_to_errno(sftp);
|
||||
} else {
|
||||
if ((ret = chmod(path, st->st_mode)) < 0)
|
||||
return ret;
|
||||
if ((ret = truncate(path, st->st_size)) < 0)
|
||||
return ret;
|
||||
if (preserve_ts)
|
||||
ret = setutimes(path, st->st_atim, st->st_mtim);
|
||||
if (preserve_ts) {
|
||||
if ((ret = setutimes(path, st->st_atim, st->st_mtim)) < 0)
|
||||
return ret;
|
||||
}
|
||||
if ((ret = chmod(path, st->st_mode)) < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user