views:

14

answers:

0

I am trying to create a file in Apache for writing debugging messages (Just to write some log messages).. But unable to create a file under Apache module.

Just check out my code & kindly help me out! Do advice me with a code snippet, is there any way to log debugging messages under Apache??

============ (Header files are removed for clarity)

static int authenticate_basic_myuser(request_rec *r)

{
apr_status_t    rv ; 
apr_pool_t      *mp ;
apr_file_t      *fp ; 
const char  *fname="999.txt" ; 
apr_finfo_t finfo ; 

system("touch /root/Desktop/success.txt");

    int fd1 ; 
    fd1 = open("/root/Desktop/1.txt",O_RDWR|O_APPEND,0666);
    write(fd1, "raghu", 6) ; 

    FILE *f1 ;
    f1 = fopen("/root/Desktop/one.txt", "w+") ;
    fwrite( "just",5, 1,f1 );
    fprintf(stderr, "%s", "one") ; 
    fflush(stderr) ; 

    apr_initialize() ; 
    apr_pool_create(&mp, NULL) ; 

    rv = apr_file_open(&fp, fname, APR_FOPEN_READ|APR_SHARELOCK, 
        APR_FPROT_OS_DEFAULT, mp ) ;

    if(rv != APR_SUCCESS)
    {
     return -1 ; 
    }

    rv = apr_file_info_get(&finfo, APR_FINFO_NORM, fp);
    rv = apr_stat(&finfo, fname, APR_FINFO_NORM, mp) ; 

    apr_file_close(fp);
    apr_terminate() ; 

      const char *current_auth;
      current_auth = ap_auth_type(r);

      write(fd1,"haiall",8);
      write(fd1,current_auth,5);
      return OK ; 

}

static void register_hooks(apr_pool_t *p)
{
    ap_hook_check_user_id(authenticate_basic_myuser,NULL,NULL,APR_HOOK_FIRST);
}

module AP_MODULE_DECLARE_DATA test_module = {
STANDARD20_MODULE_STUFF,
NULL,
NULL,
NULL,
NULL,
NULL,
register_hooks
} ;

===================

Regards Raghu