Home › Forums › OS X Server and Client Discussion › Mail › Mail plist reading and writing
- This topic has 1 reply, 1 voice, and was last updated 18 years, 1 month ago by
rmleonard.
-
AuthorPosts
-
May 6, 2008 at 7:58 pm #372599
rmleonard
ParticipantOur security gurus are demanding that all mail transactions be secure …
so – how do i go about scanning all of my macs, and finding all users on a given box, reading their per client mail settings, finding the settings block for our server, and change the settings to be “secure”
I can read en bulk
defaults read com.apple.mail MailAccountsI can (in theory) use that to scan each user’s mail.plist
but – how do I drill down to only read the Hostname section that applies to the server in question?
once that is done, I should be able to defaults write the changes toPortNumber = 993;
SMTPIdentifier = “YourServer.here”;
SSLEnabled = YES;
SecurityLayerType = 3;but if they have multiple email accounts – I need to be sure that it is the “correct” one
MailAccounts “names” can be anything – as there is no standardization in that field (around here)I care about matching the Hostname, once I know that I need to grab the MailAccount and then write out the sections
I suppose I can read each mail account – test values and move on…????
is there an easy way to script the xml reading?
Rich
May 7, 2008 at 9:15 pm #372623rmleonard
Participantokay -I’ll leave this as academic to finish
plistbuddy can write the dictionary items out and add what is needed
can anyone see a “better” way of doing this?
WGM and mcx settings per se are not an option
All I can think of is the following brute force method, ugly as it isARD can copy this file to a blanket load of machines, and then execute it….
This should fix all MacMail folk…. (once i add the fixits to writeback the data)[code]
#!/bin/bashplistbuddy=$(stat -f “%N” $(find /Library/Receipts -name “PlistBuddy” -print) 2>/dev/null | sort -n | tail -1 | cut -f2-)
mailfile=”/Library/Preferences/com.apple.mail”
mailplist=”$mailfile.plist”function testhostname {
COUNTER=$1
USERNAME=$2
servername=$($plistbuddy -c “Print :MailAccounts:$COUNTER:Hostname” /Users/$USERNAME/$mailplist)
if [ “$servername” = “exchange.csupomona.edu” ]; then
echo “Account $COUNTER is pointing at Exchange”
echo “The Account type is $($plistbuddy -c “Print :MailAccounts:$COUNTER:AccountType” /Users/$USERNAME/$mailplist)”
echo “the SSL Settings are”
echo “… Port Number $($plistbuddy -c “Print :MailAccounts:$COUNTER:PortNumber” /Users/$USERNAME/$mailplist)”
echo “… SSL enabled $($plistbuddy -c “Print :MailAccounts:$COUNTER:SSLEnabled” /Users/$USERNAME/$mailplist)”
fi
}AC=0
ls -1 /Users | while read i
do
if [ -f “/Users/$i/$mailplist” ]; then
echo “working on user $i and file /Users/$i/$mailplist”
defaults read /Users/$i/$mailfile MailAccounts | {
AC=0
USERNAME=$i
while read i
do
if [ ${#i} -gt 8 ]; then
left8=$(echo $i | cut -c 1-8)
if [ “$left8” = “Hostname” ]; then
let AC=AC+1
testhostname $AC $USERNAME
fi
fi
done
echo “total accounts = $AC”
}
fi
done[/code]
-
AuthorPosts
- You must be logged in to reply to this topic.
Comments are closed