Questions tagged [execve]

207 questions
170
votes
9 answers

"No such file or directory" error when executing a binary

I was installing a binary Linux application on Ubuntu 9.10 x86_64. The app shipped with an old version of gzip (1.2.4), that was compiled for a much older kernel: $ file gzip gzip: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV),…
Lorin Hochstein
  • 57,372
  • 31
  • 105
  • 141
38
votes
4 answers

How does kernel get an executable binary file running under linux?

How does kernel get an executable binary file running under linux? It seems a simple question, but anyone can help me dig deep? How the file is loaded to memory and how execution code get started? Can anyone help me and tell what's happening step by…
Daniel
  • 631
  • 2
  • 7
  • 14
18
votes
3 answers

understanding requirements for execve and setting environment vars

We are having a lot of trouble interpreting our teacher. We asked for clarification and got the following back from him For execve, send it a environment you setup with your exported variables and create a builtin command to spawn a subshell of…
james
  • 712
  • 4
  • 11
  • 29
18
votes
1 answer

Python sys.executable is empty

I am testing out doing some shenanigans with os.execve and virtual environments. I am running into the problem where sys.executable is empty if I replace the current python process with another python subprocess. The example below shows what's going…
d0c_s4vage
  • 3,947
  • 6
  • 23
  • 32
10
votes
3 answers

execve("/bin/sh", 0, 0); in a pipe

I have the following example program: #include int main(int argc, char ** argv){ char buf[100]; printf("Please enter your name: "); fflush(stdout); gets(buf); printf("Hello \"%s\"\n", buf); execve("/bin/sh", 0,…
A. Nilsson
  • 539
  • 3
  • 5
  • 19
10
votes
1 answer

How does execve call dynamic linker/loader (ld-linux.so.2)

I used gcc to compile and link the most basic C program, test.c: int main() { } As expected, the output is a dynamically linked executable: $ file test test: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared…
user3610871
  • 133
  • 1
  • 4
8
votes
3 answers

Why do we pass the command name twice to execve, as a path and in the argument list?

I have a program written by my professor that prints the working directory (pwd) by using execve(), but I don't understand the parameters. pid_t pid = fork(); if(pid <0) perror(NULL); else if(pid == 0) { char*argv[] = {"pwd",NULL}; …
Andrei Manolache
  • 766
  • 1
  • 8
  • 17
8
votes
1 answer

What is proper way to call execve with arguments in assembly?

I am trying to execute the following with execve: /bin//nc -lnke /bin/bash -p 4444 When reading the man page for execve, I see the following requirements: int execve(const char *filename, char *const argv[], char *const…
user1529891
6
votes
2 answers

Killed process by SIGKILL

I have a process that get killed immediately after executing the program. This is the code of the compiled executable, and it is a small program that reads several graphs represented by numbers from standard input (a descriptive file usually) and…
Youssef Khloufi
  • 685
  • 3
  • 13
  • 24
6
votes
2 answers

Why we must use a list in subprocess.Popen?

My question is more theoretical than practical, I've found more answers that explains how but not why should we use a list in a subprocess.Popen call. For example as is known: Python 2.7.10 (default, Oct 14 2015, 16:09:02) [GCC 5.2.1 20151010] on…
mvarge
  • 316
  • 1
  • 11
6
votes
3 answers

How to execve a process, retaining capabilities in spite of missing filesystem-based capabilities?

I want to make system usable without setuid, file "+p" capabilities, and in general without things which are disabled when I set PR_SET_NO_NEW_PRIVS. With this approach (init sets PR_SET_NO_NEW_PRIVS and filesystem-based capability elevation no…
Vi.
  • 37,014
  • 18
  • 93
  • 148
6
votes
2 answers

execve - No such file or directory?

I'm having some problems with execve. I'm trying to make a shell that can function just like the bash shell, but I have problems with the forked child executing a command. Here is what I have for the child. cmd is a char * with the command that the…
theeggman85
  • 1,745
  • 6
  • 23
  • 36
5
votes
2 answers

C execve() parameters [spawn a shell example]

I have to fill the parameters for: int execve(const char *filename, char *const argv[], char *const envp[]); If I execute this program: #include int main() { char *args[2]; args[0] = "/bin/sh"; args[1] = NULL; …
rh0x
  • 1,066
  • 1
  • 13
  • 33
5
votes
1 answer

Using execve() in c

I need to see a concrete example of how to specify the environment for execve() in a c program. In my class, we are writing a program that will utilize both standard LINUX executables and our own executables. Thus, the environment searching PATH…
William-H
  • 53
  • 1
  • 1
  • 4
5
votes
4 answers

Where do I find the assembly that creates a static variable in the .data section of my C program?

First time poster. 2nd year CS student. I am exploring the creation of static variables in the .data section of the Virtual Address Space in the context of a C source->GCC compilation->Linux execution environment. C program is test.c int main() { …
phraxOS
  • 53
  • 1
  • 3
1
2 3
13 14