mirror of
https://github.com/3proxy/3proxy.git
synced 2026-10-28 22:05:48 +08:00
Logs: no ODBC user and password in messages about a log
A log string is shown only up to its first comma, where an ODBC string goes on with the user and the password: in the message on a log which failed, and in the errors on a log or -l which cannot be opened. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
d613750b94
commit
e87ffcd7e1
@ -388,7 +388,9 @@ static int h_log(int argc, unsigned char ** argv){
|
|||||||
/* the same log as before is not opened again */
|
/* the same log as before is not opened again */
|
||||||
lg = logget((argc > 1)? argv[1] : (unsigned char *)"", rotation);
|
lg = logget((argc > 1)? argv[1] : (unsigned char *)"", rotation);
|
||||||
if(!lg){
|
if(!lg){
|
||||||
perror((argc > 1)? (char *)argv[1] : "log");
|
fprintf(stderr, "Unable to open log %.*s: %s, line %d\n",
|
||||||
|
(int)logselen((argc > 1)? argv[1] : (unsigned char *)""),
|
||||||
|
(argc > 1)? (char *)argv[1] : "", strerror(errno), linenum);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if(conf->stacksize < lg->type->stacksize) conf->stacksize = lg->type->stacksize;
|
if(conf->stacksize < lg->type->stacksize) conf->stacksize = lg->type->stacksize;
|
||||||
|
|||||||
11
src/log.c
11
src/log.c
@ -808,6 +808,14 @@ static void logfallback(struct logger *lg, struct clientparam *param, const unsi
|
|||||||
logput(to);
|
logput(to);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* The part of a log string fit to be shown: up to a comma, an ODBC string
|
||||||
|
going on with the user and the password, and at most 200 bytes. */
|
||||||
|
size_t logselen(const unsigned char *selector){
|
||||||
|
size_t len = strcspn((char *)selector, ",");
|
||||||
|
|
||||||
|
return len > 200? 200 : len;
|
||||||
|
}
|
||||||
|
|
||||||
static void logwrite(struct logger *lg, struct clientparam *param, const unsigned char *buf, int len){
|
static void logwrite(struct logger *lg, struct clientparam *param, const unsigned char *buf, int len){
|
||||||
int res = 0, failed, report = 0;
|
int res = 0, failed, report = 0;
|
||||||
time_t t;
|
time_t t;
|
||||||
@ -838,7 +846,8 @@ static void logwrite(struct logger *lg, struct clientparam *param, const unsigne
|
|||||||
if(report){
|
if(report){
|
||||||
unsigned char msg[300];
|
unsigned char msg[300];
|
||||||
|
|
||||||
sprintf((char *)msg, "Log %.200s failed, its lines go to the error log", lg->selector);
|
/* up to a comma: an ODBC string goes on with user and password */
|
||||||
|
sprintf((char *)msg, "Log %.*s failed, its lines go to the error log", (int)logselen(lg->selector), lg->selector);
|
||||||
logerror(msg);
|
logerror(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -322,7 +322,8 @@ static int srvprepare(struct srvstart *s, int argc, char **argv){
|
|||||||
/* the same log the log command, or another service,
|
/* the same log the log command, or another service,
|
||||||
opened is shared with it */
|
opened is shared with it */
|
||||||
if(!(lg = logget((unsigned char *)argv[i] + 2, NONE))){
|
if(!(lg = logget((unsigned char *)argv[i] + 2, NONE))){
|
||||||
perror(argv[i] + 2);
|
fprintf(stderr, "Unable to open log %.*s: %s\n",
|
||||||
|
(int)logselen((unsigned char *)argv[i] + 2), argv[i] + 2, strerror(errno));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
logput(srv->logger);
|
logput(srv->logger);
|
||||||
|
|||||||
@ -352,6 +352,7 @@ void logput(struct logger *lg);
|
|||||||
void logcommit(struct extparam *c);
|
void logcommit(struct extparam *c);
|
||||||
void logerrset(struct logger *lg);
|
void logerrset(struct logger *lg);
|
||||||
void logstdclose(void);
|
void logstdclose(void);
|
||||||
|
size_t logselen(const unsigned char *selector);
|
||||||
void logtick(time_t t);
|
void logtick(time_t t);
|
||||||
void logfinish(void);
|
void logfinish(void);
|
||||||
int timechanged (time_t oldtime, time_t newtime, ROTATION lt);
|
int timechanged (time_t oldtime, time_t newtime, ROTATION lt);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user