mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-10 01:17:44 +03:00
journal-gatewayd: add --directory option (#3913)
Serve journals in the specified directory instead of default journals.
This commit is contained in:
parent
23dab159d7
commit
1aa1e59c7f
@ -100,6 +100,16 @@
|
|||||||
with <option>--cert=</option>.</para></listitem>
|
with <option>--cert=</option>.</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>-D <replaceable>DIR</replaceable></option></term>
|
||||||
|
<term><option>--directory=<replaceable>DIR</replaceable></option></term>
|
||||||
|
|
||||||
|
<listitem><para>Takes a directory path as argument. If
|
||||||
|
specified, <command>systemd-journal-gatewayd</command> will serve the
|
||||||
|
specified journal directory <replaceable>DIR</replaceable> instead of
|
||||||
|
the default runtime and system journal paths.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<xi:include href="standard-options.xml" xpointer="help" />
|
<xi:include href="standard-options.xml" xpointer="help" />
|
||||||
<xi:include href="standard-options.xml" xpointer="version" />
|
<xi:include href="standard-options.xml" xpointer="version" />
|
||||||
</variablelist>
|
</variablelist>
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
static char *arg_key_pem = NULL;
|
static char *arg_key_pem = NULL;
|
||||||
static char *arg_cert_pem = NULL;
|
static char *arg_cert_pem = NULL;
|
||||||
static char *arg_trust_pem = NULL;
|
static char *arg_trust_pem = NULL;
|
||||||
|
static char *arg_directory = NULL;
|
||||||
|
|
||||||
typedef struct RequestMeta {
|
typedef struct RequestMeta {
|
||||||
sd_journal *journal;
|
sd_journal *journal;
|
||||||
@ -115,7 +116,10 @@ static int open_journal(RequestMeta *m) {
|
|||||||
if (m->journal)
|
if (m->journal)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return sd_journal_open(&m->journal, SD_JOURNAL_LOCAL_ONLY|SD_JOURNAL_SYSTEM);
|
if (arg_directory)
|
||||||
|
return sd_journal_open_directory(&m->journal, arg_directory, 0);
|
||||||
|
else
|
||||||
|
return sd_journal_open(&m->journal, SD_JOURNAL_LOCAL_ONLY|SD_JOURNAL_SYSTEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int request_meta_ensure_tmp(RequestMeta *m) {
|
static int request_meta_ensure_tmp(RequestMeta *m) {
|
||||||
@ -878,7 +882,8 @@ static void help(void) {
|
|||||||
" --version Show package version\n"
|
" --version Show package version\n"
|
||||||
" --cert=CERT.PEM Server certificate in PEM format\n"
|
" --cert=CERT.PEM Server certificate in PEM format\n"
|
||||||
" --key=KEY.PEM Server key in PEM format\n"
|
" --key=KEY.PEM Server key in PEM format\n"
|
||||||
" --trust=CERT.PEM Certificat authority certificate in PEM format\n",
|
" --trust=CERT.PEM Certificat authority certificate in PEM format\n"
|
||||||
|
" -D --directory=PATH Serve journal files in directory\n",
|
||||||
program_invocation_short_name);
|
program_invocation_short_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -893,11 +898,12 @@ static int parse_argv(int argc, char *argv[]) {
|
|||||||
int r, c;
|
int r, c;
|
||||||
|
|
||||||
static const struct option options[] = {
|
static const struct option options[] = {
|
||||||
{ "help", no_argument, NULL, 'h' },
|
{ "help", no_argument, NULL, 'h' },
|
||||||
{ "version", no_argument, NULL, ARG_VERSION },
|
{ "version", no_argument, NULL, ARG_VERSION },
|
||||||
{ "key", required_argument, NULL, ARG_KEY },
|
{ "key", required_argument, NULL, ARG_KEY },
|
||||||
{ "cert", required_argument, NULL, ARG_CERT },
|
{ "cert", required_argument, NULL, ARG_CERT },
|
||||||
{ "trust", required_argument, NULL, ARG_TRUST },
|
{ "trust", required_argument, NULL, ARG_TRUST },
|
||||||
|
{ "directory", required_argument, NULL, 'D' },
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -951,6 +957,9 @@ static int parse_argv(int argc, char *argv[]) {
|
|||||||
#else
|
#else
|
||||||
log_error("Option --trust is not available.");
|
log_error("Option --trust is not available.");
|
||||||
#endif
|
#endif
|
||||||
|
case 'D':
|
||||||
|
arg_directory = optarg;
|
||||||
|
break;
|
||||||
|
|
||||||
case '?':
|
case '?':
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
Loading…
Reference in New Issue
Block a user