X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=contrib%2Ffsm_checker%2FCHROOT_CHECK%2Fchroot_jail.c;fp=contrib%2Ffsm_checker%2FCHROOT_CHECK%2Fchroot_jail.c;h=1528d78d7d1713659bd07693abebc6ba6e457f9e;hb=e09e518ebf18d490dbeb72c6358968af7d05d675;hp=0000000000000000000000000000000000000000;hpb=58f53b56557577b64911d0e7a2bba3fbb521d71d;p=lttv.git diff --git a/contrib/fsm_checker/CHROOT_CHECK/chroot_jail.c b/contrib/fsm_checker/CHROOT_CHECK/chroot_jail.c new file mode 100755 index 00000000..1528d78d --- /dev/null +++ b/contrib/fsm_checker/CHROOT_CHECK/chroot_jail.c @@ -0,0 +1,34 @@ +#include +#include +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; +}