Dump environment variables as well for the sys_execve system calls

This commit is contained in:
Gerard Wagener 2010-01-18 14:21:30 +01:00
parent 36228e179a
commit 1144fdee80

View file

@ -72,6 +72,24 @@ inline void __aha_set_type_tag(int fd, char* buf,int size,int tag)
} }
inline void __aha_dump_str_array(int fd, char** argv,char*id, char* p, char*q)
{
char* a;
int cnt;
for (;;) {
if (get_user(a,argv))
break;
if (!a)
break;
if (strncpy_from_user(p,a, MAX_DUMP_BUF) > 0) {
cnt=snprintf(q,MAX_DUMP_BUF,"%s=%s\n",id,p);
__aha_os_write_file_ck(fd,q,MAX_DUMP_BUF,cnt);
}
argv++;
}
}
/* Tansfers the file names and arguments to the host OS /* Tansfers the file names and arguments to the host OS
* The transfer via files is an good awfull solution. * The transfer via files is an good awfull solution.
* The dumping is done in a best effort manner. If it succeds * The dumping is done in a best effort manner. If it succeds
@ -83,7 +101,7 @@ inline void __aha_set_type_tag(int fd, char* buf,int size,int tag)
char* aha_dump_execve(char __user *file, char __user *__user *argv, char* aha_dump_execve(char __user *file, char __user *__user *argv,
char __user *__user *env) char __user *__user *env)
{ {
char *p, *a, *q, *r; char *p, *q, *r;
int mode = 0644; int mode = 0644;
int fd,cnt; int fd,cnt;
struct openflags flg; struct openflags flg;
@ -110,19 +128,9 @@ char* aha_dump_execve(char __user *file, char __user *__user *argv,
cnt = snprintf((char*)q,MAX_DUMP_BUF,"file=%s\n",p); cnt = snprintf((char*)q,MAX_DUMP_BUF,"file=%s\n",p);
__aha_os_write_file_ck(fd,q,MAX_DUMP_BUF,cnt); __aha_os_write_file_ck(fd,q,MAX_DUMP_BUF,cnt);
} }
/* Dump the arguments */ __aha_dump_str_array(fd,argv,"argument",p,q);
for (;;) { __aha_dump_str_array(fd,env,"env",p,q);
if (get_user(a,argv)) __aha_dump_pid_ppids(fd,q,MAX_DUMP_BUF);
break;
if (!a)
break;
if (strncpy_from_user(p,a, MAX_DUMP_BUF) > 0) {
cnt=snprintf(q,MAX_DUMP_BUF,"argument=%s\n",p);
__aha_os_write_file_ck(fd,q,MAX_DUMP_BUF,cnt);
}
argv++;
}
__aha_dump_pid_ppids(fd,q,MAX_DUMP_BUF);
__aha_set_done_tag(fd,q,MAX_DUMP_BUF); __aha_set_done_tag(fd,q,MAX_DUMP_BUF);
os_close_file(fd); os_close_file(fd);
kfree(p); kfree(p);