{"id":89,"date":"2014-09-17T20:46:34","date_gmt":"2014-09-17T18:46:34","guid":{"rendered":"http:\/\/techblog.vindvejr.dk\/?p=89"},"modified":"2014-09-17T20:46:34","modified_gmt":"2014-09-17T18:46:34","slug":"raspbmc-and-nfs-permissions","status":"publish","type":"post","link":"https:\/\/techblog.vindvejr.dk\/?p=89","title":{"rendered":"Raspbmc and NFS permissions"},"content":{"rendered":"<p>NFS is often used for accessing network shares from Raspbmc, due to its low overhead. Many tutorials describe how to set this up, for example with a Synology NAS. One subject isn&#8217;t covered much, though: A setup with restrictive permissions.<\/p>\n<p>On my Synology my media files are usually owned by me, and has &#8216;dlna&#8217; as group with read-only permissions. Example:<\/p>\n<pre>\r\ndrwxr-x---  9 jacob dlna   4096 Jun 15  2012 video\r\n<\/pre>\n<p>On the NAS I have created a user for Raspbmc and made it a member of this group:<\/p>\n<pre>\r\nDiskStation> cat \/etc\/group | grep dlna\r\ndlna:x:65536:admin,jacob,raspbmc\r\nDiskStation> cat \/etc\/passwd | grep raspbmc\r\nraspbmc:x:1046:100:Raspberry Pie XBMC:\/var\/services\/homes\/raspbmc:\/sbin\/nologin\r\n<\/pre>\n<p>To get this to work on the Raspberry I&#8217;ve first had to synchronize the GID\/UID&#8217;s. Since the NAS is the master, I&#8217;ve done this on the Raspberry (logged in as the <strong>pi<\/strong> user):<\/p>\n<pre>\r\npi@raspbmc:~$ sudo groupadd -g 65536 dlna\r\npi@raspbmc:~$ sudo usermod -a -G dlna pi\r\n<\/pre>\n<p>After enabling root access, I&#8217;ve changed the <strong>pi<\/strong> user to match the UID of the <strong>raspbmc<\/strong> user on the NAS:<\/p>\n<pre>\r\nroot@raspbmc:~# usermod -u 1046 pi\r\n<\/pre>\n<p>(For this to work I had to kill a number of processes first)<\/p>\n<p>Changing UID of the <strong>pi<\/strong> user will cause a lot of trouble for Raspbmc, which expects the user to have UID 1000. This is hardcoded in at least two scripts:<\/p>\n<ul>\n<li>\/opt\/xbmc-bcm\/xbmc-bin\/share\/xbmc\/addons\/script.raspbmc.settings\/default.py<\/li>\n<li>\/opt\/xbmc-bcm\/xbmc-bin\/share\/xbmc\/addons\/script.raspbmc.settings\/autostart.py<\/li>\n<\/ul>\n<p>Fix this by adding:<\/p>\n<pre>\r\nsed -i 's\/getpwuid(1000)\/getpwuid(1046)\/g' \/opt\/xbmc-bcm\/xbmc-bin\/share\/xbmc\/addons\/script.raspbmc.settings\/default.py\r\nsed -i 's\/getpwuid(1000)\/getpwuid(1046)\/g' \/opt\/xbmc-bcm\/xbmc-bin\/share\/xbmc\/addons\/script.raspbmc.settings\/autostart.py\r\n<\/pre>\n<p>to \/etc\/rc.local so the scripts are automatically fixed during startup. Replace 1046 with your <strong>pi<\/strong> UID.<\/p>\n<p>Without this fix automatic updates won&#8217;t work, and you&#8217;ll see script errors during startup &#8211; and can&#8217;t launch the Raspbmc settings.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>NFS is often used for accessing network shares from Raspbmc, due to its low overhead. Many tutorials describe how to set this up, for example with a Synology NAS. One subject isn&#8217;t covered much, though: A setup with restrictive permissions. &hellip; <a href=\"https:\/\/techblog.vindvejr.dk\/?p=89\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,7],"tags":[],"class_list":["post-89","post","type-post","status-publish","format-standard","hentry","category-linux","category-raspberry-pi"],"_links":{"self":[{"href":"https:\/\/techblog.vindvejr.dk\/index.php?rest_route=\/wp\/v2\/posts\/89","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techblog.vindvejr.dk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techblog.vindvejr.dk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techblog.vindvejr.dk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techblog.vindvejr.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=89"}],"version-history":[{"count":1,"href":"https:\/\/techblog.vindvejr.dk\/index.php?rest_route=\/wp\/v2\/posts\/89\/revisions"}],"predecessor-version":[{"id":90,"href":"https:\/\/techblog.vindvejr.dk\/index.php?rest_route=\/wp\/v2\/posts\/89\/revisions\/90"}],"wp:attachment":[{"href":"https:\/\/techblog.vindvejr.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=89"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techblog.vindvejr.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=89"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techblog.vindvejr.dk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=89"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}