[OpenWrt-Devel] [PATCH] Revert "samba36: add hotplug support"

Rafał Miłecki zajec5 at gmail.com
Tue Dec 25 12:46:44 EST 2018


From: Rafał Miłecki <rafal at milecki.pl>

This reverts commit fd569e5e9d0a46ea957cb253e97a4b3ea8c2c540.

After an extra review & discussion few concerns were raised regarding
that feature:
1) It reacts to hotplug.d "block" events instead of more accurate (but
   currently unavailable) "mount" events.
2) It requires *something* to mount block device before samba hotplug.d
   gets fired. Otherwise samba_add_section() will just return.
3) It doesn't reload Samba which some users may expect
4) It operates on /etc/ which is not a right place for autogenerated
   ephemeral config.
5) It doesn't include any cleanup for non-existing shares.

Cc: Rosy Song <rosysong at rosinson.com>
Cc: Jo-Philipp Wich <jo at mein.io>
Signed-off-by: Rafał Miłecki <rafal at milecki.pl>
---
 package/network/services/samba36/Makefile          | 14 ----
 .../network/services/samba36/files/lib/samba.sh    | 89 ----------------------
 .../network/services/samba36/files/samba.hotplug   | 11 ---
 3 files changed, 114 deletions(-)
 delete mode 100644 package/network/services/samba36/files/lib/samba.sh
 delete mode 100644 package/network/services/samba36/files/samba.hotplug

diff --git a/package/network/services/samba36/Makefile b/package/network/services/samba36/Makefile
index d38e942074..b63c2eaad3 100644
--- a/package/network/services/samba36/Makefile
+++ b/package/network/services/samba36/Makefile
@@ -43,12 +43,6 @@ define Package/samba36-server
   DEPENDS:=+USE_GLIBC:librt $(ICONV_DEPENDS)
 endef
 
-define Package/samba36-hotplug
-  $(call Package/samba/Default)
-  TITLE+= hotplug
-  DEPENDS:=+block-mount
-endef
-
 define Package/samba36-client
   $(call Package/samba/Default)
   TITLE+= client
@@ -167,13 +161,6 @@ define Package/samba36-server/install
 	$(LN) samba_multicall $(1)/usr/sbin/smbpasswd
 endef
 
-define Package/samba36-hotplug/install
-	$(INSTALL_DIR) $(1)/lib/samba
-	$(INSTALL_CONF) ./files/lib/samba.sh $(1)/lib/samba/samba.sh
-	$(INSTALL_DIR) $(1)/etc/hotplug.d/block
-	$(INSTALL_CONF) ./files/samba.hotplug $(1)/etc/hotplug.d/block/60-samba
-endef
-
 define Package/samba36-client/install
 	$(INSTALL_DIR) $(1)/usr/sbin
 	$(INSTALL_BIN) $(PKG_BUILD_BIN)/smbclient $(1)/usr/sbin
@@ -187,6 +174,5 @@ endef
 
 $(eval $(call BuildPackage,samba36-client))
 $(eval $(call BuildPackage,samba36-server))
-$(eval $(call BuildPackage,samba36-hotplug))
 $(eval $(call BuildPackage,samba36-net))
 
diff --git a/package/network/services/samba36/files/lib/samba.sh b/package/network/services/samba36/files/lib/samba.sh
deleted file mode 100644
index a72a2a1933..0000000000
--- a/package/network/services/samba36/files/lib/samba.sh
+++ /dev/null
@@ -1,89 +0,0 @@
-#!/bin/sh
-#
-# Copyright (C) 2018 OpenWrt.org
-# Copyright (C) 2018 rosysong at rosinson.com
-#
-
-. /lib/functions.sh
-
-FLAG_DEV_TYPE=
-FLAG_DEV_MOPT=
-FLAG_HAS_SECT=
-
-samba_dev_filter() { # <devname> <[path,/dev/]>
-	case $1 in
-	${2}mtdblock*|\
-	${2}ubi*)
-		FLAG_DEV_TYPE="mtd"
-		;;
-	${2}loop*|\
-	${2}mmcblk*|\
-	${2}sd*|\
-	${2}hd*|\
-	${2}md*|\
-	${2}nvme*|\
-	${2}vd*|\
-	${2}xvd*)
-		FLAG_DEV_TYPE="not-mtd"
-		;;
-	*)
-		[ -b ${2}${1} ] && FLAG_DEV_TYPE="not-mtd"
-		[ -b /dev/mapper/$1 ] && FLAG_DEV_TYPE="not-mtd"
-		;;
-	esac
-}
-
-samba_cfg_lookup() { # <section> <name>
-	config_get name $1 name
-	[ "$name" = "$2" ] || return
-	FLAG_HAS_SECT=y
-}
-
-samba_cfg_delete() { # <section> <name>
-	config_get name $1 name
-	[ "$name" = "$2" ] || return
-	uci -q delete samba.$1
-}
-
-samba_find_mount_point() { # <devname>
-	# search mount point in /proc/mounts
-	while read l; do
-		local d=$(echo $l | awk '/^\/dev/ {print $1}')
-		[ "$d" = "/dev/$1" ] || continue
-
-		FLAG_DEV_MOPT=$(echo $l | awk '/^\/dev/ {print $2}')
-		break
-	done < /proc/mounts
-}
-
-_samba_add_section() { # <devname> <mount point>
-	uci -q batch <<-EOF
-		add samba sambashare
-		set samba. at sambashare[-1].browseable='yes'
-		set samba. at sambashare[-1].name='$1'
-		set samba. at sambashare[-1].path='$2'
-		set samba. at sambashare[-1].users='root'
-		set samba. at sambashare[-1].read_only='no'
-		set samba. at sambashare[-1].guest_ok='yes'
-		set samba. at sambashare[-1].create_mask='0755'
-		set samba. at sambashare[-1].dir_mask='0755'
-	EOF
-}
-
-samba_add_section() { # <devname> [<mount point>]
-	FLAG_HAS_SECT=
-	FLAG_DEV_MOPT=
-
-	config_foreach samba_cfg_lookup sambashare $1
-	[ -z "$FLAG_HAS_SECT" ] || return
-
-	samba_find_mount_point $1
-	[ -n "$FLAG_DEV_MOPT" ] || return
-
-	[ -n "$2" -a "$2" = "$FLAG_DEV_MOPT" ] || \
-		_samba_add_section $1 $FLAG_DEV_MOPT
-}
-
-samba_delete_section() { # <devname>
-	config_foreach samba_cfg_delete sambashare $1
-}
diff --git a/package/network/services/samba36/files/samba.hotplug b/package/network/services/samba36/files/samba.hotplug
deleted file mode 100644
index 9c6dbe5e41..0000000000
--- a/package/network/services/samba36/files/samba.hotplug
+++ /dev/null
@@ -1,11 +0,0 @@
-. /lib/samba/samba.sh
-
-samba_dev_filter $DEVNAME
-[ "$FLAG_DEV_TYPE" = "not-mtd" ]  || exit
-
-config_load samba
-case $ACTION in
-	add) samba_add_section $DEVNAME;;
-	remove) samba_delete_section $DEVNAME;;
-esac
-uci commit samba
-- 
2.13.7


_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list