File tree 4 files changed +34
-3
lines changed
krb5-provision-keytab/src
4 files changed +34
-3
lines changed Original file line number Diff line number Diff line change @@ -11,8 +11,10 @@ All notable changes to this project will be documented in this file.
11
11
### Changed
12
12
13
13
- ` operator-rs ` ` 0.27.1 ` -> ` 0.41.0 ` ([ #275 ] ).
14
+ - Removed dummy key from generated Kerberos keytab ([ #285 ] ).
14
15
15
16
[ #275 ] : https://github.com/stackabletech/secret-operator/pull/275
17
+ [ #285 ] : https://github.com/stackabletech/secret-operator/pull/285
16
18
17
19
## [ 23.4.0] - 2023-04-17
18
20
Original file line number Diff line number Diff line change 15
15
} ;
16
16
krb5-sys = attrs : {
17
17
nativeBuildInputs = [ pkgs . pkg-config ] ;
18
- buildInputs = [ ( pkgs . enableDebugging pkgs . krb5 ) ] ;
18
+ buildInputs = [ pkgs . krb5 ] ;
19
+ LIBCLANG_PATH = "${ pkgs . libclang . lib } /lib" ;
20
+ BINDGEN_EXTRA_CLANG_ARGS = "-I${ pkgs . glibc . dev } /include -I${ pkgs . clang . cc . lib } /lib/clang/${ pkgs . lib . getVersion pkgs . clang . cc } /include" ;
21
+ } ;
22
+ libgssapi-sys = attrs : {
23
+ buildInputs = [ pkgs . krb5 ] ;
19
24
LIBCLANG_PATH = "${ pkgs . libclang . lib } /lib" ;
20
25
BINDGEN_EXTRA_CLANG_ARGS = "-I${ pkgs . glibc . dev } /include -I${ pkgs . clang . cc . lib } /lib/clang/${ pkgs . lib . getVersion pkgs . clang . cc } /include" ;
21
26
} ;
Original file line number Diff line number Diff line change @@ -56,8 +56,10 @@ enum Error {
56
56
source : kadm5:: Error ,
57
57
principal : String ,
58
58
} ,
59
- #[ snafu( display( "failed to add dummy key keytab" ) ) ]
59
+ #[ snafu( display( "failed to add dummy key to keytab" ) ) ]
60
60
AddDummyToKeytab { source : krb5:: Error } ,
61
+ #[ snafu( display( "failed to remove dummy key from keytab" ) ) ]
62
+ RemoveDummyFromKeytab { source : krb5:: Error } ,
61
63
}
62
64
63
65
enum AdminConnection < ' a > {
@@ -116,15 +118,20 @@ async fn run() -> Result<Response, Error> {
116
118
. context ( ParsePrincipalSnafu {
117
119
principal : dummy_principal_name,
118
120
} ) ?;
121
+ let dummy_kvno = 0 ;
119
122
kt. add (
120
123
& dummy_principal,
121
- 0 ,
124
+ dummy_kvno ,
122
125
// keyblock len must be >0, or kt.add() will always fail
123
126
& Keyblock :: new ( & krb, 0 , 1 )
124
127
. context ( AddDummyToKeytabSnafu ) ?
125
128
. as_ref ( ) ,
126
129
)
127
130
. context ( AddDummyToKeytabSnafu ) ?;
131
+ // Remove dummy key once we have forced the keytab to be created,
132
+ // to avoid tools trying to use it to authenticate
133
+ kt. remove ( & dummy_principal, dummy_kvno)
134
+ . context ( RemoveDummyFromKeytabSnafu ) ?;
128
135
129
136
for princ_req in req. principals {
130
137
let princ = krb
Original file line number Diff line number Diff line change @@ -413,6 +413,23 @@ impl<'a> Keytab<'a> {
413
413
)
414
414
}
415
415
}
416
+
417
+ /// Remove the specified key from the keytab.
418
+ pub fn remove (
419
+ & mut self ,
420
+ principal : & Principal ,
421
+ kvno : krb5_sys:: krb5_kvno ,
422
+ ) -> Result < ( ) , Error > {
423
+ unsafe {
424
+ let mut entry: krb5_sys:: krb5_keytab_entry = std:: mem:: zeroed ( ) ;
425
+ entry. principal = principal. raw ;
426
+ entry. vno = kvno;
427
+ Error :: from_call_result (
428
+ Some ( self . ctx ) ,
429
+ krb5_sys:: krb5_kt_remove_entry ( self . ctx . raw , self . raw , & mut entry) ,
430
+ )
431
+ }
432
+ }
416
433
}
417
434
impl Drop for Keytab < ' _ > {
418
435
fn drop ( & mut self ) {
You can’t perform that action at this time.
0 commit comments