# Authors: Simo Sorce <ssorce@redhat.com>
# Alexander Bokovoy <abokovoy@redhat.com>
# Tomas Babej <tbabej@redhat.com>
#
# Copyright (C) 2007-2014 Red Hat
# see file 'COPYING' for use and warranty information
#
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
""" Authconfig Module """
import os
"""
AuthConfig class implements a system-independent interface to configure
system authentication resources. In Red Hat systems this is done with
authconfig(8) utility.
AuthConfig class is nothing more than a tool to gather configuration
options and execute their processing. These options are then converted by
an actual implementation to a series of system calls to appropriate
utilities performing real configuration.
If you need to re-use existing AuthConfig instance for multiple runs,
make sure to call 'AuthConfig.reset()' between the runs.
"""
""" Initialize host
:param str host: hostname
"""
self.parameters = {}
"""
Option to be passed to authconfig
:param str option: authconfig options
"""
return self
"""
Disable options
:param str option: authconfig options
"""
return self
"""
Add option
:param str option: authconfig options
"""
return self
"""
Add parameters
:param str option: authconfig options
:param str values: values
"""
return self
"""
Reset to the default
"""
self.parameters = {}
return self
"""
Build argument list from options provided
"""
args = []
if value:
else:
elif value is None:
else:
return args
""" Execute authconfig command """
if update:
raise Exception("Failed to run Authconfig")
""" Backup existing authconfig options
:param str path: path where existing files are backed
"""
raise Exception("Unable to save backup")
# do not backup these files since we don't want to mess with
# having them deleted from backup dir
for filename in files_to_remove:
try:
except CalledProcessError:
pass
""" Restore from backup
:param str path: backup path
"""