Share Volume Script Showing Credentials In The Clear In Logs

Muz70
New Contributor

Hey everybody,

I am working on a script to afp mount a shared storage volume.

The script works, but it shows the users username and password in plaintext when I check the logs of the policy I have attached the script to. For security reasons I don't want that. I want to use the script in a policy in Self Service so the user can mount the volume from there. I can't figure out what to add or how to rewrite it to still mount and ask the user for their AD username and password, but hide the credentials in the logs.

#!/bin/sh
}
function mountV {
    if mount | grep /Volumes/V > /dev/null
        then
            echo "V Volume already mounted!"
            (osascript -e '
                tell application "Finder"
                    activate
                    display dialog "V Volume is already mounted!"
            end tell')
            continue
        else
            /usr/bin/su "$userNAME" -c "jamf  mount -server servername.com -share V -type afp -username $userNAME -password $newPASSWORD -visible"
            if mount | grep /Volumes/V > /dev/null
                then
                    echo "Successfully mounted V Volume!"
                    echo "Exit Code:" $?
                    success[5]='Z'
                else
                    echo "Failed to mount V Volume!"
                    echo "Exit Code:" $?
                    (osascript -e '
                        tell application "Finder"
                            activate
                            display dialog "Failed to mount V Volume! Please check your password and try again."
                    end tell')
            fi
    fi
}
userNAME=$null
while [ "$userNAME" = "" ];
    do
        userNAME=$(osascript -e '
        tell application "Finder"
            activate
           display dialog "Enter your Username" default answer "" with title "Volumes"
            set userNAME to the (text returned of the result)
        end tell')
    done
while [ "$newPASSWORD" = "" ];
    do
        newPASSWORD=$(osascript -e '
        tell application "Finder"
            activate
            display dialog "Enter your Password" default answer "" with hidden answer with title "Volumes"
                set newPASSWORD to the (text returned of the result)
        end tell')
    done
echo "Successfully mounted:" ${success[@]}
set -- ${success[*]}
if [ $# -ne 0 ]; then
osascript <<EOF
tell application "Finder"
        activate
        display dialog "Successfully mounted: ${success[@]}"
end tell
say "$text" using "Alex"
EOF
fi
exit

I'm sure someone will be able to figure this out, but it's racking my brain!

0 REPLIES 0