mirror of
https://github.com/curl/curl.git
synced 2025-09-30 16:06:51 +03:00
Changed slightly the SFTP quote commands chmod, chown and chgrp to only
set the attribute that has changed instead of all possible ones. Hopefully, this will solve the "Permission denied" problem that Nagarajan Sreenivasan reported when setting some modes, but regardless, it saves a protocol round trip in the chmod case.
This commit is contained in:
parent
6b7ccde156
commit
b4b6cfdb1c
7
CHANGES
7
CHANGES
|
@ -6,6 +6,13 @@
|
||||||
|
|
||||||
Changelog
|
Changelog
|
||||||
|
|
||||||
|
Daniel Fandrich (10 Jul 2008)
|
||||||
|
- Changed slightly the SFTP quote commands chmod, chown and chgrp to only
|
||||||
|
set the attribute that has changed instead of all possible ones. Hopefully,
|
||||||
|
this will solve the "Permission denied" problem that Nagarajan Sreenivasan
|
||||||
|
reported when setting some modes, but regardless, it saves a protocol
|
||||||
|
round trip in the chmod case.
|
||||||
|
|
||||||
Yang Tse (10 Jul 2008)
|
Yang Tse (10 Jul 2008)
|
||||||
- Peter Lamberg filed bug report #2015126: "poll gives WSAEINVAL when POLLPRI
|
- Peter Lamberg filed bug report #2015126: "poll gives WSAEINVAL when POLLPRI
|
||||||
is set in fdset.events" (http://curl.haxx.se/bug/view.cgi?id=2015126) which
|
is set in fdset.events" (http://curl.haxx.se/bug/view.cgi?id=2015126) which
|
||||||
|
|
|
@ -997,6 +997,11 @@ static CURLcode ssh_statemach_act(struct connectdata *conn)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SSH_SFTP_QUOTE_STAT:
|
case SSH_SFTP_QUOTE_STAT:
|
||||||
|
if(!curl_strnequal(sshc->quote_item->data, "chmod", 5)) {
|
||||||
|
/* Since chown and chgrp only set owner OR group but libssh2 wants to
|
||||||
|
* set them both at once, we need to obtain the current ownership first.
|
||||||
|
* This takes an extra protocol round trip.
|
||||||
|
*/
|
||||||
rc = libssh2_sftp_stat(sshc->sftp_session, sshc->quote_path2,
|
rc = libssh2_sftp_stat(sshc->sftp_session, sshc->quote_path2,
|
||||||
&sshc->quote_attrs);
|
&sshc->quote_attrs);
|
||||||
if(rc == LIBSSH2_ERROR_EAGAIN) {
|
if(rc == LIBSSH2_ERROR_EAGAIN) {
|
||||||
|
@ -1014,10 +1019,12 @@ static CURLcode ssh_statemach_act(struct connectdata *conn)
|
||||||
sshc->actualcode = CURLE_QUOTE_ERROR;
|
sshc->actualcode = CURLE_QUOTE_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Now set the new attributes... */
|
/* Now set the new attributes... */
|
||||||
if(curl_strnequal(sshc->quote_item->data, "chgrp", 5)) {
|
if(curl_strnequal(sshc->quote_item->data, "chgrp", 5)) {
|
||||||
sshc->quote_attrs.gid = strtol(sshc->quote_path1, NULL, 10);
|
sshc->quote_attrs.gid = strtol(sshc->quote_path1, NULL, 10);
|
||||||
|
sshc->quote_attrs.flags = LIBSSH2_SFTP_ATTR_UIDGID;
|
||||||
if(sshc->quote_attrs.gid == 0 && !ISDIGIT(sshc->quote_path1[0])) {
|
if(sshc->quote_attrs.gid == 0 && !ISDIGIT(sshc->quote_path1[0])) {
|
||||||
Curl_safefree(sshc->quote_path1);
|
Curl_safefree(sshc->quote_path1);
|
||||||
sshc->quote_path1 = NULL;
|
sshc->quote_path1 = NULL;
|
||||||
|
@ -1031,6 +1038,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn)
|
||||||
}
|
}
|
||||||
else if(curl_strnequal(sshc->quote_item->data, "chmod", 5)) {
|
else if(curl_strnequal(sshc->quote_item->data, "chmod", 5)) {
|
||||||
sshc->quote_attrs.permissions = strtol(sshc->quote_path1, NULL, 8);
|
sshc->quote_attrs.permissions = strtol(sshc->quote_path1, NULL, 8);
|
||||||
|
sshc->quote_attrs.flags = LIBSSH2_SFTP_ATTR_PERMISSIONS;
|
||||||
/* permissions are octal */
|
/* permissions are octal */
|
||||||
if(sshc->quote_attrs.permissions == 0 &&
|
if(sshc->quote_attrs.permissions == 0 &&
|
||||||
!ISDIGIT(sshc->quote_path1[0])) {
|
!ISDIGIT(sshc->quote_path1[0])) {
|
||||||
|
@ -1046,6 +1054,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn)
|
||||||
}
|
}
|
||||||
else if(curl_strnequal(sshc->quote_item->data, "chown", 5)) {
|
else if(curl_strnequal(sshc->quote_item->data, "chown", 5)) {
|
||||||
sshc->quote_attrs.uid = strtol(sshc->quote_path1, NULL, 10);
|
sshc->quote_attrs.uid = strtol(sshc->quote_path1, NULL, 10);
|
||||||
|
sshc->quote_attrs.flags = LIBSSH2_SFTP_ATTR_UIDGID;
|
||||||
if(sshc->quote_attrs.uid == 0 && !ISDIGIT(sshc->quote_path1[0])) {
|
if(sshc->quote_attrs.uid == 0 && !ISDIGIT(sshc->quote_path1[0])) {
|
||||||
Curl_safefree(sshc->quote_path1);
|
Curl_safefree(sshc->quote_path1);
|
||||||
sshc->quote_path1 = NULL;
|
sshc->quote_path1 = NULL;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user