Ignore:
Timestamp:
26/07/06 11:18:55 (13 years ago)
Author:
spascoe
Message:

I've created a bbftpd log facility to replace syslog.
At present it allows you to log messages to a file in addition
to syslog. This should help testing on other machines.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI05-delivery/trunk/src/bbftp-server-3.2.0/bbftpd/bbftpd_cert.c

    r773 r1328  
    3333#include <pwd.h> 
    3434#include <stdio.h> 
    35 #include <syslog.h> 
     35#include <bbftpd_log.h> 
    3636#include <sys/socket.h> 
    3737#if TIME_WITH_SYS_TIME 
     
    103103        strcat(logmessage, messages->msg); 
    104104        while (messages != NULL) { 
    105             syslog(BBFTPD_ERR,"gfw_accept_sec_context failed: %s", messages->msg) ; 
     105            bbftpd_log(BBFTPD_ERR,"gfw_accept_sec_context failed: %s", messages->msg) ; 
    106106            messages = messages->next; 
    107107        } 
     
    110110        } 
    111111         
    112     syslog(BBFTPD_INFO,"Checked certificate : \"%s\"",(char *)client_name.value) ; 
     112    bbftpd_log(BBFTPD_INFO,"Checked certificate : \"%s\"",(char *)client_name.value) ; 
    113113        /* 
    114114        ** Map cert with local user 
    115115        */ 
    116116        if (globus_gss_assist_gridmap((char *)client_name.value, &username) != 0) { 
    117         syslog(BBFTPD_ERR,"mapping failed for: %s",(char *)client_name.value) ; 
     117        bbftpd_log(BBFTPD_ERR,"mapping failed for: %s",(char *)client_name.value) ; 
    118118                strcat(logmessage, " : grid mapping failed"); 
    119119        reply(MSG_BAD_NO_RETRY,logmessage) ; 
    120120        return -1 ; 
    121121        } 
    122         syslog(BBFTPD_INFO, "Mapfile user is:%s", username); 
     122        bbftpd_log(BBFTPD_INFO, "Mapfile user is:%s", username); 
    123123    /* 
    124124    ** Here we check the username and pass and set the default dir 
    125125    */ 
    126126    if ( (uspass = getpwnam(username)) == NULL ) { 
    127         syslog(BBFTPD_ERR,"%s is not a local user",username) ; 
     127        bbftpd_log(BBFTPD_ERR,"%s is not a local user",username) ; 
    128128        strcat(logmessage," : You need an account on the server") ; 
    129129        reply(MSG_BAD_NO_RETRY,logmessage) ; 
     
    134134    */ 
    135135    if ( setgid(uspass->pw_gid) < 0 ) { 
    136         syslog(BBFTPD_ERR,"Error setgid user %s : %s",username,strerror(errno)) ; 
     136        bbftpd_log(BBFTPD_ERR,"Error setgid user %s : %s",username,strerror(errno)) ; 
    137137        strcat(logmessage," : Cannot set gid: ") ; 
    138138        strcat(logmessage,strerror(errno)); 
     
    141141    } 
    142142    if ( setuid(uspass->pw_uid) < 0 ) { 
    143         syslog(BBFTPD_ERR,"Error setuid user %s : %s",username,strerror(errno)) ; 
     143        bbftpd_log(BBFTPD_ERR,"Error setuid user %s : %s",username,strerror(errno)) ; 
    144144        strcat(logmessage," : Cannot set uid: ") ; 
    145145        strcat(logmessage,strerror(errno)); 
     
    148148    } 
    149149    if ( uspass->pw_dir == NULL ) { 
    150         syslog(BBFTPD_ERR,"No home directory for user %s : %s",username,strerror(errno)) ; 
     150        bbftpd_log(BBFTPD_ERR,"No home directory for user %s : %s",username,strerror(errno)) ; 
    151151        strcat(logmessage," : You need a home directory on the server") ; 
    152152        reply(MSG_BAD,logmessage) ; 
     
    159159    if ( chdir(uspass->pw_dir) < 0) { 
    160160        if ( errno == EACCES) { 
    161             syslog(BBFTPD_WARNING,"Permission denied on user %s home directory: using /tmp",username) ; 
     161            bbftpd_log(BBFTPD_WARNING,"Permission denied on user %s home directory: using /tmp",username) ; 
    162162            if ( chdir("/tmp") < 0) { 
    163                 syslog(BBFTPD_ERR,"Cannot cd into /tmp: %s",strerror(errno)) ; 
     163                bbftpd_log(BBFTPD_ERR,"Cannot cd into /tmp: %s",strerror(errno)) ; 
    164164                strcat(logmessage," : Cannot access home directory nor /tmp") ; 
    165165                reply(MSG_BAD,logmessage) ; 
     
    167167            } 
    168168            strcat(logmessage," : Home directory not accessible, /tmp used instead") ; 
    169             syslog(BBFTPD_INFO,"User %s connected",username) ; 
     169            bbftpd_log(BBFTPD_INFO,"User %s connected",username) ; 
    170170            strcpy(currentusername,username) ; 
    171171            reply(MSG_WARN,logmessage) ; 
    172172            return 1 ; 
    173173        } else { 
    174             syslog(BBFTPD_ERR,"Cannot cd into user %s home directory: %s",username,strerror(errno)) ; 
     174            bbftpd_log(BBFTPD_ERR,"Cannot cd into user %s home directory: %s",username,strerror(errno)) ; 
    175175            strcat(logmessage," : Cannot access home directory: ") ; 
    176176            strcat(logmessage,strerror(errno)); 
     
    180180    } 
    181181                 
    182     syslog(BBFTPD_INFO,"User %s connected",username) ; 
     182    bbftpd_log(BBFTPD_INFO,"User %s connected",username) ; 
    183183    strcpy(currentusername,username) ; 
    184184    return 0 ; 
Note: See TracChangeset for help on using the changeset viewer.