~ubuntu-branches/ubuntu/saucy/curl/saucy-201307251546

« back to all changes in this revision

Viewing changes to lib/ssh.c

  • Committer: Package Import Robot
  • Author(s): Alessandro Ghedini
  • Date: 2012-03-23 16:24:51 UTC
  • mto: (3.6.1 experimental) (1.3.1)
  • mto: This revision was merged to the branch mainline in revision 59.
  • Revision ID: package-import@ubuntu.com-20120323162451-z4gstlabjkgnrh7h
Tags: upstream-7.25.0
ImportĀ upstreamĀ versionĀ 7.25.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 *                            | (__| |_| |  _ <| |___
6
6
 *                             \___|\___/|_| \_\_____|
7
7
 *
8
 
 * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
 
8
 * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
9
9
 *
10
10
 * This software is licensed as described in the file COPYING, which
11
11
 * you should have received as part of this distribution. The terms
108
108
                         have their definition hidden well */
109
109
#endif
110
110
 
 
111
#define sftp_libssh2_realpath(s,p,t,m) \
 
112
        libssh2_sftp_symlink_ex((s), (p), curlx_uztoui(strlen(p)), \
 
113
                                (t), (m), LIBSSH2_SFTP_REALPATH)
 
114
 
111
115
/* Local functions: */
112
116
static const char *sftp_libssh2_strerror(unsigned long err);
113
117
static LIBSSH2_ALLOC_FUNC(my_libssh2_malloc);
225
229
#endif  /* CURL_LIBSSH2_DEBUG */
226
230
  if(num_prompts == 1) {
227
231
    responses[0].text = strdup(conn->passwd);
228
 
    responses[0].length = (unsigned int)strlen(conn->passwd);
 
232
    responses[0].length = curlx_uztoui(strlen(conn->passwd));
229
233
  }
230
234
  (void)prompts;
231
235
  (void)abstract;
734
738
       */
735
739
      sshc->authlist = libssh2_userauth_list(sshc->ssh_session,
736
740
                                             conn->user,
737
 
                                             (unsigned int)strlen(conn->user));
 
741
                                             curlx_uztoui(strlen(conn->user)));
738
742
 
739
743
      if(!sshc->authlist) {
740
744
        if((err = libssh2_session_last_errno(sshc->ssh_session)) ==
827
831
       */
828
832
      rc = libssh2_userauth_publickey_fromfile_ex(sshc->ssh_session,
829
833
                                                  conn->user,
830
 
                                                  (unsigned int)
831
 
                                                  strlen(conn->user),
 
834
                                                  curlx_uztoui(
 
835
                                                    strlen(conn->user)),
832
836
                                                  sshc->rsa_pub,
833
837
                                                  sshc->rsa, sshc->passphrase);
834
838
      if(rc == LIBSSH2_ERROR_EAGAIN) {
866
870
 
867
871
    case SSH_AUTH_PASS:
868
872
      rc = libssh2_userauth_password_ex(sshc->ssh_session, conn->user,
869
 
                                        (unsigned int)strlen(conn->user),
 
873
                                        curlx_uztoui(strlen(conn->user)),
870
874
                                        conn->passwd,
871
 
                                        (unsigned int)strlen(conn->passwd),
 
875
                                        curlx_uztoui(strlen(conn->passwd)),
872
876
                                        NULL);
873
877
      if(rc == LIBSSH2_ERROR_EAGAIN) {
874
878
        break;
911
915
      /* Authentication failed. Continue with keyboard-interactive now. */
912
916
      rc = libssh2_userauth_keyboard_interactive_ex(sshc->ssh_session,
913
917
                                                    conn->user,
914
 
                                                    (unsigned int)
915
 
                                                    strlen(conn->user),
 
918
                                                    curlx_uztoui(
 
919
                                                      strlen(conn->user)),
916
920
                                                    &kbd_callback);
917
921
      if(rc == LIBSSH2_ERROR_EAGAIN) {
918
922
        break;
982
986
      /*
983
987
       * Get the "home" directory
984
988
       */
985
 
      rc = libssh2_sftp_realpath(sshc->sftp_session, ".",
 
989
      rc = sftp_libssh2_realpath(sshc->sftp_session, ".",
986
990
                                 tempHome, PATH_MAX-1);
987
991
      if(rc == LIBSSH2_ERROR_EAGAIN) {
988
992
        break;
1271
1275
         * first.  This takes an extra protocol round trip.
1272
1276
         */
1273
1277
        rc = libssh2_sftp_stat_ex(sshc->sftp_session, sshc->quote_path2,
1274
 
                                  (unsigned int)strlen(sshc->quote_path2),
 
1278
                                  curlx_uztoui(strlen(sshc->quote_path2)),
1275
1279
                                  LIBSSH2_SFTP_STAT,
1276
1280
                                  &sshc->quote_attrs);
1277
1281
        if(rc == LIBSSH2_ERROR_EAGAIN) {
1350
1354
 
1351
1355
    case SSH_SFTP_QUOTE_SETSTAT:
1352
1356
      rc = libssh2_sftp_stat_ex(sshc->sftp_session, sshc->quote_path2,
1353
 
                                (unsigned int)strlen(sshc->quote_path2),
 
1357
                                curlx_uztoui(strlen(sshc->quote_path2)),
1354
1358
                                LIBSSH2_SFTP_SETSTAT,
1355
1359
                                &sshc->quote_attrs);
1356
1360
      if(rc == LIBSSH2_ERROR_EAGAIN) {
1374
1378
 
1375
1379
    case SSH_SFTP_QUOTE_SYMLINK:
1376
1380
      rc = libssh2_sftp_symlink_ex(sshc->sftp_session, sshc->quote_path1,
1377
 
                                   (unsigned int)strlen(sshc->quote_path1),
 
1381
                                   curlx_uztoui(strlen(sshc->quote_path1)),
1378
1382
                                   sshc->quote_path2,
1379
 
                                   (unsigned int)strlen(sshc->quote_path2),
 
1383
                                   curlx_uztoui(strlen(sshc->quote_path2)),
1380
1384
                                   LIBSSH2_SFTP_SYMLINK);
1381
1385
      if(rc == LIBSSH2_ERROR_EAGAIN) {
1382
1386
        break;
1399
1403
 
1400
1404
    case SSH_SFTP_QUOTE_MKDIR:
1401
1405
      rc = libssh2_sftp_mkdir_ex(sshc->sftp_session, sshc->quote_path1,
1402
 
                                 (unsigned int)strlen(sshc->quote_path1),
 
1406
                                 curlx_uztoui(strlen(sshc->quote_path1)),
1403
1407
                                 data->set.new_directory_perms);
1404
1408
      if(rc == LIBSSH2_ERROR_EAGAIN) {
1405
1409
        break;
1419
1423
 
1420
1424
    case SSH_SFTP_QUOTE_RENAME:
1421
1425
      rc = libssh2_sftp_rename_ex(sshc->sftp_session, sshc->quote_path1,
1422
 
                                  (unsigned int)strlen(sshc->quote_path1),
 
1426
                                  curlx_uztoui(strlen(sshc->quote_path1)),
1423
1427
                                  sshc->quote_path2,
1424
 
                                  (unsigned int)strlen(sshc->quote_path2),
 
1428
                                  curlx_uztoui(strlen(sshc->quote_path2)),
1425
1429
                                  LIBSSH2_SFTP_RENAME_OVERWRITE |
1426
1430
                                  LIBSSH2_SFTP_RENAME_ATOMIC |
1427
1431
                                  LIBSSH2_SFTP_RENAME_NATIVE);
1446
1450
 
1447
1451
    case SSH_SFTP_QUOTE_RMDIR:
1448
1452
      rc = libssh2_sftp_rmdir_ex(sshc->sftp_session, sshc->quote_path1,
1449
 
                                 (unsigned int)strlen(sshc->quote_path1));
 
1453
                                 curlx_uztoui(strlen(sshc->quote_path1)));
1450
1454
      if(rc == LIBSSH2_ERROR_EAGAIN) {
1451
1455
        break;
1452
1456
      }
1465
1469
 
1466
1470
    case SSH_SFTP_QUOTE_UNLINK:
1467
1471
      rc = libssh2_sftp_unlink_ex(sshc->sftp_session, sshc->quote_path1,
1468
 
                                  (unsigned int)strlen(sshc->quote_path1));
 
1472
                                  curlx_uztoui(strlen(sshc->quote_path1)));
1469
1473
      if(rc == LIBSSH2_ERROR_EAGAIN) {
1470
1474
        break;
1471
1475
      }
1509
1513
        LIBSSH2_SFTP_ATTRIBUTES attrs;
1510
1514
        if(data->state.resume_from < 0) {
1511
1515
          rc = libssh2_sftp_stat_ex(sshc->sftp_session, sftp_scp->path,
1512
 
                                    (unsigned int)strlen(sftp_scp->path),
 
1516
                                    curlx_uztoui(strlen(sftp_scp->path)),
1513
1517
                                    LIBSSH2_SFTP_STAT, &attrs);
1514
1518
          if(rc == LIBSSH2_ERROR_EAGAIN) {
1515
1519
            break;
1540
1544
 
1541
1545
      sshc->sftp_handle =
1542
1546
        libssh2_sftp_open_ex(sshc->sftp_session, sftp_scp->path,
1543
 
                             (unsigned int)strlen(sftp_scp->path),
 
1547
                             curlx_uztoui(strlen(sftp_scp->path)),
1544
1548
                             flags, data->set.new_file_perms,
1545
1549
                             LIBSSH2_SFTP_OPENFILE);
1546
1550
 
1699
1703
    case SSH_SFTP_CREATE_DIRS_MKDIR:
1700
1704
      /* 'mode' - parameter is preliminary - default to 0644 */
1701
1705
      rc = libssh2_sftp_mkdir_ex(sshc->sftp_session, sftp_scp->path,
1702
 
                                 (unsigned int)strlen(sftp_scp->path),
 
1706
                                 curlx_uztoui(strlen(sftp_scp->path)),
1703
1707
                                 data->set.new_directory_perms);
1704
1708
      if(rc == LIBSSH2_ERROR_EAGAIN) {
1705
1709
        break;
1733
1737
       */
1734
1738
      sshc->sftp_handle = libssh2_sftp_open_ex(sshc->sftp_session,
1735
1739
                                               sftp_scp->path,
1736
 
                                               (unsigned int)
1737
 
                                               strlen(sftp_scp->path),
 
1740
                                               curlx_uztoui(
 
1741
                                                 strlen(sftp_scp->path)),
1738
1742
                                               0, 0, LIBSSH2_SFTP_OPENDIR);
1739
1743
      if(!sshc->sftp_handle) {
1740
1744
        if(libssh2_session_last_errno(sshc->ssh_session) ==
1875
1879
      sshc->readdir_len =
1876
1880
        libssh2_sftp_symlink_ex(sshc->sftp_session,
1877
1881
                                sshc->readdir_linkPath,
1878
 
                                (unsigned int) strlen(sshc->readdir_linkPath),
 
1882
                                curlx_uztoui(strlen(sshc->readdir_linkPath)),
1879
1883
                                sshc->readdir_filename,
1880
1884
                                PATH_MAX, LIBSSH2_SFTP_READLINK);
1881
1885
      if(sshc->readdir_len == LIBSSH2_ERROR_EAGAIN) {
1961
1965
       */
1962
1966
      sshc->sftp_handle =
1963
1967
        libssh2_sftp_open_ex(sshc->sftp_session, sftp_scp->path,
1964
 
                             (unsigned int)strlen(sftp_scp->path),
 
1968
                             curlx_uztoui(strlen(sftp_scp->path)),
1965
1969
                             LIBSSH2_FXF_READ, data->set.new_file_perms,
1966
1970
                             LIBSSH2_SFTP_OPENFILE);
1967
1971
      if(!sshc->sftp_handle) {
1988
1992
      LIBSSH2_SFTP_ATTRIBUTES attrs;
1989
1993
 
1990
1994
      rc = libssh2_sftp_stat_ex(sshc->sftp_session, sftp_scp->path,
1991
 
                                (unsigned int)strlen(sftp_scp->path),
 
1995
                                curlx_uztoui(strlen(sftp_scp->path)),
1992
1996
                                LIBSSH2_SFTP_STAT, &attrs);
1993
1997
      if(rc == LIBSSH2_ERROR_EAGAIN) {
1994
1998
        break;