# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
#
"""Name Service Switch classes used by nscfg."""
"""Name Service Switch class. Represents the configuration
of the name service switch. See nsswitch.conf(4) for details."""
# This class only supports the nsswitch_config property group
# The Nssfiles class supports the files_config property group
'host': 'astring',
'password': 'astring',
'group': 'astring',
'network': 'astring',
'protocol': 'astring',
'rpc': 'astring',
'ether': 'astring',
'netmask': 'astring',
'bootparam': 'astring',
'publickey': 'astring',
'netgroup': 'astring',
'automount': 'astring',
'alias': 'astring',
'service': 'astring',
'printer': 'astring',
'project': 'astring',
'auth_attr': 'astring',
'prof_attr': 'astring',
'tnrhtp': 'astring',
'tnrhdb': 'astring',
'sudoer': 'astring',
'enable_passwd_compat': 'boolean',
'enable_group_compat': 'boolean', }
# nsswitch.conf order is not important, but administrators
# historically tend to expect it in this specific order.
'protocols', 'rpc', 'ethers', 'netmasks', 'bootparams',
'publickey', 'netgroup', 'automount', 'aliases',
'services', 'printers', 'project', 'auth_attr',
'prof_attr', 'tnrhtp', 'tnrhdb', 'sudoers',)
UNCPROP = (
( 'default', 'astring', 'files' ),
( 'printer', 'astring', 'user files' ),
)
"""Export from SMF. Re-generate nsswitch.conf file"""
# Map SMF properties to DB
db = {}
if k == 'passwd' and pwd_config:
elif k == 'group' and grp_config:
else:
# Save to temp file, with header
return ret
"""Import to SMF. Configure SMF from nsswitch.conf file.
The default props are always reset."""
db = []
pwd_val = None
grp_val = None
if lines == None: # defaults always exist
lines = []
for l in lines:
continue
if idx > 0:
l = l[:idx]
l = l[:-1]
if l == '': # Skip enpty lines
continue
continue
try:
continue # Not a valid DB key
if key == 'ipnodes':
continue # use 'hosts' not 'ipnodes'
continue
continue
if pwd_config == False:
continue # ignore (actually error)
if grp_config == False:
continue # ignore (actually error)
else:
if map == 'password':
if map == 'group':
except:
continue
# Backwards compatibility checks
# Check and adjust for passwd: compat w/ no passwd_compat line.
if pwd_config and pwd_val == None:
map = 'password'
if grp_config and grp_val == None:
map = 'group'
# Exit before write processing
# Commit the property group
continue # Skip over default 'files'
# Commit the property group
# validate
"""Unconfigure SMF. Reset DEFPG."""
# Commit the property group