#
# Module for simulation of utility "id" from coreutils
#
# Copyright (c) 2015 Red Hat, Inc.
# Author: Lukas Slebodnik <lslebodn@redhat.com>
#
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 only
#
# 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/>.
#
import config
import pwd
import grp
""" 'enum' class for name service switch return code """
"""
Function will initialize the supplementary group access list
for given user. It will gather groups only provided by sssd.
Arguments are the same as for C function initgroups
@param string user name of user
@param int gid the additional gid will be also added to the list.
@return (int, int, List[int]) (err, errno, gids)
gids should contain user group IDs if err is NssReturnCode.SUCCESS
otherwise errno will contain non-zero value.
"""
gids = []
"one gid"
# add primary group if missing
"""
Function will initialize the supplementary group access list
for given user. It will gather groups only provided by sssd.
Arguments are the same as for C function initgroups
@param string user name of user
@return (int, int, List[int]) (err, errno, gids)
gids should contain user group IDs if err is NssReturnCode.SUCCESS
otherwise errno will contain non-zero value.
"""
"""
Function will map numeric GID into names.
If there isn't a group for GID (getgrgid failed)
then the function will return decimal representation of ID.
@param int gid ID of groups which should be converted to string.
@return string name of group with requested ID or decimal
representation of ID
"""
try:
except KeyError:
"""
Function will initialize the supplementary group access list
for given user. It will gather groups only provided by sssd.
Arguments are the same as for C function initgroups
@param string user name of user
@return (int, int, List[string]) (err, errno, groups)
groups should contain names of user groups
if err is NssReturnCode.SUCCESS
otherwise errno will contain non-zero value.
"""
groups = []