This is an automated email from the ASF dual-hosted git repository.
alexey pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git
The following commit(s) were added to refs/heads/master by this push:
new c9617d121 [mini_kdc] remove duplicate code in CreateServiceKeytab()
c9617d121 is described below
commit c9617d1211eff12e15d5aed976d6c2b962a618b7
Author: Alexey Serbin <[email protected]>
AuthorDate: Mon Nov 3 16:34:48 2025 -0800
[mini_kdc] remove duplicate code in CreateServiceKeytab()
This is a follow-up to cdbe4577a91a171718ff485acc1dd1261e73a8d2.
Change-Id: I01689ec129572e9942932e05395429b3e85e5b63
Reviewed-on: http://gerrit.cloudera.org:8080/23625
Tested-by: Alexey Serbin <[email protected]>
Reviewed-by: Marton Greber <[email protected]>
Reviewed-by: Gabriella Lotz <[email protected]>
---
src/kudu/security/test/mini_kdc.cc | 26 +++++++-------------------
1 file changed, 7 insertions(+), 19 deletions(-)
diff --git a/src/kudu/security/test/mini_kdc.cc
b/src/kudu/security/test/mini_kdc.cc
index c9b520b9f..516fdc2b5 100644
--- a/src/kudu/security/test/mini_kdc.cc
+++ b/src/kudu/security/test/mini_kdc.cc
@@ -257,28 +257,16 @@ Status MiniKdc::CreateUserPrincipal(const string&
username) {
{ kadmin, "-q", Substitute("add_principal -pw $0 $0", username) }));
}
-Status MiniKdc::CreateServiceKeytab(const string& spn,
- string* path) {
- SCOPED_LOG_SLOW_EXECUTION(WARNING, 100, Substitute("creating service keytab
for $0", spn));
- string kt_path = spn;
- StripString(&kt_path, "/", '_');
- kt_path = JoinPathSegments(options_.data_root, kt_path) + ".keytab";
-
- string kadmin;
- RETURN_NOT_OK(GetBinaryPath("kadmin.local", &kadmin));
- RETURN_NOT_OK(Subprocess::Call(MakeArgv(
- { kadmin, "-q", Substitute("add_principal -randkey $0", spn) })));
- RETURN_NOT_OK(Subprocess::Call(MakeArgv(
- { kadmin, "-q", Substitute("ktadd -k $0 $1", kt_path, spn) })));
- *path = kt_path;
- return Status::OK();
+Status MiniKdc::CreateServiceKeytab(const string& spn, string* path) {
+ string name = spn;
+ StripString(&name, "/", '_');
+ return CreateServiceKeytabWithName(spn, name, path);
}
-Status MiniKdc::CreateServiceKeytabWithName(const string& spn, const string&
name,
- string* path) {
+Status MiniKdc::CreateServiceKeytabWithName(
+ const string& spn, const string& name, string* path) {
SCOPED_LOG_SLOW_EXECUTION(WARNING, 100, Substitute("creating service keytab
for $0", spn));
- string kt_path = name;
- kt_path = JoinPathSegments(options_.data_root, kt_path) + ".keytab";
+ const string kt_path = JoinPathSegments(options_.data_root, name) +
".keytab";
string kadmin;
RETURN_NOT_OK(GetBinaryPath("kadmin.local", &kadmin));