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()) {
114 fqrn = *args.find(
'f')->second;
115 key_path = *args.find(
'k')->second;
116 if (args.find(
't') != args.end()) text = *args.find(
't')->second;
117 if (args.find(
'z') != args.end()) cacrl_path = *args.find(
'z')->second;
123 if (!InitVerifyingSignatureManager(key_path, cacrl_path)) {
127 const bool follow_redirects =
false;
128 const unsigned max_pool_handles = 2;
130 (args.find(
'@') != args.end()) ? *args.find(
'@')->second :
"";
131 if (!this->InitDownloadManager(follow_redirects, proxy, max_pool_handles)) {
137 signature_manager());
138 retval_wl = whitelist.
LoadUrl(repository_url);
146 const char *ready =
"ready";
147 WriteErlang(reinterpret_cast<const unsigned char *>(ready), 5);
153 unsigned char buf[65000];
155 text = string(reinterpret_cast<char *>(buf), length);
160 while ((num_read = read(0, &c, 1)) == 1) {
165 if (num_read != 1)
return exit_code;
169 if ((time(NULL) + 3600*24*3) > whitelist.
expires()) {
172 signature_manager());
173 retval_wl = refresh.
LoadUrl(repository_url);
181 retval_ltr = letter.
Verify(max_age, &message, &cert);
202 if ((exit_code == 0) && (message.length() > 60000))
204 WriteErlang(reinterpret_cast<unsigned char *>(&exit_code), 1);
206 WriteErlang(reinterpret_cast<const unsigned char *>(message.data()),
219 if (!InitSigningSignatureManager(certificate_path,
221 certificate_password)) {
227 while (read(0, &c, 1) == 1) {
236 text_letter.
Sign(hash_algorithm).c_str());
#define LogCvmfs(source, mask,...)
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)