diff --git a/.travis.yml b/.travis.yml index 22bd322..2f73dce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ matrix: cache: apt before_install: - sudo apt-get update -qq - - sudo apt-get install -qq cppcheck libfuse-dev openjdk-7-jdk libjsoncpp-dev + - sudo apt-get install -qq cppcheck libfuse-dev openjdk-7-jdk - sudo update-alternatives --set java /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java script: - ./autogen.sh @@ -24,7 +24,7 @@ matrix: osx_image: xcode8.3 before_install: - brew update - - brew install truncate jsoncpp + - brew install truncate - brew tap caskroom/cask - brew cask install osxfuse - if [ -f /Library/Filesystems/osxfusefs.fs/Support/load_osxfusefs ]; then sudo chmod +s /Library/Filesystems/osxfusefs.fs/Support/load_osxfusefs ; elif [ -f /Library/Filesystems/osxfuse.fs/Contents/Resources/load_osxfuse ]; then sudo chmod +s /Library/Filesystems/osxfuse.fs/Contents/Resources/load_osxfuse ; fi diff --git a/configure.ac b/configure.ac index a4db042..5adb891 100644 --- a/configure.ac +++ b/configure.ac @@ -176,13 +176,13 @@ dnl dnl For PKG_CONFIG before checking nss/gnutls. dnl this is redundant checking, but we need checking before following. dnl -PKG_CHECK_MODULES([common_lib_checking], [fuse >= ${min_fuse_version} libcurl >= 7.0 libxml-2.0 >= 2.6 jsoncpp >= 0.6 ]) +PKG_CHECK_MODULES([common_lib_checking], [fuse >= ${min_fuse_version} libcurl >= 7.0 libxml-2.0 >= 2.6 ]) AC_MSG_CHECKING([compile s3fs with]) case "${auth_lib}" in openssl) AC_MSG_RESULT(OpenSSL) - PKG_CHECK_MODULES([DEPS], [fuse >= ${min_fuse_version} libcurl >= 7.0 libxml-2.0 >= 2.6 libcrypto >= 0.9 jsoncpp >= 0.6 ]) + PKG_CHECK_MODULES([DEPS], [fuse >= ${min_fuse_version} libcurl >= 7.0 libxml-2.0 >= 2.6 libcrypto >= 0.9 ]) ;; gnutls) AC_MSG_RESULT(GnuTLS-gcrypt) @@ -191,7 +191,7 @@ gnutls) AS_IF([test "$gnutls_nettle" = ""], [AC_CHECK_LIB(gcrypt, gcry_control, [gnutls_nettle=0])]) AS_IF([test $gnutls_nettle = 0], [ - PKG_CHECK_MODULES([DEPS], [fuse >= ${min_fuse_version} libcurl >= 7.0 libxml-2.0 >= 2.6 gnutls >= 2.12.0 jsoncpp >= 0.6 ]) + PKG_CHECK_MODULES([DEPS], [fuse >= ${min_fuse_version} libcurl >= 7.0 libxml-2.0 >= 2.6 gnutls >= 2.12.0 ]) LIBS="-lgnutls -lgcrypt $LIBS" AC_MSG_CHECKING([gnutls is build with]) AC_MSG_RESULT(gcrypt) @@ -205,7 +205,7 @@ nettle) AS_IF([test "$gnutls_nettle" = ""], [AC_CHECK_LIB(nettle, nettle_MD5Init, [gnutls_nettle=1])]) AS_IF([test $gnutls_nettle = 1], [ - PKG_CHECK_MODULES([DEPS], [fuse >= ${min_fuse_version} libcurl >= 7.0 libxml-2.0 >= 2.6 nettle >= 2.7.1 jsoncpp >= 0.6 ]) + PKG_CHECK_MODULES([DEPS], [fuse >= ${min_fuse_version} libcurl >= 7.0 libxml-2.0 >= 2.6 nettle >= 2.7.1 ]) LIBS="-lgnutls -lnettle $LIBS" AC_MSG_CHECKING([gnutls is build with]) AC_MSG_RESULT(nettle) @@ -214,7 +214,7 @@ nettle) ;; nss) AC_MSG_RESULT(NSS) - PKG_CHECK_MODULES([DEPS], [fuse >= ${min_fuse_version} libcurl >= 7.0 libxml-2.0 >= 2.6 nss >= 3.15.0 jsoncpp >= 0.6 ]) + PKG_CHECK_MODULES([DEPS], [fuse >= ${min_fuse_version} libcurl >= 7.0 libxml-2.0 >= 2.6 nss >= 3.15.0 ]) ;; *) AC_MSG_ERROR([unknown ssl library type.]) diff --git a/src/curl.cpp b/src/curl.cpp index d623403..f550e7f 100644 --- a/src/curl.cpp +++ b/src/curl.cpp @@ -42,8 +42,6 @@ #include #include #include -#include -#include #include "common.h" #include "curl.h" @@ -1426,23 +1424,39 @@ bool S3fsCurl::ParseIAMCredentialResponse(const char* response, iamcredmap_t& ke if(!response){ return false; } - - Json::Value root; - Json::Reader reader; - - if (!reader.parse(response, root)) { - return false; + istringstream sscred(response); + string oneline; + keyval.clear(); + while(getline(sscred, oneline, '\n')){ + string::size_type pos; + string key; + string val; + if(string::npos != (pos = oneline.find(IAMCRED_ACCESSKEYID))){ + key = IAMCRED_ACCESSKEYID; + }else if(string::npos != (pos = oneline.find(IAMCRED_SECRETACCESSKEY))){ + key = IAMCRED_SECRETACCESSKEY; + }else if(string::npos != (pos = oneline.find(IAMCRED_ACCESSTOKEN))){ + key = IAMCRED_ACCESSTOKEN; + }else if(string::npos != (pos = oneline.find(IAMCRED_EXPIRATION))){ + key = IAMCRED_EXPIRATION; + }else if(string::npos != (pos = oneline.find(IAMCRED_ROLEARN))){ + key = IAMCRED_ROLEARN; + }else{ + continue; + } + if(string::npos == (pos = oneline.find(':', pos + key.length()))){ + continue; + } + if(string::npos == (pos = oneline.find('\"', pos))){ + continue; + } + oneline = oneline.substr(pos + sizeof(char)); + if(string::npos == (pos = oneline.find('\"'))){ + continue; + } + val = oneline.substr(0, pos); + keyval[key] = val; } - - keyval[string(IAMCRED_ACCESSKEYID)] = root.get(IAMCRED_ACCESSKEYID, "").asString(); - keyval[string(IAMCRED_SECRETACCESSKEY)] = root.get(IAMCRED_SECRETACCESSKEY, "").asString(); - keyval[string(IAMCRED_ACCESSTOKEN)] = root.get(IAMCRED_ACCESSTOKEN, "").asString(); - keyval[string(IAMCRED_EXPIRATION)] = root.get(IAMCRED_EXPIRATION, "").asString(); - - if (S3fsCurl::is_ecs) { - keyval[string(IAMCRED_ROLEARN)] = root.get(IAMCRED_ROLEARN, "").asString(); - } - return true; }