def _setup_selinux_for_keys(fs, sshdir):
 if (not fs.has_file(os.path.join('etc', 'selinux'))):
  return
 rclocal = os.path.join('etc', 'rc.local')
 rc_d = os.path.join('etc', 'rc.d')
 if ((not fs.has_file(rclocal)) and fs.has_file(rc_d)):
  rclocal = os.path.join(rc_d, 'rc.local')
 restorecon = ['\n', '# Added by Nova to ensure injected ssh keys have the right context\n', ('restorecon -RF %s 2>/dev/null || :\n' % sshdir)]
 if (not fs.has_file(rclocal)):
  restorecon.insert(0, '#!/bin/sh')
 _inject_file_into_fs(fs, rclocal, ''.join(restorecon), append=True)
 fs.set_permissions(rclocal, 448)

def _setup_selinux_for_keys ( fs , sshdir ) : if ( not fs . has_file ( os . path . join ( 'etc' , 'selinux' ) ) ) : return rclocal = os . path . join ( 'etc' , 'rc.local' ) rc_d = os . path . join ( 'etc' , 'rc.d' ) if ( ( not fs . has_file ( rclocal ) ) and fs . has_file ( rc_d ) ) : rclocal = os . path . join ( rc_d , 'rc.local' ) restorecon = [ '\n' , '# Added by Nova to ensure injected ssh keys have the right context\n' , ( 'restorecon -RF %s 2>/dev/null || :\n' % sshdir ) ] if ( not fs . has_file ( rclocal ) ) : restorecon . insert ( 0 , '#!/bin/sh' ) _inject_file_into_fs ( fs , rclocal , '' . join ( restorecon ) , append = True ) fs . set_permissions ( rclocal , 448 )
get selinux guests to ensure correct context on injected keys .