LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 08-04-2010, 05:57 AM   #1
doru
Member
 
Registered: Sep 2008
Distribution: Ubuntu 8.04 LTS Server
Posts: 85

Rep: Reputation: 16
cgi log permissions


I am writing a cgi (in fact, fast cgi) application under Ubuntu using Apache, and I want this application to log messages to a file.

The problem is that /var/log, and most files in it, has write permission for root only, while the process runs as www-data. How should I solve this problem? Should I write to a file in /usr/lib/cgi-bin/ owned by www-data? This would work safely with logrotate? I am lost at this, please give me any idea.
 
Old 08-04-2010, 11:54 PM   #2
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hey - so not the problem !

From the fast_cgi documentation:
Quote:
http://www.fastcgi.com/mod_fastcgi/d...d_fastcgi.html

mod_fastcgi logs FastCGI application error (stderr) output to the server log associated with the request. Errors reported by the FastCGI process manager, fcgi-pm, are reported to the main server log (typically, logs/error_log). Data written to stdout or stderr before entering the FastCGI accept loop or via a mechanism that is not FastCGI protocol aware will also be directed to the main server log. If Apache's LogLevel is set to info additional informational messages are printed to the logs, these messages may be especially helpful while debugging a configuration.
So all you have to do is "printf()" or "fprintf (stderr)" - and voila! Your message automatically gets syslogged!

'Hope that helps .. PSM
 
Old 08-05-2010, 02:34 AM   #3
doru
Member
 
Registered: Sep 2008
Distribution: Ubuntu 8.04 LTS Server
Posts: 85

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by paulsm4 View Post
Hey - so not the problem :)!

From the fast_cgi documentation:


So all you have to do is "printf()" or "fprintf (stderr)" - and voila! Your message automatically gets syslogged!

'Hope that helps .. PSM
Thank you, I did not expect to find a solution in fast cgi, because I expected a solution for all cgi programs.

I sort of prefer to log all activity of my fast cgi program in a separate file. I will put the log file in cgi-bin, I hope this will not be a security risk.
 
  


Reply

Tags
cgi, log, permissions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
permissions denied with perl/cgi script shifter Programming 3 02-23-2010 05:05 PM
cgi error log not showing up pdavis68 Linux - Server 1 01-03-2008 02:51 PM
CGI script to view log files twantrd Programming 4 03-02-2007 10:19 AM
changing permissions of document root and cgi-bin abtimoteo Ubuntu 2 08-13-2005 09:36 AM
File permissions and cgi scripts shaggystyle Linux - General 5 02-16-2004 02:36 PM


All times are GMT -5. The time now is 01:23 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration