mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-29 21:56:42 +00:00
Merge pull request #308 from stefansaraev/samba
samba: add an option to password protect all shared folders
This commit is contained in:
commit
280d1ccf44
@ -26,6 +26,9 @@
|
||||
<setting id="NET2_SECURITY" value="NONE" />
|
||||
<setting id="NET2_SSID" value="" />
|
||||
<setting id="SAMBA_START" value="true" />
|
||||
<setting id="SAMBA_SECURITY" value="false" />
|
||||
<setting id="SAMBA_USERNAME" value="openelec" />
|
||||
<setting id="SAMBA_PASSWORD" value="openelec" />
|
||||
<setting id="UPDATE_AUTO" value="manual" />
|
||||
<setting id="X11_KEYMAP" value="us" />
|
||||
<setting id="X11_KEYMAP2" value="" />
|
||||
|
@ -36,5 +36,8 @@
|
||||
<string id="5000">Samba</string>
|
||||
<string id="5010">Boot</string>
|
||||
<string id="5011">Start Samba at boot</string>
|
||||
<string id="5012">Use Samba Passwords</string>
|
||||
<string id="5013">Samba Username</string>
|
||||
<string id="5014">Samba Password</string>
|
||||
|
||||
</strings>
|
||||
|
@ -67,5 +67,8 @@
|
||||
<setting label="5010" type="lsep"/>
|
||||
<setting type="sep" />
|
||||
<setting id="SAMBA_START" type="bool" label="5011" default="true" />
|
||||
<setting id="SAMBA_SECURITY" type="bool" label="5012" default="false" enable="eq(-1,true)"/>
|
||||
<setting id="SAMBA_USERNAME" type="text" label="5013" default="openelec" enable="eq(-1,true) + eq(-2,true)"/>
|
||||
<setting id="SAMBA_PASSWORD" type="text" option="hidden" label="5014" default="openelec" enable="eq(-2,true)+ eq(-3,true)"/>
|
||||
</category>
|
||||
</settings>
|
||||
|
@ -111,6 +111,7 @@ make bin/libsmbclient.so
|
||||
if [ "$SAMBA_SERVER" = yes ]; then
|
||||
make bin/smbd
|
||||
make bin/nmbd
|
||||
make bin/smbpasswd
|
||||
fi
|
||||
|
||||
mkdir -p $SYSROOT_PREFIX/usr/lib
|
||||
|
@ -29,6 +29,7 @@ if [ "$SAMBA_SERVER" = "yes" ]; then
|
||||
mkdir -p $INSTALL/usr/bin
|
||||
cp $PKG_BUILD/source3/bin/smbd $INSTALL/usr/bin
|
||||
cp $PKG_BUILD/source3/bin/nmbd $INSTALL/usr/bin
|
||||
cp $PKG_BUILD/source3/bin/smbpasswd $INSTALL/usr/bin
|
||||
|
||||
mkdir -p $INSTALL/etc/samba
|
||||
cp $PKG_DIR/config/smb.conf $INSTALL/etc/samba
|
||||
|
@ -35,13 +35,49 @@
|
||||
|
||||
SMB_USERCONF="/storage/.config/samba.conf"
|
||||
SMB_DEFCONF="/etc/samba/smb.conf"
|
||||
SMB_CONF="/var/run/smb.conf"
|
||||
|
||||
mkdir -p /var/run
|
||||
if [ -f $SMB_USERCONF ]; then
|
||||
SMB_ARG="--configfile=$SMB_USERCONF"
|
||||
cp $SMB_USERCONF $SMB_CONF
|
||||
else
|
||||
SMB_ARG="--configfile=$SMB_DEFCONF"
|
||||
cp $SMB_DEFCONF $SMB_CONF
|
||||
fi
|
||||
|
||||
# only letters & numbers permitted for username & password
|
||||
SAMBA_USERNAME=`echo $SAMBA_USERNAME | sed "s/[^a-zA-Z0-9]//g;"`
|
||||
SAMBA_PASSWORD=`echo $SAMBA_PASSWORD | sed "s/[^a-zA-Z0-9]//g;"`
|
||||
|
||||
if [ "$SAMBA_SECURITY" == "true" -a ! "$SAMBA_USERNAME" == "" -a ! "$SAMBA_PASSWORD" == "" ] ; then
|
||||
# username map: first line makes sure plain root does not work all the time
|
||||
# processing continues, so if user chooses root as username, second line overrides the first
|
||||
# this is done always in case user uses passwords in userconf.
|
||||
# many thanks to viljoviitanen for this
|
||||
echo -e "$SAMBA_PASSWORD\n$SAMBA_PASSWORD" | smbpasswd -s -a root >/dev/null 2>&1
|
||||
echo -e "nobody = root\nroot = $SAMBA_USERNAME" > /var/run/samba.map
|
||||
|
||||
# set public = no
|
||||
sed -e 's|^.[ \t]*.public.=.*| public = no |' $SMB_CONF > $SMB_CONF.tmp && \
|
||||
mv $SMB_CONF.tmp $SMB_CONF
|
||||
# remove username map (if any in userconfig)
|
||||
sed -e 's|^.[ \t]*.username map.=.*||' $SMB_CONF > $SMB_CONF.tmp && \
|
||||
mv $SMB_CONF.tmp $SMB_CONF
|
||||
# set security = share, add username map
|
||||
sed -e 's|^.[ \t]*.security.=.*| security = user\n username map = /var/run/samba.map|' $SMB_CONF > $SMB_CONF.tmp && \
|
||||
mv $SMB_CONF.tmp $SMB_CONF
|
||||
else
|
||||
# set public = yes
|
||||
sed -e 's|^.[ \t]*.public.=.*| public = yes |' $SMB_CONF > $SMB_CONF.tmp && \
|
||||
mv $SMB_CONF.tmp $SMB_CONF
|
||||
# remove username map (if any in userconfig)
|
||||
sed -e 's|^.[ \t]*.username map.=.*||' $SMB_CONF > $SMB_CONF.tmp && \
|
||||
mv $SMB_CONF.tmp $SMB_CONF
|
||||
# set security = share
|
||||
sed -e 's|^.[ \t]*.security.=.*| security = share|' $SMB_CONF > $SMB_CONF.tmp && \
|
||||
mv $SMB_CONF.tmp $SMB_CONF
|
||||
fi
|
||||
|
||||
SMB_ARG="--configfile=$SMB_CONF"
|
||||
mkdir -p /var/log/samba
|
||||
nmbd --daemon $SMB_ARG > /dev/null 2>&1
|
||||
smbd --daemon $SMB_ARG > /dev/null 2>&1
|
||||
|
Loading…
x
Reference in New Issue
Block a user