Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. #!/usr/bin/python
  2. '''Converts a standard Wi-Fi configuration profile for iOS/macOS that uses
  3. a user certificate, and converts it into a SystemConfiguration profile type
  4. that can be used to connect to a Wi-Fi network at macOS login screen.
  5. This is useful where you need a laptop to be able to bind to an AD or LDAP
  6. server, or just want to have user credential free Wi-Fi connection at the
  7. system level.'''
  8.  
  9. import os
  10. import plistlib
  11. import sys
  12.  
  13. try:
  14. infile = os.path.expanduser(os.path.expandvars(sys.argv[1]))
  15. outfile = os.path.expanduser(os.path.expandvars(sys.argv[2]))
  16.  
  17. if all([infile.endswith('.mobileconfig'), outfile.endswith('.mobileconfig')]): # NOQA
  18. try:
  19. config = plistlib.readPlist(infile)
  20. # This goes into the PayloadContent
  21. # (where 'AutoJoin' exists)
  22. for payload in config['PayloadContent']:
  23. # Target the payload with 'AutoJoin' in it
  24. if 'AutoJoin' in payload.keys():
  25. payload['SetupModes'] = ['System'] # NOQA
  26. payload['PayloadScope'] = 'System' # NOQA
  27.  
  28. # Convert the profile from a standard Configuration
  29. # type, to SystemConfiguration type
  30. config['PayloadType'] = 'SystemConfiguration'
  31.  
  32. plistlib.writePlist(config, outfile)
  33. except Exception as e:
  34. print '{} {}'.format(e, infile)
  35. else:
  36. print 'In/Out files must be \'.mobileconfig\' type.'
  37. sys.exit(1)
  38. except:
  39. print 'Usage: {} infile outfile'.format(sys.argv[0])
  40. sys.exit(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement