# Hints for writing a service - ownership



## Kuka (Nov 21, 2022)

I do have a process writing as root (0644) log files and other the FreeBSD System.
Those files I want to fetch and delete them by using sFTP as a regular user.

As I am pretty unfamiliar with FreeBSD I would welcome some hints to "automatically" change in the background by a script (or otherwise) the permission of all files in a specified directory.
So far, I think I will have to write a service / script linked with rc.conf. I do not know what is the best practise within this service/script. My actual thought goes in the directon to oeriodially set the permissions to all files within the directory. 
This isn't really elegant so I hope somebody has a better idea


----------



## Alain De Vos (Nov 21, 2022)

Your question is unclear to me.
Here an example script,








						Practical rc scripting very short tutorial
					

First make make daemon which will print "Hello World" each few seconds on the screen. A file /usr/local/etc/myservice2 , chmod 755 with following content:  #!/usr/local/bin/mksh echo "Starting" while true do     echo "Hello World"     sleep 6 done  Then we create the rc-script to stop and start...




					forums.freebsd.org
				



Instead of printing hello world you could chown,chmod at regular intervals ?


----------



## covacat (Nov 21, 2022)

make the parent dir of said files g=rwx for the sftp user's primary group
then you can delete them with sftp, rsync, whatever
you can also play with acls (setfacl)


----------

