welcome@113:~$ sudo -l Matching Defaults entries for welcome on 113: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin
User welcome may run the following commands on 113: (ALL) NOPASSWD: /opt/113.sh welcome@113:~$ ls -l /opt/113.sh -rwxr-xr-x 1 root root 280 Jan 14 08:35 /opt/113.sh
if [ "$#" -ne 3 ];then# 检查传入脚本的参数个数是否为3个 exit# 不是3个参数则直接退出,无任何输出 fi
if [ "$3" != "mazesec" ] # 检查第3个参数是否严格等于字符串"mazesec" then echo"\$3 must be mazesec"# 不等于则输出提示信息 exit# 退出脚本 else /bin/cp /usr/bin/mazesec $sandbox# 满足条件:将系统中的/usr/bin/mazesec复制到临时沙箱目录 exec_="$sandbox/mazesec"# 定义exec_变量,指向沙箱中的mazesec程序路径 fi
if [ "$1" = "exec_" ];then# 检查第1个参数是否严格等于字符串"exec_" exit# 等于则直接退出,禁止将$1设为exec_ fi