data to itself. This enables several curl handles to share data. If the curl
handles are used simultaneously, you \fBMUST\fP use the locking methods in the
share handle. See \fIcurl_share_setopt(3)\fP for details.
+.IP CURLOPT_NEW_FILE_PERMS
+Pass a long as a parameter, containing the value of the permissions that will
+be assigned to newly created files on the remote server. The default value is
+\fI0644\fP, but any valid value can be used. The only protocols that can use
+this are \fIsftp://\fP, \fIscp://\fP and \fIfile://\fP. (Added in 7.16.4)
+.IP CURLOPT_NEW_DIRECTORY_PERMS
+Pass a long as a parameter, containing the value of the permissions that will
+be assigned to newly created directories on the remote server. The default
+value is \fI0755\fP, but any valid value can be used. The only protocols that
+can use this are \fIsftp://\fP, \fIscp://\fP and \fIfile://\fP.
+(Added in 7.16.4)
.SH TELNET OPTIONS
.IP CURLOPT_TELNETOPTIONS
Provide a pointer to a curl_slist with variables to pass to the telnet
if(data->reqdata.resume_from)
fp = fopen( file->path, "ab" );
- else
+ else {
+ int fd;
+
+#if defined(WIN32) || defined(MSDOS) || defined(__EMX__)
+ fd = open(file->path, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY,
+ conn->data->set.new_file_perms);
+#else /* !(WIN32 || MSDOS || __EMX__) */
+ fd = open(file->path, O_WRONLY|O_CREAT|O_TRUNC,
+ conn->data->set.new_file_perms);
+#endif /* !(WIN32 || MSDOS || __EMX__) */
+ if (fd < 0) {
+ failf(data, "Can't open %s for writing", file->path);
+ return CURLE_WRITE_ERROR;
+ }
+ close(fd);
fp = fopen(file->path, "wb");
+ }
if(!fp) {
failf(data, "Can't open %s for writing", file->path);
#if (LIBSSH2_APINO >= 200706012030)
do {
scp->ssh_channel = libssh2_scp_send_ex(scp->ssh_session, scp->path,
- LIBSSH2_SFTP_S_IRUSR|
- LIBSSH2_SFTP_S_IWUSR|
- LIBSSH2_SFTP_S_IRGRP|
- LIBSSH2_SFTP_S_IROTH,
+ conn->data->set.new_file_perms,
conn->data->set.infilesize, 0, 0);
if (!scp->ssh_channel &&
(libssh2_session_last_errno(scp->ssh_session) !=
} while (!scp->ssh_channel);
#else /* !(LIBSSH2_APINO >= 200706012030) */
scp->ssh_channel = libssh2_scp_send_ex(scp->ssh_session, scp->path,
- LIBSSH2_SFTP_S_IRUSR|
- LIBSSH2_SFTP_S_IWUSR|
- LIBSSH2_SFTP_S_IRGRP|
- LIBSSH2_SFTP_S_IROTH,
+ conn->data->set.new_file_perms,
conn->data->set.infilesize, 0, 0);
if (!scp->ssh_channel)
return CURLE_FAILED_INIT;
sftp->sftp_handle =
libssh2_sftp_open(sftp->sftp_session, sftp->path,
LIBSSH2_FXF_WRITE|LIBSSH2_FXF_CREAT|LIBSSH2_FXF_TRUNC,
- LIBSSH2_SFTP_S_IRUSR|LIBSSH2_SFTP_S_IWUSR|
- LIBSSH2_SFTP_S_IRGRP|LIBSSH2_SFTP_S_IROTH);
+ data->set.new_file_perms);
if (!sftp->sftp_handle &&
(libssh2_session_last_errno(sftp->ssh_session) !=
LIBSSH2_ERROR_EAGAIN)) {
sftp->sftp_handle = libssh2_sftp_open(sftp->sftp_session,
sftp->path,
LIBSSH2_FXF_WRITE|LIBSSH2_FXF_CREAT|LIBSSH2_FXF_TRUNC,
- LIBSSH2_SFTP_S_IRUSR|LIBSSH2_SFTP_S_IWUSR|
- LIBSSH2_SFTP_S_IRGRP|LIBSSH2_SFTP_S_IROTH);
+ data->set.new_file_perms);
if (!sftp->sftp_handle &&
(libssh2_session_last_errno(sftp->ssh_session) !=
LIBSSH2_ERROR_EAGAIN)) {
sftp->sftp_handle =
libssh2_sftp_open(sftp->sftp_session, sftp->path,
LIBSSH2_FXF_WRITE|LIBSSH2_FXF_CREAT|LIBSSH2_FXF_TRUNC,
- LIBSSH2_SFTP_S_IRUSR|LIBSSH2_SFTP_S_IWUSR|
- LIBSSH2_SFTP_S_IRGRP|LIBSSH2_SFTP_S_IROTH);
+ data->set.new_file_perms);
if (!sftp->sftp_handle) {
err = libssh2_sftp_last_error(sftp->sftp_session);
if (((err == LIBSSH2_FX_NO_SUCH_FILE) ||
if (res == 0) {
sftp->sftp_handle = libssh2_sftp_open(sftp->sftp_session, sftp->path,
LIBSSH2_FXF_WRITE|LIBSSH2_FXF_CREAT|LIBSSH2_FXF_TRUNC,
- LIBSSH2_SFTP_S_IRUSR|LIBSSH2_SFTP_S_IWUSR|
- LIBSSH2_SFTP_S_IRGRP|LIBSSH2_SFTP_S_IROTH);
+ data->set.new_file_perms);
}
}
if (!sftp->sftp_handle) {
do {
sftp->sftp_handle =
libssh2_sftp_open(sftp->sftp_session, sftp->path, LIBSSH2_FXF_READ,
- LIBSSH2_SFTP_S_IRUSR|LIBSSH2_SFTP_S_IWUSR|
- LIBSSH2_SFTP_S_IRGRP|LIBSSH2_SFTP_S_IROTH);
+ data->set.new_file_perms);
if (!sftp->sftp_handle &&
(libssh2_session_last_errno(sftp->ssh_session) !=
LIBSSH2_ERROR_EAGAIN)) {
#else /* !(LIBSSH2_APINO >= 200706012030) */
sftp->sftp_handle =
libssh2_sftp_open(sftp->sftp_session, sftp->path, LIBSSH2_FXF_READ,
- LIBSSH2_SFTP_S_IRUSR|LIBSSH2_SFTP_S_IWUSR|
- LIBSSH2_SFTP_S_IRGRP|LIBSSH2_SFTP_S_IROTH);
+ data->set.new_file_perms);
if (!sftp->sftp_handle) {
err = libssh2_sftp_last_error(sftp->sftp_session);
failf(conn->data, "Could not open remote file for reading: %s",
/* 'mode' - parameter is preliminary - default to 0644 */
#if (LIBSSH2_APINO >= 200706012030)
while ((rc = libssh2_sftp_mkdir(sftp->sftp_session, sftp->path,
- LIBSSH2_SFTP_S_IRWXU |
- LIBSSH2_SFTP_S_IRGRP | LIBSSH2_SFTP_S_IXGRP |
- LIBSSH2_SFTP_S_IROTH | LIBSSH2_SFTP_S_IXOTH)) ==
+ conn->data->set.new_directory_perms)) ==
LIBSSH2_ERROR_EAGAIN);
#else /* !(LIBSSH2_APINO >= 200706012030) */
rc = libssh2_sftp_mkdir(sftp->sftp_session, sftp->path,
- LIBSSH2_SFTP_S_IRWXU |
- LIBSSH2_SFTP_S_IRGRP | LIBSSH2_SFTP_S_IXGRP |
- LIBSSH2_SFTP_S_IROTH | LIBSSH2_SFTP_S_IXOTH);
+ conn->data->set.new_directory_perms);
#endif /* !(LIBSSH2_APINO >= 200706012030) */
*slash_pos = '/';
++slash_pos;
data->set.ssh_auth_types = CURLSSH_AUTH_DEFAULT; /* defaults to any auth
type */
+ data->set.new_file_perms = 0644; /* Default permissions */
+ data->set.new_directory_perms = 0755; /* Default permissions */
/* most recent connection is not yet defined */
data->state.lastconnect = -1;
*/
data->set.http_ce_skip = (bool)(0 == va_arg(param, long));
break;
+
+ case CURLOPT_NEW_FILE_PERMS:
+ /*
+ * Uses these permissions instead of 0644
+ */
+ data->set.new_file_perms = va_arg(param, long);
+ break;
+
+ case CURLOPT_NEW_DIRECTORY_PERMS:
+ /*
+ * Uses these permissions instead of 0755
+ */
+ data->set.new_directory_perms = va_arg(param, long);
+ break;
+
default:
/* unknown tag and its companion, just ignore: */
result = CURLE_FAILED_INIT; /* correct this */