#
# Module for simulation of utility "getent passwd -s sss" from coreutils
#
# Copyright (c) 2016 Red Hat, Inc.
#
# 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/>.
#
("pw_passwd", c_char_p),
("pw_uid", c_int),
("pw_gid", c_int),
("pw_gecos", c_char_p),
("pw_dir", c_char_p),
("pw_shell", c_char_p)]
return dict()
return user_dict
"""
ctypes wrapper for:
enum nss_status _nss_sss_getpwnam_r(const char *name,
struct passwd *result,
char *buffer,
size_t buflen,
int *errnop)
"""
"""
ctypes wrapper for:
enum nss_status _nss_sss_getpwuid_r(uid_t uid,
struct passwd *result,
char *buffer,
size_t buflen,
int *errnop)
"""
def setpwent():
"""
ctypes wrapper for:
void setpwent(void)
"""
if errno != 0:
def endpwent():
"""
ctypes wrapper for:
void endpwent(void)
"""
if errno != 0:
"""
ctypes wrapper for:
enum nss_status _nss_sss_getpwent_r(struct passwd *result,
char *buffer, size_t buflen,
int *errnop)
"""
def getpwent():
if errno != 0:
"""
A Python wrapper to retrieve a user by name. Returns:
(res, user_dict)
if res is NssReturnCode.SUCCESS, then user_dict contains the keys
corresponding to the C passwd structure fields. Otherwise, the dictionary
is empty and errno indicates the error code
"""
if errno != 0:
"""
A Python wrapper to retrieve a user by UID. Returns:
(res, user_dict)
if res is NssReturnCode.SUCCESS, then user_dict contains the keys
corresponding to the C passwd structure fields. Otherwise, the dictionary
is empty and errno indicates the error code
"""
if errno != 0:
def call_sssd_enumeration():
"""
enumerate users from sssd module only
"""
setpwent()
user_list = []
endpwent()
return user_list