msarthak1614
Posts: 2
Joined: Sun Jun 21, 2015 5:29 pm

Change Ownership of directory owned by a service

Sun Jun 21, 2015 5:40 pm

I am using my pi as a file server as well as a 24*7 torrent download box using arch linux and transmission. My problem is that there are frequent power outages in my area and the sd card gets corrupt again and again. So i have made a clone of the sd on my ubuntu and simply format and dd the card everytime it goes kaput. Now all the .torrent files as well as the config files of my torrents(the ones i am downloading as well as seeding) are stored in the directory /var/lib/transmission , so the ideal thing to do would be to simply copy the transmission directory from my corrupt sd card( as only the boot partion gets affected ) and paste it onto the newly imaged one. But when i insert the sd in my pc and browse /var/lib as root , the transmission folder shows up empty. I used the ls -l command on /var/lib and came to know that the transmission directory's ownership is with the transmission service . How can i copy this directory and then paste it into the newly formatted and imaged sd. ????!? :?: :?: :?: :?: :?: :?: :?: :?:
Any help is highly appreciated.

sdjf
Posts: 1395
Joined: Fri Mar 16, 2012 5:20 am
Location: California
Contact: Website

Re: Change Ownership of directory owned by a service

Mon Jun 22, 2015 3:57 pm

There is more than one way to go with this. You can change ownership and group of the files to something other than what they are using the chown and chgrp commands, but it sounds like the issue is read/write permission. For changing that, you use the chmod command.

Cannot really give you appropriate examples as you did not paste any ls -l results. But it sounds to me like if you do something like "chmod a+rw" recursively in the transmission directory, your PC should be able to read/write. But there could be a security issue in doing that, you might want to just do "chmod a+r" since you aren't going to rewrite on the original card, just copy.

Another approach would be to give root read permission of all files in the transmission directory, since root is the only user other than transmission who needs access.
FORUM TIP: To view someone's posting history, sign in, click on their user name, then on "Search User's Posts." || Running ArchLinuxArm on Model 2B and 512MB Model B

msarthak1614
Posts: 2
Joined: Sun Jun 21, 2015 5:29 pm

Re: Change Ownership of directory owned by a service

Tue Jun 23, 2015 3:15 pm

This is my ls -l output:-
[root@RASPI ~]# cd /var/lib
[root@RASPI lib]# ls -l
total 56
drwxr-xr-x 2 root root 4096 May 28 00:16 arpd
drwxr-xr-x 2 root root 4096 Jun 5 00:57 dbus
drwxr-xr-x 2 root root 4096 May 18 17:33 dhcpcd
drwxrwxrwt 2 root root 4096 May 10 08:45 ex
drwxr-xr-x 2 root root 4096 Mar 31 08:54 ip6tables
drwxr-xr-x 2 root root 4096 Mar 31 08:54 iptables
drwxr-xr-x 2 root root 4096 Feb 17 01:06 krb5kdc
-rw-r--r-- 1 root root 1132 Jun 23 00:00 logrotate.status
drwx------ 2 root root 4096 Jan 1 1970 machines
drwxr-xr-x 2 root root 4096 Feb 24 14:27 misc
drwxr-xr-x 4 root root 4096 Jun 20 14:23 pacman
drwxr-xr-x 4 root root 4096 Jun 19 15:55 samba
drwxr-xr-x 5 root root 4096 Feb 16 20:55 systemd
drwx------ 3 transmission transmission 4096 Jun 19 17:29 transmission
[root@RASPI lib]#

so you are suggesting that if i do a chmod a+r on the transmission directory , i would be able to copy the transmission directory and then paste it on my sd card after i have formatted and reinstalled the image?
and I am just curious as to what security vulnerabilities will be there in case i plan on doing a chmod a+rw instead of chmod a+r.

sdjf
Posts: 1395
Joined: Fri Mar 16, 2012 5:20 am
Location: California
Contact: Website

Re: Change Ownership of directory owned by a service

Wed Jun 24, 2015 7:16 pm

I honestly do not know. We need an expert on transmission and security here!

Looking at the other directories, I would question needing write permission, it looks like it might be chmod a+rx.

But what do the files underneath look like (ls -l /var/lib/transmission/*)?
FORUM TIP: To view someone's posting history, sign in, click on their user name, then on "Search User's Posts." || Running ArchLinuxArm on Model 2B and 512MB Model B


User avatar
jojopi
Posts: 3271
Joined: Tue Oct 11, 2011 8:38 pm

Re: Change Ownership of directory owned by a service

Tue Jun 30, 2015 9:39 am

msarthak1614 wrote:But when i insert the sd in my pc and browse /var/lib as root , the transmission folder shows up empty.
As root, you cannot have any permissions problem. Also, not having permission should give an error, not make the directory appear empty.

I do not see that it makes any sense to change permissions in advance on the off chance that you might need to mount the card in another computer in future. You will need to have root on the other computer to mount the card anyway.

Return to “Arch”