From 906b740710a160ed1e95dcd001c1c658fa7b0347 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Einar=20J=C3=B8rgen=20Haraldseid?= Date: Wed, 15 Mar 2017 11:53:59 +0100 Subject: [PATCH] Possibly added working password check for OSX --- addfollowmeprint.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/addfollowmeprint.sh b/addfollowmeprint.sh index 1c710b3..23edde8 100755 --- a/addfollowmeprint.sh +++ b/addfollowmeprint.sh @@ -209,7 +209,6 @@ stty "${Settings}" echo "" # Some further tests for Linux systems -# TODO: Add similar tests for macOS if [ "${Uname}" = "linux" ]; then echo -e "\nNOTE: Your credentials will be stored in plaintext in /etc/cups/printers.conf.\nThis file us usually not readable for normal users, but still:\nDo not use this script on multi user systems!" # Test for valid username and password if on Linux @@ -228,6 +227,20 @@ if [ "${Uname}" = "linux" ]; then fi fi +# Similar tests for OSX +if [ "${Uname}" = "darwin" ]; then + smbutil view -A "//${Workgroup};${Username}:${Password}@${PrintServer}" > /dev/null 2>&1 + if [ $? -ne 0 ]; then + printerror "User name or password incorrect, or no contact with the print server ${PrintServer}." + exit 1 + fi + ShareFound=$(smbutil view "//${Workgroup};${Username}:${Password}@${PrintServer}" 2>/dev/null | grep ${PrintShare} | cut -d " " -f 1) + if [ "${ShareFound}" != "${PrintShare}" ]; then + printerror "Could not find printer share called ${PrintShare} on the server" + printerror "This script must be broken or outdated. Please contact orakel@ntnu.no for further assistance." + exit 1 + fi + # Finally we can add the printer # The Linux way -- 2.30.2