def extend_path(conn, arguments):
    """
    get the remote environment's env so we can explicitly add the path without
    wiping out everything
    """
    try:
        result = conn.gateway.remote_exec(
            'import os; channel.send(os.environ.copy())')
        env = result.receive()
    except Exception:
        conn.logger.exception(
            'failed to retrieve the remote environment variables')
        env = {}
    path = env.get('PATH', '')
    env['PATH'
        ] = path + '/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin'
    arguments['env'] = env
    return arguments
