自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

啟用SELinux時遇到的問題

運維 系統(tǒng)運維
一臺CentOS5.7的機(jī)器,原來只是在公司內(nèi)部訪問,SELinux是禁用的狀態(tài),現(xiàn)需要搭建成FTP服務(wù)器并發(fā)布到外網(wǎng)上去,為了安全,啟用SELinux。

 一臺CentOS5.7的機(jī)器,原來只是在公司內(nèi)部訪問,SELinux是禁用的狀態(tài),現(xiàn)需要搭建成FTP服務(wù)器并發(fā)布到外網(wǎng)上去,為了安全,啟用SELinux。編輯/etc/selinux/config文件,將SELINUX=disabled改為SELINUX=permissive,保存后重啟系統(tǒng)。(SELinux從禁用狀態(tài)轉(zhuǎn)變?yōu)閱⒂脮r,需要重啟系統(tǒng)以重新標(biāo)記文件的上下文,紅帽建議先將SELinux的值設(shè)置為permissive,重新標(biāo)記完成后再設(shè)置為enforcing。)

按道理說,重新對整個文件系統(tǒng)進(jìn)行標(biāo)記應(yīng)該是比較費時間的,至少需要幾分鐘,但在這臺機(jī)器上敲入reboot命令后,發(fā)現(xiàn)它很快就啟動起來的。登錄后使用命令getenforce,返回permissive,說明SELinux的狀態(tài)正常,于是把SELinux的狀態(tài)設(shè)置為Enforcing,設(shè)置完成后重啟了一下vsftpd和httpd服務(wù),這下問題大了,服務(wù)無法正常啟動,提示“errorwhile loading shared libraries: libssl.so.6: failed to map segment from sharedobject: Permission denied”,直覺告訴我是因為重啟時沒有對整個文件系統(tǒng)進(jìn)行正確的relabeling引起的,于是執(zhí)行命令touch   /.autorelabel   ,在/下創(chuàng)建一個.autorelabel文件,有這個文件存在,系統(tǒng)在重啟時就會對整個文件系統(tǒng)進(jìn)行relabeling,但奇怪的是重啟又很快完成,看來還是沒有完成relabeling。

***google了一下,發(fā)現(xiàn)一個解決方案,執(zhí)行下面三條命令:

fixfiles    -f   relabel

touch   /.autorelabel

reboot

但在執(zhí)行***條命令時就報錯,提示“/etc/selinux/targeted/contexts/files/file_contexts.homedirs: line 18 hasinvalid context user_u:object_r:user_mozilla_home_t:s0”,報錯信息有多條類似的,不止這一條。

再次google,***在紅帽的網(wǎng)站上找到了原因,之所以會出現(xiàn)這個問題因為在SELinux是disabled的狀態(tài)下升級了操作系統(tǒng),參見https://bugzilla.redhat.com/show_bug.cgi?id=449420

解決方法:

                在啟用SELinux并重啟后,執(zhí)行下列命令:

 genhomedircon

 touch /.autorelabel

 reboot

這次在重啟的時候就停在relabeling的地方,大概花了5分鐘左右,完成后進(jìn)入系統(tǒng),將SELinux設(shè)置為Enforcing模式,執(zhí)行命令ps  -eZ  查看進(jìn)程的SELinux上下文,一切正常。

附:

系統(tǒng)啟動時,運行/etc/rc.d/rc.sysinit腳本,在這個腳本中判斷了/.autorelabel文件是否存在,如果存在,則會調(diào)用fixfiles命令對整個文件系統(tǒng)進(jìn)行relabeling,相關(guān)代碼如下:

If   [ -f /.autorelabel ] || strstr"$cmdline" autorelabel ; then

       relabel_selinux

    fi

relabel_selinux() {

    if [ -x/usr/bin/rhgb-client ] && /usr/bin/rhgb-client --ping ; then

        chvt 1

    fi

    # if /sbin/init isnot labeled correctly this process is running in the

    # wrong context,so a reboot will be reuired after relabel

   REBOOTFLAG=`restorecon -v /sbin/init`

    AUTORELABEL=

    ./etc/selinux/config

    if ["$AUTORELABEL" = "0" ]; then

        rm -f  /.autorelabel

 

        echo

        echo$"*** Warning -- SELinux ${SELINUXTYPE} policy relabel is required. "

        echo $"*** /etc/selinux/configindicates you want to manually fix labeling"

        echo$"*** problems. Dropping you to a shell; the system will reboot"

        echo$"*** when you leave the shell."

        echo"0" > $selinuxfs/enforce

        sulogin

 

        echo$"Unmounting file systems"

        umount -a

        mount -n -oremount,ro /

        echo$"Automatic reboot in progress."

        reboot -f

    else

        echo

        echo$"*** Warning -- SELinux ${SELINUXTYPE} policy relabel is required."

        echo$"*** Relabeling could take a very long time, depending on file"

        echo$"*** system size and speed of hard drives."

 

        echo"0" > $selinuxfs/enforce

        /sbin/fixfiles  restore > /dev/null 2>&1

        rm -f  /.autorelabel

if [ ! -z "$REBOOTFLAG" ]; then

            echo$"Automatic reboot in progress."

            reboot -f

        fi

        echo$SELINUX_STATE > $selinuxfs/enforce

        if [ -x/usr/bin/rhgb-client ] && /usr/bin/rhgb-client --ping ; then

            chvt 8

        fi

    fi

}

【責(zé)任編輯:IT瘋 TEL:(010)68476606】

【編輯推薦】

  1. Chkdsk大躍進(jìn):Win8磁盤檢測時間大大縮短
  2. Linux下使用mke2fsk格式化分區(qū)的方法
  3. Ubuntu 11.10 利用終端環(huán)境備份還原
責(zé)任編輯:趙寧寧
相關(guān)推薦

2009-07-07 13:12:44

Java Servle

2016-12-20 12:42:28

MySQL腳本問題

2010-08-06 08:50:21

ASP.NET

2011-07-18 16:33:20

sqlite

2012-09-05 11:09:15

SELinux操作系統(tǒng)

2024-01-09 15:37:46

2023-01-30 08:09:18

權(quán)限GreatSQL運行

2024-04-29 13:07:00

運維保命原則Oracle

2021-10-12 00:04:24

腳本備份MariDB

2015-07-30 10:31:21

微軟Windows 10升級

2010-04-29 14:33:01

Unix系統(tǒng)

2011-07-04 11:08:52

數(shù)據(jù)中心機(jī)房建設(shè)擴(kuò)容

2013-05-06 16:36:55

SELinuxSELinux故障

2021-04-22 07:47:47

面試內(nèi)存磁盤

2011-05-31 14:22:23

2023-11-03 18:09:31

sed文件屬性

2024-04-01 07:53:51

MySQL索引字符

2019-01-07 14:36:36

Go系統(tǒng)開源庫

2016-02-26 15:25:45

程序員Bug反應(yīng)

2010-01-05 16:18:17

學(xué)習(xí)JavaScrip
點贊
收藏

51CTO技術(shù)棧公眾號