From: Simon Marchi Date: Thu, 15 Apr 2021 11:31:01 +0000 (-0400) Subject: lttng {add,list,remove}-trigger: rename user id to owner uid X-Git-Tag: v2.13.0-rc1~40 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=481c5310f698d32187c0f20bd0d1da3b8b696b06;p=lttng-tools.git lttng {add,list,remove}-trigger: rename user id to owner uid Implement the proposal to rename the --user-id option to --owner-uid in the add-trigger and remove-trigger commands. Update the output of list-triggers as well. Change-Id: I79977a0efe80d96917fcaf55909a78c81047c388 Signed-off-by: Simon Marchi Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng/commands/add_trigger.c b/src/bin/lttng/commands/add_trigger.c index 934464349..b1ec6dd47 100644 --- a/src/bin/lttng/commands/add_trigger.c +++ b/src/bin/lttng/commands/add_trigger.c @@ -40,7 +40,7 @@ enum { OPT_CONDITION, OPT_ACTION, OPT_ID, - OPT_USER_ID, + OPT_OWNER_UID, OPT_RATE_POLICY, OPT_NAME, @@ -2089,7 +2089,7 @@ struct argpar_opt_descr add_trigger_options[] = { { OPT_CONDITION, '\0', "condition", true }, { OPT_ACTION, '\0', "action", true }, { OPT_NAME, '\0', "name", true }, - { OPT_USER_ID, '\0', "user-id", true }, + { OPT_OWNER_UID, '\0', "owner-uid", true }, ARGPAR_OPT_DESCR_SENTINEL, }; @@ -2116,7 +2116,7 @@ int cmd_add_trigger(int argc, const char **argv) char *error = NULL; char *name = NULL; int i; - char *user_id = NULL; + char *owner_uid = NULL; lttng_dynamic_pointer_array_init(&actions, lttng_actions_destructor); @@ -2222,10 +2222,10 @@ int cmd_add_trigger(int argc, const char **argv) break; } - case OPT_USER_ID: + case OPT_OWNER_UID: { - if (!assign_string(&user_id, item_opt->arg, - "--user-id")) { + if (!assign_string(&owner_uid, item_opt->arg, + "--owner-uid")) { goto error; } @@ -2284,15 +2284,15 @@ int cmd_add_trigger(int argc, const char **argv) } } - if (user_id) { + if (owner_uid) { enum lttng_trigger_status trigger_status; char *end; long long uid; errno = 0; - uid = strtol(user_id, &end, 10); - if (end == user_id || *end != '\0' || errno != 0) { - ERR("Failed to parse `%s` as a user id.", user_id); + uid = strtol(owner_uid, &end, 10); + if (end == owner_uid || *end != '\0' || errno != 0) { + ERR("Failed to parse `%s` as a user id.", owner_uid); } trigger_status = lttng_trigger_set_owner_uid(trigger, uid); @@ -2325,6 +2325,6 @@ end: lttng_trigger_destroy(trigger); free(error); free(name); - free(user_id); + free(owner_uid); return ret; } diff --git a/src/bin/lttng/commands/list_triggers.c b/src/bin/lttng/commands/list_triggers.c index 3b806e7ea..91ff1c068 100644 --- a/src/bin/lttng/commands/list_triggers.c +++ b/src/bin/lttng/commands/list_triggers.c @@ -817,7 +817,7 @@ void print_one_trigger(const struct lttng_trigger *trigger) assert(trigger_status == LTTNG_TRIGGER_STATUS_OK); MSG("- name: %s", name); - MSG(" user id: %d", trigger_uid); + MSG(" owner uid: %d", trigger_uid); condition = lttng_trigger_get_const_condition(trigger); condition_type = lttng_condition_get_type(condition); diff --git a/src/bin/lttng/commands/remove_trigger.c b/src/bin/lttng/commands/remove_trigger.c index 1fabc70ec..401b59742 100644 --- a/src/bin/lttng/commands/remove_trigger.c +++ b/src/bin/lttng/commands/remove_trigger.c @@ -19,14 +19,14 @@ static const char help_msg[] = enum { OPT_HELP, OPT_LIST_OPTIONS, - OPT_USER_ID, + OPT_OWNER_UID, }; static const struct argpar_opt_descr remove_trigger_options[] = { { OPT_HELP, 'h', "help", false }, { OPT_LIST_OPTIONS, '\0', "list-options", false }, - { OPT_USER_ID, '\0', "user-id", true }, + { OPT_OWNER_UID, '\0', "owner-uid", true }, ARGPAR_OPT_DESCR_SENTINEL, }; @@ -66,7 +66,7 @@ int cmd_remove_trigger(int argc, const char **argv) unsigned int triggers_count; enum lttng_trigger_status trigger_status; const struct lttng_trigger *trigger_to_remove = NULL; - char *user_id = NULL; + char *owner_uid = NULL; long long uid; argpar_parse_ret = argpar_parse(argc - 1, argv + 1, @@ -94,10 +94,10 @@ int cmd_remove_trigger(int argc, const char **argv) remove_trigger_options); ret = 0; goto end; - case OPT_USER_ID: + case OPT_OWNER_UID: { - if (!assign_string(&user_id, item_opt->arg, - "--user-id")) { + if (!assign_string(&owner_uid, item_opt->arg, + "--owner-uid")) { goto error; } break; @@ -123,13 +123,13 @@ int cmd_remove_trigger(int argc, const char **argv) goto error; } - if (user_id) { + if (owner_uid) { char *end; errno = 0; - uid = strtol(user_id, &end, 10); - if (end == user_id || *end != '\0' || errno != 0) { - ERR("Failed to parse `%s` as an integer.", user_id); + uid = strtol(owner_uid, &end, 10); + if (end == owner_uid || *end != '\0' || errno != 0) { + ERR("Failed to parse `%s` as an integer.", owner_uid); } } else { uid = geteuid(); @@ -185,7 +185,7 @@ error: end: argpar_parse_ret_fini(&argpar_parse_ret); lttng_triggers_destroy(triggers); - free(user_id); + free(owner_uid); return ret; } diff --git a/tests/regression/tools/trigger/test_list_triggers_cli b/tests/regression/tools/trigger/test_list_triggers_cli index f5d34f967..31ba7b366 100755 --- a/tests/regression/tools/trigger/test_list_triggers_cli +++ b/tests/regression/tools/trigger/test_list_triggers_cli @@ -73,7 +73,7 @@ test_top_level_options () cat > "${tmp_expected_stdout}" <<- EOF - name: hello - user id: ${uid} + owner uid: ${uid} condition: event rule hit rule: test-name (type: tracepoint, domain: ust) actions: @@ -104,7 +104,7 @@ test_on_event_tracepoint () cat > "${tmp_expected_stdout}" <<- EOF - name: A - user id: ${uid} + owner uid: ${uid} condition: event rule hit rule: aaa (type: tracepoint, domain: ust, filter: p == 2) actions: @@ -112,7 +112,7 @@ test_on_event_tracepoint () errors: none errors: none - name: B - user id: ${uid} + owner uid: ${uid} condition: event rule hit rule: gerboise (type: tracepoint, domain: ust, log level at least INFO) actions: @@ -120,7 +120,7 @@ test_on_event_tracepoint () errors: none errors: none - name: C - user id: ${uid} + owner uid: ${uid} condition: event rule hit rule: * (type: tracepoint, domain: ust) actions: @@ -128,7 +128,7 @@ test_on_event_tracepoint () errors: none errors: none - name: D - user id: ${uid} + owner uid: ${uid} condition: event rule hit rule: hello* (type: tracepoint, domain: ust, exclusions: hello2,hello3,hello4) actions: @@ -136,7 +136,7 @@ test_on_event_tracepoint () errors: none errors: none - name: E - user id: ${uid} + owner uid: ${uid} condition: event rule hit rule: lemming (type: tracepoint, domain: ust, log level is WARNING) actions: @@ -144,7 +144,7 @@ test_on_event_tracepoint () errors: none errors: none - name: F - user id: ${uid} + owner uid: ${uid} condition: event rule hit rule: capture-payload-field (type: tracepoint, domain: ust) captures: @@ -154,7 +154,7 @@ test_on_event_tracepoint () errors: none errors: none - name: G - user id: ${uid} + owner uid: ${uid} condition: event rule hit rule: capture-array (type: tracepoint, domain: ust) captures: @@ -165,7 +165,7 @@ test_on_event_tracepoint () errors: none errors: none - name: H - user id: ${uid} + owner uid: ${uid} condition: event rule hit rule: capture-chan-ctx (type: tracepoint, domain: ust) captures: @@ -175,7 +175,7 @@ test_on_event_tracepoint () errors: none errors: none - name: I - user id: ${uid} + owner uid: ${uid} condition: event rule hit rule: capture-app-ctx (type: tracepoint, domain: ust) captures: @@ -185,7 +185,7 @@ test_on_event_tracepoint () errors: none errors: none - name: J - user id: ${uid} + owner uid: ${uid} condition: event rule hit rule: lemming (type: tracepoint, domain: ust) actions: @@ -237,7 +237,7 @@ test_on_event_probe () cat > "${tmp_expected_stdout}" <<- EOF - name: T0 - user id: ${uid} + owner uid: ${uid} condition: event rule hit rule: my_channel_enable (type: probe, location: lttng_channel_enable) actions: @@ -245,7 +245,7 @@ test_on_event_probe () errors: none errors: none - name: T1 - user id: ${uid} + owner uid: ${uid} condition: event rule hit rule: my_channel_enable (type: probe, location: ${base_symbol}+${offset_hex}) actions: @@ -253,7 +253,7 @@ test_on_event_probe () errors: none errors: none - name: T2 - user id: ${uid} + owner uid: ${uid} condition: event rule hit rule: my_channel_enable (type: probe, location: 0x${channel_enable_addr}) actions: @@ -279,7 +279,7 @@ test_on_event_userspace_probe_elf () cat > "${tmp_expected_stdout}" <<- EOF - name: T0 - user id: ${uid} + owner uid: ${uid} condition: event rule hit rule: ma-probe-elf (type: userspace probe, location type: ELF, location: ${uprobe_elf_binary}:${elf_function_name}) actions: @@ -327,7 +327,7 @@ test_on_event_syscall () cat > "${tmp_expected_stdout}" <<- EOF - name: T0 - user id: ${uid} + owner uid: ${uid} condition: event rule hit rule: open (type: syscall) actions: @@ -335,7 +335,7 @@ test_on_event_syscall () errors: none errors: none - name: T1 - user id: ${uid} + owner uid: ${uid} condition: event rule hit rule: ptrace (type: syscall, filter: a > 2) actions: @@ -367,7 +367,7 @@ test_snapshot_action () cat > "${tmp_expected_stdout}" <<- EOF - name: T0 - user id: ${uid} + owner uid: ${uid} condition: event rule hit rule: some-event (type: tracepoint, domain: ust) actions: @@ -375,7 +375,7 @@ test_snapshot_action () errors: none errors: none - name: T1 - user id: ${uid} + owner uid: ${uid} condition: event rule hit rule: some-event (type: tracepoint, domain: ust) actions: @@ -383,7 +383,7 @@ test_snapshot_action () errors: none errors: none - name: T2 - user id: ${uid} + owner uid: ${uid} condition: event rule hit rule: some-event (type: tracepoint, domain: ust) actions: @@ -391,7 +391,7 @@ test_snapshot_action () errors: none errors: none - name: T3 - user id: ${uid} + owner uid: ${uid} condition: event rule hit rule: some-event (type: tracepoint, domain: ust) actions: @@ -399,7 +399,7 @@ test_snapshot_action () errors: none errors: none - name: T4 - user id: ${uid} + owner uid: ${uid} condition: event rule hit rule: some-event (type: tracepoint, domain: ust) actions: @@ -407,7 +407,7 @@ test_snapshot_action () errors: none errors: none - name: T5 - user id: ${uid} + owner uid: ${uid} condition: event rule hit rule: some-event (type: tracepoint, domain: ust) actions: @@ -415,7 +415,7 @@ test_snapshot_action () errors: none errors: none - name: T6 - user id: ${uid} + owner uid: ${uid} condition: event rule hit rule: some-event (type: tracepoint, domain: ust) actions: @@ -423,7 +423,7 @@ test_snapshot_action () errors: none errors: none - name: T7 - user id: ${uid} + owner uid: ${uid} condition: event rule hit rule: some-event (type: tracepoint, domain: ust) actions: @@ -431,7 +431,7 @@ test_snapshot_action () errors: none errors: none - name: T8 - user id: ${uid} + owner uid: ${uid} condition: event rule hit rule: some-event (type: tracepoint, domain: ust) actions: @@ -439,7 +439,7 @@ test_snapshot_action () errors: none errors: none - name: T9 - user id: ${uid} + owner uid: ${uid} condition: event rule hit rule: some-event (type: tracepoint, domain: ust) actions: @@ -469,7 +469,7 @@ test_notify_action () cat > "${tmp_expected_stdout}" <<- EOF - name: T0 - user id: ${uid} + owner uid: ${uid} condition: event rule hit rule: some-event (type: tracepoint, domain: ust) actions: @@ -477,7 +477,7 @@ test_notify_action () errors: none errors: none - name: T1 - user id: ${uid} + owner uid: ${uid} condition: event rule hit rule: some-event (type: tracepoint, domain: ust) actions: diff --git a/tests/regression/tools/trigger/test_remove_trigger_cli b/tests/regression/tools/trigger/test_remove_trigger_cli index fbfc202b6..8d539d4b2 100755 --- a/tests/regression/tools/trigger/test_remove_trigger_cli +++ b/tests/regression/tools/trigger/test_remove_trigger_cli @@ -73,7 +73,7 @@ lttng_add_trigger_ok "DEF" --condition event-rule-matches --domain=user --action cat > "${tmp_expected_stdout}" <<- EOF - name: ABC - user id: ${uid} + owner uid: ${uid} condition: event rule hit rule: aaa (type: tracepoint, domain: ust, filter: p == 2) actions: @@ -81,7 +81,7 @@ cat > "${tmp_expected_stdout}" <<- EOF errors: none errors: none - name: DEF - user id: ${uid} + owner uid: ${uid} condition: event rule hit rule: * (type: tracepoint, domain: ust) actions: @@ -95,7 +95,7 @@ remove_trigger "ABC" cat > "${tmp_expected_stdout}" <<- EOF - name: DEF - user id: ${uid} + owner uid: ${uid} condition: event rule hit rule: * (type: tracepoint, domain: ust) actions: