From 3573351539870f4dc366731664a6e04361ae5199 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Tue, 3 May 2016 12:34:29 +0200 Subject: [PATCH 05/10] STAP: Add helper functions to for human-readable account request representation The caller of the systemtap script would be able to see what kind of account request sssd received with a string representation, not just the cryptic hexadecimal number. --- Makefile.am | 5 ++- src/providers/data_provider_req.h | 2 ++ src/systemtap/sssd_functions.stp | 66 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 src/systemtap/sssd_functions.stp diff --git a/Makefile.am b/Makefile.am index 87f0741c3dac0de57542c365daa5eb95d5e3fe2f..b87db91ee22300da670ff8e57eedea3355a5ed11 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1079,7 +1079,10 @@ SYSTEMTAP_PROBES = \ $(srcdir)/src/systemtap/sssd_probes.d \ $(NULL) -dist_systemtap_tap_DATA = $(builddir)/src/systemtap/sssd.stp +dist_systemtap_tap_DATA = \ + $(builddir)/src/systemtap/sssd.stp \ + $(builddir)/src/systemtap/sssd_functions.stp \ + $(NULL) if BUILD_SYSTEMTAP stap_generated_probes.h: $(srcdir)/src/systemtap/sssd_probes.d diff --git a/src/providers/data_provider_req.h b/src/providers/data_provider_req.h index 338f8192f80f732b89c5dc3dd3b79fb5a6edb8c7..a2889cda5c27d91ac42eaeb3777e5ec9181f31f9 100644 --- a/src/providers/data_provider_req.h +++ b/src/providers/data_provider_req.h @@ -24,6 +24,8 @@ #include +/* When changing these constants, also please change sssd_functions.stp + */ #define BE_REQ_USER 0x0001 #define BE_REQ_GROUP 0x0002 #define BE_REQ_INITGROUPS 0x0003 diff --git a/src/systemtap/sssd_functions.stp b/src/systemtap/sssd_functions.stp new file mode 100644 index 0000000000000000000000000000000000000000..bad194eadb1b7154e85bb05c42240323896abe45 --- /dev/null +++ b/src/systemtap/sssd_functions.stp @@ -0,0 +1,66 @@ +function acct_req_desc(entry_type) +{ + if (entry_type == 0x0001) { + str_entry_type = "user" + } else if (entry_type == 0x0002) { + str_entry_type = "group" + } else if (entry_type == 0x0003) { + str_entry_type = "initgroups" + } else if (entry_type == 0x0004) { + str_entry_type = "netgroups" + } else if (entry_type == 0x0005) { + str_entry_type = "services" + } else if (entry_type == 0x0006) { + str_entry_type = "sudo_full" + } else if (entry_type == 0x0007) { + str_entry_type = "sudo_rules" + # See src/providers/data_provider_req.h, no 0x0008 there.. + } else if (entry_type == 0x0009) { + str_entry_type = "autofs" + } else if (entry_type == 0x0010) { + str_entry_type = "host" + } else if (entry_type == 0x0011) { + str_entry_type = "by_secid" + } else if (entry_type == 0x0012) { + str_entry_type = "user_and_group" + } else if (entry_type == 0x0013) { + str_entry_type = "by_uuid" + } else if (entry_type == 0x0014) { + str_entry_type = "by_cert" + } else { + str_entry_type = sprintf("%X", entry_type) + } + + return str_entry_type +} + +function sssd_acct_req_probestr(fc_name, entry_type, filter_type, + filter_value, extra_value) +{ + str_entry_type = acct_req_desc(entry_type) + + # Maybe we could use guru mode here and include the constants + # directly.. + if (filter_type == 1) { + str_filter_type = "name" + } else if (filter_type == 2) { + str_filter_type = "idnum" + } else if (filter_type == 3) { + str_filter_type = "enum" + } else if (filter_type == 4) { + str_filter_type = "secid" + } else if (filter_type == 5) { + str_filter_type = "uuid" + } else if (filter_type == 6) { + str_filter_type = "cert" + } else if (filter_type == 7) { + str_filter_type = "wildcard" + } else { + str_filter_type = sprintf("%d", filter_type) + } + + probestr = sprintf("%s(entry_type=%s, filter_type=%s, filter_value=%s, extra_value=%s)", + fc_name, str_entry_type, str_filter_type, + filter_value, extra_value) + return probestr +} -- 2.4.11