projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Relayd: disallow-clear option parsing
[lttng-tools.git]
/
src
/
bin
/
lttng-relayd
/
main.c
diff --git
a/src/bin/lttng-relayd/main.c
b/src/bin/lttng-relayd/main.c
index 1e2e9050fef2d6d77ca78e9767a2fea759ba99be..2900e2fe0a040912ebcf1bc81afd5932bb4e1a3e 100644
(file)
--- a/
src/bin/lttng-relayd/main.c
+++ b/
src/bin/lttng-relayd/main.c
@@
-85,7
+85,7
@@
NULL
enum relay_connection_status {
RELAY_CONNECTION_STATUS_OK,
enum relay_connection_status {
RELAY_CONNECTION_STATUS_OK,
- /* An error occured while processing an event on the connection. */
+ /* An error occur
r
ed while processing an event on the connection. */
RELAY_CONNECTION_STATUS_ERROR,
/* Connection closed/shutdown cleanly. */
RELAY_CONNECTION_STATUS_CLOSED,
RELAY_CONNECTION_STATUS_ERROR,
/* Connection closed/shutdown cleanly. */
RELAY_CONNECTION_STATUS_CLOSED,
@@
-94,6
+94,7
@@
enum relay_connection_status {
/* command line options */
char *opt_output_path;
static int opt_daemon, opt_background;
/* command line options */
char *opt_output_path;
static int opt_daemon, opt_background;
+static int opt_allow_clear = 1;
/*
* We need to wait for listener and live listener threads, as well as
/*
* We need to wait for listener and live listener threads, as well as
@@
-179,6
+180,7
@@
static struct option long_options[] = {
{ "verbose", 0, 0, 'v', },
{ "config", 1, 0, 'f' },
{ "version", 0, 0, 'V' },
{ "verbose", 0, 0, 'v', },
{ "config", 1, 0, 'f' },
{ "version", 0, 0, 'V' },
+ { "disallow-clear", 0, 0, 'x' },
{ NULL, 0, 0, 0, },
};
{ NULL, 0, 0, 0, },
};
@@
-300,6
+302,10
@@
static int set_option(int opt, const char *arg, const char *optname)
}
}
break;
}
}
break;
+ case 'x':
+ /* Disallow clear */
+ opt_allow_clear = 0;
+ break;
default:
/* Unknown option or other error.
* Error is printed by getopt, just return */
default:
/* Unknown option or other error.
* Error is printed by getopt, just return */
@@
-375,6
+381,7
@@
static int set_options(int argc, char **argv)
int orig_optopt = optopt, orig_optind = optind;
char *default_address, *optstring;
const char *config_path = NULL;
int orig_optopt = optopt, orig_optind = optind;
char *default_address, *optstring;
const char *config_path = NULL;
+ const char *value = NULL;
optstring = utils_generate_optstring(long_options,
sizeof(long_options) / sizeof(struct option));
optstring = utils_generate_optstring(long_options,
sizeof(long_options) / sizeof(struct option));
@@
-487,6
+494,20
@@
static int set_options(int argc, char **argv)
}
}
}
}
+ if (opt_allow_clear) {
+ /* Check if env variable exists. */
+ value = lttng_secure_getenv(DEFAULT_LTTNG_RELAYD_DISALLOW_CLEAR_ENV);
+ if (value) {
+ ret = config_parse_value(value);
+ if (ret < 0) {
+ ERR("Invalid value for %s specified", DEFAULT_LTTNG_RELAYD_DISALLOW_CLEAR_ENV);
+ retval = -1;
+ goto exit;
+ }
+ opt_allow_clear = !ret;
+ }
+ }
+
exit:
free(optstring);
return retval;
exit:
free(optstring);
return retval;
@@
-1640,7
+1661,7
@@
int rotate_truncate_stream(struct relay_stream *stream)
/*
* Rewind the current tracefile to the position at which the rotation
/*
* Rewind the current tracefile to the position at which the rotation
- * should have occured.
+ * should have occur
r
ed.
*/
lseek_ret = lseek(stream->stream_fd->fd,
stream->pos_after_last_complete_data_index, SEEK_SET);
*/
lseek_ret = lseek(stream->stream_fd->fd,
stream->pos_after_last_complete_data_index, SEEK_SET);
@@
-2973,7
+2994,7
@@
int relay_rotate_pending(const struct lttcomm_relayd_hdr *recv_hdr,
rotate_pending = true;
DBG("Stream %" PRIu64 " is still rotating",
stream->stream_handle);
rotate_pending = true;
DBG("Stream %" PRIu64 " is still rotating",
stream->stream_handle);
- } else if (stream->current_chunk_id.value < chunk_id) {
+ } else if (stream->current_chunk_id.value <
=
chunk_id) {
/*
* Stream closed on the consumer but still active on the
* relay.
/*
* Stream closed on the consumer but still active on the
* relay.
@@
-4092,6
+4113,10
@@
int main(int argc, char **argv)
goto exit_options;
}
goto exit_options;
}
+ if (!opt_allow_clear) {
+ DBG("Clear command disallowed.");
+ }
+
/* Try to create directory if -o, --output is specified. */
if (opt_output_path) {
if (*opt_output_path != '/') {
/* Try to create directory if -o, --output is specified. */
if (opt_output_path) {
if (*opt_output_path != '/') {
This page took
0.026181 seconds
and
5
git commands to generate.