From: "Александр Берсенев" <bay@hackerdom.ru>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/autodep:master commit in: src/hook_lib/
Date: Fri, 30 Sep 2011 07:21:36 +0000 (UTC) [thread overview]
Message-ID: <b6e44ffc06122453c92801d39d08f3c6ebc3ba14.bay@gentoo> (raw)
commit: b6e44ffc06122453c92801d39d08f3c6ebc3ba14
Author: Alexander Bersenev <bay <AT> hackerdom <DOT> ru>
AuthorDate: Sat Sep 24 01:51:28 2011 +0000
Commit: Александр Берсенев <bay <AT> hackerdom <DOT> ru>
CommitDate: Sat Sep 24 01:51:28 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/autodep.git;a=commit;h=b6e44ffc
fixes bug with pmake. Use libc\'s snprintf
---
src/hook_lib/Makefile | 2 +-
src/hook_lib/file_hook.c | 15 +++++++++++++--
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/hook_lib/Makefile b/src/hook_lib/Makefile
index 365ceee..2457fb2 100644
--- a/src/hook_lib/Makefile
+++ b/src/hook_lib/Makefile
@@ -2,7 +2,7 @@ file_hook.so: file_hook.o
ld -shared -o file_hook.so -ldl -lc file_hook.o
file_hook.o: file_hook.c
- cc -Wall -fPIC -o file_hook.o -c file_hook.c
+ cc -Wall -O0 -fPIC -o file_hook.o -c file_hook.c
all: file_hook.so
diff --git a/src/hook_lib/file_hook.c b/src/hook_lib/file_hook.c
index 9e9bddc..5630581 100644
--- a/src/hook_lib/file_hook.c
+++ b/src/hook_lib/file_hook.c
@@ -79,6 +79,12 @@ pid_t (*_fork)();
int (*_setenv)(const char *name, const char *value, int overwrite);
int (*_close)(int fd); // we hooking this, because some programs closes our socket
+// we not hook this functions but we should be sure that these functions
+// are from glibc
+
+int (*_snprintf)(char *str, size_t size, const char *format, ...);
+
+
int is_initialized=0; // when init not lauched yet we should no do any actions
int log_socket=-1;
@@ -159,6 +165,7 @@ void __init_hooks() {
_setenv=(int (*)(const char *name, const char *value, int overwrite)) dlsym(RTLD_NEXT, "setenv");
_close= (int (*)(int fd)) dlsym(RTLD_NEXT, "close");
+ _snprintf=(int (*)(char *str, size_t size, const char *format, ...)) dlsym(RTLD_NEXT, "snprintf");
if(_open==NULL || _open64==NULL ||
_fopen==NULL || _fopen64==NULL ||
@@ -233,16 +240,20 @@ static int __raw_log_event(const char *event_type, const char *filename, char *r
char msg_buff[MAXSOCKETMSGLEN];
int bytes_to_send;
if(strcmp(result,"ERR")==0) {
- bytes_to_send=snprintf(msg_buff,MAXSOCKETMSGLEN,"%lld%c%s%c%s%c%s%c%s/%d",
+ bytes_to_send=_snprintf(msg_buff,MAXSOCKETMSGLEN,"%lld%c%s%c%s%c%s%c%s/%d",
(unsigned long long)time(NULL),0,event_type,0,filename,0,stage,0,result,err);
} else {
- bytes_to_send=snprintf(msg_buff,MAXSOCKETMSGLEN,"%lld%c%s%c%s%c%s%c%s",
+ bytes_to_send=_snprintf(msg_buff,MAXSOCKETMSGLEN,"%lld%c%s%c%s%c%s%c%s",
(unsigned long long)time(NULL),0,event_type,0,filename,0,stage,0,result);
}
if(bytes_to_send>=MAXSOCKETMSGLEN)
return 0;
+ // we need to recount bytes_to_send here because some programs
+ // use hackish snprintf which returns strlen(buf)
+
+
if(send(log_socket,msg_buff,bytes_to_send,0)==-1) {
__doreconnect(); // looks like our socket has been destroyed by logged program
// try to recreate it
next reply other threads:[~2011-09-30 7:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-30 7:21 Александр Берсенев [this message]
-- strict thread matches above, loose matches on Subject: below --
2012-02-11 20:56 [gentoo-commits] proj/autodep:master commit in: src/hook_lib/ Александр Берсенев
2012-01-31 12:30 Александр Берсенев
2011-10-21 4:45 Александр Берсенев
2011-08-21 18:50 Александр Берсенев
2011-08-16 7:31 Александр Берсенев
2011-08-02 20:19 Александр Берсенев
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b6e44ffc06122453c92801d39d08f3c6ebc3ba14.bay@gentoo \
--to=bay@hackerdom.ru \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox