need help in dealing with a simple thing (file permissions)

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

need help in dealing with a simple thing (file permissions)

leva (Bugzilla)
Hi!

I know this is a rather simple problem, but I would like to hear the
advices.

I'm using a piped Custom- and ErrorLog in apache, it pipes the output to
cronolog (the log files are rotated per 24hour). The log files are
created with 644 permissions, and this is what I try to avoid, and
force the new logfile to have 640 permissions.
So far I thought of a cron line which would be `chmod -R
o= /var/www/logs/`.
Then the umask command came to my mind, but then I would have to make a
script, which contains the umask line, and after that call cronolog,
and pipe the logs to this script.
Would someone please hint me with a more simple and elegant solution?

Thanks!

Daniel

--
LeVA

Reply | Threaded
Open this post in threaded view
|

Re: need help in dealing with a simple thing (file permissions)

Joachim Schipper
On Sat, Oct 21, 2006 at 02:50:57PM +0200, LeVA wrote:

> Hi!
>
> I know this is a rather simple problem, but I would like to hear the
> advices.
>
> I'm using a piped Custom- and ErrorLog in apache, it pipes the output to
> cronolog (the log files are rotated per 24hour). The log files are
> created with 644 permissions, and this is what I try to avoid, and
> force the new logfile to have 640 permissions.
> So far I thought of a cron line which would be `chmod -R
> o= /var/www/logs/`.
> Then the umask command came to my mind, but then I would have to make a
> script, which contains the umask line, and after that call cronolog,
> and pipe the logs to this script.
> Would someone please hint me with a more simple and elegant solution?
>
> Thanks!
>
> Daniel

The last solution works fine:

#!/bin/sh

umask 027
exec /usr/.../cronolog

The alternative would be chmod'ing the log directory to 0750, or
somesuch.

                Joachim

Reply | Threaded
Open this post in threaded view
|

Re: need help in dealing with a simple thing (file permissions)

Han Boetes
In reply to this post by leva (Bugzilla)
Read /etc/newsyslog and man newsyslog.


# Han

Reply | Threaded
Open this post in threaded view
|

Re: need help in dealing with a simple thing (file permissions)

leva (Bugzilla)
2006. October 21. 16:23, Han Boetes:
> Read /etc/newsyslog and man newsyslog.
>
>
> # Han
Thanks, but newsyslog can not help me, because it can not reload my
apache when the rotation happening (it is chrooted and has to load
external modules).

Daniel

--
LeVA

Reply | Threaded
Open this post in threaded view
|

Re: need help in dealing with a simple thing (file permissions)

Matthew R. Dempsky
In reply to this post by leva (Bugzilla)
On Sat, Oct 21, 2006 at 02:50:57PM +0200, LeVA wrote:
> Then the umask command came to my mind, but then I would have to make a
> script, which contains the umask line, and after that call cronolog,
> and pipe the logs to this script.
> Would someone please hint me with a more simple and elegant solution?

I think the shell script solution is fine, but if you want something
more flexible, put the following into /usr/local/bin/with-umask:

    #!/bin/sh -e
    umask "$1"; shift
    exec "$@"

and then change your call to

    cronolog...

to

    with-umask 027 cronolog....