Example #1
0
def displayAppleUpdateInfo():
    '''Prints Apple update information'''
    try:
        updatelist = FoundationPlist.readPlist(appleUpdatesFile())
    except FoundationPlist.FoundationPlistException:
        return
    else:
        appleupdates = updatelist.get('AppleUpdates', [])
        if len(appleupdates):
            munkicommon.display_info(
                "The following Apple Software Updates are available to install:"
            )
        for item in appleupdates:
            munkicommon.display_info("    + %s-%s" % (item.get(
                'display_name', ''), item.get('version_to_install', '')))
            if item.get('RestartAction') == 'RequireRestart' or \
               item.get('RestartAction') == 'RecommendRestart':
                munkicommon.display_info("       *Restart required")
                munkicommon.report['RestartRequired'] = True
            if item.get('RestartAction') == 'RequireLogout':
                munkicommon.display_info("       *Logout required")
                munkicommon.report['LogoutRequired'] = True
Example #2
0
def displayAppleUpdateInfo():
    '''Prints Apple update information'''
    try:
        updatelist = FoundationPlist.readPlist(appleUpdatesFile())
    except FoundationPlist.FoundationPlistException:
        return
    else:
        appleupdates = updatelist.get('AppleUpdates', [])
        if len(appleupdates):
            munkicommon.display_info(
            "The following Apple Software Updates are available to install:")
        for item in appleupdates:
            munkicommon.display_info("    + %s-%s" %
                                        (item.get('display_name',''),
                                         item.get('version_to_install','')))
            if item.get('RestartAction') == 'RequireRestart' or \
               item.get('RestartAction') == 'RecommendRestart':
                munkicommon.display_info("       *Restart required")
                munkicommon.report['RestartRequired'] = True
            if item.get('RestartAction') == 'RequireLogout':
                munkicommon.display_info("       *Logout required")
                munkicommon.report['LogoutRequired'] = True
Example #3
0
                # but man that's slow.
                # I think there's a lot of overhead with the
                # subprocess call. I'm going to use os.remove.
                # I hope I don't regret it.
                retcode = ''
                try:
                    os.remove(pathtoremove)
                except (OSError, IOError), err:
                    msg = "Couldn't remove item %s: %s" % (pathtoremove, err)
                    munkicommon.display_error(msg)
                    removalerrors = removalerrors + "\n" + msg

        munkicommon.display_percent_done(itemindex, itemcount)

    if removalerrors:
        munkicommon.display_info(
            "---------------------------------------------------")
        munkicommon.display_info(
            "There were problems removing some filesystem items.")
        munkicommon.display_info(
            "---------------------------------------------------")
        munkicommon.display_info(removalerrors)


def removepackages(pkgnames,
                   forcedeletebundles=False,
                   listfiles=False,
                   rebuildpkgdb=False,
                   noremovereceipts=False,
                   noupdateapplepkgdb=False):
    """
    Our main function, called by installer.py to remove items based on
Example #4
0
                    'Setting identity preference for %s failed: %s'
                    % (url, err))
        if default_keychain:
            # We originally had a different default, set it back
            output = security(
                'default-keychain', '-s', default_keychain)
            if output:
                munkicommon.display_debug2(output)

    # we're done, clean up.
    if added_keychain:
        remove_from_keychain_list(abs_keychain_path)
    if original_home:
        # switch it back
        os.environ['HOME'] = original_home
    munkicommon.display_info(
        'Completed creation of client keychain at %s' % abs_keychain_path)


def add_to_keychain_list(keychain_path):
    '''Ensure the keychain is in the search path. Returns True if we
    added the keychain to the list.'''

    # we use *foo to expand a list of keychain paths
    # pylint: disable=W0142

    added_keychain = False
    output = security('list-keychains', '-d', 'user')
    # Split the output and strip it of whitespace and leading/trailing
    # quotes, the result are absolute paths to keychains
    # Preserve the order in case we need to append to them
    search_keychains = [x.strip().strip('"')
Example #5
0
                # but man that's slow.
                # I think there's a lot of overhead with the
                # subprocess call. I'm going to use os.remove.
                # I hope I don't regret it.
                retcode = ''
                try:
                    os.remove(pathtoremove)
                except (OSError, IOError), err:
                    msg = "Couldn't remove item %s: %s" % (pathtoremove, err)
                    munkicommon.display_error(msg)
                    removalerrors = removalerrors + "\n" + msg

        munkicommon.display_percent_done(itemindex, itemcount)

    if removalerrors:
        munkicommon.display_info(
                        "---------------------------------------------------")
        munkicommon.display_info(
                        "There were problems removing some filesystem items.")
        munkicommon.display_info(
                        "---------------------------------------------------")
        munkicommon.display_info(removalerrors)


def removepackages(pkgnames, forcedeletebundles=False, listfiles=False,
                    rebuildpkgdb=False, noremovereceipts=False,
                    noupdateapplepkgdb=False):
    """
    Our main function, called by installer.py to remove items based on
    receipt info.
    """
    if pkgnames == []:
Example #6
0
 def test_display_info_with_str_msg_str_arg(self):
     munkicommon.display_info(MSG_STR, ARG_STR)
Example #7
0
 def test_display_info_with_unicode_msg_str_arg(self):
     munkicommon.display_info(MSG_UNI, ARG_STR)
Example #8
0
 def test_display_info_with_unicode_msg(self):
     munkicommon.display_info(MSG_UNI)
Example #9
0
            if re.search(r'URL returned error: [0-9]+$', curlerr):
                header['http_result_code'] = curlerr[curlerr.rfind(' ')+1:]

        if os.path.exists(tempdownloadpath):
            if not resume:
                os.remove(tempdownloadpath)
            elif retcode == 33 or header.get('http_result_code') == '412':
                # 33: server doesn't support range requests
                # 412: Etag didn't match (precondition failed), could not
                #   resume partial download as file on server has changed.
                if retcode == 33 and not 'HTTPRange' in WARNINGSLOGGED:
                    # use display_info instead of display_warning so these
                    # don't get reported but are available in the log
                    # and in command-line output
                    munkicommon.display_info('WARNING: Web server refused '
                            'partial/range request. Munki cannot run '
                            'efficiently when this support is absent for '
                            'pkg urls. URL: %s' % url)
                    WARNINGSLOGGED['HTTPRange'] = 1
                os.remove(tempdownloadpath)
                # The partial failed immediately as not supported.
                # Try a full download again immediately.
                if not donotrecurse:
                    return curl(url, destinationpath, 
                                cert_info=cert_info,
                                custom_headers=custom_headers,
                                donotrecurse=True,
                                etag=etag,
                                message=message,
                                onlyifnewer=onlyifnewer,
                                resume=resume,
                                follow_redirects=follow_redirects)
Example #10
0
            if re.search(r'URL returned error: [0-9]+$', curlerr):
                header['http_result_code'] = curlerr[curlerr.rfind(' ')+1:]

        if os.path.exists(tempdownloadpath):
            if not resume:
                os.remove(tempdownloadpath)
            elif retcode == 33 or header.get('http_result_code') == '412':
                # 33: server doesn't support range requests
                # 412: Etag didn't match (precondition failed), could not
                #   resume partial download as file on server has changed.
                if retcode == 33 and not 'HTTPRange' in WARNINGSLOGGED:
                    # use display_info instead of display_warning so these
                    # don't get reported but are available in the log
                    # and in command-line output
                    munkicommon.display_info('WARNING: Web server refused '
                            'partial/range request. Munki cannot run '
                            'efficiently when this support is absent for '
                            'pkg urls. URL: %s' % url)
                    WARNINGSLOGGED['HTTPRange'] = 1
                os.remove(tempdownloadpath)
                # The partial failed immediately as not supported.
                # Try a full download again immediately.
                if not donotrecurse:
                    return curl(url, destinationpath,
                                cert_info=cert_info,
                                custom_headers=custom_headers,
                                donotrecurse=True,
                                etag=etag,
                                message=message,
                                onlyifnewer=onlyifnewer,
                                resume=resume,
                                follow_redirects=follow_redirects)
Example #11
0
                    munkicommon.display_debug2(output)
            except SecurityError, err:
                munkicommon.display_error(
                    'Setting identity preference failed: %s' % err)
            if default_keychain:
                # We originally had a different one, set it back
                output = security('default-keychain', '-s', default_keychain)
                if output:
                    munkicommon.display_debug2(output)
    # we're done, clean up.
    if added_keychain:
        remove_from_keychain_list(abs_keychain_path)
    if original_home:
        # switch it back
        os.environ['HOME'] = original_home
    munkicommon.display_info('Completed creation of client keychain at %s' %
                             abs_keychain_path)


def add_to_keychain_list(keychain_path):
    '''Ensure the keychain is in the search path. Returns True if we
    added the keychain to the list.'''

    # we use *foo to expand a list of keychain paths
    # pylint: disable=W0142

    added_keychain = False
    output = security('list-keychains', '-d', 'user')
    # Split the output and strip it of whitespace and leading/trailing
    # quotes, the result are absolute paths to keychains
    # Preserve the order in case we need to append to them
    search_keychains = [