selinux-policy-default(2:2.20231119-2)軟件包內容詳細介紹(2)

接前一篇文章:selinux-policy-default(2:2.20231119-2)軟件包內容詳細介紹(1)

4. 重點文件內容解析

(1)control/postist文件

文件內容如下:

#!/bin/sh
set -e# summary of how this script can be called:
#        * <postinst> `configure' <most-recently-configured-version>
#        * <old-postinst> `abort-upgrade' <new version>
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#          <new-version>
#        * <postinst> `abort-remove'
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package# Will be replaced by the binary package flavour in debian/rules
flavour="default"
priority=100# modules which are not enabled by default, because they are usually
# not needed on a debian system
notdefault="aisexec amtu bugzilla cobbler condor cyphesis git ksmtuned likewise livecd nessus numad oddjob openca rlogin rshd soundserver telnet publicfile thunderbird updfstab usernetctl"platform=$(hostnamectl chassis) || true
case "$platform" inhandset)
# dont need staff rolenotdefault="$notdefault staff"
# dont need hardware specific things for non phone hardwarenotdefault="$notdefault acpi cdrecord fcoe iscsi isns openct raid rasdaemon tgtd tvtime vbetool"
# dont need VM thingsnotdefault="$notdefault hypervkvp"
# dont need serious server daemonsnotdefault="$notdefault afs aide amanda amavis apcupsd aptcacher asterisk awstats bacula bind bird bitlbee boinc cachefilesd calamaris certbot cfengine clamav cockpit corosync couchdb courier ctdb cvs cyrus dbadm dictd distcc djbdns dkim dmidecode docker dovecot drbd fetchmail gitosis glance glusterfs inn irc ircd jabber kerberos keystone ldap lightsquid mailman matrixd mediawiki memcached milter minidlna mojomojo mongodb monop mrtg munin nagios nis nsd nslcd ntop nut openhpi openvswitch pacemaker passenger pcscd pegasus perdition pingd portmap portslave postfixpolicyd postgresql postgrey prelude procmail puppet pxe pyzor qemu qmail qpid quantum rabbitmq radius radvd razor realmd redis rsync samba samhain sanlock sasl sblim secadm shibboleth snort spamassassin squid stunnel svnserve sympa tftp tripwire uml uucp uwimap varnishd virt vmware wdmd webadm webalizer xen zabbix zarafa zebra"
# dont need time sharing system daemonsnotdefault="$notdefault comsat finger oident rwho slocate slrnpull uptime quota";;vm)
# dont need hardware specific things for vmsnotdefault="$notdefault acpi cdrecord fcoe iscsi isns openct raid rasdaemon tgtd tvtime vbetool"
# dont need handset stuffnotdefault="$notdefault eg25manager feedbackd geoclue iiosensorproxy";;desktop)
# dont need VM thingsnotdefault="$notdefault hypervkvp"
# dont need portable stuffnotdefault="$notdefault geoclue"
# dont need handset stuffnotdefault="$notdefault eg25manager feedbackd iiosensorproxy";;laptop)
# dont need VM thingsnotdefault="$notdefault hypervkvp"
# dont need handset stuffnotdefault="$notdefault eg25manager feedbackd iiosensorproxy";;*)echo "Unknown output from hostnamectl or not running systemd";;
esac. /etc/selinux/configcase "$1" inconfigure)echo -n "Updating selinux ${flavour} policy (this step might take a moment)..."# list all the modules that are already installed with our priorityalready_installed=`semodule -s ${flavour} --list-modules=full | grep -e "^${priority} " | cut -d' ' -f2`# record which non-default modules do not yet exist for disabling them laterto_disable=""for module in ${notdefault}; doinstalled=0for inst_module in ${already_installed}; doif [ $module = $inst_module ]; theninstalled=1breakfidoneif [ $installed -ne 1 ]; thento_disable="$to_disable -d${module}"fidone# List all the modules that we are going to installto_install=""for module in `cat /usr/share/selinux/${flavour}/.modules`; doto_install="$to_install -i/usr/share/selinux/${flavour}/${module}.pp.bz2"done# Now build a list of the modules that we were shipping before but that we are not# anymore and that we need to removeto_remove=""for inst_module in $already_installed; doremove_module=1for pkg_module in `cat /usr/share/selinux/${flavour}/.modules`; doif [ $inst_module = $pkg_module ]; thenremove_module=0breakfidoneif [ $remove_module -eq 1 ]; thento_remove="$to_remove -r${inst_module}"fidone# Now load policy into the kernel if it is the configured policy# and we are running selinuxif [ "${SELINUXTYPE}" != "${flavour}" ] || ! selinuxenabled; thennoreload='-n'firet=0semodule -X $priority $noreload -s $flavour $to_remove $to_install $to_disable || ret=$?if [ $ret -eq 0 ]; thenecho " done."elseecho " failed."exit $retfiFC=/etc/selinux/$flavour/contexts/files/file_contextsOLDFC=$FC.oldif [ -f $OLDFC ]; thenOLDSORT=$(mktemp)NEWSORT=$(mktemp)sort < $OLDFC > $OLDSORTsort < $FC > $NEWSORTORIGDIFF=$(mktemp)diff $OLDSORT $NEWSORT | grep -v ^[0-9] > $ORIGDIFF || truerm $OLDSORT $NEWSORTif [ -s $ORIGDIFF ]; thenDIFF=$(mktemp)cut -f2 -d\  < $ORIGDIFF > $DIFFGOOD=$(mktemp)grep -v ^/run $DIFF |grep -v ^/dev | grep "/.*/" > $GOOD || trueif [ -s $GOOD ]; thenecho ""echo "Relabeling matches for the following file context changes:"cat $GOODecho ""DIRS=$(cat $GOOD | sed -e 's/(\.\*\/).*$//' -e 's/(.*$//' -e 's/\/[^/]*$//' -e 's/\/[0-9a-z]*\[.*$//' | sort -u | /usr/libexec/selinux/remove-leaf-dirs)echo The following directories: $DIRSrestorecon -R -v $DIRS || echo "restorecon gave an error but package is still ok"firm $GOODPROB=$(mktemp)grep ^../run $ORIGDIFF > $PROB || truegrep ^../dev $ORIGDIFF >> $PROB || truegrep -v "/.*/" $ORIGDIFF >> $PROB || trueif [ -s $PROB ]; thenecho "The following lines have changes that can't be automatically applied, consider"echo "manually relabelling them if appropriate:"cat $PROBfirm $DIFF $PROBelseecho "No changes to file contexts"firm $ORIGDIFF $OLDFCfi;;abort-upgrade|abort-remove|abort-deconfigure);;*)echo "postinst called with unknown argument \`$1'" >&2exit 1;;
esac# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.# Automatically added by dh_installdeb/13.11.6
dpkg-maintscript-helper rm_conffile /etc/selinux/default/users/local.users 2:2.20140421-10\~ -- "$@"
dpkg-maintscript-helper rm_conffile /etc/selinux/default/users/system.users 2:2.20140421-10\~ -- "$@"
dpkg-maintscript-helper rm_conffile /etc/selinux/default/modules/semanage.read.LOCK 2:2.20140421-10\~ -- "$@"
dpkg-maintscript-helper rm_conffile /etc/selinux/default/modules/semanage.trans.LOCK 2:2.20140421-10\~ -- "$@"
dpkg-maintscript-helper rm_conffile /etc/selinux/default/modules/active/file_contexts.local 2:2.20140421-10\~ -- "$@"
# End automatically added sectionexit 0

control/postist文件總共189行,還是比較長的,內容也比較多。下邊一段一段來看。

1)!#/bin/sh

這無需多言,#!/bin/sh是指此腳本使用/bin/sh來解釋執行。

2)set -e

set -e是shell中的一個選項,其作用是在腳本執行過程中,一旦出現任何命令執行失敗(返回非零的退出狀態碼),腳本就會立即退出,后續的腳本將不會得到執行的機會。

注意:

使用set -e,當一行命令中包含多個子命令時,即使某個子命令返回值不為0,但最終那一行命令的返回值為0,腳本也不會報錯退出。

3)注釋說明

接下來是一段如何運行postinst的具體說明。這一段如下:

# summary of how this script can be called:
#        * <postinst> `configure' <most-recently-configured-version>
#        * <old-postinst> `abort-upgrade' <new version>
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#          <new-version>
#        * <postinst> `abort-remove'
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package

這一段是關于如何調用此(postinst)腳本的摘要。更多詳細信息,參閱http://www.debian.org/doc/debian-policy/或debian-policy包。

4)變量賦值語句

接下來是幾個變量賦值語句,代碼片段如下:

# Will be replaced by the binary package flavour in debian/rules
flavour="default"
priority=100# modules which are not enabled by default, because they are usually
# not needed on a debian system
notdefault="aisexec amtu bugzilla cobbler condor cyphesis git ksmtuned likewise livecd nessus numad oddjob openca rlogin rshd soundserver telnet publicfile thunderbird updfstab usernetctl"

設置變量flavour的值為"default",此值將被debian/rule中的二進制包flavour所代替。

設置變量priority的值為100。

設置變量nodefault的值為"aisexec amtu bugzilla cobbler condor cyphesis git ksmtuned likewise livecd nessus numad oddjob openca rlogin rshd soundserver telnet publicfile thunderbird updfstab usernetctl"。這些值代表默認情況下不會被使能的模塊,因為debian系統通常不需要這些模塊。

5)platform變量賦值

接下來是以下一行代碼:

platform=$(hostnamectl chassis) || true

雖然只有一行,但其中內容還是挺多的。主要涉及到hostnamectl命令。

關于hostnamectl命令的詳解,請參考相關文章。在此列出筆者電腦中的相關信息,如下:?

$ hostnamectl Static hostname: Ding-Perlis-MP26JBT0Icon name: computerMachine ID: ccd4c48fdb304652ad40edc548349078Boot ID: 11b3d0d94b7c40cb96663b7ff7ee8790
Operating System: DingOS 0.1 (ding-perlis-minsky-v00)Kernel: Linux 6.1.46-01-perlis001-2Architecture: x86-64Hardware Vendor: LenovoHardware Model: ThinkBook 14 G2 ITL
Firmware Version: F8CN46WW(V2.09)

命令用法:

$ hostnamectl -h
hostnamectl [OPTIONS...] COMMAND ...Query or change system hostname.Commands:status                 Show current hostname settingshostname [NAME]        Get/set system hostnameicon-name [NAME]       Get/set icon name for hostchassis [NAME]         Get/set chassis type for hostdeployment [NAME]      Get/set deployment environment for hostlocation [NAME]        Get/set location for hostOptions:-h --help              Show this help--version           Show package version--no-ask-password   Do not prompt for password-H --host=[USER@]HOST  Operate on remote host-M --machine=CONTAINER Operate on local container--transient         Only set transient hostname--static            Only set static hostname--pretty            Only set pretty hostname--json=pretty|short|offGenerate JSON outputSee the hostnamectl(1) man page for details.

實際hostnamectl chassis命令的返回值:

$ hostnamectl chassis

6)根據platform變量的值決定notdefault的進一步值

代碼片段如下:

case "$platform" inhandset)
# dont need staff rolenotdefault="$notdefault staff"
# dont need hardware specific things for non phone hardwarenotdefault="$notdefault acpi cdrecord fcoe iscsi isns openct raid rasdaemon tgtd tvtime vbetool"
# dont need VM thingsnotdefault="$notdefault hypervkvp"
# dont need serious server daemonsnotdefault="$notdefault afs aide amanda amavis apcupsd aptcacher asterisk awstats bacula bind bird bitlbee boinc cachefilesd calamaris certbot cfengine clamav cockpit corosync couchdb courier ctdb cvs cyrus dbadm dictd distcc djbdns dkim dmidecode docker dovecot drbd fetchmail gitosis glance glusterfs inn irc ircd jabber kerberos keystone ldap lightsquid mailman matrixd mediawiki memcached milter minidlna mojomojo mongodb monop mrtg munin nagios nis nsd nslcd ntop nut openhpi openvswitch pacemaker passenger pcscd pegasus perdition pingd portmap portslave postfixpolicyd postgresql postgrey prelude procmail puppet pxe pyzor qemu qmail qpid quantum rabbitmq radius radvd razor realmd redis rsync samba samhain sanlock sasl sblim secadm shibboleth snort spamassassin squid stunnel svnserve sympa tftp tripwire uml uucp uwimap varnishd virt vmware wdmd webadm webalizer xen zabbix zarafa zebra"
# dont need time sharing system daemonsnotdefault="$notdefault comsat finger oident rwho slocate slrnpull uptime quota";;vm)
# dont need hardware specific things for vmsnotdefault="$notdefault acpi cdrecord fcoe iscsi isns openct raid rasdaemon tgtd tvtime vbetool"
# dont need handset stuffnotdefault="$notdefault eg25manager feedbackd geoclue iiosensorproxy";;desktop)
# dont need VM thingsnotdefault="$notdefault hypervkvp"
# dont need portable stuffnotdefault="$notdefault geoclue"
# dont need handset stuffnotdefault="$notdefault eg25manager feedbackd iiosensorproxy";;laptop)
# dont need VM thingsnotdefault="$notdefault hypervkvp"
# dont need handset stuffnotdefault="$notdefault eg25manager feedbackd iiosensorproxy";;*)echo "Unknown output from hostnamectl or not running systemd";;
esac

postinst的其余代碼請看下回。

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/160789.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/160789.shtml
英文地址,請注明出處:http://en.pswp.cn/news/160789.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

22LLMSecEval數據集及其在評估大模型代碼安全中的應用:GPT3和Codex根據LLMSecEval的提示生成代碼和代碼補全,CodeQL進行安全評估

LLMSecEval: A Dataset of Natural Language Prompts for Security Evaluations 寫在最前面主要工作 課堂討論大模型和密碼方向&#xff08;沒做&#xff0c;只是一個idea&#xff09; 相關研究提示集目標NL提示的建立NL提示的建立流程 數據集數據集分析 存在的問題 寫在最前面…

力扣算法練習BM45—滑塊窗口的最大值

題目 給定一個長度為 n 的數組 num 和滑動窗口的大小 size &#xff0c;找出所有滑動窗口里數值的最大值。 例如&#xff0c;如果輸入數組{2,3,4,2,6,2,5,1}及滑動窗口的大小3&#xff0c;那么一共存在6個滑動窗口&#xff0c;他們的最大值分別為{4,4,6,6,6,5}&#xff1b; 針…

使用Python畫一棵樹

&#x1f38a;專欄【不單調的代碼】 &#x1f354;喜歡的詩句&#xff1a;更喜岷山千里雪 三軍過后盡開顏。 &#x1f386;音樂分享【如愿】 &#x1f970;歡迎并且感謝大家指出我的問題 文章目錄 &#x1f339;Turtle模塊&#x1f384;效果&#x1f33a;代碼&#x1f6f8;代碼…

【tomcat】java.lang.Exception: Socket bind failed: [730048

項目中一些舊工程運行情況處理 問題 1、啟動端口占用 2、打印編碼亂碼 ??&#xfffd;&#xfffd; 13, 2023 9:33:26 &#xfffd;&#xfffd;&#xfffd;&#xfffd; org.apache.coyote.AbstractProtocol init &#xfffd;&#xfffd;&#xfffd;&#xfffd;: Fa…

五毛QQ項目記

問題與挑戰&#xff1a;某公司為了實現某馬總造福全人類&#xff0c;紅旗插遍全球的宏偉目標&#xff0c;為應對后續用戶量激增的問題。特別安排了一次針對全體用戶的秒殺活動&#xff1a;于XXXX年XX月XX日XX時XX分XX秒開始的秒殺五毛錢一百個QQ幣的活動。每個賬戶僅限一次&…

oracle面試相關的,Oracle基本操作的SQL命令

文章目錄 數據庫-Oracle〇、Oracle用戶管理一、Oracle數據庫操作二、Oracle表操作1、創建表2、刪除表3、重命名表4、增加字段5、修改字段6、重名字段7、刪除字段8、添加主鍵9、刪除主鍵10、創建索引11、刪除索引12、創建視圖13、刪除視圖 三、Oracle操作數據1、數據查詢2、插入…

ubuntu 20.04如何切換gcc/g++/python的版本

ubuntu 20.04如何切換gcc/g/python的版本 1 安裝gcc/g/python2 設置gcc/g/python的備選項3 選擇當前系統要使用的gcc/g/python版本3.1 切換gcc/g/python版本3.2 切換示例 當系統同時存在gcc-9以及gcc-10時該如何切換讓當前的系統gcc版本指向gcc-9或是gcc-10呢&#xff1f;g也同…

Connect-The-Dots_2

Connect-The-Dots_2 一、主機發現和端口掃描 主機發現&#xff0c;靶機地址192.168.80.148 arp-scan -l端口掃描 nmap -A -p- -sV 192.168.80.148開放端口 21/tcp open ftp vsftpd 2.0.8 or later 80/tcp open http Apache httpd 2.4.38 ((Debian)) 111/tcp …

循環隊列詳解!!c 語言版本(兩種方法)雙向鏈表和數組法!!

目錄 1.什么是循環隊列 2.循環隊列的實現&#xff08;兩種方法&#xff09; 第一種方法 數組法 1.源代碼 2.源代碼詳解&#xff01;&#xff01; 1.創造隊列空間和struct變量 2.隊列判空 3.隊列判滿&#xff08;重點&#xff09; 4.隊列的元素插入 5.隊列的元素刪除 …

GIT實踐與常用命令---回退

實踐場景 場景1 回退提交 在日常工作中&#xff0c;我們可能會和多個同事在同一個分支進行開發&#xff0c;有時候我們可能會出現一些錯誤提交&#xff0c;這些錯誤提交如果想撤銷&#xff0c;可以有兩種解決辦法:回退( reset )、反做(revert) keywords&#xff1a;reset、rev…

2023軟件測試的4個技術等級,你在哪個級別?

最近&#xff0c;我們討論了軟件測試工程的的分級&#xff0c;大家都貢獻了自己的想法&#xff0c;對于大家來說&#xff0c;軟件測試人的分級其實也代表了我們的進階方向&#xff0c;職業發展。總體來說&#xff0c;測試工程師未來發展有三個方向&#xff1a; 技術精英 行業專…

層次分析法--可以幫助你做決策的簡單算法

作用 層次分析法是一個多指標的評價算法&#xff0c;主要用來在做決策時&#xff0c;給目標的多個影響因子做權重評分。特別是那些需要主觀決策的、或者需要用經驗判斷的決策方案&#xff0c;例如&#xff1a; 買房子&#xff08;主觀決策&#xff09;選擇旅游地&#xff08;…

android11 申請所有文件訪問權限

Android 11 引入了強制執行分區存儲的限制&#xff0c;導致應用默認不能訪問外部文件。 針對以前涉及較多文件的操作&#xff0c;可采用申請所有文件訪問權限的方式來解決這一問題&#xff0c;實現方式如下。 &#xff08;雖然這樣做安全性低&#xff0c;官方并不推薦這樣&…

preplexity test

Preplexity test can use model claude and gpt-4, feel speed is ok and only for $10 with coupon (below give a link). Feel ok to try reference link: https://perplexity.ai/pro?referral_codeV6UOS5PH

Shell判斷:模式匹配:case(三)

系統管理工具箱 1、需求&#xff1a;Linux提供的豐富的管理命令&#xff0c;用戶管理&#xff0c;內存管理&#xff0c;磁盤管理&#xff0c;進程管理&#xff0c;日志管理&#xff0c;文件管理&#xff0c;軟件管理&#xff0c;網絡管理等等數十個工具包。如果你能通過shell編…

【代碼隨想錄】算法訓練計劃30

【代碼隨想錄】算法訓練計劃30 1、51. N 皇后 按照國際象棋的規則&#xff0c;皇后可以攻擊與之處在同一行或同一列或同一斜線上的棋子。 n 皇后問題 研究的是如何將 n 個皇后放置在 nn 的棋盤上&#xff0c;并且使皇后彼此之間不能相互攻擊。 給你一個整數 n &#xff0c;…

微信API:探究Android平臺下Hook技術的比較與應用場景分析

微信API&#xff1a;探究Android平臺下Hook技術的比較與應用場景分析 正文&#xff1a; 在Android平臺開發中&#xff0c;Hook技術是一種常用的技術手段&#xff0c;用于在運行時修改應用程序的行為。下面對一些常見的Hook技術進行比較&#xff0c;并分析它們的適用場景和優缺…

信息系統項目管理師論文

軟考官網&#xff1a;中國計算機技術職業資格網 (ruankao.org.cn) 2020年 2020年下半年試題一&#xff1a;論信息系統項目的成本管理 2019年 2019年下半年試題一&#xff1a;論信息系統項目的整體管理 2019年下半年試題二&#xff1a;論信息系統項目的溝通管理

PCI5565反射內存網技術的應用研究

隨著嵌入式與通信技術的發展&#xff0c;數控系統經歷了由傳統的單處理器的集中式體系結構到開放式體系結構&#xff0c;再到多處理器的分布式數控系統體系結構的發展過程。分布式數控系統以高精、高速的加工特征為發展核心&#xff0c;同時以達到異構網絡間信息的無縫融合&…