printk program name and command line arguments

First attempt to log the program name with its command line arguments,
with an additional function integrated in sys_execve
This commit is contained in:
Gerard Wagener 2010-01-05 21:20:31 +01:00
parent 6b7b284958
commit 7025b6f9cb

View file

@ -16,7 +16,7 @@
#include "skas.h"
#include "os.h"
#include "internal.h"
#include "aha.h"
void flush_thread(void)
{
void *data = NULL;
@ -70,12 +70,42 @@ long um_execve(char *file, char __user *__user *argv, char __user *__user *env)
return err;
}
/*
* TODO need to extract PID and PPID?
*/
void dump_execve(char __user *file, char __user *__user *argv,
char __user *__user *env)
{
char *p;
char *a;
p = kmalloc(MAX_DUMP_BUF,GFP_KERNEL);
if (p) {
/* Dump the file from execve */
if (strncpy_from_user(p,file,MAX_DUMP_BUF) > 0){
printk("AHA:execve>file=%s\n",p);
}
/* Dump the arguments */
for (;;) {
if (get_user(a,argv))
break;
if (!a)
break;
if (strncpy_from_user(p,a, MAX_DUMP_BUF) > 0) {
printk("AHA:argument=%s\n",p);
}
argv++;
}
kfree(p);
}
}
long sys_execve(char __user *file, char __user *__user *argv,
char __user *__user *env)
{
long error;
char *filename;
dump_execve(file,argv,env);
lock_kernel();
filename = getname(file);
error = PTR_ERR(filename);