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 */ 22*462be471Sceastha /* 23*462be471Sceastha * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*462be471Sceastha * Use is subject to license terms. 25*462be471Sceastha */ 26*462be471Sceastha 277c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 287c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate 31*462be471Sceastha #pragma ident "%Z%%M% %I% %E% SMI" 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #include "uucp.h" 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #define MAXLENGTH 256 367c478bd9Sstevel@tonic-gate #define C_MAX 512 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate static void insert(); 397c478bd9Sstevel@tonic-gate void rproc(), uproc(); 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate static char Nnament[MAXLENGTH][NAMESIZE]; 427c478bd9Sstevel@tonic-gate static char *Nptr[MAXLENGTH]; 437c478bd9Sstevel@tonic-gate static short Nnames = 0; 447c478bd9Sstevel@tonic-gate 45*462be471Sceastha int 467c478bd9Sstevel@tonic-gate main(argc, argv) 477c478bd9Sstevel@tonic-gate int argc; 487c478bd9Sstevel@tonic-gate char **argv; 497c478bd9Sstevel@tonic-gate { 507c478bd9Sstevel@tonic-gate int c, i, uopt = 0; 517c478bd9Sstevel@tonic-gate char prev[2 * NAMESIZE]; 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate if (eaccess(GRADES, 04) == -1) { 547c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "No administrator defined service grades available on this machine, use single letter/number only\n"); 557c478bd9Sstevel@tonic-gate exit(0); 567c478bd9Sstevel@tonic-gate } 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate while ((c = getopt(argc, argv, "x:u")) != EOF) 597c478bd9Sstevel@tonic-gate switch(c) { 607c478bd9Sstevel@tonic-gate case 'u': 617c478bd9Sstevel@tonic-gate uopt++; 627c478bd9Sstevel@tonic-gate break; 637c478bd9Sstevel@tonic-gate case 'x': 647c478bd9Sstevel@tonic-gate Debug = atoi(optarg); 657c478bd9Sstevel@tonic-gate if (Debug < 0) 667c478bd9Sstevel@tonic-gate Debug = 1; 677c478bd9Sstevel@tonic-gate break; 687c478bd9Sstevel@tonic-gate default: 697c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "usage: uuglist [-u] [-xLEVEL]\n"); 707c478bd9Sstevel@tonic-gate exit(-1); 717c478bd9Sstevel@tonic-gate } 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gate if (uopt) { 747c478bd9Sstevel@tonic-gate Uid = getuid(); 757c478bd9Sstevel@tonic-gate 767c478bd9Sstevel@tonic-gate if (Uid == 0) 777c478bd9Sstevel@tonic-gate (void) setuid(UUCPUID); 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate (void) guinfo(Uid, User); 807c478bd9Sstevel@tonic-gate 817c478bd9Sstevel@tonic-gate uproc(); 827c478bd9Sstevel@tonic-gate } else 837c478bd9Sstevel@tonic-gate rproc(); 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate for (i = 0; i < Nnames; i++) { 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gate if (EQUALS(Nptr[i], prev)) 887c478bd9Sstevel@tonic-gate continue; 897c478bd9Sstevel@tonic-gate 907c478bd9Sstevel@tonic-gate puts(Nptr[i]); 917c478bd9Sstevel@tonic-gate (void) strcpy(prev, Nptr[i]); 927c478bd9Sstevel@tonic-gate } 93*462be471Sceastha return (0); 947c478bd9Sstevel@tonic-gate } 957c478bd9Sstevel@tonic-gate static void 967c478bd9Sstevel@tonic-gate insert(name) 977c478bd9Sstevel@tonic-gate char *name; 987c478bd9Sstevel@tonic-gate { 99*462be471Sceastha int i,j; 100*462be471Sceastha char *p; 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate DEBUG(7, "insert(%s) ", name); 1037c478bd9Sstevel@tonic-gate 1047c478bd9Sstevel@tonic-gate for (i = Nnames; i > 0; i--) 1057c478bd9Sstevel@tonic-gate if (strcmp(name, Nptr[i-1]) > 0) 1067c478bd9Sstevel@tonic-gate break; 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate if (i == MAXLENGTH) 1097c478bd9Sstevel@tonic-gate return; 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate if (Nnames == MAXLENGTH) 1127c478bd9Sstevel@tonic-gate p = strcpy(Nptr[--Nnames], name); 1137c478bd9Sstevel@tonic-gate else 1147c478bd9Sstevel@tonic-gate p = strcpy(Nnament[Nnames], name); 1157c478bd9Sstevel@tonic-gate 1167c478bd9Sstevel@tonic-gate for (j = Nnames; j > i; j--) 1177c478bd9Sstevel@tonic-gate Nptr[j] = Nptr[j-1]; 1187c478bd9Sstevel@tonic-gate 1197c478bd9Sstevel@tonic-gate DEBUG(7, "insert %s ", p); 1207c478bd9Sstevel@tonic-gate DEBUG(7, "at %d\n", i); 1217c478bd9Sstevel@tonic-gate Nptr[i] = p; 1227c478bd9Sstevel@tonic-gate Nnames++; 1237c478bd9Sstevel@tonic-gate return; 1247c478bd9Sstevel@tonic-gate } 1257c478bd9Sstevel@tonic-gate 1267c478bd9Sstevel@tonic-gate void 1277c478bd9Sstevel@tonic-gate rproc() 1287c478bd9Sstevel@tonic-gate { 1297c478bd9Sstevel@tonic-gate FILE *cfd; 1307c478bd9Sstevel@tonic-gate char line[BUFSIZ]; 1317c478bd9Sstevel@tonic-gate char *carray[C_MAX]; 1327c478bd9Sstevel@tonic-gate int na; 1337c478bd9Sstevel@tonic-gate 1347c478bd9Sstevel@tonic-gate cfd = fopen(GRADES, "r"); 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate while (rdfulline(cfd, line, BUFSIZ) != 0) { 1377c478bd9Sstevel@tonic-gate 1387c478bd9Sstevel@tonic-gate na = getargs(line, carray, C_MAX); 1397c478bd9Sstevel@tonic-gate insert(carray[0]); 1407c478bd9Sstevel@tonic-gate } 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate (void) fclose(cfd); 1437c478bd9Sstevel@tonic-gate return; 1447c478bd9Sstevel@tonic-gate } 1457c478bd9Sstevel@tonic-gate 1467c478bd9Sstevel@tonic-gate void 1477c478bd9Sstevel@tonic-gate uproc() 1487c478bd9Sstevel@tonic-gate { 1497c478bd9Sstevel@tonic-gate FILE *cfd; 1507c478bd9Sstevel@tonic-gate char line[BUFSIZ]; 1517c478bd9Sstevel@tonic-gate char *carray[C_MAX]; 1527c478bd9Sstevel@tonic-gate int na; 1537c478bd9Sstevel@tonic-gate 1547c478bd9Sstevel@tonic-gate cfd = fopen(GRADES, "r"); 1557c478bd9Sstevel@tonic-gate 1567c478bd9Sstevel@tonic-gate while (rdfulline(cfd, line, BUFSIZ) != 0) { 1577c478bd9Sstevel@tonic-gate 1587c478bd9Sstevel@tonic-gate na = getargs(line, carray, C_MAX); 1597c478bd9Sstevel@tonic-gate 1607c478bd9Sstevel@tonic-gate if (upermit(carray, na) != FAIL) 1617c478bd9Sstevel@tonic-gate insert(carray[0]); 1627c478bd9Sstevel@tonic-gate } 1637c478bd9Sstevel@tonic-gate 1647c478bd9Sstevel@tonic-gate (void) fclose(cfd); 1657c478bd9Sstevel@tonic-gate return; 1667c478bd9Sstevel@tonic-gate } 1677c478bd9Sstevel@tonic-gate 1687c478bd9Sstevel@tonic-gate int Dfileused = FALSE; 169*462be471Sceastha void wfcommit() {} 1707c478bd9Sstevel@tonic-gate void cleanup() {} 171*462be471Sceastha int gnamef() { return (0); } 172*462be471Sceastha int gdirf() { return (0); } 173*462be471Sceastha int cklock() { return (0); } 1747c478bd9Sstevel@tonic-gate 1757c478bd9Sstevel@tonic-gate /*VARARGS*/ 1767c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 1777c478bd9Sstevel@tonic-gate void 1787c478bd9Sstevel@tonic-gate assert (s1, s2, i1, s3, i2) 1797c478bd9Sstevel@tonic-gate char *s1, *s2, *s3; 1807c478bd9Sstevel@tonic-gate int i1, i2; 1817c478bd9Sstevel@tonic-gate { } /* for ASSERT in gnamef.c */ 1827c478bd9Sstevel@tonic-gate 1837c478bd9Sstevel@tonic-gate /*VARARGS*/ 1847c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 1857c478bd9Sstevel@tonic-gate void 1867c478bd9Sstevel@tonic-gate errent(s1, s2, i1, file, line) 1877c478bd9Sstevel@tonic-gate char *s1, *s2, *file; 1887c478bd9Sstevel@tonic-gate { } 189