multi-user iTunes with files in a network disk

OK, here is my first technical post, so I post in English. I could’nt find this particular solution mentioned elsewhere, so I thought I should share my knowledge! Οι Έλληνες χρήστες που δεν κατανοούν τα αγγλικά, ας το ζητήσουν να ποστάρω και στα ελληνικά.

So, I have my iTunes Library shared by all the users of my computer. This is easily accomplished by just making an alias of the actual folder containing the iTunes folder and renaming the alias iTunes. This must be done on every user that you want to share your Music with. Note that I am not writing about the iTunes Music, I am writing about the whole iTunes folder, so all the users share their playlists, statistics and so on.
If the iTunes folder is located inside your primary disk (that is, the disk that boots the MacOS X), you will have permissions issues and iTunes complaining about not being able to write to the iTunes Library. Unfortunately, iTunes uses a method of reading, deleting and creating the iTunes Library.xml file, not just editing the actual file. Having the iTunes.app running under different users makes it impossible for iTunes to delete this file, since it belongs to another user.
I have found two solutions for this. One is moving the iTunes folder to a second disk or partition AND making that partition ignoring any permissions. Easy, right? Second one, if you don’t have a second disk or you can’t afford having it without permissions (accidents happen!), you could just edit the iTunes executable by setting the user id. By issuing the command (in Terminal)

sudo chmod +s /Applications/iTunes.app/Contents/MacOS/iTunes

you force the iTunes application to run as one user, most likely the first user of your computer. So, even if your sister or father uses iTunes, iTunes runs always as if it was running by you. This way, iTunes is always able to handle correctly the iTunes Library files, deleting/creating new files/folders in its Music folder, etc. On every update of iTunes, or after repairing permissions, you have to reissue the command, however.

Alas, the second solution didn’t work for me because of M-Audio’s poorly written drivers. I use an M-Audio Firewire 410, and running iTunes as a different user makes all audio produced by iTunes being routed to built-in audio, hence rendering my equipment useless. So, I had for long time chose the option of having my iTunes folder to external disk.

After I set up my Linux box I decided to move my iTunes Library there. Without getting into further technicalities, I had all the users auto-mount at login the particular afp share containing my iTunes folder. And that broke instantaneously the multi-user setup. Messing with permissions doesn’t work, as I said before, and having the file permissions ignored on a Linux box is impossible. No way, Linux always handles permissions, no matter what.
The solution in this case was to setgid (set group id) on the directory containing the iTunes folder, on the Linux box. Thus, every file or folder created in this folder is assigned the same group permissions as its parent. By

chmod -r 775 /path/to/iTunes/folder

and

chmod -r +s /path/to/iTunes/folder

you work just as before!

PS. The experienced user will notice that chmod -r 775 is not good as it makes both the directories and the files executable. A better approach is using the

find . -type d -exec chmod 775 {} \;

and

find . -type f -exec chmod 664 {} \;

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.