@@ -320,11 +320,13 @@ def setup_kdc(testdir, wrapenv):
320
320
with open (kdcconf , 'w+' ) as f :
321
321
f .write (text )
322
322
323
- kdcenv = {'PATH' : f'/sbin:/bin:/usr/sbin:/usr/bin:{ wrapenv ["PATH" ]} ' ,
324
- 'KRB5_CONFIG' : krb5conf ,
325
- 'KRB5_KDC_PROFILE' : kdcconf ,
326
- 'KRB5_TRACE' : os .path .join (testdir , 'krbtrace.log' )}
327
- kdcenv .update (wrapenv )
323
+ kdcenv = wrapenv .copy ()
324
+ kdcenv .update ({
325
+ 'PATH' : f'/sbin:/bin:/usr/sbin:/usr/bin:{ wrapenv ["PATH" ]} ' ,
326
+ 'KRB5_CONFIG' : krb5conf ,
327
+ 'KRB5_KDC_PROFILE' : kdcconf ,
328
+ 'KRB5_TRACE' : os .path .join (testdir , 'krbtrace.log' ),
329
+ })
328
330
329
331
logfile = open (testlog , 'a' )
330
332
ksetup = subprocess .Popen (["kdb5_util" , "create" , "-W" , "-s" ,
@@ -393,8 +395,10 @@ def setup_keys(tesdir, env):
393
395
cmd = "addprinc -nokey -e %s %s" % (KEY_TYPE , USR_NAME_3 )
394
396
kadmin_local (cmd , env , logfile )
395
397
396
- keys_env = {"KRB5_KTNAME" : svc_keytab , }
397
- keys_env .update (env )
398
+ keys_env = env .copy ()
399
+ keys_env .update ({
400
+ "KRB5_KTNAME" : svc_keytab ,
401
+ })
398
402
return keys_env
399
403
400
404
@@ -431,10 +435,12 @@ def setup_http(testdir, so_dir, wrapenv):
431
435
432
436
shutil .copy ('tests/401.html' , os .path .join (httpdir , 'html' ))
433
437
434
- httpenv = {'PATH' : f'/sbin:/bin:/usr/sbin:/usr/bin:{ wrapenv ["PATH" ]} ' ,
435
- 'MALLOC_CHECK_' : '3' ,
436
- 'MALLOC_PERTURB_' : str (random .randint (0 , 32767 ) % 255 + 1 )}
437
- httpenv .update (wrapenv )
438
+ httpenv = wrapenv .copy ()
439
+ httpenv .update ({
440
+ 'PATH' : f'/sbin:/bin:/usr/sbin:/usr/bin:{ wrapenv ["PATH" ]} ' ,
441
+ 'MALLOC_CHECK_' : '3' ,
442
+ 'MALLOC_PERTURB_' : str (random .randint (0 , 32767 ) % 255 + 1 ),
443
+ })
438
444
439
445
httpd = "httpd" if distro == "Fedora" else "apache2"
440
446
httpproc = subprocess .Popen ([httpd , '-DFOREGROUND' , '-f' , config ],
@@ -445,8 +451,10 @@ def setup_http(testdir, so_dir, wrapenv):
445
451
def kinit_user (testdir , kdcenv ):
446
452
testlog = os .path .join (testdir , 'kinit.log' )
447
453
ccache = os .path .join (testdir , 'k5ccache' )
448
- testenv = {'KRB5CCNAME' : ccache }
449
- testenv .update (kdcenv )
454
+ testenv = kdcenv .copy ()
455
+ testenv .update ({
456
+ 'KRB5CCNAME' : ccache ,
457
+ })
450
458
451
459
with (open (testlog , 'a' )) as logfile :
452
460
kinit = subprocess .Popen (["kinit" , USR_NAME ],
@@ -467,8 +475,10 @@ def kinit_certuser(testdir, kdcenv):
467
475
pkinit_user_cert = os .path .join (testdir , PKINIT_USER_CERT )
468
476
pkinit_key = os .path .join (testdir , PKINIT_KEY )
469
477
ident = "X509_user_identity=FILE:" + pkinit_user_cert + "," + pkinit_key
470
- testenv = {'KRB5CCNAME' : ccache }
471
- testenv .update (kdcenv )
478
+ testenv = kdcenv .copy ()
479
+ testenv .update ({
480
+ 'KRB5CCNAME' : ccache ,
481
+ })
472
482
with (open (testlog , 'a' )) as logfile :
473
483
logfile .write ('PKINIT for maguser3\n ' )
474
484
kinit = subprocess .Popen (["kinit" , USR_NAME_3 , "-X" , ident ],
@@ -754,17 +764,21 @@ def faketime_setup(testenv):
754
764
raise NotImplementedError
755
765
756
766
# spedup x100
757
- fakeenv = {'FAKETIME' : '+0 x100' }
758
- fakeenv .update (testenv )
759
- fakeenv ['LD_PRELOAD' ] = ' ' .join ((testenv ['LD_PRELOAD' ], libfaketime ))
767
+ fakeenv = testenv .copy ()
768
+ fakeenv .update ({
769
+ 'FAKETIME' : '+0 x100' ,
770
+ 'LD_PRELOAD' : ' ' .join ((testenv ['LD_PRELOAD' ], libfaketime )),
771
+ })
760
772
return fakeenv
761
773
762
774
763
775
def http_restart (testdir , so_dir , testenv ):
764
- httpenv = {'PATH' : f'/sbin:/bin:/usr/sbin:/usr/bin:{ testenv ["PATH" ]} ' ,
765
- 'MALLOC_CHECK_' : '3' ,
766
- 'MALLOC_PERTURB_' : str (random .randint (0 , 32767 ) % 255 + 1 )}
767
- httpenv .update (testenv )
776
+ httpenv = testenv .copy ()
777
+ httpenv .update ({
778
+ 'PATH' : f'/sbin:/bin:/usr/sbin:/usr/bin:{ testenv ["PATH" ]} ' ,
779
+ 'MALLOC_CHECK_' : '3' ,
780
+ 'MALLOC_PERTURB_' : str (random .randint (0 , 32767 ) % 255 + 1 ),
781
+ })
768
782
769
783
httpd = "httpd" if os .path .exists ("/etc/httpd/modules" ) else "apache2"
770
784
config = os .path .join (testdir , 'httpd' , 'httpd.conf' )
@@ -844,11 +858,13 @@ def test_mech_name(testdir, testenv, logfile):
844
858
sys .stderr .write ("krb5 PKINIT module not found, skipping name "
845
859
"attribute tests\n " )
846
860
847
- testenv = {'MAG_USER_NAME' : USR_NAME ,
848
- 'MAG_USER_PASSWORD' : USR_PWD ,
849
- 'MAG_USER_NAME_2' : USR_NAME_2 ,
850
- 'MAG_USER_PASSWORD_2' : USR_PWD_2 }
851
- testenv .update (kdcenv )
861
+ testenv = kdcenv .copy ()
862
+ testenv .update ({
863
+ 'MAG_USER_NAME' : USR_NAME ,
864
+ 'MAG_USER_PASSWORD' : USR_PWD ,
865
+ 'MAG_USER_NAME_2' : USR_NAME_2 ,
866
+ 'MAG_USER_PASSWORD_2' : USR_PWD_2 ,
867
+ })
852
868
853
869
errs += test_basic_auth_krb5 (testdir , testenv , logfile )
854
870
@@ -859,9 +875,11 @@ def test_mech_name(testdir, testenv, logfile):
859
875
# After this point we need to speed up httpd to test creds timeout
860
876
try :
861
877
fakeenv = faketime_setup (kdcenv )
862
- timeenv = {'TIMEOUT_USER' : USR_NAME_4 ,
863
- 'MAG_USER_PASSWORD' : USR_PWD }
864
- timeenv .update (fakeenv )
878
+ timeenv = fakeenv .copy ()
879
+ timeenv .update ({
880
+ 'TIMEOUT_USER' : USR_NAME_4 ,
881
+ 'MAG_USER_PASSWORD' : USR_PWD ,
882
+ })
865
883
curporc = httpproc
866
884
pid = processes ['HTTPD(%d)' % httpproc .pid ].pid
867
885
os .killpg (pid , signal .SIGTERM )
0 commit comments