Share the code you have written. You seem to have a grasp on what you want to do, but we need to see what happens before and after, and most specifically within the chdir() line and the line where you try to run the Makefile.
If you are successfully creating the directory by cloning from a repo with the current user, and then attempting to change directories and execute something with the same user, it is hard to believe that it is a permission issue.
I could very well be wrong, but your code will help :)
|