xref: /illumos-gate/usr/src/cmd/bnu/uuglist.c (revision 3b296559)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
22462be471Sceastha /*
23d7c57852SGary Mills  * Copyright 2017 Gary Mills
24462be471Sceastha  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
25462be471Sceastha  * Use is subject to license terms.
26462be471Sceastha  */
27462be471Sceastha 
287c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
297c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #include	"uucp.h"
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate #define MAXLENGTH 256
357c478bd9Sstevel@tonic-gate #define C_MAX	  512
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate static void insert();
387c478bd9Sstevel@tonic-gate void rproc(), uproc();
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate static char  Nnament[MAXLENGTH][NAMESIZE];
417c478bd9Sstevel@tonic-gate static char *Nptr[MAXLENGTH];
427c478bd9Sstevel@tonic-gate static short Nnames = 0;
437c478bd9Sstevel@tonic-gate 
44462be471Sceastha int
main(argc,argv)457c478bd9Sstevel@tonic-gate main(argc, argv)
467c478bd9Sstevel@tonic-gate int argc;
477c478bd9Sstevel@tonic-gate char **argv;
487c478bd9Sstevel@tonic-gate {
497c478bd9Sstevel@tonic-gate 	int c, i, uopt = 0;
507c478bd9Sstevel@tonic-gate 	char prev[2 * NAMESIZE];
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate 	if (eaccess(GRADES, 04) == -1) {
537c478bd9Sstevel@tonic-gate 		(void) fprintf(stderr, "No administrator defined service grades available on this machine, use single letter/number only\n");
547c478bd9Sstevel@tonic-gate 		exit(0);
557c478bd9Sstevel@tonic-gate 	}
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate 	while ((c = getopt(argc, argv, "x:u")) != EOF)
587c478bd9Sstevel@tonic-gate 		switch(c) {
597c478bd9Sstevel@tonic-gate 		case 'u':
607c478bd9Sstevel@tonic-gate 			uopt++;
617c478bd9Sstevel@tonic-gate 			break;
627c478bd9Sstevel@tonic-gate 		case 'x':
637c478bd9Sstevel@tonic-gate 			Debug = atoi(optarg);
647c478bd9Sstevel@tonic-gate 			if (Debug < 0)
657c478bd9Sstevel@tonic-gate 				Debug = 1;
667c478bd9Sstevel@tonic-gate 			break;
677c478bd9Sstevel@tonic-gate 		default:
687c478bd9Sstevel@tonic-gate 			(void) fprintf(stderr, "usage: uuglist [-u] [-xLEVEL]\n");
697c478bd9Sstevel@tonic-gate 			exit(-1);
707c478bd9Sstevel@tonic-gate 		}
717c478bd9Sstevel@tonic-gate 
727c478bd9Sstevel@tonic-gate 	if (uopt) {
737c478bd9Sstevel@tonic-gate 		Uid = getuid();
747c478bd9Sstevel@tonic-gate 
757c478bd9Sstevel@tonic-gate 		if (Uid == 0)
767c478bd9Sstevel@tonic-gate 			(void) setuid(UUCPUID);
777c478bd9Sstevel@tonic-gate 
787c478bd9Sstevel@tonic-gate 		(void) guinfo(Uid, User);
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate 		uproc();
817c478bd9Sstevel@tonic-gate 	} else
827c478bd9Sstevel@tonic-gate 		rproc();
837c478bd9Sstevel@tonic-gate 
847c478bd9Sstevel@tonic-gate 	for (i = 0; i < Nnames; i++) {
857c478bd9Sstevel@tonic-gate 
867c478bd9Sstevel@tonic-gate 		if (EQUALS(Nptr[i], prev))
877c478bd9Sstevel@tonic-gate 			continue;
887c478bd9Sstevel@tonic-gate 
897c478bd9Sstevel@tonic-gate 		puts(Nptr[i]);
907c478bd9Sstevel@tonic-gate 		(void) strcpy(prev, Nptr[i]);
917c478bd9Sstevel@tonic-gate 	}
92462be471Sceastha 	return (0);
937c478bd9Sstevel@tonic-gate }
947c478bd9Sstevel@tonic-gate static void
insert(name)957c478bd9Sstevel@tonic-gate insert(name)
967c478bd9Sstevel@tonic-gate char *name;
977c478bd9Sstevel@tonic-gate {
98462be471Sceastha 	int i,j;
99462be471Sceastha 	char *p;
1007c478bd9Sstevel@tonic-gate 
1017c478bd9Sstevel@tonic-gate 	DEBUG(7, "insert(%s) ", name);
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate 	for (i = Nnames; i > 0; i--)
1047c478bd9Sstevel@tonic-gate 		if (strcmp(name, Nptr[i-1]) > 0)
1057c478bd9Sstevel@tonic-gate 			break;
1067c478bd9Sstevel@tonic-gate 
1077c478bd9Sstevel@tonic-gate 	if (i == MAXLENGTH)
1087c478bd9Sstevel@tonic-gate 		return;
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate 	if (Nnames == MAXLENGTH)
1117c478bd9Sstevel@tonic-gate 		p = strcpy(Nptr[--Nnames], name);
1127c478bd9Sstevel@tonic-gate 	else
1137c478bd9Sstevel@tonic-gate 		p = strcpy(Nnament[Nnames], name);
1147c478bd9Sstevel@tonic-gate 
1157c478bd9Sstevel@tonic-gate 	for (j = Nnames; j > i; j--)
1167c478bd9Sstevel@tonic-gate 		Nptr[j] = Nptr[j-1];
1177c478bd9Sstevel@tonic-gate 
1187c478bd9Sstevel@tonic-gate 	DEBUG(7, "insert %s ", p);
1197c478bd9Sstevel@tonic-gate 	DEBUG(7, "at %d\n", i);
1207c478bd9Sstevel@tonic-gate 	Nptr[i] = p;
1217c478bd9Sstevel@tonic-gate 	Nnames++;
1227c478bd9Sstevel@tonic-gate 	return;
1237c478bd9Sstevel@tonic-gate }
1247c478bd9Sstevel@tonic-gate 
1257c478bd9Sstevel@tonic-gate void
rproc()1267c478bd9Sstevel@tonic-gate rproc()
1277c478bd9Sstevel@tonic-gate {
1287c478bd9Sstevel@tonic-gate 	FILE *cfd;
1297c478bd9Sstevel@tonic-gate 	char line[BUFSIZ];
1307c478bd9Sstevel@tonic-gate 	char *carray[C_MAX];
1317c478bd9Sstevel@tonic-gate 
1327c478bd9Sstevel@tonic-gate 	cfd = fopen(GRADES, "r");
1337c478bd9Sstevel@tonic-gate 
1347c478bd9Sstevel@tonic-gate 	while (rdfulline(cfd, line, BUFSIZ) != 0) {
1357c478bd9Sstevel@tonic-gate 
136d7c57852SGary Mills 		(void) getargs(line, carray, C_MAX);
1377c478bd9Sstevel@tonic-gate 		insert(carray[0]);
1387c478bd9Sstevel@tonic-gate 	}
1397c478bd9Sstevel@tonic-gate 
1407c478bd9Sstevel@tonic-gate 	(void) fclose(cfd);
1417c478bd9Sstevel@tonic-gate 	return;
1427c478bd9Sstevel@tonic-gate }
1437c478bd9Sstevel@tonic-gate 
1447c478bd9Sstevel@tonic-gate void
uproc()1457c478bd9Sstevel@tonic-gate uproc()
1467c478bd9Sstevel@tonic-gate {
1477c478bd9Sstevel@tonic-gate 	FILE *cfd;
1487c478bd9Sstevel@tonic-gate 	char line[BUFSIZ];
1497c478bd9Sstevel@tonic-gate 	char *carray[C_MAX];
1507c478bd9Sstevel@tonic-gate 	int na;
1517c478bd9Sstevel@tonic-gate 
1527c478bd9Sstevel@tonic-gate 	cfd = fopen(GRADES, "r");
1537c478bd9Sstevel@tonic-gate 
1547c478bd9Sstevel@tonic-gate 	while (rdfulline(cfd, line, BUFSIZ) != 0) {
1557c478bd9Sstevel@tonic-gate 
1567c478bd9Sstevel@tonic-gate 		na = getargs(line, carray, C_MAX);
15755fea89dSDan Cross 
1587c478bd9Sstevel@tonic-gate 		if (upermit(carray, na) != FAIL)
1597c478bd9Sstevel@tonic-gate 			insert(carray[0]);
1607c478bd9Sstevel@tonic-gate 	}
1617c478bd9Sstevel@tonic-gate 
1627c478bd9Sstevel@tonic-gate 	(void) fclose(cfd);
1637c478bd9Sstevel@tonic-gate 	return;
1647c478bd9Sstevel@tonic-gate }
1657c478bd9Sstevel@tonic-gate 
1667c478bd9Sstevel@tonic-gate int Dfileused = FALSE;
wfcommit()167462be471Sceastha void wfcommit() {}
cleanup()1687c478bd9Sstevel@tonic-gate void cleanup() {}
gnamef()169462be471Sceastha int gnamef() { return (0); }
gdirf()170462be471Sceastha int gdirf() { return (0); }
cklock()171462be471Sceastha int cklock() { return (0); }
1727c478bd9Sstevel@tonic-gate 
1737c478bd9Sstevel@tonic-gate /*VARARGS*/
1747c478bd9Sstevel@tonic-gate /*ARGSUSED*/
1757c478bd9Sstevel@tonic-gate void
assert(s1,s2,i1,s3,i2)1767c478bd9Sstevel@tonic-gate assert (s1, s2, i1, s3, i2)
1777c478bd9Sstevel@tonic-gate char *s1, *s2, *s3;
1787c478bd9Sstevel@tonic-gate int i1, i2;
1797c478bd9Sstevel@tonic-gate { }		/* for ASSERT in gnamef.c */
1807c478bd9Sstevel@tonic-gate 
1817c478bd9Sstevel@tonic-gate /*VARARGS*/
1827c478bd9Sstevel@tonic-gate /*ARGSUSED*/
1837c478bd9Sstevel@tonic-gate void
errent(char * s1,char * s2,int i1,char * file,int line)184*3b296559SToomas Soome errent(char *s1, char *s2, int i1, char *file, int line)
185*3b296559SToomas Soome {
186*3b296559SToomas Soome }
187