3 \�mev � @ sL d dl Z d dlZd dlZd dlmZmZ e je�ZG dd� dej j j�ZdS )� N)�subp�utilc @ sb e Zd ZdZdgZddd�Zdd� Zdd � Zedd �e e d�dd ��Z dd� Zdd� Zdd� Z dS )�Distroz/etc/mynameZrcctlNc C s t j| j�S )N)r Z load_file�hostname_conf_fn)�self�filename�default� r �/usr/lib/python3.6/openbsd.py�_read_hostname s zDistro._read_hostnamec C s |d }t j| j|� d S )N� )r Z write_filer )r Zhostnamer Zcontentr r r �_write_hostname s zDistro._write_hostnamec C s dd||gS )N�usermodz-Gr )r �member_nameZ group_namer r r �_get_add_member_to_group_cmd s z#Distro._get_add_member_to_group_cmd)�rcs)�action�servicec G s` | j }d|gd|gd|gd|gd|gd|gd|gd|gd�}t|�t|| � }tj|d|d �S ) z� Perform the requested action on a service. This handles OpenBSD's 'rcctl'. May raise ProcessExecutionError �stop�start�enable�disable�restartZcheck)r r r r r �reloadz try-reloadZstatusT)Zcapturer )�init_cmd�listr )�clsr r r Z extra_argsr Zcmds�cmdr r r �manage_service s zDistro.manage_servicec C s@ yt j ddd|g� W n$ tk r: tjtd|� � Y nX d S )Nr z-p�*zFailed to lock user %s)r � Exceptionr Zlogexc�LOG)r �namer r r �lock_passwd1 s zDistro.lock_passwdc C s d S )Nr )r r"