403Webshell
Server IP : 103.119.228.120  /  Your IP : 3.136.236.178
Web Server : Apache
System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User : nobody ( 99)
PHP Version : 5.6.40
Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime
MySQL : ON |  cURL : ON |  WGET : ON |  Perl : ON |  Python : ON |  Sudo : ON |  Pkexec : ON
Directory :  /bin/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /bin/linux-boot-prober
#!/bin/sh

# dash shell does not have "{varname}>&1" feature that bash shell has
# for auto-assignment of new filedescriptors.
# It is cumbersome to write the 'eval' to use our own variables in redirections.
# Therefore use fixed numbers.
export fd_result=3  # file descriptor for external results
export fd_logger=9  # file descriptor for input to logger

. /usr/share/os-prober/common.sh

set -e

newns "$@"
require_tmpdir
ERR="n"

tmpmnt=/var/lib/os-prober/mount
if [ ! -d "$tmpmnt" ]; then
	mkdir "$tmpmnt"
fi

mounted=
bootmnt=
bootsv=
bootuuid=

grep "^/dev/" /proc/mounts | parse_proc_mounts >"$OS_PROBER_TMP/mounted-map" || true

if [ -z "$1" ]; then
	ERR=y
elif [ "$1" = btrfs -a -z "$2" ]; then
	ERR=y
elif [ "$1" = btrfs -a -z "$3" ]; then
	ERR=y
elif [ "$1" = btrfs ]; then
	type=btrfs
	echo "$2" | grep -q "^UUID=" || ERR=y
	echo "$3" | grep -q "^subvol=" || ERR=y	
	export "$2"
	export "$3"
	partition=$(blkid | grep "$UUID" | cut -d ':' -f 1 | tr '\n' ' ' | cut -d ' ' -f 1)
	debug "btrfs: partition=$partition, UUID=$UUID, subvol=$subvol"
else
	partition="$1"
	type=other
fi

if [ "x$ERR" != xn ]; then
	echo "usage: linux-boot-prober partition" >&2
	echo "       linux-boot-prober btrfs UUID=<> subvol=<>" >&2
	exit 1
fi

if [ "$type" = btrfs ]; then
	# handle all of the btrfs stuff here
	if [ ! -e "/proc/self/mountinfo" ]; then
		warn "/proc/self/mountinfo does not exist, exiting"
		umount "$tmpmnt" 2>/dev/null
		rmdir "$tmpmnt" 2>/dev/null
		exit 1
	fi
	mpoint=$(grep "btrfs" /proc/self/mountinfo | grep " /$subvol " | grep " $partition " | cut -d ' ' -f 5)
	if [ "$mpoint" = "/" ]; then
		warn "specifying active root not valid, exiting"
		umount "$tmpmnt" 2>/dev/null
		rmdir "$tmpmnt" 2>/dev/null
		exit 1
	fi
	if [ "$mpoint" = "$tmpmnt" ]; then
		warn "btrfs subvol=$subvool, UUID=$UUID, already mounted on $tmpmnt **ERROR**"
		umount "$tmpmnt" 2>/dev/null
		rmdir "$tmpmnt" 2>/dev/null
		exit 1
	fi
	if [ -z "$mpoint" ]; then
		# mount the btrfs root
		if ! mount -o subvol=$subvol -t btrfs -U $UUID "$tmpmnt" 2>/dev/null; then
			warn "error mounting btrfs subvol=$subvol UUID=$UUID"
			umount "$tmpmnt/boot" 2>/dev/null
			umount "$tmpmnt" 2>/dev/null
			rmdir "$tmpmnt" 2>/dev/null
			exit 1
		fi
	else
		# bind-mount
		if ! mount -o bind "$mpoint" "$tmpmnt" 2>/dev/null; then
			warn "error mounting btrfs bindfrom=$mpoint subvol=$subvol UUID=$UUID"
			umount "$tmpmnt/boot" 2>/dev/null
			umount "$tmpmnt" 2>/dev/null
			rmdir "$tmpmnt" 2>/dev/null
			exit 1
		fi
	fi
	debug "mounted btrfs $partition, subvol=$subvol on $tmpmnt"
	if [ ! -e "$tmpmnt/etc/fstab" ]; then
		warn "btrfs subvol=$subvol not root"
		umount "$tmpmnt" 2>/dev/null
		rmdir "$tmpmnt" 2>/dev/null
		exit 1
	fi
	bootmnt=$(parsefstab < "$tmpmnt/etc/fstab" | grep " /boot ") || true
	if [ -z "$bootmnt" ]; then
		# /boot is part of the root
		bootpart="$partition"
		bootsv="$subvol"
	elif echo "$bootmnt" | cut -d ' ' -f 3 | grep -q "btrfs"; then
		# separate btrfs /boot subvolume
		bootsv=$(echo "$bootmnt" | cut -d ' ' -f 4 | grep "^subvol=" | sed "s/subvol=//" )
		bootuuid=$(echo "$bootmnt" | cut -d ' ' -f 1 | grep "^UUID=" | sed "s/UUID=//" )
		debug "mounting btrfs $tmpmnt/boot UUID=$bootuuid subvol=$bootsv"
		bindfrom=$(check_btrfs_mounted $bootsv $bootuuid)
		if [ -n "$bindfrom" ]; then
			# already mounted some place
			if ! mount -o bind $bindfrom "$tmpmnt/boot" 2>/dev/null; then
				warn "error bind mounting btrfs boot subvol=$bootsv, from=$bindfrom"
				umount "$tmpmnt/boot" 2>/dev/null
				umount "$tmpmnt" 2>/dev/null
				rmdir "$tmpmnt" 2>/dev/null
				exit 1
			fi
		elif ! mount -o subvol=$bootsv -t btrfs -U $bootuuid "$tmpmnt/boot" 2>/dev/null; then
			warn "error mounting btrfs boot partition subvol=$bootsv, UUID=$bootuuid"
			umount "$tmpmnt/boot" 2>/dev/null
			umount "$tmpmnt" 2>/dev/null
			rmdir "$tmpmnt" 2>/dev/null
			exit 1
		fi
		bootpart=$(grep " btrfs " /proc/self/mountinfo | grep " /$bootsv " | cut -d ' ' -f 10)
	else
		# non-btrfs partition or logical volume
		linux_mount_boot $partition $tmpmnt
		bootpart="${mountboot%% *}"
		bootsv=
	fi
	
	test="/usr/libexec/linux-boot-probes/mounted/40grub2"
	if [ -f $test ] && [ -x $test ]; then
		debug "running $test $partition $bootpart $tmpmnt $type $subvol $bootsv"
		if $test "$partition" "$bootpart" "$tmpmnt" "$type" "$subvol" "$bootsv"; then
			debug "$test succeeded"
		fi
	fi
	umount "$tmpmnt/boot" 2>/dev/null || true
	if ! umount "$tmpmnt" 2>/dev/null; then
		warn "problem umount $tmpmnt"
	fi
	rmdir "$tmpmnt" 2>/dev/null || true

	exit 0
fi

if ! mapped="$(mapdevfs "$partition")"; then
	log "Device '$partition' does not exist; skipping"
	continue
fi

( (
if ! grep -q "^$mapped " "$OS_PROBER_TMP/mounted-map"; then
	for test in /usr/libexec/linux-boot-probes/*; do
		if [ -x $test ] && [ -f $test ]; then
			debug "running $test"
			if $test "$partition"; then
				debug "linux detected by $test"
				break
			fi
		fi
	done
else
	mpoint=$(grep "^$mapped " "$OS_PROBER_TMP/mounted-map" | head -n1 | cut -d " " -f 2)
	mpoint="$(unescape_mount "$mpoint")"
	if [ "$mpoint" != "/target/boot" ] && [ "$mpoint" != "/target" ] && [ "$mpoint" != "/" ]; then
		type=$(grep "^$mapped " "$OS_PROBER_TMP/mounted-map" | head -n1 | cut -d " " -f 3)
		if ! grep -q " $mpoint/boot " "$OS_PROBER_TMP/mounted-map"; then
			linux_mount_boot "$partition" "$mpoint"
			bootpart="${mountboot%% *}"
			bootmounted="${mountboot#* }"
		else
			bootpart="$(grep " $mpoint/boot " "$OS_PROBER_TMP/mounted-map" | head -n1 | cut -d " " -f 4)"
			bootmounted=0
		fi
		for test in /usr/libexec/linux-boot-probes/mounted/*; do
			if [ -f $test ] && [ -x $test ]; then
				debug "running $test on mounted $partition"
				if $test "$partition" "$bootpart" "$mpoint" "$type"; then
					debug "$test succeeded"
					break
				fi
			fi
		done
		if [ "$bootmounted" = 1 ]; then
			if ! umount "$mpoint/boot"; then
				warn "failed to umount $mpoint/boot"
			fi
		fi
	fi
fi
) 9>&1 | logger 1>&-  # fd_logger
) 3>&1  # fd_result

Youez - 2016 - github.com/yon3zu
LinuXploit