jailkit-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Jailkit-users] error in jailkit code: jk_lib.c


From: Marcus Eting
Subject: [Jailkit-users] error in jailkit code: jk_lib.c
Date: Wed, 5 Jun 2013 23:06:41 -0400

shouldn't the next to last line of jk_lib.c be "return 0;" instead of "return 
1" ?


/* if it returns 1 it will allocate new memory for jaildir and newhomedir
 * else it will return 0
 */
int getjaildir(const char *oldhomedir, char **jaildir, char **newhomedir) {

        int i=strlen(oldhomedir);
        /* we will not accept /./ as jail, so we continue looking while i > 4 
(minimum then is /a/./ )
         * we start at the end so if there are multiple /path/./path2/./path3 
the user will be jailed in the most minimized path
         */
        while (i > 4) {
/*              DEBUG_MSG("oldhomedir[%d]=%c\n",i,oldhomedir[i]);*/
                if (oldhomedir[i] == '/' && oldhomedir[i-1] == '.' && 
oldhomedir[i-2] == '/') {
                        DEBUG_MSG("&oldhomedir[%d]=%s\n",i,&oldhomedir[i]);
                        *jaildir = strndup(oldhomedir, i-2);
                        *newhomedir = strdup(&oldhomedir[i]);
                        return 1;
                }
                i--;
        }
        return 1;
}


reply via email to

[Prev in Thread] Current Thread [Next in Thread]