Managedinstalls.plist is converted to binary by "defaults write" updates

285 views
Skip to first unread message

Justin McWilliams

unread,
Sep 8, 2010, 10:48:18 AM9/8/10
to munk...@googlegroups.com, Greg Neagle
Are there any objections to calling "plutil -convert xml1" on this
plist immediately after "defaults write" is called to convert it back
to XML? Alternatively, am I missing a way to get defaults to write as
XML instead of binary?

I only see three occurrences of this write, all being in
managedsoftwareupdate:
http://www.google.com/codesearch?hl=en&lr=&q=defaults',+'write'+package:http://munki\.googlecode\.com&sbtn=Search

- Justin

Edward Marczak

unread,
Sep 8, 2010, 10:58:33 AM9/8/10
to munk...@googlegroups.com
On Wed, Sep 8, 2010 at 10:48 AM, Justin McWilliams <og...@google.com> wrote:
> Are there any objections to calling "plutil -convert xml1" on this
> plist immediately after "defaults write" is called to convert it back
> to XML?  Alternatively, am I missing a way to get defaults to write as
> XML instead of binary?

That's just how the defaults command works - it converts to binary
plists on write no matter what the original format was.

You'd need to code this with Cocoa classes or plistlib to write it out as XML1.

>
> I only see three occurrences of this write, all being in
> managedsoftwareupdate:
> http://www.google.com/codesearch?hl=en&lr=&q=defaults',+'write'+package:http://munki\.googlecode\.com&sbtn=Search
>
> - Justin
>

> --
> You received this message because you are subscribed to the Google Groups "munki-dev" group.
> To post to this group, send email to munk...@googlegroups.com.
> To unsubscribe from this group, send email to munki-dev+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/munki-dev?hl=en.
>
>

--
Ed Marczak
e: mar...@radiotope.com
w: http://www.radiotope.com/writing
MacTech Conference: http://www.mactech.com/conference

Greg Neagle

unread,
Sep 8, 2010, 11:07:32 AM9/8/10
to og...@google.com, munk...@googlegroups.com
Is there a problem you are trying to solve or an issue you are trying to avoid by converting back to XML? Generally, I find it best to not assume anything about the format of a plist. Even if we are careful in munki's code to make sure a plist remains in XML format, an administrator can use the defaults command on their own and ruin your assumptions.

Sent from my iPad

MiqViq

unread,
Sep 8, 2010, 11:18:37 AM9/8/10
to munki-dev
I guess the only "automated" solution for converting a certain plist
to XML-version would be to have a LaunchDaemon which is triggered by
any changes to that certain plist file and then converts it to XML.
But is there truly a need for such?
I found out that even the free TextWrangler can convert a binary plist
to XML for vieving and editing purposes.
But if one needs to have that certain plist as XML then that
LaunchDaemon approach could be the solution...

Generally I use plutil -convert xml1 path/to/pref.plist command
sometimes if I have something that needs to be parsed using some other
legacy method like sed, awk. I have not tried PlistBuddy, it probably
would be handy when one needs deeper access to nested arrays within
plist.

-MiqViq

On Sep 8, 6:07 pm, Greg Neagle <gregnea...@mac.com> wrote:
> Is there a problem you are trying to solve or an issue you are trying to avoid by converting back to XML?  Generally, I find it best to not assume anything about the format of a plist.  Even if we are careful in munki's code to make sure a plist remains in XML format, an administrator can use the defaults command on their own and ruin your assumptions.
>
> Sent from my iPad
>
> On Sep 8, 2010, at 7:48 AM, Justin McWilliams <o...@google.com> wrote:
>
>
>
> > Are there any objections to calling "plutil -convert xml1" on this
> > plist immediately after "defaults write" is called to convert it back
> > to XML?  Alternatively, am I missing a way to get defaults to write as
> > XML instead of binary?
>
> > I only see three occurrences of this write, all being in
> > managedsoftwareupdate:
> >http://www.google.com/codesearch?hl=en&lr=&q=defaults',+'write'+packa....googlecode\.com&sbtn=Search
>
> > - Justin

Justin McWilliams

unread,
Sep 8, 2010, 11:18:53 AM9/8/10
to Greg Neagle, munk...@googlegroups.com
On Wed, Sep 8, 2010 at 11:07 AM, Greg Neagle <gregn...@mac.com> wrote:
> Is there a problem you are trying to solve or an issue you are trying to avoid by converting back to XML?

plistlib cannot read binary plists. FoundationPlist can it seems, but
I'd like to use the standard py libraries whenever possible. It's
also nice to be able to view/modify the plist in a text editor, after
all we are starting with XML.....

> Generally, I find it best to not assume anything about the format of a plist.  Even if we are careful in munki's code to make sure a plist remains in XML format, an administrator can use the defaults command on their own and ruin your assumptions.

we could immediately convert to XML whenever munki runs, then assume
it's XML after that until the next run. I guess that still leaves
room for admins to stomp on your toes in between though.

Edward Marczak

unread,
Sep 8, 2010, 11:23:55 AM9/8/10
to munk...@googlegroups.com
On Wed, Sep 8, 2010 at 11:18 AM, Justin McWilliams <og...@google.com> wrote:
> On Wed, Sep 8, 2010 at 11:07 AM, Greg Neagle <gregn...@mac.com> wrote:
>> Is there a problem you are trying to solve or an issue you are trying to avoid by converting back to XML?
>
> plistlib cannot read binary plists.  FoundationPlist can it seems, but
> I'd like to use the standard py libraries whenever possible.  It's
> also nice to be able to view/modify the plist in a text editor, after
> all we are starting with XML.....


The NSPropertyListSerialization class will read plists in either
format and write them in the format that was read in.

Greg Neagle

unread,
Sep 8, 2010, 11:30:41 AM9/8/10
to munk...@googlegroups.com
This is why munki uses my FoundationPlist module -- it uses the NSPropertyListSerialization methods.

-Greg

Justin McWilliams

unread,
Sep 8, 2010, 11:38:07 AM9/8/10
to munk...@googlegroups.com
Okay. I'll use that instead of plistlib.
Reply all
Reply to author
Forward
0 new messages