You are not logged in.

#1 2011-09-16 23:04:00

j0lly
Member
From: ~Milan
Registered: 2011-08-16
Posts: 49

file type permissions for shared folder? [SOLVED]

Hi all,
I can't find any answer about this question, maybe couse i'm making bad searches...
I got a samba server running on my machine sharing my music folder within my homemates when i'm at home.
I've set the permissions 1775 (to not have any surprise tongue) but i would like to improve the security and the cleaness of my folder allowing only music type file to be uploaded /as mp3 etc.).
Can someone puts me in the right direction?
Because i can't find a related discussion.
Thank you!!

Last edited by j0lly (2011-09-20 04:25:52)


...why not

Offline

#2 2011-09-16 23:44:26

dschrute
Member
From: NJ, USA
Registered: 2007-04-09
Posts: 183

Re: file type permissions for shared folder? [SOLVED]

AFAIK there isn't a easy/practical way to allow only specific file types.  You can block access to specific file types using the "veto files" share parameter, but logically that does a "allow file types except those listed" rather than "only allow file types listed".

Offline

#3 2011-09-17 07:34:00

Proofrific
Member
Registered: 2008-01-05
Posts: 215

Re: file type permissions for shared folder? [SOLVED]

You can set up a bunch of hard symlinks to your mp3 files only, and then only share that folder of links.

Offline

#4 2011-09-17 14:37:28

j0lly
Member
From: ~Milan
Registered: 2011-08-16
Posts: 49

Re: file type permissions for shared folder? [SOLVED]

AFAIK there isn't a easy/practical way to allow only specific file types

that sounds bad!
the veto way is surely a good step ahead, but is terribly long to set at least the most commons file formats for system/video/images!!!
i'll start with this method, but i hope will come out a more flexible and simple way to allow only certain file formats.

p.s.
my shared folder would be a place to drop music and not only listen/copy it, so the hardlinks way is not feasible


...why not

Offline

#5 2011-09-17 17:53:13

rwd
Member
Registered: 2009-02-08
Posts: 664

Re: file type permissions for shared folder? [SOLVED]

you could run a script as a cron job every x minutes, or triggered by file changes with inotify-tools,  that deletes all files that are not of certain mime types.

Offline

#6 2011-09-20 04:25:07

j0lly
Member
From: ~Milan
Registered: 2011-08-16
Posts: 49

Re: file type permissions for shared folder? [SOLVED]

yeah this sould be the best way to achive the practice, if samba doesn't allow any better practices...
i think i can put solved...
thanks for the effort smile

So, i just made a cron job that eliminate every file different than the most common audio formats from the shared samba...
solved!

i stick the scripts i gonna use, if someone will needs something similar:

#!/bin/bash
find /path/to/find -type f ! -name "*.mp3" ! -name "*.aac" ! -name "*.wma" ! -name "*.flac" ! -name "*.wav" ! -name "*.ogg" -exec rm -f {}  \; 

cheers


...why not

Offline

#7 2011-09-20 14:31:14

perbh
Member
From: Republic of Texas
Registered: 2005-03-04
Posts: 765

Re: file type permissions for shared folder? [SOLVED]

and ...
If someone is sitting on a windoze-machine, you can bet your holy life that the filenames will be in upper-case :-(
So - you have to allow for that as well ...
and ...
Maybe some of the files have 'spaces' in the name? -> more trouble

Last edited by perbh (2011-09-20 14:32:28)

Offline

#8 2011-09-20 16:31:14

j0lly
Member
From: ~Milan
Registered: 2011-08-16
Posts: 49

Re: file type permissions for shared folder? [SOLVED]

hugh... i havn't thoght about  that... for the upper is just a little work...  and for the spaces?


...why not

Offline

#9 2011-09-20 16:55:22

rwd
Member
Registered: 2009-02-08
Posts: 664

Re: file type permissions for shared folder? [SOLVED]

use google?

Offline

#10 2011-09-20 21:19:44

perbh
Member
From: Republic of Texas
Registered: 2005-03-04
Posts: 765

Re: file type permissions for shared folder? [SOLVED]

@J0lly:
Actually -what you have is a real hornet's nest - and it all needs some serious scripting.
So let me just give you some few guidelines ...
1) I presume you have (at least) 3 directory levels: {artist}/{album}/{tracks}
2) decide on a global representation, so you don't end up with something like:
/Jim Brown/Greatest Hits/She's alone with "another".MP3

My suggestion is to convert spaces to underscores, all lower-case and remove 'punctuations', eg, apostrophy, quotation-mark and commas and ampersands (and I have seen them all)
The above then boils down to:
/jim_brown/greatest_hits/shes_alone_with_another.mp3
3) I would also strongly suggest that your 'collection' is read-only, but that you supply an 'upload'-directory where everyone can contribute and you have a script that converts everything to the standard I indicated and check if they allready exist - thus moving them from 'upload' to 'collection'

4) also, be aware that different rippers work different ways. Me - I prefer to prepend the track-name (song-name) with a two-digit track-number followed by a '-', eg.
04-this_is_my_song.mp3

Obviously - others may have ripped the same album and do not prepend the track-number and put it in the upload area for inclusion - that is about the 'hardest' one to figure out ... I guess that if the artist and album allready exists - there is a good chance that you have a copy ...

Not to mention some of these: "different artists" *lol* - that can be a teaser - what do you do with it?
ie you can have "various artists/greatest hits/track(s)" - and the albums are _not_ the same!! - in which case I guess you need to compare the song-names ... with or witout a track-no.


As I said - a real hornet's nest!!

Last edited by perbh (2011-09-20 21:39:57)

Offline

#11 2011-09-20 21:43:32

perbh
Member
From: Republic of Texas
Registered: 2005-03-04
Posts: 765

Re: file type permissions for shared folder? [SOLVED]

Infact - in any one directory - you _could_ use the following to sanitize it all ...

fixfn() {
        for i in *; do
                f="`echo $i | tr -d "['\",]" | tr ' ' '_' | tr '[A-Z]' '[a-z]' | \
                        sed -e 's/\&/and/g'`"
                test "$i" = "$f" || mv "$i" "$f"
        done
        return 0
}

oh and btw - in the above I have not just deleted the ampersand, but replaced it with 'and'

You really need to traverse the (hopefully) 3 levels of directories, and then in the end - when it comes down to the single tracks, you could do something like this:

for f in *; do
   x=${f##*.}
  case $x in
    mp3|wma|flac|ogg| ....)  ;;
    *) rm $f ;;
  esac
done

Last edited by perbh (2011-09-20 21:55:55)

Offline

Board footer

Powered by FluxBB