1*00277c9eSGary Mills /* 2*00277c9eSGary Mills * CDDL HEADER START 3*00277c9eSGary Mills * 4*00277c9eSGary Mills * The contents of this file are subject to the terms of the 5*00277c9eSGary Mills * Common Development and Distribution License (the "License"). 6*00277c9eSGary Mills * You may not use this file except in compliance with the License. 7*00277c9eSGary Mills * 8*00277c9eSGary Mills * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*00277c9eSGary Mills * or http://www.opensolaris.org/os/licensing. 10*00277c9eSGary Mills * See the License for the specific language governing permissions 11*00277c9eSGary Mills * and limitations under the License. 12*00277c9eSGary Mills * 13*00277c9eSGary Mills * When distributing Covered Code, include this CDDL HEADER in each 14*00277c9eSGary Mills * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*00277c9eSGary Mills * If applicable, add the following below this CDDL HEADER, with the 16*00277c9eSGary Mills * fields enclosed by brackets "[]" replaced with your own identifying 17*00277c9eSGary Mills * information: Portions Copyright [yyyy] [name of copyright owner] 18*00277c9eSGary Mills * 19*00277c9eSGary Mills * CDDL HEADER END 20*00277c9eSGary Mills */ 21*00277c9eSGary Mills 22*00277c9eSGary Mills /* 23*00277c9eSGary Mills * Copyright (c) 2014 Gary Mills 24*00277c9eSGary Mills * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 25*00277c9eSGary Mills * Copyright 2012 Nexenta Systems, Inc. All rights reserved. 26*00277c9eSGary Mills * Use is subject to license terms. 27*00277c9eSGary Mills */ 28*00277c9eSGary Mills 29*00277c9eSGary Mills #include <stdio.h> 30*00277c9eSGary Mills #include <shadow.h> 31*00277c9eSGary Mills #include <stdlib.h> 32*00277c9eSGary Mills #include <errno.h> 33*00277c9eSGary Mills #include "getent.h" 34*00277c9eSGary Mills 35*00277c9eSGary Mills /* 36*00277c9eSGary Mills * getspnam - get entries from shadow database 37*00277c9eSGary Mills */ 38*00277c9eSGary Mills int 39*00277c9eSGary Mills dogetsp(const char **list) 40*00277c9eSGary Mills { 41*00277c9eSGary Mills struct spwd *sp; 42*00277c9eSGary Mills int rc = EXC_SUCCESS; 43*00277c9eSGary Mills char *ptr; 44*00277c9eSGary Mills uid_t uid; 45*00277c9eSGary Mills 46*00277c9eSGary Mills 47*00277c9eSGary Mills if (list == NULL || *list == NULL) { 48*00277c9eSGary Mills setspent(); 49*00277c9eSGary Mills while ((sp = getspent()) != NULL) 50*00277c9eSGary Mills (void) putspent(sp, stdout); 51*00277c9eSGary Mills endspent(); 52*00277c9eSGary Mills } else { 53*00277c9eSGary Mills for (; *list != NULL; list++) { 54*00277c9eSGary Mills sp = getspnam(*list); 55*00277c9eSGary Mills if (sp == NULL) 56*00277c9eSGary Mills rc = EXC_NAME_NOT_FOUND; 57*00277c9eSGary Mills else 58*00277c9eSGary Mills (void) putspent(sp, stdout); 59*00277c9eSGary Mills } 60*00277c9eSGary Mills } 61*00277c9eSGary Mills 62*00277c9eSGary Mills return (rc); 63*00277c9eSGary Mills } 64