> File permissions on mathopd are 555 root.wheel. But files
> created by mathopd are daemon.wheel. I think that's something to do with
> BSD's rc.d system.

On BSD, group ownership of a file is inherited from the parent directory.
So if you have a directory that is owned by 'wheel', any file you create
in there will have owner 'wheel' too, regardless of any groups the creator
is in.

> That aside, I'd like to put the pid file with other pids in /var/run which
> has permissions of 775 root.wheel. My question is, if I'm a member of
> wheel and have no problems creating files in /var/run, why does mathopd? I
> get the error on startup:
> 
> /usr/local/sbin/mathopd: Cannot open PID file
> open: Permission denied

Mathopd creates the PID file after it has changed UIDs.

> If I create a directory /var/run/mathopd and chown it daemon.wheel,
> placing the files in there works fine. I looked through the code, and
> I'm also a little iffy about DEFAULT_FILEMODE, which is set 0666. When
> the pid file get's created it's as 640.  What am I missing?

The default filemode is combined with the current umask, which is
DEFAULT_UMASK by default (you can change this with the Umask declaration
in the config file.) So if the umask is 026 for example, all files created
will be mode 640.

What I would do personally is create a directory /var/mathopd, change the
group owner of that directory to whatever is appropriate. Then change the
owner of the directory so that mathopd can write in there. Then set the
umask to 026 so that all files created by mathopd are readably only to
members of your group and noone else. Finally modify the configuration so
that all files, including the PIDFile are created under /var/mathopd.

HTH

Cheers
Michiel

Reply via email to