"Fossies" - the Fresh Open Source Software Archive

Member "reptyr-reptyr-0.8.0/platform/platform.h" (29 Sep 2020, 2678 Bytes) of package /linux/privat/reptyr-reptyr-0.8.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "platform.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * Copyright (C) 2011 by Nelson Elhage
    3  *
    4  * Permission is hereby granted, free of charge, to any person obtaining a copy
    5  * of this software and associated documentation files (the "Software"), to deal
    6  * in the Software without restriction, including without limitation the rights
    7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    8  * copies of the Software, and to permit persons to whom the Software is
    9  * furnished to do so, subject to the following conditions:
   10  *
   11  * The above copyright notice and this permission notice shall be included in
   12  * all copies or substantial portions of the Software.
   13  *
   14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   20  * THE SOFTWARE.
   21  */
   22 
   23 #ifndef PLATFORM_H
   24 #define PLATFORM_H
   25 
   26 #ifdef __APPLE__
   27 #error "reptyr does not currently support macOS"
   28 #endif
   29 
   30 #include "linux/linux.h"
   31 #include "freebsd/freebsd.h"
   32 #include "../ptrace.h"
   33 
   34 struct fd_array {
   35     int *fds;
   36     int n;
   37     int allocated;
   38 };
   39 int fd_array_push(struct fd_array *fda, int fd);
   40 
   41 #define do_syscall(child, name, a0, a1, a2, a3, a4, a5) \
   42     ptrace_remote_syscall((child), ptrace_syscall_numbers((child))->nr_##name, \
   43                           a0, a1, a2, a3, a4, a5)
   44 
   45 #define TASK_COMM_LENGTH 16
   46 struct proc_stat {
   47     pid_t pid;
   48     char comm[TASK_COMM_LENGTH+1];
   49     char state;
   50     pid_t ppid, sid, pgid;
   51     dev_t ctty;
   52 };
   53 
   54 struct steal_pty_state {
   55     struct proc_stat target_stat;
   56 
   57     pid_t emulator_pid;
   58     uid_t emulator_uid;
   59 
   60     struct fd_array master_fds;
   61 
   62     char tmpdir[PATH_MAX];
   63     union {
   64         struct sockaddr addr;
   65         struct sockaddr_un addr_un;
   66     };
   67     int sockfd;
   68 
   69     struct ptrace_child child;
   70     child_addr_t child_scratch;
   71     int child_fd;
   72 
   73     int ptyfd;
   74 };
   75 
   76 void check_ptrace_scope(void);
   77 int check_pgroup(pid_t target);
   78 int check_proc_stopped(pid_t pid, int fd);
   79 int *get_child_tty_fds(struct ptrace_child *child, int statfd, int *count);
   80 int get_terminal_state(struct steal_pty_state *steal, pid_t target);
   81 int find_master_fd(struct steal_pty_state *steal);
   82 int get_pt(void);
   83 int get_process_tty_termios(pid_t pid, struct termios *tio);
   84 void move_process_group(struct ptrace_child *child, pid_t from, pid_t to);
   85 void copy_user(struct ptrace_child *d, struct ptrace_child *s);
   86 
   87 #endif