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 */ 227c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 237c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 247c478bd9Sstevel@tonic-gate 257c478bd9Sstevel@tonic-gate /* 26*34e48580Sdp * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 27*34e48580Sdp * Use is subject to license terms. 287c478bd9Sstevel@tonic-gate */ 297c478bd9Sstevel@tonic-gate 30*34e48580Sdp #pragma ident "%Z%%M% %I% %E% SMI" 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #include <stdio.h> 33*34e48580Sdp #include <stdlib.h> 347c478bd9Sstevel@tonic-gate #include <signal.h> 357c478bd9Sstevel@tonic-gate #include "misc.h" 367c478bd9Sstevel@tonic-gate #include "msgs.h" 377c478bd9Sstevel@tonic-gate #include <sac.h> 387c478bd9Sstevel@tonic-gate #include "structs.h" 397c478bd9Sstevel@tonic-gate #include <sys/types.h> 407c478bd9Sstevel@tonic-gate #include <unistd.h> 417c478bd9Sstevel@tonic-gate #include "extern.h" 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate /* 457c478bd9Sstevel@tonic-gate * read_table - read in SAC's administrative file and build internal 467c478bd9Sstevel@tonic-gate * data structures 477c478bd9Sstevel@tonic-gate * 487c478bd9Sstevel@tonic-gate * args: startflag - flag to indicate if port monitor's should be 497c478bd9Sstevel@tonic-gate * started as a side effect of reading 507c478bd9Sstevel@tonic-gate */ 517c478bd9Sstevel@tonic-gate 527c478bd9Sstevel@tonic-gate void 537c478bd9Sstevel@tonic-gate read_table(startflag) 547c478bd9Sstevel@tonic-gate int startflag; 557c478bd9Sstevel@tonic-gate { 567c478bd9Sstevel@tonic-gate FILE *fp; /* scratch file pointer */ 577c478bd9Sstevel@tonic-gate int ret; /* return code from check_version */ 587c478bd9Sstevel@tonic-gate struct sactab *sp; /* working pointer to move through PM info */ 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gate # ifdef DEBUG 617c478bd9Sstevel@tonic-gate debug("in read_table"); 627c478bd9Sstevel@tonic-gate # endif 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate /* 657c478bd9Sstevel@tonic-gate * make sure _sactab is ok 667c478bd9Sstevel@tonic-gate */ 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate Nentries = 0; 697c478bd9Sstevel@tonic-gate if ((ret = check_version(VERSION, SACTAB)) == 1) 707c478bd9Sstevel@tonic-gate error(E_BADVER, EXIT); 717c478bd9Sstevel@tonic-gate else if (ret == 2) 727c478bd9Sstevel@tonic-gate error(E_SACOPEN, EXIT); 737c478bd9Sstevel@tonic-gate else if (ret == 3) 747c478bd9Sstevel@tonic-gate error(E_BADFILE, EXIT); 757c478bd9Sstevel@tonic-gate fp = fopen(SACTAB, "r"); 767c478bd9Sstevel@tonic-gate if (fp == NULL) 777c478bd9Sstevel@tonic-gate error(E_SACOPEN, EXIT); 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate /* 807c478bd9Sstevel@tonic-gate * mark all entries as invalid 817c478bd9Sstevel@tonic-gate */ 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate for (sp = Sactab; sp; sp = sp->sc_next) 847c478bd9Sstevel@tonic-gate sp->sc_valid = 0; 857c478bd9Sstevel@tonic-gate 867c478bd9Sstevel@tonic-gate /* 877c478bd9Sstevel@tonic-gate * build internal structures 887c478bd9Sstevel@tonic-gate */ 897c478bd9Sstevel@tonic-gate 907c478bd9Sstevel@tonic-gate while (sp = read_entry(fp)) 917c478bd9Sstevel@tonic-gate insert(sp, startflag); 927c478bd9Sstevel@tonic-gate purge(); 937c478bd9Sstevel@tonic-gate (void) fclose(fp); 947c478bd9Sstevel@tonic-gate } 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate /* 987c478bd9Sstevel@tonic-gate * read_entry - read an entry from _sactab 997c478bd9Sstevel@tonic-gate * 1007c478bd9Sstevel@tonic-gate * args: fp - file pointer referencing _sactab 1017c478bd9Sstevel@tonic-gate */ 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate struct sactab * 1047c478bd9Sstevel@tonic-gate read_entry(fp) 1057c478bd9Sstevel@tonic-gate FILE *fp; 1067c478bd9Sstevel@tonic-gate { 1077c478bd9Sstevel@tonic-gate register struct sactab *sp; /* working pointer */ 1087c478bd9Sstevel@tonic-gate register char *p; /* scratch pointer */ 1097c478bd9Sstevel@tonic-gate char buf[SIZE]; /* scratch buffer */ 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate /* 1127c478bd9Sstevel@tonic-gate * retrieve a line from the file 1137c478bd9Sstevel@tonic-gate */ 1147c478bd9Sstevel@tonic-gate 1157c478bd9Sstevel@tonic-gate do { 1167c478bd9Sstevel@tonic-gate if (fgets(buf, SIZE, fp) == NULL) 1177c478bd9Sstevel@tonic-gate return(NULL); 1187c478bd9Sstevel@tonic-gate p = trim(buf); 1197c478bd9Sstevel@tonic-gate } while (*p == '\0'); 1207c478bd9Sstevel@tonic-gate 1217c478bd9Sstevel@tonic-gate /* 1227c478bd9Sstevel@tonic-gate * allocate a list element for it and then parse the line, parsed 1237c478bd9Sstevel@tonic-gate * info goes into list element 1247c478bd9Sstevel@tonic-gate */ 1257c478bd9Sstevel@tonic-gate 1267c478bd9Sstevel@tonic-gate sp = (struct sactab *) calloc(1, sizeof(struct sactab)); 1277c478bd9Sstevel@tonic-gate if (sp == NULL) 1287c478bd9Sstevel@tonic-gate error(E_MALLOC, EXIT); 1297c478bd9Sstevel@tonic-gate sp->sc_sstate = sp->sc_lstate = sp->sc_pstate = NOTRUNNING; 1307c478bd9Sstevel@tonic-gate (void) memset(sp->sc_utid, '\0', IDLEN); 1317c478bd9Sstevel@tonic-gate parse(p, sp); 1327c478bd9Sstevel@tonic-gate return(sp); 1337c478bd9Sstevel@tonic-gate } 1347c478bd9Sstevel@tonic-gate 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate /* 1377c478bd9Sstevel@tonic-gate * insert - insert a sactab entry into the linked list 1387c478bd9Sstevel@tonic-gate * 1397c478bd9Sstevel@tonic-gate * args: sp - entry to be inserted 1407c478bd9Sstevel@tonic-gate * startflag - flag to indicate if port monitor's should be 1417c478bd9Sstevel@tonic-gate * started as a side effect of reading 1427c478bd9Sstevel@tonic-gate */ 1437c478bd9Sstevel@tonic-gate 1447c478bd9Sstevel@tonic-gate void 1457c478bd9Sstevel@tonic-gate insert(sp, startflag) 1467c478bd9Sstevel@tonic-gate register struct sactab *sp; 1477c478bd9Sstevel@tonic-gate int startflag; 1487c478bd9Sstevel@tonic-gate { 1497c478bd9Sstevel@tonic-gate register struct sactab *tsp, *savtsp; /* scratch pointers */ 1507c478bd9Sstevel@tonic-gate int ret; /* strcmp return value */ 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate # ifdef DEBUG 1537c478bd9Sstevel@tonic-gate debug("in insert"); 1547c478bd9Sstevel@tonic-gate # endif 1557c478bd9Sstevel@tonic-gate savtsp = tsp = Sactab; 1567c478bd9Sstevel@tonic-gate 1577c478bd9Sstevel@tonic-gate /* 1587c478bd9Sstevel@tonic-gate * find the correct place to insert this element 1597c478bd9Sstevel@tonic-gate */ 1607c478bd9Sstevel@tonic-gate 1617c478bd9Sstevel@tonic-gate while (tsp) { 1627c478bd9Sstevel@tonic-gate ret = strcmp(sp->sc_tag, tsp->sc_tag); 1637c478bd9Sstevel@tonic-gate # ifdef DEBUG 1647c478bd9Sstevel@tonic-gate (void) sprintf(Scratch, "sp->sc_tag <%s> tsp->sc_tag <%s>, ret is %d", sp->sc_tag, tsp->sc_tag, ret); 1657c478bd9Sstevel@tonic-gate debug(Scratch); 1667c478bd9Sstevel@tonic-gate # endif 1677c478bd9Sstevel@tonic-gate if (ret > 0) { 1687c478bd9Sstevel@tonic-gate /* keep on looking */ 1697c478bd9Sstevel@tonic-gate savtsp = tsp; 1707c478bd9Sstevel@tonic-gate tsp = tsp->sc_next; 1717c478bd9Sstevel@tonic-gate continue; 1727c478bd9Sstevel@tonic-gate } 1737c478bd9Sstevel@tonic-gate else if (ret == 0) { 1747c478bd9Sstevel@tonic-gate 1757c478bd9Sstevel@tonic-gate /* 1767c478bd9Sstevel@tonic-gate * found an entry for it in the list, either a duplicate or we're 1777c478bd9Sstevel@tonic-gate * rereading the file. 1787c478bd9Sstevel@tonic-gate */ 1797c478bd9Sstevel@tonic-gate 1807c478bd9Sstevel@tonic-gate if (tsp->sc_valid) { 1817c478bd9Sstevel@tonic-gate /* this is a duplicate entry, ignore it */ 1827c478bd9Sstevel@tonic-gate (void) sprintf(Scratch, "Ignoring duplicate entry for <%s>", tsp->sc_tag); 1837c478bd9Sstevel@tonic-gate log(Scratch); 1847c478bd9Sstevel@tonic-gate } 1857c478bd9Sstevel@tonic-gate else { 1867c478bd9Sstevel@tonic-gate /* found a valid match, replace flags & restart max only */ 1877c478bd9Sstevel@tonic-gate tsp->sc_rsmax = sp->sc_rsmax; 1887c478bd9Sstevel@tonic-gate tsp->sc_flags = sp->sc_flags; 1897c478bd9Sstevel@tonic-gate # ifdef DEBUG 1907c478bd9Sstevel@tonic-gate (void) sprintf(Scratch, "replacing <%s>", sp->sc_tag); 1917c478bd9Sstevel@tonic-gate debug(Scratch); 1927c478bd9Sstevel@tonic-gate # endif 1937c478bd9Sstevel@tonic-gate /* this entry is "current" */ 1947c478bd9Sstevel@tonic-gate tsp->sc_valid = 1; 1957c478bd9Sstevel@tonic-gate Nentries++; 1967c478bd9Sstevel@tonic-gate } 1977c478bd9Sstevel@tonic-gate free(sp->sc_cmd); 1987c478bd9Sstevel@tonic-gate free(sp); 1997c478bd9Sstevel@tonic-gate return; 2007c478bd9Sstevel@tonic-gate } 2017c478bd9Sstevel@tonic-gate else { 2027c478bd9Sstevel@tonic-gate /* insert it here */ 2037c478bd9Sstevel@tonic-gate if (tsp == Sactab) { 2047c478bd9Sstevel@tonic-gate sp->sc_next = Sactab; 2057c478bd9Sstevel@tonic-gate Sactab = sp; 2067c478bd9Sstevel@tonic-gate } 2077c478bd9Sstevel@tonic-gate else { 2087c478bd9Sstevel@tonic-gate sp->sc_next = savtsp->sc_next; 2097c478bd9Sstevel@tonic-gate savtsp->sc_next = sp; 2107c478bd9Sstevel@tonic-gate } 2117c478bd9Sstevel@tonic-gate # ifdef DEBUG 2127c478bd9Sstevel@tonic-gate (void) sprintf(Scratch, "adding <%s>", sp->sc_tag); 2137c478bd9Sstevel@tonic-gate debug(Scratch); 2147c478bd9Sstevel@tonic-gate # endif 2157c478bd9Sstevel@tonic-gate Nentries++; 2167c478bd9Sstevel@tonic-gate /* this entry is "current" */ 2177c478bd9Sstevel@tonic-gate sp->sc_valid = 1; 2187c478bd9Sstevel@tonic-gate if (startflag && !(sp->sc_flags & X_FLAG)) 2197c478bd9Sstevel@tonic-gate (void) startpm(sp); 2207c478bd9Sstevel@tonic-gate return; 2217c478bd9Sstevel@tonic-gate } 2227c478bd9Sstevel@tonic-gate } 2237c478bd9Sstevel@tonic-gate 2247c478bd9Sstevel@tonic-gate /* 2257c478bd9Sstevel@tonic-gate * either an empty list or should put element at end of list 2267c478bd9Sstevel@tonic-gate */ 2277c478bd9Sstevel@tonic-gate 2287c478bd9Sstevel@tonic-gate sp->sc_next = NULL; 2297c478bd9Sstevel@tonic-gate if (Sactab == NULL) 2307c478bd9Sstevel@tonic-gate Sactab = sp; 2317c478bd9Sstevel@tonic-gate else 2327c478bd9Sstevel@tonic-gate savtsp->sc_next = sp; 2337c478bd9Sstevel@tonic-gate # ifdef DEBUG 2347c478bd9Sstevel@tonic-gate (void) sprintf(Scratch, "adding <%s>", sp->sc_tag); 2357c478bd9Sstevel@tonic-gate debug(Scratch); 2367c478bd9Sstevel@tonic-gate # endif 2377c478bd9Sstevel@tonic-gate ++Nentries; 2387c478bd9Sstevel@tonic-gate /* this entry is "current" */ 2397c478bd9Sstevel@tonic-gate sp->sc_valid = 1; 2407c478bd9Sstevel@tonic-gate if (startflag && !(sp->sc_flags & X_FLAG)) 2417c478bd9Sstevel@tonic-gate (void) startpm(sp); 2427c478bd9Sstevel@tonic-gate } 2437c478bd9Sstevel@tonic-gate 2447c478bd9Sstevel@tonic-gate 2457c478bd9Sstevel@tonic-gate 2467c478bd9Sstevel@tonic-gate /* 2477c478bd9Sstevel@tonic-gate * purge - purge linked list of "old" entries 2487c478bd9Sstevel@tonic-gate */ 2497c478bd9Sstevel@tonic-gate 2507c478bd9Sstevel@tonic-gate 2517c478bd9Sstevel@tonic-gate void 2527c478bd9Sstevel@tonic-gate purge() 2537c478bd9Sstevel@tonic-gate { 2547c478bd9Sstevel@tonic-gate register struct sactab *sp; /* working pointer */ 2557c478bd9Sstevel@tonic-gate register struct sactab *savesp, *tsp; /* scratch pointers */ 2567c478bd9Sstevel@tonic-gate sigset_t cset; /* for signal handling */ 2577c478bd9Sstevel@tonic-gate sigset_t tset; /* for signal handling */ 2587c478bd9Sstevel@tonic-gate 2597c478bd9Sstevel@tonic-gate # ifdef DEBUG 2607c478bd9Sstevel@tonic-gate debug("in purge"); 2617c478bd9Sstevel@tonic-gate # endif 2627c478bd9Sstevel@tonic-gate /* get current signal mask */ 2637c478bd9Sstevel@tonic-gate (void) sigprocmask(SIG_SETMASK, NULL, &cset); 2647c478bd9Sstevel@tonic-gate sp = savesp = Sactab; 2657c478bd9Sstevel@tonic-gate while (sp) { 2667c478bd9Sstevel@tonic-gate if (sp->sc_valid) { 2677c478bd9Sstevel@tonic-gate savesp = sp; 2687c478bd9Sstevel@tonic-gate sp = sp->sc_next; 2697c478bd9Sstevel@tonic-gate continue; 2707c478bd9Sstevel@tonic-gate } 2717c478bd9Sstevel@tonic-gate 2727c478bd9Sstevel@tonic-gate /* element should be removed */ 2737c478bd9Sstevel@tonic-gate switch (sp->sc_sstate) { 2747c478bd9Sstevel@tonic-gate case UNKNOWN: 2757c478bd9Sstevel@tonic-gate case ENABLED: 2767c478bd9Sstevel@tonic-gate case DISABLED: 2777c478bd9Sstevel@tonic-gate case STARTING: 2787c478bd9Sstevel@tonic-gate /* need to kill it */ 2797c478bd9Sstevel@tonic-gate tset = cset; 2807c478bd9Sstevel@tonic-gate (void) sigaddset(&tset, SIGALRM); 2817c478bd9Sstevel@tonic-gate (void) sigaddset(&tset, SIGCLD); 2827c478bd9Sstevel@tonic-gate (void) sigprocmask(SIG_SETMASK, &tset, NULL); 2837c478bd9Sstevel@tonic-gate if (sendsig(sp, SIGTERM)) 2847c478bd9Sstevel@tonic-gate (void) sprintf(Scratch, "could not send SIGTERM to <%s>", sp->sc_tag); 2857c478bd9Sstevel@tonic-gate else 2867c478bd9Sstevel@tonic-gate (void) sprintf(Scratch, "terminating <%s>", sp->sc_tag); 2877c478bd9Sstevel@tonic-gate log(Scratch); 2887c478bd9Sstevel@tonic-gate (void) sigdelset(&tset, SIGALRM); 2897c478bd9Sstevel@tonic-gate (void) sigprocmask(SIG_SETMASK, &tset, NULL); 2907c478bd9Sstevel@tonic-gate /* fall thru */ 2917c478bd9Sstevel@tonic-gate case STOPPING: 2927c478bd9Sstevel@tonic-gate (void) close(sp->sc_fd); 2937c478bd9Sstevel@tonic-gate /* fall thru */ 2947c478bd9Sstevel@tonic-gate case NOTRUNNING: 2957c478bd9Sstevel@tonic-gate case FAILED: 2967c478bd9Sstevel@tonic-gate cleanutx(sp); 2977c478bd9Sstevel@tonic-gate tsp = sp; 2987c478bd9Sstevel@tonic-gate if (tsp == Sactab) { 2997c478bd9Sstevel@tonic-gate Sactab = sp->sc_next; 3007c478bd9Sstevel@tonic-gate savesp = Sactab; 3017c478bd9Sstevel@tonic-gate } 3027c478bd9Sstevel@tonic-gate else 3037c478bd9Sstevel@tonic-gate savesp->sc_next = sp->sc_next; 3047c478bd9Sstevel@tonic-gate # ifdef DEBUG 3057c478bd9Sstevel@tonic-gate (void) sprintf(Scratch, "purging <%s>", sp->sc_tag); 3067c478bd9Sstevel@tonic-gate debug(Scratch); 3077c478bd9Sstevel@tonic-gate # endif 3087c478bd9Sstevel@tonic-gate sp = sp->sc_next; 3097c478bd9Sstevel@tonic-gate free(tsp->sc_cmd); 3107c478bd9Sstevel@tonic-gate free(tsp->sc_comment); 3117c478bd9Sstevel@tonic-gate free(tsp); 3127c478bd9Sstevel@tonic-gate 3137c478bd9Sstevel@tonic-gate /* 3147c478bd9Sstevel@tonic-gate * all done cleaning up, restore signal mask 3157c478bd9Sstevel@tonic-gate */ 3167c478bd9Sstevel@tonic-gate 3177c478bd9Sstevel@tonic-gate (void) sigprocmask(SIG_SETMASK, &cset, NULL); 3187c478bd9Sstevel@tonic-gate break; 3197c478bd9Sstevel@tonic-gate } 3207c478bd9Sstevel@tonic-gate } 3217c478bd9Sstevel@tonic-gate } 3227c478bd9Sstevel@tonic-gate 3237c478bd9Sstevel@tonic-gate 3247c478bd9Sstevel@tonic-gate /* 3257c478bd9Sstevel@tonic-gate * dump_table - dump the internal SAC table, used to satisfy sacadm -l 3267c478bd9Sstevel@tonic-gate */ 3277c478bd9Sstevel@tonic-gate 3287c478bd9Sstevel@tonic-gate 3297c478bd9Sstevel@tonic-gate char ** 3307c478bd9Sstevel@tonic-gate dump_table() 3317c478bd9Sstevel@tonic-gate { 3327c478bd9Sstevel@tonic-gate register struct sactab *sp; /* working pointer */ 3337c478bd9Sstevel@tonic-gate register char *p; /* scratch pointer */ 3347c478bd9Sstevel@tonic-gate register int size; /* size of "dumped" table */ 3357c478bd9Sstevel@tonic-gate char **info, **savinfo; /* scratch pointers */ 3367c478bd9Sstevel@tonic-gate 3377c478bd9Sstevel@tonic-gate # ifdef DEBUG 3387c478bd9Sstevel@tonic-gate (void) sprintf(Scratch, "about to 'info' malloc %d entries", Nentries); 3397c478bd9Sstevel@tonic-gate debug(Scratch); 3407c478bd9Sstevel@tonic-gate # endif 3417c478bd9Sstevel@tonic-gate 3427c478bd9Sstevel@tonic-gate /* 3437c478bd9Sstevel@tonic-gate * get space for number of entries we have 3447c478bd9Sstevel@tonic-gate */ 3457c478bd9Sstevel@tonic-gate 3467c478bd9Sstevel@tonic-gate if (Nentries == 0) 3477c478bd9Sstevel@tonic-gate return(NULL); 3487c478bd9Sstevel@tonic-gate if ((info = (char **) malloc(Nentries * sizeof(char *))) == NULL) { 3497c478bd9Sstevel@tonic-gate error(E_MALLOC, CONT); 3507c478bd9Sstevel@tonic-gate return(NULL); 3517c478bd9Sstevel@tonic-gate } 3527c478bd9Sstevel@tonic-gate savinfo = info; 3537c478bd9Sstevel@tonic-gate 3547c478bd9Sstevel@tonic-gate /* 3557c478bd9Sstevel@tonic-gate * traverse the list allocating space for entries and formatting them 3567c478bd9Sstevel@tonic-gate */ 3577c478bd9Sstevel@tonic-gate 3587c478bd9Sstevel@tonic-gate for (sp = Sactab; sp; sp = sp->sc_next) { 3597c478bd9Sstevel@tonic-gate size = strlen(sp->sc_tag) + strlen(sp->sc_type) + strlen(sp->sc_cmd) + strlen(sp->sc_comment) + SLOP; 3607c478bd9Sstevel@tonic-gate if ((p = malloc((unsigned) size)) == NULL) { 3617c478bd9Sstevel@tonic-gate error(E_MALLOC, CONT); 3627c478bd9Sstevel@tonic-gate return(NULL); 3637c478bd9Sstevel@tonic-gate } 3647c478bd9Sstevel@tonic-gate (void) sprintf(p, "%s:%s:%d:%d:%d:%s:%s\n", sp->sc_tag, sp->sc_type, 3657c478bd9Sstevel@tonic-gate sp->sc_flags, sp->sc_rsmax, sp->sc_pstate, sp->sc_cmd, sp->sc_comment); 3667c478bd9Sstevel@tonic-gate *info++ = p; 3677c478bd9Sstevel@tonic-gate # ifdef DEBUG 3687c478bd9Sstevel@tonic-gate debug(*(info - 1)); 3697c478bd9Sstevel@tonic-gate # endif 3707c478bd9Sstevel@tonic-gate } 3717c478bd9Sstevel@tonic-gate return(savinfo); 3727c478bd9Sstevel@tonic-gate } 373