功能测试通过
This commit is contained in:
parent
0276822ab4
commit
a0592ddb9f
|
|
@ -16,7 +16,9 @@
|
|||
"dlfcn.h": "c",
|
||||
"signal.h": "c",
|
||||
"stdio.h": "c",
|
||||
"wait.h": "c"
|
||||
"wait.h": "c",
|
||||
"signal_handlers.h": "c",
|
||||
"terminal_utils.h": "c"
|
||||
},
|
||||
"C_Cpp.errorSquiggles": "disabled"
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
BIN
build/logging.o
BIN
build/logging.o
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -16,6 +16,26 @@
|
|||
"type": "warn",
|
||||
"msg": "使用pip安装torch时,请注意使用厂家支持版本",
|
||||
"args": ["install", "torch"]
|
||||
},
|
||||
{
|
||||
"cmd": "dirname",
|
||||
"type": "skip"
|
||||
},
|
||||
{
|
||||
"cmd": "lesspipe",
|
||||
"type": "skip"
|
||||
},
|
||||
{
|
||||
"cmd": "command-not-found",
|
||||
"type": "skip"
|
||||
},
|
||||
{
|
||||
"cmd": "dircolors",
|
||||
"type": "skip"
|
||||
},
|
||||
{
|
||||
"cmd": "basename",
|
||||
"type": "skip"
|
||||
}
|
||||
]
|
||||
}
|
||||
308
logs/execve.log
308
logs/execve.log
|
|
@ -5824,3 +5824,311 @@ arg[1]: -b
|
|||
arg[0]: /usr/lib/command-not-found
|
||||
arg[1]: --
|
||||
arg[2]:
|
||||
[Tue Apr 8 20:53:13 2025
|
||||
] Command: /usr/bin/lesspipe
|
||||
arg[0]: lesspipe
|
||||
[Tue Apr 8 20:53:14 2025
|
||||
] Command: /usr/bin/dircolors
|
||||
arg[0]: dircolors
|
||||
arg[1]: -b
|
||||
[Tue Apr 8 20:54:00 2025
|
||||
] Command: /usr/bin/lesspipe
|
||||
arg[0]: lesspipe
|
||||
[Tue Apr 8 20:54:00 2025
|
||||
] Command: /usr/bin/dircolors
|
||||
arg[0]: dircolors
|
||||
arg[1]: -b
|
||||
[Tue Apr 8 20:54:12 2025
|
||||
] Command: /usr/bin/lesspipe
|
||||
arg[0]: lesspipe
|
||||
[Tue Apr 8 20:54:12 2025
|
||||
] Command: /usr/bin/dircolors
|
||||
arg[0]: dircolors
|
||||
arg[1]: -b
|
||||
[Wed Apr 9 14:20:41 2025
|
||||
] Command: /usr/bin/lesspipe
|
||||
arg[0]: lesspipe
|
||||
[Wed Apr 9 14:20:41 2025
|
||||
] Command: /usr/bin/dircolors
|
||||
arg[0]: dircolors
|
||||
arg[1]: -b
|
||||
[Wed Apr 9 14:20:42 2025
|
||||
] Command: /usr/bin/ls
|
||||
arg[0]: ls
|
||||
arg[1]: --color=auto
|
||||
[Wed Apr 9 14:20:43 2025
|
||||
] Command: /usr/bin/ls
|
||||
arg[0]: ls
|
||||
arg[1]: --color=auto
|
||||
arg[2]: -alF
|
||||
[Wed Apr 9 14:20:46 2025
|
||||
] Command: /usr/bin/htop
|
||||
arg[0]: htop
|
||||
[Wed Apr 9 14:21:00 2025
|
||||
] Command: /usr/bin/ls
|
||||
arg[0]: ls
|
||||
arg[1]: --color=auto
|
||||
[Wed Apr 9 14:28:59 2025
|
||||
] Command: /usr/bin/lesspipe
|
||||
arg[0]: lesspipe
|
||||
[Wed Apr 9 14:28:59 2025
|
||||
] Command: /usr/bin/dircolors
|
||||
arg[0]: dircolors
|
||||
arg[1]: -b
|
||||
[Wed Apr 9 14:29:07 2025
|
||||
] Command: /usr/bin/lesspipe
|
||||
arg[0]: lesspipe
|
||||
[Wed Apr 9 14:29:07 2025
|
||||
] Command: /usr/bin/dircolors
|
||||
arg[0]: dircolors
|
||||
arg[1]: -b
|
||||
[Wed Apr 9 14:29:30 2025
|
||||
] Command: /usr/bin/ls
|
||||
arg[0]: ls
|
||||
arg[1]: --color=auto
|
||||
arg[2]: -alF
|
||||
[Wed Apr 9 14:29:46 2025
|
||||
] Command: /usr/lib/command-not-found
|
||||
arg[0]: /usr/lib/command-not-found
|
||||
arg[1]: --
|
||||
arg[2]: nvidia-smi
|
||||
[Wed Apr 9 14:29:59 2025
|
||||
] Command: /usr/bin/ls
|
||||
arg[0]: ls
|
||||
arg[1]: --color=auto
|
||||
[Wed Apr 9 14:30:07 2025
|
||||
] Command: /usr/bin/wget
|
||||
arg[0]: wget
|
||||
[Wed Apr 9 14:30:13 2025
|
||||
] Command: /usr/bin/htop
|
||||
arg[0]: htop
|
||||
[Wed Apr 9 14:59:11 2025
|
||||
] Command: /usr/bin/lesspipe
|
||||
arg[0]: lesspipe
|
||||
[Wed Apr 9 14:59:11 2025
|
||||
] Command: /usr/bin/dircolors
|
||||
arg[0]: dircolors
|
||||
arg[1]: -b
|
||||
[Wed Apr 9 17:14:19 2025
|
||||
] Command: /usr/bin/lesspipe
|
||||
arg[0]: lesspipe
|
||||
[Wed Apr 9 17:14:19 2025
|
||||
] Command: /usr/bin/dircolors
|
||||
arg[0]: dircolors
|
||||
arg[1]: -b
|
||||
[Wed Apr 9 17:14:20 2025
|
||||
] Command: /usr/bin/ls
|
||||
arg[0]: ls
|
||||
arg[1]: --color=auto
|
||||
[Wed Apr 9 17:14:21 2025
|
||||
] Command: /usr/bin/ls
|
||||
arg[0]: ls
|
||||
arg[1]: --color=auto
|
||||
arg[2]: -alF
|
||||
[Wed Apr 9 17:14:32 2025
|
||||
] Command: /usr/bin/ls
|
||||
arg[0]: ls
|
||||
arg[1]: --color=auto
|
||||
[Wed Apr 9 17:15:18 2025
|
||||
] Command: /usr/bin/lesspipe
|
||||
arg[0]: lesspipe
|
||||
[Wed Apr 9 17:15:18 2025
|
||||
] Command: /usr/bin/dircolors
|
||||
arg[0]: dircolors
|
||||
arg[1]: -b
|
||||
[Wed Apr 9 17:15:20 2025
|
||||
] Command: /usr/bin/ls
|
||||
arg[0]: ls
|
||||
arg[1]: --color=auto
|
||||
[Wed Apr 9 17:15:40 2025
|
||||
] Command: /usr/bin/lesspipe
|
||||
arg[0]: lesspipe
|
||||
[Wed Apr 9 17:15:40 2025
|
||||
] Command: /usr/bin/dircolors
|
||||
arg[0]: dircolors
|
||||
arg[1]: -b
|
||||
[Wed Apr 9 17:16:19 2025
|
||||
] Command: /usr/bin/lesspipe
|
||||
arg[0]: lesspipe
|
||||
[Wed Apr 9 17:16:19 2025
|
||||
] Command: /usr/bin/dircolors
|
||||
arg[0]: dircolors
|
||||
arg[1]: -b
|
||||
[Wed Apr 9 17:16:20 2025
|
||||
] Command: /usr/bin/ls
|
||||
arg[0]: ls
|
||||
arg[1]: --color=auto
|
||||
[Wed Apr 9 17:16:21 2025
|
||||
] Command: /usr/bin/ls
|
||||
arg[0]: ls
|
||||
arg[1]: --color=auto
|
||||
arg[2]: -alF
|
||||
[Wed Apr 9 17:26:44 2025
|
||||
] Command: /usr/bin/lesspipe
|
||||
arg[0]: lesspipe
|
||||
[Wed Apr 9 17:26:44 2025
|
||||
] Command: /usr/bin/dircolors
|
||||
arg[0]: dircolors
|
||||
arg[1]: -b
|
||||
[Wed Apr 9 17:27:02 2025
|
||||
] Command: /usr/bin/lesspipe
|
||||
arg[0]: lesspipe
|
||||
[Wed Apr 9 17:27:02 2025
|
||||
] Command: /usr/lib/command-not-found
|
||||
arg[0]: /usr/lib/command-not-found
|
||||
arg[1]: --
|
||||
arg[2]:
|
||||
[Wed Apr 9 17:27:02 2025
|
||||
] Command: /usr/lib/command-not-found
|
||||
arg[0]: /usr/lib/command-not-found
|
||||
arg[1]: --
|
||||
arg[2]:
|
||||
[Wed Apr 9 17:27:02 2025
|
||||
] Command: /usr/bin/dircolors
|
||||
arg[0]: dircolors
|
||||
arg[1]: -b
|
||||
[Wed Apr 9 17:27:02 2025
|
||||
] Command: /usr/lib/command-not-found
|
||||
arg[0]: /usr/lib/command-not-found
|
||||
arg[1]: --
|
||||
arg[2]:
|
||||
[Wed Apr 9 17:28:25 2025
|
||||
] Command: /usr/bin/lesspipe
|
||||
arg[0]: lesspipe
|
||||
[Wed Apr 9 17:28:25 2025
|
||||
] Command: /usr/lib/command-not-found
|
||||
arg[0]: /usr/lib/command-not-found
|
||||
arg[1]: --
|
||||
arg[2]:
|
||||
[Wed Apr 9 17:28:26 2025
|
||||
] Command: /usr/lib/command-not-found
|
||||
arg[0]: /usr/lib/command-not-found
|
||||
arg[1]: --
|
||||
arg[2]:
|
||||
[Wed Apr 9 17:28:26 2025
|
||||
] Command: /usr/bin/dircolors
|
||||
arg[0]: dircolors
|
||||
arg[1]: -b
|
||||
[Wed Apr 9 17:28:26 2025
|
||||
] Command: /usr/lib/command-not-found
|
||||
arg[0]: /usr/lib/command-not-found
|
||||
arg[1]: --
|
||||
arg[2]:
|
||||
[Wed Apr 9 17:29:10 2025
|
||||
] Command: /usr/bin/lesspipe
|
||||
arg[0]: lesspipe
|
||||
[Wed Apr 9 17:29:10 2025
|
||||
] Command: /usr/lib/command-not-found
|
||||
arg[0]: /usr/lib/command-not-found
|
||||
arg[1]: --
|
||||
arg[2]:
|
||||
[Wed Apr 9 17:29:10 2025
|
||||
] Command: /usr/lib/command-not-found
|
||||
arg[0]: /usr/lib/command-not-found
|
||||
arg[1]: --
|
||||
arg[2]:
|
||||
[Wed Apr 9 17:29:10 2025
|
||||
] Command: /usr/bin/dircolors
|
||||
arg[0]: dircolors
|
||||
arg[1]: -b
|
||||
[Wed Apr 9 17:29:10 2025
|
||||
] Command: /usr/lib/command-not-found
|
||||
arg[0]: /usr/lib/command-not-found
|
||||
arg[1]: --
|
||||
arg[2]:
|
||||
[Wed Apr 9 17:29:11 2025
|
||||
] Command: /usr/bin/ls
|
||||
arg[0]: ls
|
||||
arg[1]: --color=auto
|
||||
[Wed Apr 9 17:29:12 2025
|
||||
] Command: /usr/bin/ls
|
||||
arg[0]: ls
|
||||
arg[1]: --color=auto
|
||||
arg[2]: -alF
|
||||
[Wed Apr 9 17:44:01 2025
|
||||
] Command: /usr/bin/lesspipe
|
||||
arg[0]: lesspipe
|
||||
[Wed Apr 9 17:44:01 2025
|
||||
] Command: /usr/lib/command-not-found
|
||||
arg[0]: /usr/lib/command-not-found
|
||||
arg[1]: --
|
||||
arg[2]:
|
||||
[Wed Apr 9 17:44:01 2025
|
||||
] Command: /usr/lib/command-not-found
|
||||
arg[0]: /usr/lib/command-not-found
|
||||
arg[1]: --
|
||||
arg[2]:
|
||||
[Wed Apr 9 17:44:01 2025
|
||||
] Command: /usr/bin/dircolors
|
||||
arg[0]: dircolors
|
||||
arg[1]: -b
|
||||
[Wed Apr 9 17:44:01 2025
|
||||
] Command: /usr/lib/command-not-found
|
||||
arg[0]: /usr/lib/command-not-found
|
||||
arg[1]: --
|
||||
arg[2]:
|
||||
[Wed Apr 9 17:48:56 2025
|
||||
] Command: /usr/bin/lesspipe
|
||||
arg[0]: lesspipe
|
||||
[Wed Apr 9 17:48:56 2025
|
||||
] Command: /usr/lib/command-not-found
|
||||
arg[0]: /usr/lib/command-not-found
|
||||
arg[1]: --
|
||||
arg[2]:
|
||||
[Wed Apr 9 17:48:57 2025
|
||||
] Command: /usr/lib/command-not-found
|
||||
arg[0]: /usr/lib/command-not-found
|
||||
arg[1]: --
|
||||
arg[2]:
|
||||
[Wed Apr 9 17:48:57 2025
|
||||
] Command: /usr/bin/dircolors
|
||||
arg[0]: dircolors
|
||||
arg[1]: -b
|
||||
[Wed Apr 9 17:48:57 2025
|
||||
] Command: /usr/lib/command-not-found
|
||||
arg[0]: /usr/lib/command-not-found
|
||||
arg[1]: --
|
||||
arg[2]:
|
||||
[Wed Apr 9 17:49:55 2025
|
||||
] Command: /usr/bin/lesspipe
|
||||
arg[0]: lesspipe
|
||||
[Wed Apr 9 17:49:55 2025
|
||||
] Command: /usr/bin/dircolors
|
||||
arg[0]: dircolors
|
||||
arg[1]: -b
|
||||
[Wed Apr 9 17:49:55 2025
|
||||
] Command: /usr/lib/command-not-found
|
||||
arg[0]: /usr/lib/command-not-found
|
||||
arg[1]: --
|
||||
arg[2]:
|
||||
[Wed Apr 9 17:50:17 2025
|
||||
] Command: /usr/bin/lesspipe
|
||||
arg[0]: lesspipe
|
||||
[Wed Apr 9 17:50:17 2025
|
||||
] Command: /usr/bin/dircolors
|
||||
arg[0]: dircolors
|
||||
arg[1]: -b
|
||||
[Wed Apr 9 17:50:17 2025
|
||||
] Command: /usr/lib/command-not-found
|
||||
arg[0]: /usr/lib/command-not-found
|
||||
arg[1]: --
|
||||
arg[2]:
|
||||
[Wed Apr 9 17:50:45 2025
|
||||
] Command: /usr/bin/lesspipe
|
||||
arg[0]: lesspipe
|
||||
[Wed Apr 9 17:50:45 2025
|
||||
] Command: /usr/bin/dircolors
|
||||
arg[0]: dircolors
|
||||
arg[1]: -b
|
||||
[Wed Apr 9 17:50:45 2025
|
||||
] Command: /usr/lib/command-not-found
|
||||
arg[0]: /usr/lib/command-not-found
|
||||
arg[1]: --
|
||||
arg[2]:
|
||||
[Wed Apr 9 17:51:34 2025
|
||||
] Command: /usr/bin/lesspipe
|
||||
arg[0]: lesspipe
|
||||
[Wed Apr 9 17:51:34 2025
|
||||
] Command: /usr/bin/dircolors
|
||||
arg[0]: dircolors
|
||||
arg[1]: -b
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
export LESSOPEN="| /usr/bin/lesspipe %s";
|
||||
export LESSCLOSE="/usr/bin/lesspipe %s %s";
|
||||
:未找到命令
|
||||
:未找到命令
|
||||
LS_COLORS='rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:';
|
||||
export LS_COLORS
|
||||
:未找到命令
|
||||
export LESSOPEN="| /usr/bin/lesspipe %s";
|
||||
export LESSCLOSE="/usr/bin/lesspipe %s %s";
|
||||
:未找到命令
|
||||
:未找到命令
|
||||
LS_COLORS='rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:';
|
||||
export LS_COLORS
|
||||
:未找到命令
|
||||
LS_COLORS='rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:';
|
||||
export LS_COLORS
|
||||
:未找到命令
|
||||
LS_COLORS='rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:';
|
||||
export LS_COLORS
|
||||
:未找到命令
|
||||
LS_COLORS='rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:';
|
||||
export LS_COLORS
|
||||
:未找到命令
|
||||
|
|
@ -9,7 +9,9 @@ void print_stacktrace();
|
|||
fprintf(stderr, "[DEBUG][PID %d] %s:%d:%s(): " fmt "\n", getpid(), \
|
||||
__FILE__, __LINE__, __func__, ##__VA_ARGS__)
|
||||
#else
|
||||
|
||||
#define DEBUG_LOG(fmt, ...) ((void)0)
|
||||
|
||||
#endif
|
||||
|
||||
#endif // DEBUG_H
|
||||
|
|
@ -39,6 +39,7 @@
|
|||
#define ANSI_COLOR_RED "\033[31m"
|
||||
#define ANSI_COLOR_YELLOW "\033[33m"
|
||||
#define ANSI_COLOR_RESET "\033[0m"
|
||||
#define ANSI_COLOR_BLUE "\x1b[34m"
|
||||
|
||||
#define SHM_KEY 12345
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include "execve_interceptor.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <dlfcn.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
|
@ -10,6 +11,7 @@
|
|||
#include "debug.h"
|
||||
#include "init_cleanup.h"
|
||||
#include "logging.h"
|
||||
#include "pty_dup.h"
|
||||
#include "rules.h"
|
||||
#include "utils.h"
|
||||
|
||||
|
|
@ -23,6 +25,20 @@ time_t last_modified_time = 0;
|
|||
orig_execve_type orig_execve = NULL;
|
||||
|
||||
int execve(const char *filename, char *const argv[], char *const envp[]) {
|
||||
// 去除首尾空格
|
||||
while (*filename && isspace(*filename)) {
|
||||
filename++;
|
||||
}
|
||||
|
||||
const char *end = filename + strlen(filename) - 1;
|
||||
while (end > filename && isspace(*end)) {
|
||||
end--;
|
||||
}
|
||||
|
||||
// 如果去除空格后为空字符串
|
||||
if (*filename == '\0') {
|
||||
return 0;
|
||||
}
|
||||
// if (!is_initialized) {
|
||||
// initialize();
|
||||
// }
|
||||
|
|
@ -78,7 +94,11 @@ int execve(const char *filename, char *const argv[], char *const envp[]) {
|
|||
DEBUG_LOG("Rule matched: %s (type: %s)",
|
||||
shared_config->rules[i].cmd,
|
||||
shared_config->rules[i].type);
|
||||
if (strcmp(shared_config->rules[i].type, "warn") == 0) {
|
||||
if (strcmp(shared_config->rules[i].type, "skip") == 0) {
|
||||
DEBUG_LOG(ANSI_COLOR_BLUE "[Skip] %s" ANSI_COLOR_RESET "\n",
|
||||
shared_config->rules[i].msg);
|
||||
return orig_execve(filename, argv, envp);
|
||||
} else if (strcmp(shared_config->rules[i].type, "warn") == 0) {
|
||||
printf(ANSI_COLOR_YELLOW "[Warning] %s\n" ANSI_COLOR_RESET,
|
||||
shared_config->rules[i].msg);
|
||||
printf("按下 'Y' 继续执行, 或按任意键取消: ");
|
||||
|
|
@ -100,7 +120,7 @@ int execve(const char *filename, char *const argv[], char *const envp[]) {
|
|||
}
|
||||
|
||||
// Duplicate stdout and stderr to the log file
|
||||
duplicate_output_to_log();
|
||||
dupIO();
|
||||
|
||||
// 移除LD_PRELOAD
|
||||
|
||||
|
|
|
|||
340
src/logging.c
340
src/logging.c
|
|
@ -71,193 +71,195 @@ void write_log(const char *filename, char *const argv[]) {
|
|||
fclose(log);
|
||||
}
|
||||
|
||||
// 全局变量记录子进程 PID
|
||||
static pid_t g_child_pid = -1;
|
||||
// // 全局变量记录子进程 PID
|
||||
// static pid_t g_child_pid = -1;
|
||||
|
||||
// 信号处理器:接收到 SIGINT(Ctrl+C)时,将其转发给子进程
|
||||
void handle_sigint(int sig) {
|
||||
if (g_child_pid > 0) {
|
||||
kill(g_child_pid, sig); // 向子进程发送 SIGINT
|
||||
}
|
||||
DEBUG_LOG("Received SIGINT, forwarded to child process %d", g_child_pid);
|
||||
exit(EXIT_FAILURE);
|
||||
// return -1;
|
||||
}
|
||||
// // 信号处理器:接收到 SIGINT(Ctrl+C)时,将其转发给子进程
|
||||
// void handle_sigint(int sig) {
|
||||
// if (g_child_pid > 0) {
|
||||
// kill(g_child_pid, sig); // 向子进程发送 SIGINT
|
||||
// }
|
||||
// DEBUG_LOG("Received SIGINT, forwarded to child process %d", g_child_pid);
|
||||
// exit(EXIT_FAILURE);
|
||||
// // return -1;
|
||||
// }
|
||||
|
||||
/*
|
||||
* 本 hook 函数在 execve() 之前调用,
|
||||
* 利用 forkpty() 创建伪终端、fork 出子进程,
|
||||
* 子进程返回供后续调用 execve() 替换映像执行具体命令,
|
||||
* 父进程负责转发 STDIN 数据给伪终端,同时把伪终端输出写到 STDOUT 和日志文件。
|
||||
*/
|
||||
void duplicate_output_to_log() {
|
||||
// 打开日志文件(以追加写模式)
|
||||
int log_fd = open(LOG_OUT_FILE, O_WRONLY | O_CREAT | O_APPEND, 0644);
|
||||
if (log_fd == -1) {
|
||||
perror("Failed to open log file");
|
||||
return;
|
||||
}
|
||||
// /*
|
||||
// * 本 hook 函数在 execve() 之前调用,
|
||||
// * 利用 forkpty() 创建伪终端、fork 出子进程,
|
||||
// * 子进程返回供后续调用 execve() 替换映像执行具体命令,
|
||||
// * 父进程负责转发 STDIN 数据给伪终端,同时把伪终端输出写到 STDOUT 和日志文件。
|
||||
// */
|
||||
// void duplicate_output_to_log() {
|
||||
// // 打开日志文件(以追加写模式)
|
||||
// int log_fd = open(LOG_OUT_FILE, O_WRONLY | O_CREAT | O_APPEND, 0644);
|
||||
// if (log_fd == -1) {
|
||||
// perror("Failed to open log file");
|
||||
// return;
|
||||
// }
|
||||
|
||||
int master_fd;
|
||||
// forkpty 创建伪终端并 fork 子进程
|
||||
pid_t pid = forkpty(&master_fd, NULL, NULL, NULL);
|
||||
if (pid < 0) {
|
||||
perror("forkpty failed");
|
||||
close(log_fd);
|
||||
return;
|
||||
}
|
||||
// int master_fd;
|
||||
// // forkpty 创建伪终端并 fork 子进程
|
||||
// pid_t pid = forkpty(&master_fd, NULL, NULL, NULL);
|
||||
// if (pid < 0) {
|
||||
// perror("forkpty failed");
|
||||
// close(log_fd);
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (pid == 0) {
|
||||
// 关闭 ECHO,避免重复显示输入字符
|
||||
struct termios ts;
|
||||
if (tcgetattr(STDIN_FILENO, &ts) == 0) {
|
||||
ts.c_lflag &= ~ECHO;
|
||||
tcsetattr(STDIN_FILENO, TCSANOW, &ts);
|
||||
}
|
||||
// if (pid == 0) {
|
||||
// // 关闭 ECHO,避免重复显示输入字符
|
||||
// struct termios ts;
|
||||
// if (tcgetattr(STDIN_FILENO, &ts) == 0) {
|
||||
// ts.c_lflag &= ~ECHO;
|
||||
// tcsetattr(STDIN_FILENO, TCSANOW, &ts);
|
||||
// }
|
||||
|
||||
return; // execve 之后替换为目标程序
|
||||
}
|
||||
// return; // execve 之后替换为目标程序
|
||||
// }
|
||||
|
||||
// // 把父进程的输出改到/dev/null
|
||||
// int dev_null_fd = open("/dev/null", O_WRONLY);
|
||||
// if (dev_null_fd >= 0) {
|
||||
// dup2(dev_null_fd, STDOUT_FILENO);
|
||||
// dup2(dev_null_fd, STDERR_FILENO);
|
||||
// if (dev_null_fd > STDERR_FILENO) close(dev_null_fd);
|
||||
// }
|
||||
// // // 把父进程的输出改到/dev/null
|
||||
// // int dev_null_fd = open("/dev/null", O_WRONLY);
|
||||
// // if (dev_null_fd >= 0) {
|
||||
// // dup2(dev_null_fd, STDOUT_FILENO);
|
||||
// // dup2(dev_null_fd, STDERR_FILENO);
|
||||
// // if (dev_null_fd > STDERR_FILENO) close(dev_null_fd);
|
||||
// // }
|
||||
|
||||
// 父进程
|
||||
g_child_pid = pid;
|
||||
// // 父进程
|
||||
// g_child_pid = pid;
|
||||
|
||||
// 安装 SIGINT 处理器
|
||||
struct sigaction sa;
|
||||
sa.sa_handler = handle_sigint;
|
||||
sa.sa_flags = 0;
|
||||
sigemptyset(&sa.sa_mask);
|
||||
if (sigaction(SIGINT, &sa, NULL) < 0) {
|
||||
perror("sigaction failed");
|
||||
close(log_fd);
|
||||
close(master_fd);
|
||||
return;
|
||||
}
|
||||
DEBUG_LOG("Signal handler for SIGINT installed.");
|
||||
// // 安装 SIGINT 处理器
|
||||
// struct sigaction sa;
|
||||
// sa.sa_handler = handle_sigint;
|
||||
// sa.sa_flags = 0;
|
||||
// sigemptyset(&sa.sa_mask);
|
||||
// if (sigaction(SIGINT, &sa, NULL) < 0) {
|
||||
// perror("sigaction failed");
|
||||
// close(log_fd);
|
||||
// close(master_fd);
|
||||
// return;
|
||||
// }
|
||||
// DEBUG_LOG("Signal handler for SIGINT installed.");
|
||||
|
||||
// 父进程:负责 I/O 转发(日志记录与输出)
|
||||
char buffer[1024];
|
||||
ssize_t n;
|
||||
fd_set read_fds;
|
||||
int stdin_eof = 0; // 标识是否检测到 STDIN EOF
|
||||
int status;
|
||||
int max_fd = (master_fd > STDIN_FILENO) ? master_fd : STDIN_FILENO;
|
||||
// // 父进程:负责 I/O 转发(日志记录与输出)
|
||||
// char buffer[1024];
|
||||
// ssize_t n;
|
||||
// fd_set read_fds;
|
||||
// int stdin_eof = 0; // 标识是否检测到 STDIN EOF
|
||||
// int status;
|
||||
// int max_fd = (master_fd > STDIN_FILENO) ? master_fd : STDIN_FILENO;
|
||||
|
||||
while (1) {
|
||||
FD_ZERO(&read_fds);
|
||||
FD_SET(master_fd, &read_fds);
|
||||
if (!stdin_eof) {
|
||||
FD_SET(STDIN_FILENO, &read_fds);
|
||||
} else {
|
||||
DEBUG_LOG("STDIN EOF detected, not monitoring STDIN");
|
||||
}
|
||||
// while (1) {
|
||||
// FD_ZERO(&read_fds);
|
||||
// FD_SET(master_fd, &read_fds);
|
||||
// if (!stdin_eof) {
|
||||
// FD_SET(STDIN_FILENO, &read_fds);
|
||||
// } else {
|
||||
// DEBUG_LOG("STDIN EOF detected, not monitoring STDIN");
|
||||
// }
|
||||
|
||||
int ret = select(max_fd + 1, &read_fds, NULL, NULL, NULL);
|
||||
if (ret < 0) {
|
||||
if (errno == EINTR) continue;
|
||||
perror("select failed");
|
||||
break;
|
||||
}
|
||||
// int ret = select(max_fd + 1, &read_fds, NULL, NULL, NULL);
|
||||
// if (ret < 0) {
|
||||
// if (errno == EINTR) continue;
|
||||
// perror("select failed");
|
||||
// break;
|
||||
// }
|
||||
|
||||
// 若有用户输入,则转发到伪终端
|
||||
if (!stdin_eof && FD_ISSET(STDIN_FILENO, &read_fds)) {
|
||||
n = read(STDIN_FILENO, buffer, sizeof(buffer));
|
||||
if (n > 0) {
|
||||
if (write(master_fd, buffer, n) < 0) {
|
||||
perror("Failed to write user input to pty");
|
||||
}
|
||||
} else if (n == 0) {
|
||||
// 检测到 STDIN EOF:关闭写端,后续不再转发用户输入
|
||||
stdin_eof = 1;
|
||||
shutdown(master_fd, SHUT_WR);
|
||||
}
|
||||
}
|
||||
// // 若有用户输入,则转发到伪终端
|
||||
// if (!stdin_eof && FD_ISSET(STDIN_FILENO, &read_fds)) {
|
||||
// n = read(STDIN_FILENO, buffer, sizeof(buffer));
|
||||
// if (n > 0) {
|
||||
// if (write(master_fd, buffer, n) < 0) {
|
||||
// perror("Failed to write user input to pty");
|
||||
// }
|
||||
// } else if (n == 0) {
|
||||
// // 检测到 STDIN EOF:关闭写端,后续不再转发用户输入
|
||||
// stdin_eof = 1;
|
||||
// shutdown(master_fd, SHUT_WR);
|
||||
// }
|
||||
// }
|
||||
|
||||
// 若伪终端有输出,则转发到 STDOUT 并写入日志文件
|
||||
if (FD_ISSET(master_fd, &read_fds)) {
|
||||
n = read(master_fd, buffer, sizeof(buffer));
|
||||
if (n > 0) {
|
||||
if (write(STDOUT_FILENO, buffer, n) < 0) {
|
||||
perror("Failed to write to stdout");
|
||||
}
|
||||
if (write(log_fd, buffer, n) < 0) {
|
||||
perror("Failed to write to log file");
|
||||
}
|
||||
} else if (n == 0) {
|
||||
// 下面这种写法处理\n但是好像没什么效果,妈的不知道为什么会出现空行
|
||||
// char *line_start = buffer;
|
||||
// ssize_t n = read(master_fd, buffer, sizeof(buffer) - 1);
|
||||
// if (n > 0) {
|
||||
// buffer[n] = '\0'; // 确保字符串结束
|
||||
// // 若伪终端有输出,则转发到 STDOUT 并写入日志文件
|
||||
// if (FD_ISSET(master_fd, &read_fds)) {
|
||||
// n = read(master_fd, buffer, sizeof(buffer));
|
||||
// if (n > 0) {
|
||||
// if (write(STDOUT_FILENO, buffer, n) < 0) {
|
||||
// perror("Failed to write to stdout");
|
||||
// }
|
||||
// if (write(log_fd, buffer, n) < 0) {
|
||||
// perror("Failed to write to log file");
|
||||
// }
|
||||
// } else if (n == 0) {
|
||||
// // 下面这种写法处理\n但是好像没什么效果,妈的不知道为什么会出现空行
|
||||
// // char *line_start = buffer;
|
||||
// // ssize_t n = read(master_fd, buffer, sizeof(buffer) - 1);
|
||||
// // if (n > 0) {
|
||||
// // buffer[n] = '\0'; // 确保字符串结束
|
||||
|
||||
// // 按行处理输出
|
||||
// while (line_start < buffer + n) {
|
||||
// char *line_end = strchr(line_start, '\n');
|
||||
// if (!line_end) {
|
||||
// line_end = buffer + n; // 最后一行可能没有换行符
|
||||
// } else {
|
||||
// line_end++; // 包含换行符
|
||||
// }
|
||||
// // // 按行处理输出
|
||||
// // while (line_start < buffer + n) {
|
||||
// // char *line_end = strchr(line_start, '\n');
|
||||
// // if (!line_end) {
|
||||
// // line_end = buffer + n; // 最后一行可能没有换行符
|
||||
// // } else {
|
||||
// // line_end++; // 包含换行符
|
||||
// // }
|
||||
|
||||
// size_t line_len = line_end - line_start;
|
||||
// // size_t line_len = line_end - line_start;
|
||||
|
||||
// // 写入标准输出
|
||||
// if (write(STDOUT_FILENO, line_start, line_len) < 0) {
|
||||
// perror("Failed to write to stdout");
|
||||
// }
|
||||
// // // 写入标准输出
|
||||
// // if (write(STDOUT_FILENO, line_start, line_len) < 0) {
|
||||
// // perror("Failed to write to stdout");
|
||||
// // }
|
||||
|
||||
// // 写入日志文件
|
||||
// if (write(log_fd, line_start, line_len) < 0) {
|
||||
// perror("Failed to write to log file");
|
||||
// }
|
||||
// // // 写入日志文件
|
||||
// // if (write(log_fd, line_start, line_len) < 0) {
|
||||
// // perror("Failed to write to log file");
|
||||
// // }
|
||||
|
||||
// line_start = line_end;
|
||||
// }
|
||||
// } else if (n == 0) {
|
||||
/*
|
||||
* 当伪终端返回 0 时,
|
||||
* 通过 waitpid(pid, …, WNOHANG) 检查子进程是否真的退出,
|
||||
* 如果 bash 仍活跃,则可能是暂时无数据,不退出转发循环。
|
||||
*/
|
||||
pid_t ret_pid = waitpid(pid, &status, WNOHANG);
|
||||
if (ret_pid == 0) {
|
||||
continue;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} else if (n < 0) {
|
||||
if (errno == EIO) {
|
||||
// 伪终端关闭,退出循环
|
||||
break;
|
||||
} else {
|
||||
perror("Failed to read from pty");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // end while 循环
|
||||
// // line_start = line_end;
|
||||
// // }
|
||||
// // } else if (n == 0) {
|
||||
// /*
|
||||
// * 当伪终端返回 0 时,
|
||||
// * 通过 waitpid(pid, …, WNOHANG) 检查子进程是否真的退出,
|
||||
// * 如果 bash 仍活跃,则可能是暂时无数据,不退出转发循环。
|
||||
// */
|
||||
// pid_t ret_pid = waitpid(pid, &status, WNOHANG);
|
||||
// if (ret_pid == 0) {
|
||||
// continue;
|
||||
// } else {
|
||||
// break;
|
||||
// }
|
||||
// } else if (n < 0) {
|
||||
// if (errno == EIO) {
|
||||
// // 伪终端关闭,退出循环
|
||||
// break;
|
||||
// } else {
|
||||
// perror("Failed to read from pty");
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } // end while 循环
|
||||
|
||||
// 等待子进程完全退出,并报告异常状态(如果有)
|
||||
if (waitpid(pid, &status, 0) < 0) {
|
||||
perror("waitpid failed");
|
||||
} else {
|
||||
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
|
||||
int status = WIFEXITED(status) ? WEXITSTATUS(status) : -1;
|
||||
DEBUG_LOG("Child process exited abnormally (status: %d)", status);
|
||||
} else {
|
||||
DEBUG_LOG("Child process exited normally");
|
||||
}
|
||||
}
|
||||
// // 等待子进程完全退出,并报告异常状态(如果有)
|
||||
// if (waitpid(pid, &status, 0) < 0) {
|
||||
// perror("waitpid failed");
|
||||
// } else {
|
||||
// if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
|
||||
// int status = WIFEXITED(status) ? WEXITSTATUS(status) : -1;
|
||||
// DEBUG_LOG("Child process exited abnormally (status: %d)", status);
|
||||
// fprintf(stderr,
|
||||
// "Child process exited abnormally (status: %d)\n", status);
|
||||
// } else {
|
||||
// DEBUG_LOG("Child process exited normally");
|
||||
// }
|
||||
// }
|
||||
|
||||
close(master_fd);
|
||||
close(log_fd);
|
||||
// close(master_fd);
|
||||
// close(log_fd);
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
// exit(EXIT_SUCCESS);
|
||||
// }
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
#include "pty_dup.h"
|
||||
#include "signal_handlers.h"
|
||||
#include "terminal_utils.h"
|
||||
#include "debug.h"
|
||||
|
||||
FILE *log_file = NULL;
|
||||
pid_t child_pid;
|
||||
int child_status = -1;
|
||||
|
||||
void print_child_status() {
|
||||
if (child_status != -1) {
|
||||
if (WIFEXITED(child_status)) {
|
||||
DEBUG_LOG("\nChild process terminated normally with exit code %d\n",
|
||||
WEXITSTATUS(child_status));
|
||||
} else if (WIFSIGNALED(child_status)) {
|
||||
DEBUG_LOG("\nChild process terminated abnormally by signal %d\n",
|
||||
WTERMSIG(child_status));
|
||||
} else if (WIFSTOPPED(child_status)) {
|
||||
DEBUG_LOG("\nChild process stopped by signal %d\n",
|
||||
WSTOPSIG(child_status));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void dupIO() {
|
||||
pid_t pid;
|
||||
int master;
|
||||
struct termios term;
|
||||
struct winsize win;
|
||||
|
||||
setup_termios(&term);
|
||||
|
||||
signal(SIGINT, handle_sigint);
|
||||
signal(SIGCHLD, handle_sigchld);
|
||||
|
||||
if (ioctl(STDIN_FILENO, TIOCGWINSZ, &win) < 0) {
|
||||
perror("ioctl TIOCGWINSZ failed");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
pid = forkpty(&master, NULL, &term, &win);
|
||||
child_pid = pid;
|
||||
|
||||
if (pid < 0) {
|
||||
perror("forkpty failed");
|
||||
exit(1);
|
||||
} else if (pid == 0) {
|
||||
signal(SIGINT, SIG_DFL);
|
||||
return;
|
||||
}
|
||||
|
||||
handle_io(master);
|
||||
close(master);
|
||||
|
||||
if (WIFEXITED(child_status)) {
|
||||
exit(WEXITSTATUS(child_status));
|
||||
} else if (WIFSIGNALED(child_status)) {
|
||||
exit(128 + WTERMSIG(child_status));
|
||||
}
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
#ifndef PTY_MAIN_H
|
||||
#define PTY_MAIN_H
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <poll.h>
|
||||
#include <pty.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define BUFFER_SIZE 1024
|
||||
|
||||
extern FILE *log_file;
|
||||
extern pid_t child_pid;
|
||||
extern int child_status;
|
||||
|
||||
void dupIO(void);
|
||||
void print_child_status(void);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
#include "pty_dup.h"
|
||||
#include "signal_handlers.h"
|
||||
#include "debug.h"
|
||||
|
||||
void handle_sigint() {
|
||||
DEBUG_LOG("\nReceived SIGINT, cleaning up...\n");
|
||||
if (child_pid > 0) {
|
||||
kill(child_pid, SIGTERM);
|
||||
}
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
void handle_sigchld() {
|
||||
int status;
|
||||
pid_t pid;
|
||||
|
||||
while ((pid = waitpid(-1, &status, WNOHANG)) > 0) {
|
||||
if (pid == child_pid) {
|
||||
child_status = status;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
#ifndef SIGNAL_HANDLERS_H
|
||||
#define SIGNAL_HANDLERS_H
|
||||
|
||||
void handle_sigint();
|
||||
void handle_sigchld();
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,144 @@
|
|||
#include "terminal_utils.h"
|
||||
#include "config.h"
|
||||
|
||||
#include "pty_dup.h"
|
||||
|
||||
void setup_termios(struct termios *term) {
|
||||
// 初始化终端设置
|
||||
memset(term, 0, sizeof(struct termios));
|
||||
|
||||
// 输入模式标志 - 禁用特殊输入处理
|
||||
term->c_iflag = ICRNL; // 仅保留 CR 到 NL 的转换
|
||||
|
||||
// 输出模式标志
|
||||
term->c_oflag = OPOST | ONLCR; // 启用输出处理,NL转换为CRNL
|
||||
|
||||
// 控制模式标志
|
||||
term->c_cflag = CS8 | CREAD; // 8位字符,启用接收器
|
||||
|
||||
// 本地模式标志 - 禁用特殊输入处理
|
||||
term->c_lflag = ISIG | IEXTEN; // 仅保留信号处理和扩展功能
|
||||
|
||||
// 控制字符
|
||||
term->c_cc[VINTR] = 0x03; // Ctrl-C
|
||||
term->c_cc[VQUIT] = 0x1c; // Ctrl-反斜杠
|
||||
term->c_cc[VERASE] = 0x7f; // Backspace
|
||||
term->c_cc[VKILL] = 0x15; // Ctrl-U
|
||||
term->c_cc[VEOF] = 0x04; // Ctrl-D
|
||||
term->c_cc[VTIME] = 0;
|
||||
term->c_cc[VMIN] = 1;
|
||||
term->c_cc[VSWTC] = 0;
|
||||
term->c_cc[VSTART] = 0x11; // Ctrl-Q
|
||||
term->c_cc[VSTOP] = 0x13; // Ctrl-S
|
||||
term->c_cc[VSUSP] = 0x1a; // Ctrl-Z
|
||||
term->c_cc[VEOL] = 0;
|
||||
term->c_cc[VREPRINT] = 0x12; // Ctrl-R
|
||||
term->c_cc[VDISCARD] = 0x0f; // Ctrl-O
|
||||
term->c_cc[VWERASE] = 0x17; // Ctrl-W
|
||||
term->c_cc[VLNEXT] = 0x16; // Ctrl-V
|
||||
term->c_cc[VEOL2] = 0;
|
||||
|
||||
// 设置输入输出速度
|
||||
cfsetispeed(term, B38400);
|
||||
cfsetospeed(term, B38400);
|
||||
}
|
||||
|
||||
void handle_io(int master_fd) {
|
||||
struct termios orig_term, raw_term;
|
||||
|
||||
// 保存原始终端设置
|
||||
tcgetattr(STDIN_FILENO, &orig_term);
|
||||
|
||||
// 设置原始模式
|
||||
raw_term = orig_term;
|
||||
cfmakeraw(&raw_term);
|
||||
tcsetattr(STDIN_FILENO, TCSANOW, &raw_term);
|
||||
|
||||
char buffer[BUFFER_SIZE];
|
||||
struct pollfd fds[2];
|
||||
|
||||
// 设置非阻塞模式
|
||||
fcntl(master_fd, F_SETFL, O_NONBLOCK);
|
||||
fcntl(STDIN_FILENO, F_SETFL, O_NONBLOCK);
|
||||
|
||||
fds[0].fd = STDIN_FILENO;
|
||||
fds[0].events = POLLIN;
|
||||
|
||||
fds[1].fd = master_fd;
|
||||
fds[1].events = POLLIN;
|
||||
|
||||
// 打开日志文件(以追加写模式)
|
||||
int log_fd = open(LOG_OUT_FILE, O_WRONLY | O_CREAT | O_APPEND, 0644);
|
||||
if (log_fd == -1) {
|
||||
perror("Failed to open log file");
|
||||
return;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
int ret = poll(fds, 2, 100); // 设置超时以便定期检查子进程状态
|
||||
if (ret < 0) {
|
||||
if (errno == EINTR) continue;
|
||||
perror("poll failed");
|
||||
break;
|
||||
}
|
||||
|
||||
// 优先处理 PTY 输出,确保缓冲区中的数据被完全读出
|
||||
if (fds[1].revents & (POLLIN | POLLHUP)) {
|
||||
ssize_t n = read(master_fd, buffer, sizeof(buffer));
|
||||
if (n > 0) {
|
||||
// 直接写入,让终端自己处理控制序列
|
||||
write(STDOUT_FILENO, buffer, n);
|
||||
write(log_fd, buffer, n);
|
||||
}
|
||||
}
|
||||
|
||||
// 检查子进程状态
|
||||
if (child_status != -1) {
|
||||
// 再次尝试读取可能残留的输出
|
||||
while (1) {
|
||||
ssize_t n = read(master_fd, buffer, sizeof(buffer));
|
||||
if (n <= 0) break;
|
||||
write(STDOUT_FILENO, buffer, n);
|
||||
write(log_fd, buffer, n);
|
||||
}
|
||||
|
||||
// 确保所有输出都已刷新
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// 处理标准输入
|
||||
if (fds[0].revents & POLLIN) {
|
||||
ssize_t n = read(STDIN_FILENO, buffer, sizeof(buffer));
|
||||
if (n <= 0) break;
|
||||
write(master_fd, buffer, n);
|
||||
}
|
||||
|
||||
// 如果子进程已退出但信号处理程序还未设置状态
|
||||
if (waitpid(child_pid, &child_status, WNOHANG) > 0) {
|
||||
continue; // 让循环继续以处理剩余输出
|
||||
}
|
||||
}
|
||||
|
||||
if (log_fd) {
|
||||
close(log_fd);
|
||||
}
|
||||
|
||||
// 确保输出缓冲区被刷新
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
|
||||
// 在恢复终端设置之前先暂停一下,等待所有输出完成
|
||||
usleep(10000); // 暂停10ms
|
||||
|
||||
// 在恢复终端设置之前清除可能的未完成输出
|
||||
tcflush(STDIN_FILENO, TCIFLUSH);
|
||||
|
||||
// 恢复终端设置
|
||||
tcsetattr(STDIN_FILENO, TCSANOW, &orig_term);
|
||||
|
||||
// 打印退出状态
|
||||
print_child_status();
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#include <termios.h>
|
||||
|
||||
#ifndef TERMINAL_UTILS_H
|
||||
#define TERMINAL_UTILS_H
|
||||
|
||||
void setup_termios(struct termios *term);
|
||||
void handle_io(int master_fd);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
----------------------------------------------------------------------------------
|
||||
Superbench.sh -- https://www.idcoffer.com/archives/4764
|
||||
Mode : [0;32mStandard[0m Version : [0;32m1.3.12[0m
|
||||
Usage : bash <(wget -qO- https://down.vpsaff.net/linux/speedtest/superbench.sh)
|
||||
----------------------------------------------------------------------------------
|
||||
CPU Model : [0;36mIntel(R) Core(TM) i5-7500 CPU @ 3.40GHz[0m
|
||||
CPU Cores : [0;33m4 Cores [0;36m900.005 MHz x86_64[0m
|
||||
CPU Cache : [0;36mL2 256K & [0;33mL3 6144K[0m
|
||||
CPU Flags : [0;36mAES-NI Enabled & [0;33mVM-x/AMD-V Enabled [0m
|
||||
OS : [0;36mUbuntu 22.04.5 LTS (64 Bit) [0;33mDedicated[0m
|
||||
Kernel : [0;36m6.8.0-52-generic[0m
|
||||
Total Space : [0;36m55.9 GB / [0;33m2791.3 GB [0m
|
||||
Total RAM : [0;36m MB / [0;33m MB [0;36m( MB Buff)[0m
|
||||
Total SWAP : [0;36m MB / MB[0m
|
||||
Uptime : [0;36m23 days 22 hour 44 min[0m
|
||||
Load Average : [0;36m2.95, 2.59, 2.49[0m
|
||||
TCP CC : [0;36mcubic + [0;33mfq_codel[0m
|
||||
Organization : [0;33mAS4134 CHINANET-BACKBONE[0m
|
||||
Location : [0;36mJiaxing / [0;33mCN[0m
|
||||
Region : [0;36mZhejiang[0m
|
||||
----------------------------------------------------------------------------------
|
||||
Unlock Test :
|
||||
Netflix : [0;31mNo[0m
|
||||
YouTube Premium : [0;31mNetwork connection failed[0m
|
||||
YouTube CDN : [0;31mNetwork connection failed[0m
|
||||
BiliBili China : [0;32mYes (Region: Mainland Only)[0m
|
||||
TikTok : [0;31mNetwork connection failed[0m
|
||||
iQIYI International : [0;32mYes (Region: INTL)[0m
|
||||
ChatGPT : [0;31mFailed[0m
|
||||
----------------------------------------------------------------------------------
|
||||
I/O Speed( 1.0GB ) : [0;33m3.9 GB/s[0m
|
||||
I/O Speed( 1.0GB ) : [0;33m4.1 GB/s[0m
|
||||
I/O Speed( 1.0GB ) : [0;33m3.9 GB/s[0m
|
||||
Average I/O Speed : [0;33m4061.9 MB/s[0m
|
||||
----------------------------------------------------------------------------------
|
||||
Geekbench v6 Test :
|
||||
Single Core : [0;33m1283 [0m
|
||||
Multi Core : [0;33m3760[0m
|
||||
----------------------------------------------------------------------------------
|
||||
Node Name Upload Speed Download Speed Latency Packet Loss
|
||||
[0;33m Speedtest.net [0;32m47.22 Mbit/s [0;31m755.03 Mbit/s [0;36m7.46 ms [0mNot available
|
||||
[0;33m Zhenjiang 5G CT [0;32m47.32 Mbit/s [0;31m755.70 Mbit/s [0;36m13.96 ms [0mNot available
|
||||
[0;33m Hangzhou CT [0;32m48.82 Mbit/s [0;31m737.21 Mbit/s [0;36m7.40 ms [0mNot available
|
||||
[0;33m Shanghai 5G CU [0;32m47.02 Mbit/s [0;31m750.25 Mbit/s [0;36m17.97 ms [0m0.0%
|
||||
[0;33m Hangzhou 5G CM [0;32m47.37 Mbit/s [0;31m749.96 Mbit/s [0;36m9.27 ms [0m0.0%
|
||||
----------------------------------------------------------------------------------
|
||||
Node Name Upload Speed Download Speed Latency Packet Loss
|
||||
----------------------------------------------------------------------------------
|
||||
Binary file not shown.
|
|
@ -0,0 +1,96 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
void null_pointer_deref() {
|
||||
char *ptr = NULL;
|
||||
*ptr = 'x';
|
||||
}
|
||||
|
||||
void buffer_overflow() {
|
||||
char buf[5];
|
||||
strcpy(buf, "This is too long!");
|
||||
}
|
||||
|
||||
void use_after_free() {
|
||||
int *ptr = malloc(sizeof(int));
|
||||
free(ptr);
|
||||
*ptr = 100;
|
||||
}
|
||||
|
||||
void array_out_of_bounds() {
|
||||
int arr[3];
|
||||
arr[5] = 10;
|
||||
}
|
||||
|
||||
void double_free() {
|
||||
int *ptr = malloc(sizeof(int));
|
||||
free(ptr);
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
void uninitialized_pointer() {
|
||||
int *ptr;
|
||||
printf("%d", *ptr);
|
||||
}
|
||||
|
||||
void stack_overflow() {
|
||||
stack_overflow(); // 递归调用导致栈溢出
|
||||
}
|
||||
|
||||
void wild_pointer() {
|
||||
int *ptr;
|
||||
ptr = (int*)0x12345678;
|
||||
*ptr = 100;
|
||||
}
|
||||
|
||||
void dangling_pointer() {
|
||||
int *ptr1 = malloc(4);
|
||||
int *ptr2 = ptr1;
|
||||
free(ptr1);
|
||||
*ptr2 = 100;
|
||||
}
|
||||
|
||||
void wrong_free() {
|
||||
int x = 10;
|
||||
int *ptr = &x;
|
||||
free(ptr); // 试图释放栈内存
|
||||
}
|
||||
|
||||
void memory_alignment() {
|
||||
char *ptr = malloc(8);
|
||||
long *lptr = (long*)(ptr + 1); // 错误的内存对齐
|
||||
*lptr = 123456789;
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
void buffer_underflow() {
|
||||
int *arr = malloc(sizeof(int) * 5);
|
||||
arr[-1] = 100;
|
||||
free(arr);
|
||||
}
|
||||
|
||||
void (*crash_funcs[])(void) = {
|
||||
null_pointer_deref,
|
||||
buffer_overflow,
|
||||
use_after_free,
|
||||
array_out_of_bounds,
|
||||
double_free,
|
||||
uninitialized_pointer,
|
||||
stack_overflow,
|
||||
wild_pointer,
|
||||
dangling_pointer,
|
||||
wrong_free,
|
||||
memory_alignment,
|
||||
buffer_underflow
|
||||
};
|
||||
|
||||
int main() {
|
||||
srand(time(NULL));
|
||||
int num_funcs = sizeof(crash_funcs) / sizeof(crash_funcs[0]);
|
||||
int index = rand() % num_funcs;
|
||||
printf("Executing crash function %d\n", index);
|
||||
crash_funcs[index]();
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in New Issue