add fsm checker by Gabriel Matni
[lttv.git] / contrib / fsm_checker / CHROOT_CHECK / chroot_jail.c
diff --git a/contrib/fsm_checker/CHROOT_CHECK/chroot_jail.c b/contrib/fsm_checker/CHROOT_CHECK/chroot_jail.c
new file mode 100755 (executable)
index 0000000..1528d78
--- /dev/null
@@ -0,0 +1,34 @@
+#include <glib.h>
+#include <string.h>
+struct rootjail * chrootjail_Init(){
+       struct rootjail *this = (struct rootjail *) g_malloc(sizeof(struct rootjail)); 
+       rootjailContext_Init(&this->_fsm, this);
+       this->pid=-1;
+       this->newroot = g_string_new("");
+       return this;
+}
+void rootjail_savepid(struct rootjail *this, int pid){
+       this->pid=pid;
+}
+void rootjail_savenewroot(struct rootjail *this, char *newroot){
+       g_string_printf(this->newroot, newroot);
+}
+void rootjail_destroyfsm(struct rootjail *this){
+       //remove fsm from fsm_list
+       removefsm(this);
+       g_string_free(this->newroot,TRUE);
+       g_free(this);
+}
+void rootjail_warning(struct rootjail *this){
+       printf("WARNING: pid %d attempted to open a file before calling chdir()\n", this->pid);
+}
+int checknewdir(char * newdir){
+       if(!strcmp(newdir, "/"))//returns 0 when strings are equal
+               return 1;
+       return 0;
+}
+int thisprocess(struct rootjail *this, int pid){
+       if(this->pid==pid)
+               return 1;
+       return 0;       
+}
This page took 0.023584 seconds and 4 git commands to generate.