我inheritance了Centos 6.5系统,在运行rsync时输出多行错误。 rsync正在同步到本地连接的作为/storage驱动器。 该命令是:
rsync -aAXv /* /storage/backup/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/storage/*}
有三种不同types的错误logging在下面# Error concern 1, # Error concern 2, # Error concern 3在下面的输出中:
rsync -aAXv /* /storage/backup/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/storage/*} sending incremental file list etc/cron.d/ root/ root/.bash_history root/.viminfo selinux/booleans/abrt_anon_write selinux/booleans/abrt_handle_event selinux/booleans/allow_console_login [...] # Error concern 1: There are probably 80 or more of these mkstemp errors, but I've shortened it: rsync: mkstemp "/storage/backup/selinux/class/x_pointer/perms/.setfocus.0C5BYW" failed: Permission denied (13) rsync: mkstemp "/storage/backup/selinux/class/x_pointer/perms/.use.iRMquA" failed: Permission denied (13) rsync: mkstemp "/storage/backup/selinux/class/x_pointer/perms/.write.rHXg0d" failed: Permission denied (13) rsync: mkstemp "/storage/backup/selinux/class/x_property/.index.Zwc8vR" failed: Permission denied (13) rsync: mkstemp "/storage/backup/selinux/class/x_property/perms/.append.tTK01u" failed: Permission denied (13) rsync: mkstemp "/storage/backup/selinux/class/x_property/perms/.create.KGNUx8" failed: Permission denied (13) rsync: mkstemp "/storage/backup/selinux/class/x_property/perms/.destroy.IiUP3L" failed: Permission denied (13) [...] # Error concern 2: tmp/ rsync: rsync_xal_clear: lremovexattr("storage","security.selinux") failed: Permission denied (13) var/cache/man/whatis [...] # Error concern 3: var/run/utmp rsync: set_acl: sys_acl_set_file(var/run/cups/certs/0, ACL_TYPE_ACCESS): Operation not supported (95) var/run/postgresql/.s.PGSQL.5432.lock [...] # Finishing output: sent 4288406721 bytes received 52199 bytes 86635533.74 bytes/sec total size is 22337384552 speedup is 5.21 rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1039) [sender=3.0.6]
rsync似乎正常运行,直到它遇到隐藏文件/selinux目录的特定部分。 当SELinux设置为宽容时, setenforce 0 ,这些错误不会发生。 虽然# Error concern 2和# Error concern 3仍然发生。
/selinux目录和/storage目录的SELinux上下文如下所示:
drwxr-xr-x. root root system_u:object_r:security_t:s0 selinux drwxr-xr-x. root root system_u:object_r:file_t:s0 storage # /storage/backup directory drwxr-xr-x. root root unconfined_u:object_r:public_content_t:s0 backup
到目前为止# Error concern 2和# Error concern 3我没有线索。
请让我知道如果我失去了什么。 我不太熟悉CentOS 6.5,因为我不知道为什么有一个/selinux目录为/ 。 我有一个CentOS 7.2服务器,这是做一个连接的存储驱动器相同的rsync没有问题。 任何帮助或build议将不胜感激。
我通过以下方式将/storage/backup上的SELinux上下文更改为public_content_rw_t :
semanage fcontext -a -t public_content_rw_t "/storage/backup(/.*)?" restorecon -Rv /storage/backup
我将很快再次运行rsync并报告这是否改变了什么。
我已经在新的安全上下文之后再次运行rsync,并得到相同的错误结果。 我想知道,如果系统需要重新标记自身,那么rsyncing /selinux目录是否真的值得,因为系统应该有/etc/selinux备份,这将拥有所有的上下文。 任何人都可以在这里?
我倾向于不备份/selinux目录。 sestatus显示了CentOS 6.5与CentOS 7.2之间的这些差异:
CentOS 6.5 SELinux status: enabled SELinuxfs mount: /selinux Current mode: enforcing CentOS 7.2 SELinux status: enabled SELinuxfs mount: /sys/fs/selinux SELinux root directory: /etc/selinux Loaded policy name: targeted Current mode: enforcing
从我从这里收集的/selinux目录被用作SElinux文件系统的挂载点? 我想知道这是错误的原因。
/selinux和/etc/selinux (在RHEL / CentOS 6中)的不同之处在于前者是“导出安全策略API的伪文件系统” (记住强制访问控制是内核强制的)。 而后者“包含机器本地的configuration文件” 。
同步时,不应该包含/selinux (或任何其他)伪文件系统。
在Unix和Linux上有关于这个主题的很好的Q / A,有非常有用的链接文档。