1 |
|
|
/** |
2 |
|
|
* This file is part of the CernVM File System |
3 |
|
|
* |
4 |
|
|
* This tool signs a CernVM-FS manifest with an X.509 certificate. |
5 |
|
|
*/ |
6 |
|
|
|
7 |
|
|
#include "swissknife_sign.h" |
8 |
|
|
#include "cvmfs_config.h" |
9 |
|
|
|
10 |
|
|
#include <dirent.h> |
11 |
|
|
#include <sys/stat.h> |
12 |
|
|
#include <sys/types.h> |
13 |
|
|
#include <termios.h> |
14 |
|
|
#include <unistd.h> |
15 |
|
|
|
16 |
|
|
#include <cstdio> |
17 |
|
|
#include <cstdlib> |
18 |
|
|
#include <set> |
19 |
|
|
#include <string> |
20 |
|
|
#include <vector> |
21 |
|
|
|
22 |
|
|
#include "compression.h" |
23 |
|
|
#include "hash.h" |
24 |
|
|
#include "logging.h" |
25 |
|
|
#include "manifest.h" |
26 |
|
|
#include "object_fetcher.h" |
27 |
|
|
#include "reflog.h" |
28 |
|
|
#include "signature.h" |
29 |
|
|
#include "signing_tool.h" |
30 |
|
|
#include "smalloc.h" |
31 |
|
|
#include "upload.h" |
32 |
|
|
#include "util/posix.h" |
33 |
|
|
|
34 |
|
|
using namespace std; // NOLINT |
35 |
|
|
|
36 |
|
|
typedef HttpObjectFetcher<> ObjectFetcher; |
37 |
|
|
|
38 |
|
|
int swissknife::CommandSign::Main(const swissknife::ArgumentList &args) { |
39 |
|
|
string manifest_path = *args.find('m')->second; |
40 |
|
|
string repo_url = *args.find('u')->second; |
41 |
|
|
string spooler_definition = *args.find('r')->second; |
42 |
|
|
string temp_dir = *args.find('t')->second; |
43 |
|
|
|
44 |
|
|
string certificate = ""; |
45 |
|
|
if (args.find('c') != args.end()) certificate = *args.find('c')->second; |
46 |
|
|
string priv_key = ""; |
47 |
|
|
if (args.find('k') != args.end()) priv_key = *args.find('k')->second; |
48 |
|
|
string repo_name = ""; |
49 |
|
|
if (args.find('n') != args.end()) repo_name = *args.find('n')->second; |
50 |
|
|
string pwd = ""; |
51 |
|
|
if (args.find('s') != args.end()) pwd = *args.find('s')->second; |
52 |
|
|
string meta_info = ""; |
53 |
|
|
if (args.find('M') != args.end()) meta_info = *args.find('M')->second; |
54 |
|
|
const bool garbage_collectable = (args.count('g') > 0); |
55 |
|
|
const bool bootstrap_shortcuts = (args.count('A') > 0); |
56 |
|
|
const bool return_early = (args.count('e') > 0); |
57 |
|
|
|
58 |
|
|
string reflog_chksum_path; |
59 |
|
|
shash::Any reflog_hash; |
60 |
|
|
if (args.find('R') != args.end()) { |
61 |
|
|
reflog_chksum_path = *args.find('R')->second; |
62 |
|
|
} |
63 |
|
|
|
64 |
|
|
SigningTool signing_tool(this); |
65 |
|
|
return signing_tool.Run(manifest_path, repo_url, spooler_definition, temp_dir, |
66 |
|
|
certificate, priv_key, repo_name, pwd, meta_info, |
67 |
|
|
reflog_chksum_path, garbage_collectable, |
68 |
|
|
bootstrap_shortcuts, return_early); |
69 |
|
|
} |