Linux'ta SELinux içeriğini korurken dosya kopyalama
SElinux artık iyi bir Linux Sisteminin önemli bir parçası haline geldi. Çeşitli hizmetlerin yapılandırılması sırasında SELinux bağlam dosyası önemli bir rol oynar. Daha sonra kullanmak üzere önceden tanımlanmış bir SELinux içeriğine sahip dosyaları kopyalamanız veya yedeklemeniz gerektiğinde veya geçerli yapılandırmayı taklit etmeye çalıştığınız zamanlar vardır. SELinux içeriğini koruyarak bir dosyanın kopyasını oluşturmak için seçenekli
Örneğin,
cp
komutu --preserve=context
kullanın.Örneğin,
/etc/services
dosyanın SELinux dosyası bağlamını görüntüleyelim :[[email protected] ]# ls -Z /etc/services -rw-r--r--. root root system_u:object_r:etc_t:s0 /etc/servicesKopyalama işlemi sırasında
cp
varsayılan olarak bir komut yeni bir SELinux dosya içeriği oluşturur:[[email protected] ]# cp /etc/services /tmp/ [[email protected] ]# ls -Z /tmp/services -rw-r--r--. root root unconfined_u:object_r:user_tmp_t:s0 /tmp/servicesusing komutu SELinux içeriğini koruma komutunu
preserve=context
verecektir cp
:[[email protected] ]# cp --preserve=context /etc/services /tmp/ cp: overwrite ‘/tmp/services’? y [[email protected] ]# ls -Z /tmp/services -rw-r--r--. root root system_u:object_r:etc_t:s0 /tmp/servicesYukarıdaki SELinux koruma bağlamı prosedürü bir dizin için de geçerlidir:
[[email protected] ]# ls -Zd /etc/ drwxr-xr-x. root root system_u:object_r:etc_t:s0 /etc/ [[email protected] ]# cp -r /etc/ /tmp/ [[email protected] ]# ls -Zd /tmp/etc/ drwxr-xr-x. root root unconfined_u:object_r:user_tmp_t:s0 /tmp/etc/ [[email protected] ]# rm -fr /tmp/etc/ [[email protected] ]# cp -r --preserve=context /etc/ /tmp/ [[email protected] ]# ls -Zd /tmp/etc/ drwxr-xr-x. root root system_u:object_r:etc_t:s0 /tmp/etc/