7 #include "cvmfs_config.h"
27 unsigned read_all = 0;
30 if ((read_chunk = read(0, buf+read_all, num_bytes-read_all)) <= 0)
32 read_all += read_chunk;
33 }
while (read_all < num_bytes);
35 if (read_chunk == 0) exit(0);
36 assert(read_all == num_bytes);
41 const uint16_t num_bytes)
44 unsigned wrote_all = 0;
47 if ((wrote_chunk = write(1, buf+wrote_all, num_bytes-wrote_all)) <= 0)
49 wrote_all += wrote_chunk;
50 }
while (wrote_all < num_bytes);
52 assert(wrote_all == num_bytes);
60 len = (buf[0] << 8) | buf[1];
70 li = (len >> 8) & 0xff;
81 if (args.find(
'v') != args.end()) verify =
true;
82 if ((args.find(
's') != args.end()) && verify) {
84 "invalid option combination (sign + verify)");
89 string repository_url;
90 string certificate_path;
91 string certificate_password;
93 uint64_t max_age = kDefaultMaxAge;
95 repository_url = *args.find(
'r')->second;
97 if (args.find(
'e') != args.end()) erlang =
true;
99 certificate_path = *args.find(
'c')->second;
100 if (args.find(
'p') != args.end())
101 certificate_password = *args.find(
'p')->second;
102 if (args.find(
'a') != args.end()) {
113 fqrn = *args.find(
'f')->second;
114 key_path = *args.find(
'k')->second;
115 if (args.find(
't') != args.end()) text = *args.find(
't')->second;
121 if (!InitVerifyingSignatureManager(key_path)) {
125 const bool follow_redirects =
false;
126 const unsigned max_pool_handles = 2;
128 (args.find(
'@') != args.end()) ? *args.find(
'@')->second :
"";
129 if (!this->InitDownloadManager(follow_redirects, proxy, max_pool_handles)) {
135 signature_manager());
136 retval_wl = whitelist.
LoadUrl(repository_url);
144 const char *ready =
"ready";
145 WriteErlang(reinterpret_cast<const unsigned char *>(ready), 5);
151 unsigned char buf[65000];
153 text = string(reinterpret_cast<char *>(buf), length);
158 while ((num_read = read(0, &c, 1)) == 1) {
163 if (num_read != 1)
return exit_code;
167 if ((time(NULL) + 3600*24*3) > whitelist.
expires()) {
170 signature_manager());
171 retval_wl = refresh.
LoadUrl(repository_url);
179 retval_ltr = letter.
Verify(max_age, &message, &cert);
200 if ((exit_code == 0) && (message.length() > 60000))
202 WriteErlang(reinterpret_cast<unsigned char *>(&exit_code), 1);
204 WriteErlang(reinterpret_cast<const unsigned char *>(message.data()),
217 if (!InitSigningSignatureManager(certificate_path,
219 certificate_password)) {
225 while (read(0, &c, 1) == 1) {
234 text_letter.
Sign(hash_algorithm).c_str());
Failures LoadUrl(const std::string &base_url)
Failures VerifyLoadedCertificate() const
Failures Verify(uint64_t max_age, std::string *msg, std::string *cert)
assert((mem||(size==0))&&"Out Of Memory")
static void ReadStdinBytes(unsigned char *buf, const uint16_t num_bytes)
std::string Sign(const shash::Algorithms hash_algorithm)
const char * Code2Ascii(const Failures error)
static void WriteStdoutBytes(const unsigned char *buf, const uint16_t num_bytes)
int Main(const ArgumentList &args)
const whitelist::Whitelist * whitelist() const
uint64_t String2Uint64(const string &value)
std::map< char, SharedPtr< std::string > > ArgumentList
Algorithms ParseHashAlgorithm(const string &algorithm_option)
const char * Code2Ascii(const Failures error)
static void WriteErlang(const unsigned char *buf, int len)
static uint16_t ReadErlang(unsigned char *buf)
CVMFS_EXPORT void LogCvmfs(const LogSource source, const int mask, const char *format,...)