CEPH_DEFAULT_PUBKEY = f'/etc/ceph/{CEPH_PUBKEY}'
LOG_DIR_MODE = 0o770
DATA_DIR_MODE = 0o700
+DEFAULT_MODE = 0o600
CONTAINER_INIT = True
MIN_PODMAN_VERSION = (2, 0, 2)
CGROUPS_SPLIT_PODMAN_VERSION = (2, 1, 0)
def create_daemon_conf(self) -> None:
"""Creates the environment file holding 'secrets' passed to the snmp-notifier daemon"""
- with write_new(self.conf_file_path, perms=0o600) as f:
+ with write_new(self.conf_file_path) as f:
if self.snmp_version == 'V2c':
f.write(f'SNMP_NOTIFIER_COMMUNITY={self.snmp_community}\n')
else:
destination: Union[str, Path],
*,
owner: Optional[Tuple[int, int]] = None,
- perms: Optional[int] = None,
+ perms: Optional[int] = DEFAULT_MODE,
encoding: Optional[str] = None,
) -> Generator[IO, None, None]:
"""Write a new file in a robust manner, optionally specifying the owner,
config_file = os.path.join(config_dir, fname)
config_content = dict_get_join(config_files, fname)
logger.info('Write file: %s' % (config_file))
- with write_new(config_file, owner=(uid, gid), perms=0o600, encoding='utf-8') as f:
+ with write_new(config_file, owner=(uid, gid), encoding='utf-8') as f:
f.write(config_content)
# write the RGW keyring
if self.rgw:
keyring_path = os.path.join(data_dir, 'keyring.rgw')
- with write_new(keyring_path, owner=(uid, gid), perms=0o600) as f:
+ with write_new(keyring_path, owner=(uid, gid)) as f:
f.write(self.rgw.get('keyring', ''))
##################################
logger.info('Creating file: {}'.format(file_path))
content = dict_get_join(self.files, file_path)
file_path = os.path.join(data_dir, file_path.strip('/'))
- with write_new(file_path, owner=(uid, gid), perms=0o600, encoding='utf-8') as f:
+ with write_new(file_path, owner=(uid, gid), encoding='utf-8') as f:
f.write(content)
def get_daemon_args(self) -> List[str]:
if config:
config_path = os.path.join(data_dir, 'config')
- with write_new(config_path, owner=(uid, gid), perms=0o600) as f:
+ with write_new(config_path, owner=(uid, gid)) as f:
f.write(config)
if keyring:
keyring_path = os.path.join(data_dir, 'keyring')
- with write_new(keyring_path, owner=(uid, gid), perms=0o600) as f:
+ with write_new(keyring_path, owner=(uid, gid)) as f:
f.write(keyring)
if daemon_type in Monitoring.components.keys():
fpath = os.path.join(data_dir_root, fname.lstrip(os.path.sep))
else:
fpath = os.path.join(data_dir_root, config_dir, fname)
- with write_new(fpath, owner=(uid, gid), perms=0o600, encoding='utf-8') as f:
+ with write_new(fpath, owner=(uid, gid), encoding='utf-8') as f:
f.write(content)
elif daemon_type == NFSGanesha.daemon_type:
for ccf in config_json['custom_config_files']:
if all(k in ccf for k in mandatory_keys):
file_path = os.path.join(custom_config_dir, os.path.basename(ccf['mount_path']))
- with write_new(file_path, owner=(uid, gid), perms=0o600, encoding='utf-8') as f:
+ with write_new(file_path, owner=(uid, gid), encoding='utf-8') as f:
f.write(ccf['content'])
).run()
# write conf
- with write_new(mon_dir + '/config', owner=(uid, gid), perms=0o600) as f:
+ with write_new(mon_dir + '/config', owner=(uid, gid)) as f:
f.write(config)
else:
# dirs, conf, keyring
raise RuntimeError('attempting to deploy a daemon without a container image')
if not os.path.exists(data_dir + '/unit.created'):
- with write_new(data_dir + '/unit.created', owner=(uid, gid), perms=0o600) as f:
+ with write_new(data_dir + '/unit.created', owner=(uid, gid)) as f:
f.write('mtime is time the daemon deployment was created\n')
- with write_new(data_dir + '/unit.configured', owner=(uid, gid), perms=0o600) as f:
+ with write_new(data_dir + '/unit.configured', owner=(uid, gid)) as f:
f.write('mtime is time we were last configured\n')
update_firewalld(ctx, daemon_type)
data_dir = get_data_dir(fsid, ctx.data_dir, daemon_type, daemon_id)
run_file_path = data_dir + '/unit.run'
meta_file_path = data_dir + '/unit.meta'
- with write_new(run_file_path, perms=0o600) as f, \
- write_new(meta_file_path, perms=0o600) as metaf:
+ with write_new(run_file_path) as f, write_new(meta_file_path) as metaf:
f.write('set -e\n')
timeout = 30 if daemon_type == 'osd' else None
# post-stop command(s)
- with write_new(data_dir + '/unit.poststop', perms=0o600) as f:
+ with write_new(data_dir + '/unit.poststop') as f:
# this is a fallback to eventually stop any underlying container that was not stopped properly by unit.stop,
# this could happen in very slow setups as described in the issue https://tracker.ceph.com/issues/58242.
add_stop_actions(cast(TextIO, f), timeout)
f.write(' '.join(CephIscsi.configfs_mount_umount(data_dir, mount=False)) + '\n')
# post-stop command(s)
- with write_new(data_dir + '/unit.stop', perms=0o600) as f:
+ with write_new(data_dir + '/unit.stop') as f:
add_stop_actions(cast(TextIO, f), timeout)
if c:
- with write_new(data_dir + '/unit.image', perms=0o600) as f:
+ with write_new(data_dir + '/unit.image') as f:
f.write(c.image + '\n')
# sysctl
for filename in config:
if filename in self.agent.required_files:
file_path = os.path.join(self.agent.daemon_dir, filename)
- with write_new(file_path, perms=0o600) as f:
+ with write_new(file_path) as f:
f.write(config[filename])
self.agent.pull_conf_settings()
self.agent.wakeup()
for filename in config:
if filename in self.required_files:
file_path = os.path.join(self.daemon_dir, filename)
- with write_new(file_path, perms=0o600) as f:
+ with write_new(file_path) as f:
f.write(config[filename])
unit_run_path = os.path.join(self.daemon_dir, 'unit.run')
- with write_new(unit_run_path, perms=0o600) as f:
+ with write_new(unit_run_path) as f:
f.write(self.unit_run())
meta: Dict[str, Any] = {}
meta_file_path = os.path.join(self.daemon_dir, 'unit.meta')
if 'meta_json' in self.ctx and self.ctx.meta_json:
meta = json.loads(self.ctx.meta_json) or {}
- with write_new(meta_file_path, perms=0o600) as f:
+ with write_new(meta_file_path) as f:
f.write(json.dumps(meta, indent=4) + '\n')
unit_file_path = os.path.join(self.ctx.unit_dir, self.unit_name())
- with write_new(unit_file_path, perms=0o600) as f:
+ with write_new(unit_file_path) as f:
f.write(self.unit_file())
call_throws(self.ctx, ['systemctl', 'daemon-reload'])
(mon_dir, log_dir) = prepare_create_mon(ctx, uid, gid, fsid, mon_id,
bootstrap_keyring.name, monmap.name)
- with write_new(mon_dir + '/config', owner=(uid, gid), perms=0o600) as f:
+ with write_new(mon_dir + '/config', owner=(uid, gid)) as f:
f.write(config)
make_var_run(ctx, fsid, uid, gid)
cluster_network, ipv6_cluster_network)
# output files
- with write_new(ctx.output_keyring, perms=0o600) as f:
+ with write_new(ctx.output_keyring) as f:
f.write('[client.admin]\n'
'\tkey = ' + admin_key + '\n')
logger.info('Wrote keyring to %s' % ctx.output_keyring)