403Webshell
Server IP : 213.35.126.208  /  Your IP : 216.73.216.239
Web Server : Apache/2.4.37 (Oracle Linux Server) OpenSSL/1.1.1k
System : Linux ust-wp1-prod 5.15.0-308.179.6.el8uek.x86_64 #2 SMP Wed Apr 23 10:46:57 PDT 2025 x86_64
User : tomasFtp ( 1007)
PHP Version : 8.4.8
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/udev/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/udev/ociudevpersistentnaming
#!/bin/bash
#
# Script to create symlinks in devices that is based on LUN IDs.
# Link vda always points to the root device.
# This script works only for iSCSI attachments (Beta release for PSM)
#
# Copyright (C) 2022 Oracle. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, version 2.  This program is distributed in the hope that it will
# be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
# Public License for more details.  You should have received a copy of the GNU
# General Public License along with this program; if not, write to the Free
# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 021110-1307, USA.

# If number of parameters being sent to this script is not equal to 1
# , we throw an error. We expect the kernel device name like "sda", "sdb" etc.
if [ "$#" -ne 1 ]; then
	echo "invalid <device>" >&2
	exit 1
fi

if [[ "$DEVPATH" = *"virtio"* ]]; then
	# Using ID_PATH to retrieve the LU #
	# ID_PATH is virtio-pci-0000:00:04.0-scsi-0:0:2:12
	# With the substitution, we would be able to get 12 which is the LUN number.
	LUN=$(echo "$ID_PATH" | sed 's/.*://')
else
	# Using DEVPATH to retrieve the LUN #
	# DEVPATH is /devices/platform/host5/session3/target5:0:0/5:0:0:12/block/sdc
	# With first substitution, the string becomes 12/block/sdc
	# With second substitution, the string becomes 12/
	# With third substitution, the last character is removed and we are able to retrieve
	# the LUN number which is 12.
	LUN=$(echo "$DEVPATH" | sed 's/.*://' | sed 's/\([/]\).*/\1/' | sed s'/.$//')
fi

if [ x"$LUN" = "x" ]; then
	exit 1
fi

# We can use ID_PATH to figure out iSCSI boot volumes
# ID_PATH is ip-169.254.0.2:3260-iscsi-iqn.2015-02.oracle.boot:uefi-lun-1
# After the substitution, we get uefi-lun-1
BOOTLUN=${ID_PATH//.*://}
#BOOTLUN=$(echo "$ID_PATH" |sed 's/.*://')
# iSCSI boot volumes are recognized with uefi-lun-1
if [[ "$BOOTLUN" = *"uefi-lun-1"* ]]; then
	echo "$1" | sed 's#sd[a-z]*[a-z]#oracleoci/oraclevda#g'
	exit 0
fi

# In case of PV Boot volume, the ID_PATH is virtio-pci-0000:00:04.0-scsi-0:0:0:1
# By applying the substitution, we get the LUN number as 1 
# 1 is special case reserved for boot volumes.
if [ "$BOOTLUN" = "1" ]; then
        echo "$1" | sed 's#sd[a-z]*[a-z]#oracleoci/oraclevda#g'
        exit 0
fi

# Test to ensure $LUN is a number
re='^[0-9]+$'
if ! [[ "$LUN" =~ $re ]] ; then
   exit 1
fi

# We allow a maximum device name to be vdzz - corresponding to LUN=702 (26 + (26 * 26))
if [ "$LUN" -gt "702" ]; then
  exit 1
fi

# We don't allow the LUN # to be less than 1
if [ "$LUN" -le "0" ]; then
	exit 1
fi

# If the IQN of the incoming device matches the one
# persisted on the filesystem, exit with failure
FNAME=$(echo "$ID_PATH" | sed 's/.*iscsi-//' | sed 's/-lun-.*//')
if [ -f "/var/log/oracle-cloud-agent/plugins/oci-blockautoconfig/$FNAME" ]; then
	echo "This is a path to a multipath device. Skipping symlink creation"
	exit 1
fi

# Converts a number to ASCII char
chr() {
  printf \\$(printf '%03o' "$1")
}

# Construct a 2 letter suffix using the LUN ID.
# 2 means vdb, 3 means vdc and so on
# 27 means vdaa and so on.
LETTER1=$((LUN/26))
LETTER2=$(((LUN - (LETTER1 * 26)) % 26))

if [ "$LETTER2" -eq 0 ]; then
	LETTER2='z'
  	if [ "$LETTER1" -eq 1 ]; then
    		LETTER1=''
  	else
    		LETTER1=$(chr $((LETTER1 + 95)))
  	fi
else
	LETTER2=$(chr $((LETTER2 + 96)))
	if [ "$LETTER1" -eq 0 ]; then
    		LETTER1=''
  	else
    		LETTER1=$(chr $((LETTER1 + 96)))
  	fi
fi

SUFFIX="$LETTER1$LETTER2"

echo "$1" | sed "s#sd[a-z]*[a-z]#oracleoci/oraclevd$SUFFIX#g"
exit 0

Youez - 2016 - github.com/yon3zu
LinuXploit