Removing Public Share WD MyCloud

##WD MyCloud - Delete Public Share


Guide and scripts to remove or restore the public share on WD My Cloud.

![MyCloud Dahboard No Public Share](http://i.imgur.com/dyz3EVt.png "No Public Share")

Remove Public Share from WD MyCloud

Remove Public Share


curl -L https://gist.github.com/codedecay/02e5dc3d487a38d0a89f/raw | sh

#Backup Files
cp /etc/wdcomp.d/boot/bootscript_005_wd-nas /root/bootscript_005_wd-nas.bkup
cp /usr/local/sbin/createDataVolume.sh /root/createDataVolume.bkup
cp /etc/samba/overall_share /root/overall_share.bkup

#Comment out relevant lines in the boot and create script.
sed -i '209,215 s/^/#/' /etc/wdcomp.d/boot/bootscript_005_wd-nas
sed -i '23,25 s/^/#/' /usr/local/sbin/createDataVolume.sh
sed -i '29,29 s/^/#/' /usr/local/sbin/createDataVolume.sh

#Comment out validation in deleteShare.sh if it is present.
sed -i '/echo \$shareName/ {N;N; /delete Public/ s/^/#!!#/}' /usr/local/sbin/deleteShare.sh 
sed -i '/#!!#if/,+4 s/^/#/; s/#!!#//' /usr/local/sbin/deleteShare.sh`

#Delete the public share
/usr/local/sbin/deleteShare.sh "Public"

#Comment out the public share definition from the Samba config.
sed -i '1,10 s/^/#/' /etc/samba/overall_share

#Restart the samba service.
service samba restart

##Restore Public Share

curl -L https://gist.github.com/codedecay/02e5dc3d487a38d0a89f/raw | sh

#Either Restore from your backup files..
/bin/cp /root/bootscript_005_wd-nas.bkup /etc/wdcomp.d/boot/bootscript_005_wd-nas
/bin/cp /root/createDataVolume.bkup /usr/local/sbin/createDataVolume.sh
/bin/cp /root/deleteShare.bkup /usr/local/sbin/deleteShare.sh
/bin/cp /root/overall_share.bkup /etc/samba/overall_share

#Or undo the comments in the existing files.
sed -i '209,215 s/^#//' /etc/wdcomp.d/boot/bootscript_005_wd-nas
sed -i '23,25 s/^#//' /usr/local/sbin/createDataVolume.sh
sed -i '29,29 s/^#//' /usr/local/sbin/createDataVolume.sh
sed -i '1,10 s/^#//' /etc/samba/overall_share
sed -i '/#if.*shareName/,+4 s/#//' /usr/local/sbin/deleteShare.sh

#Recreate the Public Share and Directory Structure
mkdir -p "/DataVolume/shares/Public"
mkdir -p "/DataVolume/shares/Public/Shared Music"
mkdir -p "/DataVolume/shares/Public/Shared Videos"
mkdir -p "/DataVolume/shares/Public/Shared Pictures"
chmod -R 775 /DataVolume/shares
chown -R root:share /DataVolume/shares/Public

#Restart the samba service
service samba restart

1 Like

That looks promising.

But isn’t it a little dangerous to specify line numbers for your sed script to apply comments to?

What happens if WD sneak an extra line in somewhere in those files?

What firmware release is this mod applicable to?

Impressive…

so after removing Public, there are no other scripts within the Cloud that are dependant on Public?

Nice… Good Job…

Ya i suppose line numbers are no good. I’ll update it to either check the file hash before they run or to use unique data to figure out which lines to comment. Since its just commenting out lines not too terribly dangerous.

Somewhere I thought it was indicated that Twonky needs those folders for what ever reason. Why else is WD forcing those folders to be public?

A quick and dirty look at the twonkyserver.ini file shows several entries for the Public folder as a default location where certain files like “uploaded and mirrored” media content are stored.

If one isn’t using Twonky (ie has turned off Media Streaming) then removing those folders may not impact things.

I did this differently. Can’t recall where it is on the forum, but I set the ACL on the Public directory so the owner could read and write to it and everyone else could only read. Because this was done on the Kernel level all I need to do is keep the Public folder empty.

I did this knowing there will be scripts need Public to be there. I played it safe.

[quote=“Myron, post:6, topic:137086, full:true”]
Can’t recall where it is on the forum, but I set the ACL on the Public directory so the owner could read and write to it and everyone else could only read. [/quote]
Your method was posted to this thread: https://community.wd.com/t/be-careful-public-folder-photos/93037/3
For anyone not using the 04.04.00-303 or later firmware the older method using the bug in the Dashboard should still work. This thread explains it: https://community.wd.com/t/controlling-access-to-public-folder/92133

1 Like

Oh. That’s not cricket! The Cloud OS 3 undid my ACL for the Public share. Shall re-apply my desired ACL. :slight_smile:

Here is how I did it.

NAS-MC:/DataVolume/My_Settings/Directory ACL template# getfacl /shares/Public
getfacl: Removing leading '/' from absolute path names
# file: shares/Public
# owner: root
# group: share
user::rwx
user:www-data:rwx
group::rwx
mask::rwx
other::rwx

NAS-MC:/DataVolume/My_Settings/Directory ACL template# getfacl Myron/ | setfacl -R --set-file=- /shares/Public
NAS-MC:/DataVolume/My_Settings/Directory ACL template# getfacl /shares/Public
getfacl: Removing leading '/' from absolute path names
# file: shares/Public
# owner: root
# group: share
user::rwx
user:www-data:rwx
user:myron:rwx
group::---
mask::rwx
other::---
default:user::rwx
default:user:www-data:rwx
default:user:myron:rwx
default:group::---
default:mask::rwx
default:other::---

NAS-MC:/DataVolume/My_Settings/Directory ACL template#

There is a simpler cheat. Se the ACL of a share, so in this case I set the owner user to only the owner/admin user has access to it’s share and then just copy the ACL from that ACL to the Public share.

getfacl /shares/Myron/ | setfacl -R --set-file=- /shares/Public

The default ACL for Public* is:

# file: DataVolume/shares/Public/
# owner: root
# group: share
user::rwx
user:www-data:rwx
group::rwx
mask::rwx
other::rwx

It’s simpler. A a lot easier to undo. Should not break any scripts.

A quick and dirty look at the twonkyserver.ini file shows several
entries for the Public folder as a default location where certain files
like “uploaded and mirrored” media content are stored.

Yes, but they can be changed. Not from the Dashboard, though…

See:

Q: How can I change the location of the ‘Shared Media’ folders?

in my Twonky FAQ

Of course the location can be changed, point I was making was that deleting the folders could cause problems if using the Twonky (in certain instances). That’s the problem we face any time we try to fix something under the hood on the My Cloud, fixing one thing may break or cause issues with something else.

It would be nice if WD went on the record (have they?) as to why they are preventing the customer from easily setting the Public folder to private through the Dashboard.