Linux cesa-www-main 6.1.0-49-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.174-1 (2026-05-26) x86_64
Apache/2.4.68 (Debian)
Server IP : 10.218.0.2 & Your IP : 216.73.216.28
Domains :
Cant Read [ /etc/named.conf ]
User : www-data
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
usr /
lib /
google-cloud-sdk /
platform /
gsutil /
gslib /
Delete
Unzip
Name
Size
Permission
Date
Action
__pycache__
[ DIR ]
drwxr-xr-x
2026-06-08 18:08
addlhelp
[ DIR ]
drwxr-xr-x
2026-06-08 18:08
commands
[ DIR ]
drwxr-xr-x
2026-06-08 18:08
data
[ DIR ]
drwxr-xr-x
2026-06-08 18:07
tests
[ DIR ]
drwxr-xr-x
2026-06-08 18:08
third_party
[ DIR ]
drwxr-xr-x
2026-06-08 18:08
utils
[ DIR ]
drwxr-xr-x
2026-06-08 18:08
vendored
[ DIR ]
drwxr-xr-x
2026-06-08 18:08
README
378
B
-rw-r--r--
1980-01-01 08:00
__init__.py
6.3
KB
-rw-r--r--
1980-01-01 08:00
__main__.py
34.63
KB
-rw-r--r--
1980-01-01 08:00
boto_resumable_upload.py
24.69
KB
-rw-r--r--
1980-01-01 08:00
boto_translation.py
85.52
KB
-rw-r--r--
1980-01-01 08:00
bucket_listing_ref.py
3.9
KB
-rw-r--r--
1980-01-01 08:00
cloud_api.py
40.97
KB
-rw-r--r--
1980-01-01 08:00
cloud_api_delegator.py
29.87
KB
-rw-r--r--
1980-01-01 08:00
command.py
109.98
KB
-rw-r--r--
1980-01-01 08:00
command_argument.py
4.35
KB
-rw-r--r--
1980-01-01 08:00
command_runner.py
23.21
KB
-rw-r--r--
1980-01-01 08:00
context_config.py
8.36
KB
-rw-r--r--
1980-01-01 08:00
cred_types.py
1.15
KB
-rw-r--r--
1980-01-01 08:00
cs_api_map.py
3.31
KB
-rw-r--r--
1980-01-01 08:00
daisy_chain_wrapper.py
14.39
KB
-rw-r--r--
1980-01-01 08:00
devshell_auth_plugin.py
1.69
KB
-rw-r--r--
1980-01-01 08:00
discard_messages_queue.py
1.29
KB
-rw-r--r--
1980-01-01 08:00
exception.py
5.18
KB
-rw-r--r--
1980-01-01 08:00
file_part.py
3.39
KB
-rw-r--r--
1980-01-01 08:00
gcs_json_api.py
104.02
KB
-rw-r--r--
1980-01-01 08:00
gcs_json_credentials.py
20.31
KB
-rw-r--r--
1980-01-01 08:00
gcs_json_media.py
28.5
KB
-rw-r--r--
1980-01-01 08:00
help_provider.py
4.26
KB
-rw-r--r--
1980-01-01 08:00
iamcredentials_api.py
11.72
KB
-rw-r--r--
1980-01-01 08:00
impersonation_credentials.py
2.51
KB
-rw-r--r--
1980-01-01 08:00
kms_api.py
13.24
KB
-rw-r--r--
1980-01-01 08:00
lazy_wrapper.py
2.26
KB
-rw-r--r--
1980-01-01 08:00
metrics.py
38.98
KB
-rw-r--r--
1980-01-01 08:00
metrics_reporter.py
4.61
KB
-rw-r--r--
1980-01-01 08:00
metrics_tuple.py
1.44
KB
-rw-r--r--
1980-01-01 08:00
name_expansion.py
29.97
KB
-rw-r--r--
1980-01-01 08:00
no_op_auth_plugin.py
1.19
KB
-rw-r--r--
1980-01-01 08:00
no_op_credentials.py
1.03
KB
-rw-r--r--
1980-01-01 08:00
parallel_tracker_file.py
12.14
KB
-rw-r--r--
1980-01-01 08:00
plurality_checkable_iterator.py
4.4
KB
-rw-r--r--
1980-01-01 08:00
progress_callback.py
6.08
KB
-rw-r--r--
1980-01-01 08:00
project_id.py
1.69
KB
-rw-r--r--
1980-01-01 08:00
pubsub_api.py
11.17
KB
-rw-r--r--
1980-01-01 08:00
resumable_streaming_upload.py
8.53
KB
-rw-r--r--
1980-01-01 08:00
seek_ahead_thread.py
5.11
KB
-rw-r--r--
1980-01-01 08:00
sig_handling.py
5.64
KB
-rw-r--r--
1980-01-01 08:00
storage_uri_builder.py
2.02
KB
-rw-r--r--
1980-01-01 08:00
storage_url.py
16.16
KB
-rw-r--r--
1980-01-01 08:00
tab_complete.py
10.77
KB
-rw-r--r--
1980-01-01 08:00
thread_message.py
13.71
KB
-rw-r--r--
1980-01-01 08:00
tracker_file.py
24.23
KB
-rw-r--r--
1980-01-01 08:00
tz_utc.py
2.2
KB
-rw-r--r--
1980-01-01 08:00
ui_controller.py
47.42
KB
-rw-r--r--
1980-01-01 08:00
wildcard_iterator.py
37.73
KB
-rw-r--r--
1980-01-01 08:00
Save
Rename
# -*- coding: utf-8 -*- # Copyright 2020 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Manages device context mTLS certificates.""" from __future__ import absolute_import from __future__ import print_function from __future__ import division from __future__ import unicode_literals import atexit import json import os from boto import config import gslib from gslib import exception from gslib.utils import boto_util from gslib.utils import execution_util # Maintain a single context configuration. _singleton_config = None # Metadata JSON that stores information about the default certificate provider. _DEFAULT_METADATA_PATH = os.path.expanduser( os.path.join('~', '.secureConnect', 'context_aware_metadata.json')) _CERT_PROVIDER_COMMAND = "cert_provider_command" _CERT_PROVIDER_COMMAND_PASSPHRASE_OPTION = "--with_passphrase" class CertProvisionError(Exception): """Represents errors when provisioning a client certificate.""" pass class ContextConfigSingletonAlreadyExistsError(Exception): """Error for when create_context_config is called multiple times.""" pass def _is_pem_section_marker(line): """Returns (begin:bool, end:bool, name:str).""" if line.startswith('-----BEGIN ') and line.endswith('-----'): return True, False, line[11:-5] elif line.startswith('-----END ') and line.endswith('-----'): return False, True, line[9:-5] else: return False, False, '' def _split_pem_into_sections(contents, logger): """Returns dict with {name: section} by parsing contents in PEM format. A simple parser for PEM file. Please see RFC 7468 for the format of PEM file. Not using regex to improve performance catching nested matches. Note: This parser requires the post-encapsulation label of a section to match its pre-encapsulation label. It ignores a section without a matching label. Args: contents (str): Contents of a PEM file. logger (logging.logger): gsutil logger. Returns: A dict of the PEM file sections. """ result = {} pem_lines = [] pem_section_name = None for line in contents.splitlines(): line = line.strip() if not line: continue begin, end, name = _is_pem_section_marker(line) if begin: if pem_section_name: logger.warning('Section %s missing end line and will be ignored.' % pem_section_name) if name in result.keys(): logger.warning('Section %s already exists, and the older section will ' 'be ignored.' % name) pem_section_name = name pem_lines = [] elif end: if not pem_section_name: logger.warning( 'Section %s missing a beginning line and will be ignored.' % name) elif pem_section_name != name: logger.warning('Section %s missing a matching end line. Found: %s' % (pem_section_name, name)) pem_section_name = None if pem_section_name: pem_lines.append(line) if end: result[name] = '\n'.join(pem_lines) + '\n' pem_section_name = None if pem_section_name: logger.warning('Section %s missing an end line.' % pem_section_name) return result def _check_path(): """Checks for content aware metadata. If content aware metadata exists, return its absolute path; otherwise, returns None. Returns: str: Absolute path if exists. Otherwise, None. """ metadata_path = os.path.expanduser(_DEFAULT_METADATA_PATH) if not os.path.exists(metadata_path): return None return metadata_path def _read_metadata_file(metadata_path): """Loads context aware metadata from the given path. Returns: dict: The metadata JSON. Raises: CertProvisionError: If failed to parse metadata as JSON. """ try: with open(metadata_path) as f: return json.load(f) except ValueError as e: raise CertProvisionError(e) def _default_command(): """Loads default cert provider command. Returns: str: The default command. Raises: CertProvisionError: If command cannot be found. """ metadata_path = _check_path() if not metadata_path: raise CertProvisionError("Client certificate provider file not found.") metadata_json = _read_metadata_file(metadata_path) if _CERT_PROVIDER_COMMAND not in metadata_json: raise CertProvisionError("Client certificate provider command not found.") command = metadata_json[_CERT_PROVIDER_COMMAND] if (_CERT_PROVIDER_COMMAND_PASSPHRASE_OPTION not in command): command.append(_CERT_PROVIDER_COMMAND_PASSPHRASE_OPTION) return command class _ContextConfig(object): """Represents the configurations associated with context aware access. Only one instance of Config can be created for the program. """ def __init__(self, logger): """Initializes config. Args: logger (logging.logger): gsutil logger. """ self.logger = logger self.use_client_certificate = config.getbool('Credentials', 'use_client_certificate') self.client_cert_path = None if not self.use_client_certificate: # Don't spend time generating values gsutil won't need. return # Generates certificate and deletes it afterwards. atexit.register(self._unprovision_client_cert) self.client_cert_path = os.path.join(boto_util.GetGsutilStateDir(), 'caa_cert.pem') try: # Certs provisioned using endpoint verification are stored as a # single file holding both the public certificate and the private key. self._provision_client_cert(self.client_cert_path) except CertProvisionError as e: self.logger.error('Failed to provision client certificate: %s' % e) def _provision_client_cert(self, cert_path): """Executes certificate provider to obtain client certificate and keys.""" cert_command_string = config.get('Credentials', 'cert_provider_command', None) if cert_command_string: cert_command = cert_command_string.split(' ') else: # Load the default certificate provider if sit is not provided by user. cert_command = _default_command() try: command_stdout_string, _ = execution_util.ExecuteExternalCommand( cert_command) sections = _split_pem_into_sections(command_stdout_string, self.logger) with open(cert_path, 'w+') as f: f.write(sections['CERTIFICATE']) if 'ENCRYPTED PRIVATE KEY' in sections: f.write(sections['ENCRYPTED PRIVATE KEY']) self.client_cert_password = sections['PASSPHRASE'].splitlines()[1] else: f.write(sections['PRIVATE KEY']) self.client_cert_password = None except (exception.ExternalBinaryError, OSError) as e: raise CertProvisionError(e) except KeyError as e: raise CertProvisionError( 'Invalid output format from certificate provider, no %s' % e) def _unprovision_client_cert(self): """Cleans up any files or resources provisioned during config init.""" if self.client_cert_path is not None: try: os.remove(self.client_cert_path) self.logger.debug('Unprovisioned client cert: %s' % self.client_cert_path) except OSError as e: self.logger.error('Failed to remove client certificate: %s' % e) def create_context_config(logger): """Should be run once at gsutil startup. Creates global singleton. Args: logger (logging.logger): For logging during config functions. Returns: New ContextConfig singleton. Raises: Exception if singleton already exists. """ global _singleton_config if not _singleton_config: _singleton_config = _ContextConfig(logger) return _singleton_config raise ContextConfigSingletonAlreadyExistsError def get_context_config(): """Retrieves ContextConfig global singleton. Returns: ContextConfig or None if global singleton doesn't exist. """ return _singleton_config