mirror of
https://github.com/Heleguo/lede.git
synced 2025-12-18 11:51:19 +00:00
samba36: fix autoshare CVE
This commit is contained in:
parent
2055072417
commit
5e282f08c5
@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
|
|||||||
|
|
||||||
PKG_NAME:=samba
|
PKG_NAME:=samba
|
||||||
PKG_VERSION:=4.0.26
|
PKG_VERSION:=4.0.26
|
||||||
PKG_RELEASE:=8
|
PKG_RELEASE:=9
|
||||||
|
|
||||||
PKG_SOURCE_URL:=https://ftp.samba.org/pub/samba/stable/
|
PKG_SOURCE_URL:=https://ftp.samba.org/pub/samba/stable/
|
||||||
PKG_SOURCE:=samba-$(PKG_VERSION).tar.gz
|
PKG_SOURCE:=samba-$(PKG_VERSION).tar.gz
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
|
||||||
# D-Team Technology Co.,Ltd. ShenZhen
|
#
|
||||||
# 作者:Vic
|
# D-Team Technology Co.,Ltd. ShenZhen
|
||||||
#
|
# 作者:Vic
|
||||||
#
|
#
|
||||||
# 警告:对着屏幕的哥们,我们允许你使用此脚本,但不允许你抹去作者的信息,请保留这段话。
|
# 警告:对着屏幕的哥们,我们允许你使用此脚本,但不允许你抹去作者的信息,请保留这段话。
|
||||||
#
|
#
|
||||||
|
|
||||||
. /lib/functions.sh
|
. /lib/functions.sh
|
||||||
. /lib/functions/service.sh
|
. /lib/functions/service.sh
|
||||||
|
|
||||||
@ -13,24 +14,24 @@ global=0
|
|||||||
config_file="/etc/config/samba"
|
config_file="/etc/config/samba"
|
||||||
|
|
||||||
wait_for_init() {
|
wait_for_init() {
|
||||||
for i in `seq 30`
|
for i in `seq 30`
|
||||||
do
|
do
|
||||||
[ -e /tmp/procd.done ] || {
|
[ -e /tmp/procd.done ] || {
|
||||||
sleep 1; continue;
|
sleep 1; continue;
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
smb_handle() {
|
smb_handle() {
|
||||||
config_get path $1 path
|
config_get path $1 path
|
||||||
if [ "$path" = "$2" ] ;then
|
if [ "$path" = "$2" ] ;then
|
||||||
global=1
|
global=1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
chk_en() {
|
chk_en() {
|
||||||
config_get_bool autoshare $1 autoshare 0
|
config_get_bool autoshare $1 autoshare 1
|
||||||
[ $autoshare -eq 0 ] && exit
|
[ $autoshare -eq 0 ] && exit
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,56 +42,57 @@ device=`basename $DEVPATH`
|
|||||||
|
|
||||||
case "$ACTION" in
|
case "$ACTION" in
|
||||||
add)
|
add)
|
||||||
|
|
||||||
case "$device" in
|
|
||||||
sd*) ;;
|
|
||||||
md*) ;;
|
|
||||||
hd*);;
|
|
||||||
mmcblk*);;
|
|
||||||
*) return;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
path="/dev/$device"
|
|
||||||
|
|
||||||
wait_for_init
|
case "$device" in
|
||||||
|
sd*);;
|
||||||
|
md*);;
|
||||||
|
hd*);;
|
||||||
|
mmcblk*);;
|
||||||
|
*) return;;
|
||||||
|
esac
|
||||||
|
|
||||||
cat /proc/mounts | while read j
|
path="/dev/$device"
|
||||||
do
|
|
||||||
str=${j%% *}
|
|
||||||
if [ "$str" == $path ];then
|
|
||||||
strr=${j#* }
|
|
||||||
target=${strr%% *}
|
|
||||||
global=0
|
|
||||||
config_foreach smb_handle sambashare $target
|
|
||||||
name=${target#*/mnt/}
|
|
||||||
|
|
||||||
if [ $global -eq 0 ] ;then
|
wait_for_init
|
||||||
echo -e "\n\nconfig sambashare" >> $config_file
|
|
||||||
echo -e "\toption auto '1'" >> $config_file
|
cat /proc/mounts | grep -v '/boot\|/opt|p1' | while read j
|
||||||
echo -e "\toption name '$name'" >> $config_file
|
do
|
||||||
echo -e "\toption path '$target'" >> $config_file
|
str=${j%% *}
|
||||||
echo -e "\toption read_only 'no'" >> $config_file
|
if [ "$str" == $path ];then
|
||||||
echo -e "\toption guest_ok 'yes'" >> $config_file
|
strr=${j#* }
|
||||||
echo -e "\toption device '$device'" >> $config_file
|
target=${strr%% *}
|
||||||
|
global=0
|
||||||
|
config_foreach smb_handle sambashare $target
|
||||||
|
name=${target#*/mnt/}
|
||||||
|
|
||||||
|
if [ $global -eq 0 ] ;then
|
||||||
|
echo -e "\n\nconfig sambashare" >> $config_file
|
||||||
|
echo -e "\toption auto '1'" >> $config_file
|
||||||
|
echo -e "\toption name '$name'" >> $config_file
|
||||||
|
echo -e "\toption path '$target'" >> $config_file
|
||||||
|
echo -e "\toption read_only 'no'" >> $config_file
|
||||||
|
echo -e "\toption guest_ok 'yes'" >> $config_file
|
||||||
|
echo -e "\toption create_mask '0666'" >> $config_file
|
||||||
|
echo -e "\toption dir_mask '0777'" >> $config_file
|
||||||
|
echo -e "\toption device '$device'" >> $config_file
|
||||||
/etc/init.d/samba reload
|
/etc/init.d/samba reload
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
|
|
||||||
remove)
|
remove)
|
||||||
i=0
|
i=0
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
|
|
||||||
dev=`uci get samba.@sambashare[$i].device`
|
dev=`uci get samba.@sambashare[$i].device`
|
||||||
[ $? -ne 0 ] && break
|
[ $? -ne 0 ] && break
|
||||||
|
|
||||||
[ "$dev" = "$device" ] && {
|
[ "$dev" = "$device" ] && {
|
||||||
auto=`uci get samba.@sambashare[$i].auto`
|
auto=`uci get samba.@sambashare[$i].auto`
|
||||||
[ $auto = "1" ] && {
|
[ $auto = "1" ] && {
|
||||||
mount_dir=`uci get samba.@sambashare[$i].name`
|
mount_dir=`uci get samba.@sambashare[$i].name`
|
||||||
rm -rf /mnt/$device /mnt/$mount_dir
|
|
||||||
uci delete samba.@sambashare[$i]
|
uci delete samba.@sambashare[$i]
|
||||||
uci commit
|
uci commit
|
||||||
/etc/init.d/samba reload
|
/etc/init.d/samba reload
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user