Posted on 04-26-2016 09:39 AM
What is wrong with this scrip? I am trying to add multiple .kext files. The original scrip just has this line:
if [ -d "$targetVolume/Library/Application Support/JAMF/DisabledExtensions/" ]; then
/bin/mv "$targetVolume/System/Library/Extensions/IOUSBMassStorageClass.kext"
But I want to also add those one:
if [ -d "$targetVolume/Library/Application Support/JAMF/DisabledExtensions/" ]; then
/bin/mv "$targetVolume/System/Library/Extensions/IOUSBMassStorageClass.kext",
/bin/mv "$targetVolume/System/Library/Extensions/IOFireWireSerialBusProtocolTransport.kext",
/bin/mv "$targetVolume/System/Library/Extensions/IOUSBAttachedSCSI.kext",
/bin/mv "$targetVolume/System/Library/Extensions/IOUSBFamily.kext" "$targetVolume/Library/Application Support/JAMF/DisabledExtensions/"
else
/bin/mkdir -p "$targetVolume/Library/Application Support/JAMF/DisabledExtensions/"
if [ -d "$targetVolume/Library/Application Support/JAMF/DisabledExtensions/" ]; then
/bin/mv "$targetVolume/System/Library/Extensions/IOUSBMassStorageClass.kext"
fi
Posted on 04-26-2016 11:11 AM
@Zeek if your trying to do this on a 10.11.x Mac I don't believe it will work because of System Integrity Protection.
Posted on 04-27-2016 05:03 AM
Have you looked at a config profile? There are options to restrict external storage devices to read only, or no access at all..
Posted on 04-27-2016 05:42 AM
If I run this one it will move this single extension to the JAMF folder:
if [ -d "$targetVolume/Library/Application Support/JAMF/DisabledExtensions/" ]; then
/bin/mv "$targetVolume/System/Library/Extensions/IOUSBMassStorageClass.kext"
But I need all of those moved:
1.IOUSBMassStorageClass.kext
2.IOFireWireSerialBusProtocolTransport.kext
3.OUSBAttachedSCSI.kext
4.OUSBFamily.kext
If I manually go to System/Library/Extensions and delete those four extensions it will work.
Posted on 04-27-2016 06:14 AM
I'm not sure this is a great idea, but in terms of getting the script working:
#check if the directory exists, if not then create it
[ -d "$targetVolume/Library/Application Support/JAMF/DisabledExtensions/" ] || /bin/mkdir -p "$targetVolume/Library/Application Support/JAMF/DisabledExtensions/"
#check if each file exists, if so then move it to the disabled directory
[ -e "$targetVolume/System/Library/Extensions/IOUSBMassStorageClass.kext" ] && /bin/mv "$targetVolume/System/Library/Extensions/IOUSBMassStorageClass.kext" "$targetVolume/Library/Application Support/JAMF/DisabledExtensions/"
[ -e "$targetVolume/System/Library/Extensions/IOFireWireSerialBusProtocolTransport.kext" ] && /bin/mv "$targetVolume/System/Library/Extensions/IOFireWireSerialBusProtocolTransport.kext" "$targetVolume/Library/Application Support/JAMF/DisabledExtensions/"
[ -e "$targetVolume/System/Library/Extensions/IOUSBAttachedSCSI.kext" ] && /bin/mv "$targetVolume/System/Library/Extensions/IOUSBAttachedSCSI.kext" "$targetVolume/Library/Application Support/JAMF/DisabledExtensions/"
[ -e "$targetVolume/System/Library/Extensions/IOUSBFamily.kext" ] && /bin/mv "$targetVolume/System/Library/Extensions/IOUSBFamily.kext" "$targetVolume/Library/Application Support/JAMF/DisabledExtensions/"
Or clean it up with an array and a for loop:
#check if the directory exists, if not then create it
[ -d "$targetVolume/Library/Application Support/JAMF/DisabledExtensions/" ] || /bin/mkdir -p "$targetVolume/Library/Application Support/JAMF/DisabledExtensions/"
#place file names in an array
declare -a KEXTArray=("IOUSBMassStorageClass.kext" "IOFireWireSerialBusProtocolTransport.kext" "IOUSBAttachedSCSI.kext" "IOUSBFamily.kext")
#for each file name in the array check if it exists, if it does then move it.
for KEXT in "${KEXTArray[@]}"; do
[ -e "$targetVolume/System/Library/Extensions/$KEXT" ] && /bin/mv "$targetVolume/System/Library/Extensions/$KEXT" "$targetVolume/Library/Application Support/JAMF/DisabledExtensions/"
done
Note: the >_ symbol in the JAMF nation posting tools is the script block, it makes it easier to read code.
Posted on 05-03-2016 11:19 AM
Self service pop up saying there was a problem with the scrip.
Here is the full scrip:
targetVolume=""
if [ "$1" != "" ] && [ "$targetVolume" == "" ];then
targetVolume=$1
fi
echo "Disabling the USB Drivers..."
if [ -d "$targetVolume/Library/Application Support/JAMF/DisabledExtensions/" ]; then
/bin/mv "$targetVolume/System/Library/Extensions/IOUSBMassStorageClass.kext" "$targetVolume/Library/Application Support/JAMF/DisabledExtensions/"
else
/bin/mkdir -p "$targetVolume/Library/Application Support/JAMF/DisabledExtensions/"
/bin/mv "$targetVolume/System/Library/Extensions/IOUSBMassStorageClass.kext" "$targetVolume/Library/Application Support/JAMF/DisabledExtensions/"
fi
Posted on 05-03-2016 03:29 PM
@Zeek Pretty sure that those .kext locations are in som manner SIP protected.
So doubt this will work with 10.11.
Posted on 05-03-2016 04:21 PM
+1 Config Profile or MCX if you like
+1 for SIP will stop you
$ ls -lOe /System/Library/Extensions/IOUSBMassStorageClass.kext
total 0
drwxr-xr-x 6 root wheel restricted 204 17 Feb 16:17 Contents
Posted on 09-10-2018 02:46 PM
Does anyone have a good solution for disabling USB for certain groups?