Skip to content

Instantly share code, notes, and snippets.

View jessepeterson's full-sized avatar

Jesse Peterson jessepeterson

View GitHub Profile
@jessepeterson
jessepeterson / makeinstaller.sh
Created July 24, 2014 00:09
Make OS X installer ISO (CDR) from OS Install app
#!/bin/sh
user_id=`id -u`
if [ $user_id -ne 0 ]; then
echo "$0: must be root"
exit 1
fi
if [ $# -lt 2 ]; then
@jessepeterson
jessepeterson / newsyslog-provider.rb
Created September 20, 2011 23:43
Newsyslog config file Puppet type
require 'puppet/provider/parsedfile'
newsyslog = '/etc/newsyslog.conf'
Puppet::Type.type(:newsyslog).provide(
:parsed,
:parent => Puppet::Provider::ParsedFile,
:default_target => newsyslog,
:filetype => :flat) do
@jessepeterson
jessepeterson / convert-emlx.py
Last active December 15, 2015 01:29
Convert an Apple emlx file to a .eml file (removing the Apple-proprietary parts; leaving a raw message file)
import sys
for i in sys.argv[1:]:
if i.lower().endswith('emlx'):
print 'Processing:', i
else:
print 'Unknown file:', i
sys.exit(1)
emlx = open(i, 'r')
@jessepeterson
jessepeterson / github_dlextract.pp
Last active December 19, 2015 02:28
Puppet definition to download a tarball of a Github repo and extract it to a filesystem location.
# example:
#
# github_dlextract { "mxcl/homebrew",
# path => "/my/path/directory",
# rev => "b8c7e203d1", # optional
# }
define github_dlextract ($repo = $title, $path, $rev = 'master') {
file { $path:
@jessepeterson
jessepeterson / acllength.py
Created February 3, 2016 04:08
Print files that have a specific length ACL text presentation
#!/usr/bin/python
"""Print files that have a specific length ACL text presentation
Used to debug a backup tool that may have been having problems with files
with this precise ACL representation.
Created by Jesse Peterson on 2/2/16
"""
@jessepeterson
jessepeterson / check_10.9_board_id.sh
Created January 16, 2014 20:08
Check the current Mac board ID against the list provided in the 10.9.0 installer to determine compatibility.
#!/bin/sh
BOARD_ID=`ioreg -p IODeviceTree -r -n / -d 1 | grep board-id | awk '{print $3}' | sed -n 's/\<\"\(Mac-[0-9A-Z]*\)\"\>/\1/p'`
grep $BOARD_ID > /dev/null << EOF
Mac-031B6874CF7F642A
Mac-F2268DC8
Mac-50619A408DB004DA
Mac-F2218EA9
Mac-F42D86A9
@jessepeterson
jessepeterson / plist2gostruct.py
Created November 2, 2016 18:07
convert Apple plist to set of golang structs
import sys
import plistlib
pl = plistlib.readPlist(sys.argv[1])
structs = []
def struct_from_dict(name, vals):
global structs
@jessepeterson
jessepeterson / findbadacls.py
Last active November 28, 2016 20:30
Finds bad ACE qualifiers (user/group UUIDs) in ACLs on files on macOS. Takes a list of file/directory names on stdin.
#!/usr/bin/python
'''
Takes a list of file names/paths on stdin and checks to see if they have
unresolvable ACE entries in their ACLs. E.g. ACEs which have a non-resolvable
UUID on the system.
Usage:
find /some/file/path | /path/to/findbadacls.py
'''
@jessepeterson
jessepeterson / gist:4053def24038a72d72cbfabc3120fc8c
Created January 24, 2017 19:22
changed dmgmounter.py behavior
import os
class DmgMounter(object):
"""Base class for Processors that need to mount disk images."""
DMG_EXTENSIONS = ['.dmg', '.iso', '.DMG', '.ISO']
#pylint: disable=invalid-name
def parsePathForDMG(self, pathname):
"""Helper method for working with paths that reference something
@jessepeterson
jessepeterson / getgrouplist_2.py
Last active May 30, 2018 16:30
getgrouplist using OS X-specific API
#!/usr/bin/python
import grp, pwd, os
from ctypes import *
from ctypes.util import find_library
libc = cdll.LoadLibrary(find_library('libc'))
# getgrouplist_2() is an undocumented API which, I beleive, retrives all of
# a user's groups instead of the maximum 16 groups which getgrouplist() gets