further studied)
2.2 exec system call
The system calls exec to execute an executable file to replace the execution image of the current process. It should be noted that the call did not generate a new process, but instead replaced the text of the original process on the basis of the original process. The process id remains unchanged before and after the call. But the execution program has changed (the execution command sequence has changed ). It has six calling modes, which are not exactly the
, the parameter values after-s are limited to 1 or 2, and any other values are considered invalid, will cause the program to exit directly.In addition, the path variable in the program is used to specify the absolute path of the vulnerability program. The default value is/usr/local/bin/ftpdctl. The pr_ctrls_connect () function in ctrls. c is called in the ftpdctl of the ProFTPD server, and a strncpy () in this function is the buffer overflow point of this vulnerability. In row 394 of 267. c, use
Exec replacement process impressions
Overview
On Process Creation, UNIX/Linux adopts a unique method, which separates Process Creation from loading a new process image (system calls combine these two operations ). The advantage is that there is more room to manage the two operations.
After we create a process, we usually replace the child process with a new process image. This can be done using exec functions. Of course, the exec series functions can also replace the current process (do not cal
is called once but returns two times. The only difference of two returns is that the child process ID is returned in the parent process with a value of 0.A child process is a copy of the parent process that obtains a copy of the parent process's data space, heap, stack, and so on. Note that the child process holds a "copy" of the above storage space, which means that the storage space is not shared between parent and child processes, and that only the code snippets are shared between them.Examp
);
int execle (const Char *path, const char *arg0, ..., (char*) 0, char *const envp[]);
int Execv (const Char *path, char *const argv[]);
int EXECVP (cosnt char *file, char *const argv[]);
int Execve (const Char *path, char *const argv[], char *const envp[]);
This type of function can be divided into two categories, execl, EXECLP, and execle parameters are mutable, ending with a null pointe
Inux Process Control-exec series is called the exec system call, actually in Linux, there is no EXEC () function form, exec refers to a set of functions, a total of 6, respectively:#include int execl (const char *path, const char *arg, ...);int EXECLP (const char *file, const char *arg, ...);int execle (const char *path, const char *arg, ..., Char *const envp[]);int execv (const char *path, char *const argv[]);int EXECVP (const char *file, char *const
call In fact, there is no system call called "Exec", the so-called "exec" system call is actually 6 system calls in Execab form, as shown in the following way: The A can be either L or V, depending on whether the parameter is directly in the call (list) or in the array (vector), b either has no, or p, p means to use the PATH environment variable finder, or E, E to use a specific environment. (Users cannot get features p and E at the same time in the same call.) Therefore, the 6 calls were Exec
1. Introduction
In Linux, there is no exec () function, exec refers to a set of functions, a total of 6, respectively:
#include
extern char **environ;
int execl (const char *path, const char *arg, ...);
int EXECLP (const char *file, const char *arg, ...);
int execle (const char *path, const char *arg, ..., char * const envp[]);
int execv (const char *path, char *const argv[]);
int EXECVP (const char *file, char *const argv[]);
int Execve (co
to avoid this situation, you can specify the SA_NOCLDSTOP flag when calling Sigaction ().
Part IV: Implementation of the new program Execve ()
================================================
The EXECVE () call allows the new program to be loaded into the memory space of a process, based on which the C language provides the Exec series library functions. Here are some instructions for the calls loaded by the new program:
1. The EXEC () series functions have Execve (),
use Java and exelce combination. Control execle through Java.The stream can also be used as a simulation database for storing data (combined with execle use);This week the main perfect ATM interface and data storage, QQ interface design and improvement.This object is not a member of the flow system, it encapsulates a byte stream, and also encapsulates a buffer (a character array), manipulating the data in
The problem is not in these functions, but in looking at the post-interpreter and discovering a fascinating question.#include The first parameter is the path name or file name, followed by a series of string arguments or array of pointers. To study the small program in this article.#include"apue.h"#includeChar*env_init[] = {"User=unknown","path=/tmp", NULL};intMain (void) {pid_t pid; if(PID = fork ()) 0) {Err_sys ("Fork Error"); } Else if(PID = =0) {/*Specify pathname, specify environment*/
to the parent process, and returns 0 to the child process. This means that even if you only call the Um fork once, it can return twice.
The new process created by fork is the same as the parent process.
The child process does not inherit the timeout settings of the parent process, the file lock created by the parent process, or the pending signal.
Fork's asynchronous behavior means that the code of the parent process cannot be executed in the child process.
Exec function familyInt execl
value is greater than 0, it indicates the parent process. If it is less than 0 (in fact, it is-1), it indicates that the creation process has failed.
Each process has a unique identifier, namely, PID, which can be obtained using getpid. The PID returned by the parent process is actually the PID of the child process.
It seems that fork () has no effect. In fact, if fork () is later used with other Linux functions, it is still very useful. For example, we can communicate through the communicat
1. PrefaceThis article describes a cron run on SuSE Linux that was developed by Paul Vixie. Can be confirmed by "man Cron".2. Example# examples are used to match the instructions in this article*/1 * * * * echo Hello >>/tmp/hello.txt3. Working ProcessCron does a check every minute to see which command is executable.As you can see, there are 4 fork, these 4 fork are:1) The first fork, let Cron itself become daemon process, that is to become the Guardian process;2) The second fork, when Cron check
input.When the user types the user name, Getty executes The login program, similar to the following: Execle ("Login"). Login can call Getpass () to display password: and read the user's password. and call Getpwnam for password authentication. If successful, the call is similar to execle ("shell"). In this way, the logged-on user has a shell.Third, pseudo-terminalThe above logon process, for network users,
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.