00277c9e43668ff248a12ee635ce125957750373Gary Mills/*
00277c9e43668ff248a12ee635ce125957750373Gary Mills * CDDL HEADER START
00277c9e43668ff248a12ee635ce125957750373Gary Mills *
00277c9e43668ff248a12ee635ce125957750373Gary Mills * The contents of this file are subject to the terms of the
00277c9e43668ff248a12ee635ce125957750373Gary Mills * Common Development and Distribution License (the "License").
00277c9e43668ff248a12ee635ce125957750373Gary Mills * You may not use this file except in compliance with the License.
00277c9e43668ff248a12ee635ce125957750373Gary Mills *
00277c9e43668ff248a12ee635ce125957750373Gary Mills * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
00277c9e43668ff248a12ee635ce125957750373Gary Mills * or http://www.opensolaris.org/os/licensing.
00277c9e43668ff248a12ee635ce125957750373Gary Mills * See the License for the specific language governing permissions
00277c9e43668ff248a12ee635ce125957750373Gary Mills * and limitations under the License.
00277c9e43668ff248a12ee635ce125957750373Gary Mills *
00277c9e43668ff248a12ee635ce125957750373Gary Mills * When distributing Covered Code, include this CDDL HEADER in each
00277c9e43668ff248a12ee635ce125957750373Gary Mills * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
00277c9e43668ff248a12ee635ce125957750373Gary Mills * If applicable, add the following below this CDDL HEADER, with the
00277c9e43668ff248a12ee635ce125957750373Gary Mills * fields enclosed by brackets "[]" replaced with your own identifying
00277c9e43668ff248a12ee635ce125957750373Gary Mills * information: Portions Copyright [yyyy] [name of copyright owner]
00277c9e43668ff248a12ee635ce125957750373Gary Mills *
00277c9e43668ff248a12ee635ce125957750373Gary Mills * CDDL HEADER END
00277c9e43668ff248a12ee635ce125957750373Gary Mills */
00277c9e43668ff248a12ee635ce125957750373Gary Mills
00277c9e43668ff248a12ee635ce125957750373Gary Mills/*
00277c9e43668ff248a12ee635ce125957750373Gary Mills * Copyright (c) 2014 Gary Mills
00277c9e43668ff248a12ee635ce125957750373Gary Mills * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
00277c9e43668ff248a12ee635ce125957750373Gary Mills * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
00277c9e43668ff248a12ee635ce125957750373Gary Mills * Use is subject to license terms.
00277c9e43668ff248a12ee635ce125957750373Gary Mills */
00277c9e43668ff248a12ee635ce125957750373Gary Mills
00277c9e43668ff248a12ee635ce125957750373Gary Mills#include <stdio.h>
00277c9e43668ff248a12ee635ce125957750373Gary Mills#include <shadow.h>
00277c9e43668ff248a12ee635ce125957750373Gary Mills#include <stdlib.h>
00277c9e43668ff248a12ee635ce125957750373Gary Mills#include <errno.h>
00277c9e43668ff248a12ee635ce125957750373Gary Mills#include "getent.h"
00277c9e43668ff248a12ee635ce125957750373Gary Mills
00277c9e43668ff248a12ee635ce125957750373Gary Mills/*
00277c9e43668ff248a12ee635ce125957750373Gary Mills * getspnam - get entries from shadow database
00277c9e43668ff248a12ee635ce125957750373Gary Mills */
00277c9e43668ff248a12ee635ce125957750373Gary Millsint
00277c9e43668ff248a12ee635ce125957750373Gary Millsdogetsp(const char **list)
00277c9e43668ff248a12ee635ce125957750373Gary Mills{
00277c9e43668ff248a12ee635ce125957750373Gary Mills struct spwd *sp;
00277c9e43668ff248a12ee635ce125957750373Gary Mills int rc = EXC_SUCCESS;
00277c9e43668ff248a12ee635ce125957750373Gary Mills char *ptr;
00277c9e43668ff248a12ee635ce125957750373Gary Mills uid_t uid;
00277c9e43668ff248a12ee635ce125957750373Gary Mills
00277c9e43668ff248a12ee635ce125957750373Gary Mills
00277c9e43668ff248a12ee635ce125957750373Gary Mills if (list == NULL || *list == NULL) {
00277c9e43668ff248a12ee635ce125957750373Gary Mills setspent();
00277c9e43668ff248a12ee635ce125957750373Gary Mills while ((sp = getspent()) != NULL)
00277c9e43668ff248a12ee635ce125957750373Gary Mills (void) putspent(sp, stdout);
00277c9e43668ff248a12ee635ce125957750373Gary Mills endspent();
00277c9e43668ff248a12ee635ce125957750373Gary Mills } else {
00277c9e43668ff248a12ee635ce125957750373Gary Mills for (; *list != NULL; list++) {
00277c9e43668ff248a12ee635ce125957750373Gary Mills sp = getspnam(*list);
00277c9e43668ff248a12ee635ce125957750373Gary Mills if (sp == NULL)
00277c9e43668ff248a12ee635ce125957750373Gary Mills rc = EXC_NAME_NOT_FOUND;
00277c9e43668ff248a12ee635ce125957750373Gary Mills else
00277c9e43668ff248a12ee635ce125957750373Gary Mills (void) putspent(sp, stdout);
00277c9e43668ff248a12ee635ce125957750373Gary Mills }
00277c9e43668ff248a12ee635ce125957750373Gary Mills }
00277c9e43668ff248a12ee635ce125957750373Gary Mills
00277c9e43668ff248a12ee635ce125957750373Gary Mills return (rc);
00277c9e43668ff248a12ee635ce125957750373Gary Mills}