100277c9eSGary Mills /* 200277c9eSGary Mills * CDDL HEADER START 300277c9eSGary Mills * 400277c9eSGary Mills * The contents of this file are subject to the terms of the 500277c9eSGary Mills * Common Development and Distribution License (the "License"). 600277c9eSGary Mills * You may not use this file except in compliance with the License. 700277c9eSGary Mills * 800277c9eSGary Mills * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 900277c9eSGary Mills * or http://www.opensolaris.org/os/licensing. 1000277c9eSGary Mills * See the License for the specific language governing permissions 1100277c9eSGary Mills * and limitations under the License. 1200277c9eSGary Mills * 1300277c9eSGary Mills * When distributing Covered Code, include this CDDL HEADER in each 1400277c9eSGary Mills * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 1500277c9eSGary Mills * If applicable, add the following below this CDDL HEADER, with the 1600277c9eSGary Mills * fields enclosed by brackets "[]" replaced with your own identifying 1700277c9eSGary Mills * information: Portions Copyright [yyyy] [name of copyright owner] 1800277c9eSGary Mills * 1900277c9eSGary Mills * CDDL HEADER END 2000277c9eSGary Mills */ 2100277c9eSGary Mills 2200277c9eSGary Mills /* 23*2c5ec7a8SPeter Tribble * Copyright (c) 2018 Peter Tribble. 2400277c9eSGary Mills * Copyright (c) 2014 Gary Mills 2500277c9eSGary Mills * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 2600277c9eSGary Mills * Copyright 2012 Nexenta Systems, Inc. All rights reserved. 2700277c9eSGary Mills * Use is subject to license terms. 2800277c9eSGary Mills */ 2900277c9eSGary Mills 3000277c9eSGary Mills #include <stdio.h> 3100277c9eSGary Mills #include <shadow.h> 3200277c9eSGary Mills #include <stdlib.h> 3300277c9eSGary Mills #include <errno.h> 3400277c9eSGary Mills #include "getent.h" 3500277c9eSGary Mills 3600277c9eSGary Mills /* 3700277c9eSGary Mills * getspnam - get entries from shadow database 3800277c9eSGary Mills */ 3900277c9eSGary Mills int dogetsp(const char ** list)4000277c9eSGary Millsdogetsp(const char **list) 4100277c9eSGary Mills { 4200277c9eSGary Mills struct spwd *sp; 4300277c9eSGary Mills int rc = EXC_SUCCESS; 4400277c9eSGary Mills 4500277c9eSGary Mills 4600277c9eSGary Mills if (list == NULL || *list == NULL) { 4700277c9eSGary Mills setspent(); 4800277c9eSGary Mills while ((sp = getspent()) != NULL) 4900277c9eSGary Mills (void) putspent(sp, stdout); 5000277c9eSGary Mills endspent(); 5100277c9eSGary Mills } else { 5200277c9eSGary Mills for (; *list != NULL; list++) { 5300277c9eSGary Mills sp = getspnam(*list); 5400277c9eSGary Mills if (sp == NULL) 5500277c9eSGary Mills rc = EXC_NAME_NOT_FOUND; 5600277c9eSGary Mills else 5700277c9eSGary Mills (void) putspent(sp, stdout); 5800277c9eSGary Mills } 5900277c9eSGary Mills } 6000277c9eSGary Mills 6100277c9eSGary Mills return (rc); 6200277c9eSGary Mills } 63