execve(2) not launching essential commands from /binLightweight userspace sandboxing of filesystemServer port...

Missouri raptors have wild hairdos

Extracting sublists that contain similar elements

Find hamming distance between two Strings of equal length in Java

Smallest Guaranteed hash collision cycle length

How can a layman easily get the consensus view of what academia *thinks* about a subject?

Entering the UK as a British citizen who is a Canadian permanent resident

Is there ever any indication in the MCU as to how Spider-Man got his powers?

Is taking modulus on both sides of an equation valid?

Area under the curve - Integrals (Antiderivatives)

Wireless headphones interfere with Wi-Fi signal on laptop

Can I say: "When was your train leaving?" if the train leaves in the future?

return tuple of uncopyable objects

Why is tomato paste so cheap?

Would an 8% reduction in drag outweigh the weight addition from this custom CFD-tested winglet?

Where to find every-day healthy food near Heathrow Airport?

Do I need to say 'o`clock'?

Can a tourist shoot a gun in the USA?

What information do scammers need to withdraw money from an account?

Tikz draw contour without some edges, and fill

What is the name of this Middle English letter?

On what legal basis did the UK remove the 'European Union' from its passport?

Why does my circuit work on a breadboard, but not on a perfboard? I am new to soldering

Program which behaves differently in/out of a debugger

How to cope with regret and shame about not fully utilizing opportunities during PhD?



execve(2) not launching essential commands from /bin


Lightweight userspace sandboxing of filesystemServer port doenst go back to listen and is in closed_wait state , because of starting an daemon application from clientWhat are the ways and risks of using linux namespaces as nonroot user?Separate DNS configuration in each network namespaceWhy is the “open” system call not featured in /usr/include/unistd.h ? (but “close” is)What happens to the mount namespace of an interrupted processWhat code prevents mount namespace loops? In a more complex case involving mount propagationIs linux mount propagation asynchronous to the mount call?Why can I not bind a mount namespace to a fileerror creating namespaces






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















I am trying to implement a container, and for that I create a process using the clone(2) system call with the appropriate flags:



  if ((child_pid = clone(child_main, process_struct.Stack + process_struct.StackPtr,
CLONE_NEWCGROUP
|CLONE_NEWIPC
|CLONE_NEWNET
|CLONE_NEWNS
|CLONE_NEWPID
|CLONE_NEWUTS
|SIGCHLD, &process_struct, checkpoint)) == -1){
fprintf(stderr,"Failed...%m n");
exit(EXIT_FAILURE);

}else{
fprintf(stderr,"Donen");
waitpid(child_pid, NULL, 0);
}


inside child_main() I Change the host name for the process's namespace, also i set the mount namespace, I installed a Linux file system hierarchy on a partition like a normal Linux installation (I did that to create a clean file system image clean of my files and binaries) and then I set the propagation type to MS_UNBINDABLE, then I pivot_root(2) to change my process's root directory.



const int child_main(struct process *process_struct, int *checkpoint){

char c;
fprintf(stderr,"=> IPC setup...");
//double check the IPC
close(checkpoint[1]);
fprintf(stderr,"Donen");

if ( sethostname(process_struct->Hostname,
strlen(process_struct->Hostname)) || mounting(process_struct)){
return -1;
}

// startup the IPC pipes
read(checkpoint[0], &c, 1);

if(execve("/bin/bash", (char*)0, NULL) == -1 ){
fprintf(stderr,"--> Launching process Failed %mn");
return -1;
}
return 0;

}


The problem is that my system goes over the execve(2) and does not launch the /bin/bash and the program flows without errors. When I add system(2) statement before the execve(2) : system("ls"); it lists the appropriate file system and current working directory. Also when I change the execve(2) paramters to either:
execve("/bin/ls", (char*)0, NULL) or execve("/bin/pstree", (char*)0, NULL) or any other parameter it will return an error of: No such file or directory or A NULL argv[0] was passed through an exec system call, also when I strace my program at the execve(2) system call it gives: NULL, 0, NULL) = 17992



update: the error has nothing to do with the file system image, I have performed more tests and are as the follwoing, I used for my mount namespaces my system's filesystem not the one I installed on a partition and running /bin/bash doesn't still work, I created a simple C program and compiled it, and it ran fine so there is something wrong that prevent bin/bash from being executed, to further test these results I reused for my mount namespaces the file system from my I moved the same executable to the file system first under "/" and second under the same path
my main system path to the executable= /home/omar/docs/test.out
my mounted file system from the partition path to the executable= /home/omar/docs/test.out
since I wanted to check if the same path might have caused a confusion while adding to each executable a statment so can tell which path did my program take, and it worked fine without any problem and correctly as expected, so the problem is just that system essential commands will not work.










share|improve this question

























  • Are you sure it doesn’t launch it, and then bash exits immediately?

    – Stephen Kitt
    2 days ago











  • yes, also the parent program resumes normally.

    – o.awajan
    2 days ago











  • Oh, sorry, yes, execve would replace the program if it succeeded...

    – Stephen Kitt
    2 days ago






  • 1





    What happens if you pass a valid argv array to execve?

    – Mark Plotnick
    2 days ago











  • execve(2) will launch /bin/bash and replace the program, then it will exit immediately, as if the /bin/bash doesn't actually launch, in the question I specified what strace shows me at execve(2) which is ``` NULL, 0, NULL) = 17992```

    – o.awajan
    2 days ago


















0















I am trying to implement a container, and for that I create a process using the clone(2) system call with the appropriate flags:



  if ((child_pid = clone(child_main, process_struct.Stack + process_struct.StackPtr,
CLONE_NEWCGROUP
|CLONE_NEWIPC
|CLONE_NEWNET
|CLONE_NEWNS
|CLONE_NEWPID
|CLONE_NEWUTS
|SIGCHLD, &process_struct, checkpoint)) == -1){
fprintf(stderr,"Failed...%m n");
exit(EXIT_FAILURE);

}else{
fprintf(stderr,"Donen");
waitpid(child_pid, NULL, 0);
}


inside child_main() I Change the host name for the process's namespace, also i set the mount namespace, I installed a Linux file system hierarchy on a partition like a normal Linux installation (I did that to create a clean file system image clean of my files and binaries) and then I set the propagation type to MS_UNBINDABLE, then I pivot_root(2) to change my process's root directory.



const int child_main(struct process *process_struct, int *checkpoint){

char c;
fprintf(stderr,"=> IPC setup...");
//double check the IPC
close(checkpoint[1]);
fprintf(stderr,"Donen");

if ( sethostname(process_struct->Hostname,
strlen(process_struct->Hostname)) || mounting(process_struct)){
return -1;
}

// startup the IPC pipes
read(checkpoint[0], &c, 1);

if(execve("/bin/bash", (char*)0, NULL) == -1 ){
fprintf(stderr,"--> Launching process Failed %mn");
return -1;
}
return 0;

}


The problem is that my system goes over the execve(2) and does not launch the /bin/bash and the program flows without errors. When I add system(2) statement before the execve(2) : system("ls"); it lists the appropriate file system and current working directory. Also when I change the execve(2) paramters to either:
execve("/bin/ls", (char*)0, NULL) or execve("/bin/pstree", (char*)0, NULL) or any other parameter it will return an error of: No such file or directory or A NULL argv[0] was passed through an exec system call, also when I strace my program at the execve(2) system call it gives: NULL, 0, NULL) = 17992



update: the error has nothing to do with the file system image, I have performed more tests and are as the follwoing, I used for my mount namespaces my system's filesystem not the one I installed on a partition and running /bin/bash doesn't still work, I created a simple C program and compiled it, and it ran fine so there is something wrong that prevent bin/bash from being executed, to further test these results I reused for my mount namespaces the file system from my I moved the same executable to the file system first under "/" and second under the same path
my main system path to the executable= /home/omar/docs/test.out
my mounted file system from the partition path to the executable= /home/omar/docs/test.out
since I wanted to check if the same path might have caused a confusion while adding to each executable a statment so can tell which path did my program take, and it worked fine without any problem and correctly as expected, so the problem is just that system essential commands will not work.










share|improve this question

























  • Are you sure it doesn’t launch it, and then bash exits immediately?

    – Stephen Kitt
    2 days ago











  • yes, also the parent program resumes normally.

    – o.awajan
    2 days ago











  • Oh, sorry, yes, execve would replace the program if it succeeded...

    – Stephen Kitt
    2 days ago






  • 1





    What happens if you pass a valid argv array to execve?

    – Mark Plotnick
    2 days ago











  • execve(2) will launch /bin/bash and replace the program, then it will exit immediately, as if the /bin/bash doesn't actually launch, in the question I specified what strace shows me at execve(2) which is ``` NULL, 0, NULL) = 17992```

    – o.awajan
    2 days ago














0












0








0








I am trying to implement a container, and for that I create a process using the clone(2) system call with the appropriate flags:



  if ((child_pid = clone(child_main, process_struct.Stack + process_struct.StackPtr,
CLONE_NEWCGROUP
|CLONE_NEWIPC
|CLONE_NEWNET
|CLONE_NEWNS
|CLONE_NEWPID
|CLONE_NEWUTS
|SIGCHLD, &process_struct, checkpoint)) == -1){
fprintf(stderr,"Failed...%m n");
exit(EXIT_FAILURE);

}else{
fprintf(stderr,"Donen");
waitpid(child_pid, NULL, 0);
}


inside child_main() I Change the host name for the process's namespace, also i set the mount namespace, I installed a Linux file system hierarchy on a partition like a normal Linux installation (I did that to create a clean file system image clean of my files and binaries) and then I set the propagation type to MS_UNBINDABLE, then I pivot_root(2) to change my process's root directory.



const int child_main(struct process *process_struct, int *checkpoint){

char c;
fprintf(stderr,"=> IPC setup...");
//double check the IPC
close(checkpoint[1]);
fprintf(stderr,"Donen");

if ( sethostname(process_struct->Hostname,
strlen(process_struct->Hostname)) || mounting(process_struct)){
return -1;
}

// startup the IPC pipes
read(checkpoint[0], &c, 1);

if(execve("/bin/bash", (char*)0, NULL) == -1 ){
fprintf(stderr,"--> Launching process Failed %mn");
return -1;
}
return 0;

}


The problem is that my system goes over the execve(2) and does not launch the /bin/bash and the program flows without errors. When I add system(2) statement before the execve(2) : system("ls"); it lists the appropriate file system and current working directory. Also when I change the execve(2) paramters to either:
execve("/bin/ls", (char*)0, NULL) or execve("/bin/pstree", (char*)0, NULL) or any other parameter it will return an error of: No such file or directory or A NULL argv[0] was passed through an exec system call, also when I strace my program at the execve(2) system call it gives: NULL, 0, NULL) = 17992



update: the error has nothing to do with the file system image, I have performed more tests and are as the follwoing, I used for my mount namespaces my system's filesystem not the one I installed on a partition and running /bin/bash doesn't still work, I created a simple C program and compiled it, and it ran fine so there is something wrong that prevent bin/bash from being executed, to further test these results I reused for my mount namespaces the file system from my I moved the same executable to the file system first under "/" and second under the same path
my main system path to the executable= /home/omar/docs/test.out
my mounted file system from the partition path to the executable= /home/omar/docs/test.out
since I wanted to check if the same path might have caused a confusion while adding to each executable a statment so can tell which path did my program take, and it worked fine without any problem and correctly as expected, so the problem is just that system essential commands will not work.










share|improve this question
















I am trying to implement a container, and for that I create a process using the clone(2) system call with the appropriate flags:



  if ((child_pid = clone(child_main, process_struct.Stack + process_struct.StackPtr,
CLONE_NEWCGROUP
|CLONE_NEWIPC
|CLONE_NEWNET
|CLONE_NEWNS
|CLONE_NEWPID
|CLONE_NEWUTS
|SIGCHLD, &process_struct, checkpoint)) == -1){
fprintf(stderr,"Failed...%m n");
exit(EXIT_FAILURE);

}else{
fprintf(stderr,"Donen");
waitpid(child_pid, NULL, 0);
}


inside child_main() I Change the host name for the process's namespace, also i set the mount namespace, I installed a Linux file system hierarchy on a partition like a normal Linux installation (I did that to create a clean file system image clean of my files and binaries) and then I set the propagation type to MS_UNBINDABLE, then I pivot_root(2) to change my process's root directory.



const int child_main(struct process *process_struct, int *checkpoint){

char c;
fprintf(stderr,"=> IPC setup...");
//double check the IPC
close(checkpoint[1]);
fprintf(stderr,"Donen");

if ( sethostname(process_struct->Hostname,
strlen(process_struct->Hostname)) || mounting(process_struct)){
return -1;
}

// startup the IPC pipes
read(checkpoint[0], &c, 1);

if(execve("/bin/bash", (char*)0, NULL) == -1 ){
fprintf(stderr,"--> Launching process Failed %mn");
return -1;
}
return 0;

}


The problem is that my system goes over the execve(2) and does not launch the /bin/bash and the program flows without errors. When I add system(2) statement before the execve(2) : system("ls"); it lists the appropriate file system and current working directory. Also when I change the execve(2) paramters to either:
execve("/bin/ls", (char*)0, NULL) or execve("/bin/pstree", (char*)0, NULL) or any other parameter it will return an error of: No such file or directory or A NULL argv[0] was passed through an exec system call, also when I strace my program at the execve(2) system call it gives: NULL, 0, NULL) = 17992



update: the error has nothing to do with the file system image, I have performed more tests and are as the follwoing, I used for my mount namespaces my system's filesystem not the one I installed on a partition and running /bin/bash doesn't still work, I created a simple C program and compiled it, and it ran fine so there is something wrong that prevent bin/bash from being executed, to further test these results I reused for my mount namespaces the file system from my I moved the same executable to the file system first under "/" and second under the same path
my main system path to the executable= /home/omar/docs/test.out
my mounted file system from the partition path to the executable= /home/omar/docs/test.out
since I wanted to check if the same path might have caused a confusion while adding to each executable a statment so can tell which path did my program take, and it worked fine without any problem and correctly as expected, so the problem is just that system essential commands will not work.







c system-calls namespace container clone






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 1 hour ago







o.awajan

















asked 2 days ago









o.awajano.awajan

174




174













  • Are you sure it doesn’t launch it, and then bash exits immediately?

    – Stephen Kitt
    2 days ago











  • yes, also the parent program resumes normally.

    – o.awajan
    2 days ago











  • Oh, sorry, yes, execve would replace the program if it succeeded...

    – Stephen Kitt
    2 days ago






  • 1





    What happens if you pass a valid argv array to execve?

    – Mark Plotnick
    2 days ago











  • execve(2) will launch /bin/bash and replace the program, then it will exit immediately, as if the /bin/bash doesn't actually launch, in the question I specified what strace shows me at execve(2) which is ``` NULL, 0, NULL) = 17992```

    – o.awajan
    2 days ago



















  • Are you sure it doesn’t launch it, and then bash exits immediately?

    – Stephen Kitt
    2 days ago











  • yes, also the parent program resumes normally.

    – o.awajan
    2 days ago











  • Oh, sorry, yes, execve would replace the program if it succeeded...

    – Stephen Kitt
    2 days ago






  • 1





    What happens if you pass a valid argv array to execve?

    – Mark Plotnick
    2 days ago











  • execve(2) will launch /bin/bash and replace the program, then it will exit immediately, as if the /bin/bash doesn't actually launch, in the question I specified what strace shows me at execve(2) which is ``` NULL, 0, NULL) = 17992```

    – o.awajan
    2 days ago

















Are you sure it doesn’t launch it, and then bash exits immediately?

– Stephen Kitt
2 days ago





Are you sure it doesn’t launch it, and then bash exits immediately?

– Stephen Kitt
2 days ago













yes, also the parent program resumes normally.

– o.awajan
2 days ago





yes, also the parent program resumes normally.

– o.awajan
2 days ago













Oh, sorry, yes, execve would replace the program if it succeeded...

– Stephen Kitt
2 days ago





Oh, sorry, yes, execve would replace the program if it succeeded...

– Stephen Kitt
2 days ago




1




1





What happens if you pass a valid argv array to execve?

– Mark Plotnick
2 days ago





What happens if you pass a valid argv array to execve?

– Mark Plotnick
2 days ago













execve(2) will launch /bin/bash and replace the program, then it will exit immediately, as if the /bin/bash doesn't actually launch, in the question I specified what strace shows me at execve(2) which is ``` NULL, 0, NULL) = 17992```

– o.awajan
2 days ago





execve(2) will launch /bin/bash and replace the program, then it will exit immediately, as if the /bin/bash doesn't actually launch, in the question I specified what strace shows me at execve(2) which is ``` NULL, 0, NULL) = 17992```

– o.awajan
2 days ago










0






active

oldest

votes












Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f518237%2fexecve2-not-launching-essential-commands-from-bin%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f518237%2fexecve2-not-launching-essential-commands-from-bin%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...