diff options
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/i4b/dtmfdecode/Makefile | 15 | ||||
-rw-r--r-- | usr.sbin/i4b/dtmfdecode/dtmfdecode.1 | 64 | ||||
-rw-r--r-- | usr.sbin/i4b/dtmfdecode/dtmfdecode.c | 150 | ||||
-rw-r--r-- | usr.sbin/i4b/g711conv/Makefile | 14 | ||||
-rw-r--r-- | usr.sbin/i4b/g711conv/g711conv.1 | 96 | ||||
-rw-r--r-- | usr.sbin/i4b/g711conv/g711conv.c | 304 | ||||
-rw-r--r-- | usr.sbin/inetd/builtins.c | 682 | ||||
-rw-r--r-- | usr.sbin/inetd/inetd.h | 134 | ||||
-rw-r--r-- | usr.sbin/pkg_install/add/main.c | 2 | ||||
-rw-r--r-- | usr.sbin/ppp/nat_cmd.c | 434 | ||||
-rw-r--r-- | usr.sbin/ppp/nat_cmd.h | 15 | ||||
-rw-r--r-- | usr.sbin/pw/pw_vpw.c | 316 |
12 files changed, 1 insertions, 2225 deletions
diff --git a/usr.sbin/i4b/dtmfdecode/Makefile b/usr.sbin/i4b/dtmfdecode/Makefile deleted file mode 100644 index 792b2ef39301..000000000000 --- a/usr.sbin/i4b/dtmfdecode/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -#--------------------------------------------------------------------------- -# -# $FreeBSD$ -# -# last edit-date: [Thu May 20 12:04:05 1999] -# -#--------------------------------------------------------------------------- - -PROG = dtmfdecode -SRC = dtmfdecode.c -#LDADD += -lm -CFLAGS += -Wall -g -DDEBUG -MAN1 = dtmfdecode.1 - -.include <bsd.prog.mk> diff --git a/usr.sbin/i4b/dtmfdecode/dtmfdecode.1 b/usr.sbin/i4b/dtmfdecode/dtmfdecode.1 deleted file mode 100644 index 42cd5beb7419..000000000000 --- a/usr.sbin/i4b/dtmfdecode/dtmfdecode.1 +++ /dev/null @@ -1,64 +0,0 @@ -.\" -.\" Copyright (c) 1999 Hellmuth Michaelis. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.\" -.\" last edit-date: [Mon Apr 26 13:42:15 1999] -.\" -.\" -.Dd February, 15 1999 -.Dt DTMFDECODE 1 -.Os -.Sh NAME -.Nm dtmfdecode -.Nd decodes DTMF tones from A-law audio data -.Sh SYNOPSIS -.Nm -.Sh DESCRIPTION -.Nm dtmfdecode -is part of the isdn4bsd package and is used to detect DTMF tones in the -audio stream. -.Pp -It reads audio G.711 A-Law coded data from stdin and outputs the detected -numbers values as ASCII charcters to stdout. -.Pp -The detector is implemented as 8 narrow band-pass filters realized with -an integer double-cross recursive algorithm. Various ad-hoc methods are -employed to provide hysteresis and anti-bounce for the detected signals. -.Sh EXAMPLES -The command: -.Bd -literal -offset indent -dtmfdecode < beep.al -.Ed -.Pp -will print a "1" to stdout. -.Sh STANDARDS -ITU Recommendations G.711 -.Sh AUTHORS -The -.Nm -utility was written by -.An Poul-Henning Kamp Aq phk@FreeBSD.org . -This man page was written by -.An Hellmuth Michaelis Aq hm@FreeBSD.org . diff --git a/usr.sbin/i4b/dtmfdecode/dtmfdecode.c b/usr.sbin/i4b/dtmfdecode/dtmfdecode.c deleted file mode 100644 index f96bacd42b10..000000000000 --- a/usr.sbin/i4b/dtmfdecode/dtmfdecode.c +++ /dev/null @@ -1,150 +0,0 @@ -/* - * ---------------------------------------------------------------------------- - * "THE BEER-WARE LICENSE" (Revision 42): - * <phk@FreeBSD.org> wrote this file. As long as you retain this notice you - * can do whatever you want with this stuff. If we meet some day, and you think - * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp - * ---------------------------------------------------------------------------- - * - * $FreeBSD$ - * - * Extract DTMF signalling from ISDN4BSD A-law coded audio data - * - * A-Law to linear conversion from the sox package. - * - */ - -#include <stdio.h> -#include <math.h> - -/* Integer math scaling factor */ -#define FSC (1<<12) - -/* Alaw parameters */ -#define SIGN_BIT (0x80) /* Sign bit for a A-law byte. */ -#define QUANT_MASK (0xf) /* Quantization field mask. */ -#define SEG_SHIFT (4) /* Left shift for segment number. */ -#define SEG_MASK (0x70) /* Segment field mask. */ - -static int -alaw2linear(a_val) - unsigned char a_val; -{ - int t; - int seg; - - a_val ^= 0x55; - - t = (a_val & QUANT_MASK) << 4; - seg = ((unsigned)a_val & SEG_MASK) >> SEG_SHIFT; - switch (seg) { - case 0: - t += 8; - break; - case 1: - t += 0x108; - break; - default: - t += 0x108; - t <<= seg - 1; - } - return ((a_val & SIGN_BIT) ? t : -t); -} - -#ifdef USE_COS -/* The frequencies we're trying to detect */ -static int dtmf[8] = {697, 770, 852, 941, 1209, 1336, 1477, 1633}; -#else -/* precalculated: p1[kk] = (-cos(2 * 3.141592 * dtmf[kk] / 8000.0) * FSC) */ -static int p1[8] = {-3497, -3369, -3212, -3027, -2384, -2040, -1635, -1164}; -#endif - -/* This is the Q of the filter (pole radius) */ -#define POLRAD .99 - -#define P2 ((int)(POLRAD*POLRAD*FSC)) - -int -main(int argc, char **argv) -{ - int i, kk, t, nn, s, so, ia; - int x, c, d, f, h[8], k[8], n, y[8]; -#ifdef USE_COS - int p1[8]; -#endif - int alaw[256]; - char key[256]; - - for (kk = 0; kk < 8; kk++) { - y[kk] = h[kk] = k[kk] = 0; -#ifdef USE_COS - p1[kk] = (-cos(2 * 3.141592 * dtmf[kk] / 8000.0) * FSC); -#endif - } - - for (i = 0; i < 256; i++) { - key[i] = '?'; - alaw[i] = alaw2linear(i) / (32768/FSC); - } - - /* We encode the tones in 8 bits, translate those to symbol */ - key[0x00] = '\0'; - - key[0x11] = '1'; key[0x12] = '4'; key[0x14] = '7'; key[0x18] = '*'; - key[0x21] = '2'; key[0x22] = '5'; key[0x24] = '8'; key[0x28] = '0'; - key[0x41] = '3'; key[0x42] = '6'; key[0x44] = '9'; key[0x48] = '#'; - key[0x81] = 'A'; key[0x82] = 'B'; key[0x84] = 'C'; key[0x88] = 'D'; - - nn = 0; - ia = 0; - so = 0; - t = 0; - while ((i = getchar()) != EOF) - { - t++; - - /* Convert to our format */ - x = alaw[i]; - - /* Input amplitude */ - if (x > 0) - ia += (x - ia) / 128; - else - ia += (-x - ia) / 128; - - /* For each tone */ - s = 0; - for(kk = 0; kk < 8; kk++) { - - /* Turn the crank */ - c = (P2 * (x - k[kk])) / FSC; - d = x + c; - f = (p1[kk] * (d - h[kk])) / FSC; - n = x - k[kk] - c; - k[kk] = h[kk] + f; - h[kk] = f + d; - - /* Detect and Average */ - if (n > 0) - y[kk] += (n - y[kk]) / 64; - else - y[kk] += (-n - y[kk]) / 64; - - /* Threshold */ - if (y[kk] > FSC/10 && y[kk] > ia) - s |= 1 << kk; - } - - /* Hysteresis and noise supressor */ - if (s != so) { -/* printf("x %d %x -> %x\n",t,so, s); */ - nn = 0; - so = s; - } else if (nn++ == 520 && key[s]) { - putchar(key[s]); -/* printf(" %d %x\n",t,s); */ - } - } - putchar('\n'); - return (0); -} diff --git a/usr.sbin/i4b/g711conv/Makefile b/usr.sbin/i4b/g711conv/Makefile deleted file mode 100644 index f96de268deea..000000000000 --- a/usr.sbin/i4b/g711conv/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -#--------------------------------------------------------------------------- -# -# $FreeBSD$ -# -# last edit-date: [Thu May 20 11:58:43 1999] -# -#--------------------------------------------------------------------------- - -PROG = g711conv -SRC = g711conv.c -CFLAGS += -Wall -g -MAN1 = g711conv.1 - -.include <bsd.prog.mk> diff --git a/usr.sbin/i4b/g711conv/g711conv.1 b/usr.sbin/i4b/g711conv/g711conv.1 deleted file mode 100644 index 4d9102458cad..000000000000 --- a/usr.sbin/i4b/g711conv/g711conv.1 +++ /dev/null @@ -1,96 +0,0 @@ -.\" -.\" Copyright (c) 1999 Hellmuth Michaelis. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.\" -.\" last edit-date: [Mon Mar 15 16:17:23 1999] -.\" -.Dd March 15, 1999 -.Dt G711CONV 1 -.Os -.Sh NAME -.Nm g711conv -.Nd conversions according to G.711 -.Sh SYNOPSIS -.Nm -.Op Fl a -.Op Fl u -.Op Fl P -.Op Fl A -.Op Fl R -.Sh DESCRIPTION -.Nm g711conv -is part of the isdn4bsd package and is used to convert between the A-Law and -u-law formats as specified in ITU G.711. It is based on a freely available -and freely usable reference implementation done by Sun Microsystems, Inc. -.Pp -The following options are available: -.Bl -tag -width Ds -.It Fl a -Convert A-law to u-law -.It Fl u -Convert u-law to A-law -.It Fl r -Reverse bits before conversion -.It Fl R -Reverse bits after conversion -.It Fl P -Print the resulting conversion tables (as C-source) to stdout instead of -doing the actual conversion. -.El -.Pp - -.Sh STANDARDS -A-Law and u-Law conversions are specified in ITU Recommendation G.711. -.Pp -The reference implementation done by Sun Microsystems, Inc. is available -from http://www.itu.int/itudoc/itu-t/rec/g/g700-799/refimpl.txt -.Pp - -.Sh EXAMPLES -The command: -.Bd -literal -offset indent -g711conv -P -a -.Ed -.Pp -prints out the A-law to u-law conversion table as C-source to stdout. -.Pp -The command: -.Bd -literal -offset indent -cat max_headroom.ul | g711conv -u -R > /dev/i4btel0 -.Ed -.Pp -converts the u-law coded voice of Max Headroom to A-law, reverses the -bits of the result and moves that to an active isdn4bsd telephone connection. -.Pp - -.Sh AUTHORS -The -.Nm -utility and this manpage were written by -.An Hellmuth Michaelis Aq hm@kts.org -based on the G.711 conversion reference code written by Sun Microsystems, -Inc. and code contributed to isdn4bsd by -.An Stefan Bethke . - diff --git a/usr.sbin/i4b/g711conv/g711conv.c b/usr.sbin/i4b/g711conv/g711conv.c deleted file mode 100644 index f6a442ead0d3..000000000000 --- a/usr.sbin/i4b/g711conv/g711conv.c +++ /dev/null @@ -1,304 +0,0 @@ -/* - * Copyright (c) 1999 Hellmuth Michaelis. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * --- - * - * The A-law to u-law and u-law to A-law conversion routines and tables - * were taken from the G.711 reference implementation from Sun and freely - * available as http://www.itu.int/itudoc/itu-t/rec/g/g700-799/refimpl.txt. - * - * Therefore for that part of the code, the following restrictions apply: - * - * - * This source code is a product of Sun Microsystems, Inc. and is provided - * for unrestricted use. Users may copy or modify this source code without - * charge. - * - * SUN SOURCE CODE IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING - * THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun source code is provided with no support and without any obligation on - * the part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THIS SOFTWARE - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - * - * --- - * - * The bitreverse table was contributed by Stefan Bethke. - * - *--------------------------------------------------------------------------- - * - * A-law / u-law conversions as specified in G.711 - * ----------------------------------------------- - * - * last edit-date: [Mon Apr 26 14:00:31 1999] - * - * $FreeBSD$ - * - *---------------------------------------------------------------------------*/ - -#include <stdio.h> -#include <unistd.h> -#include <machine/i4b_ioctl.h> - -/* copy from CCITT G.711 specifications */ - -/* u- to A-law conversions */ - -unsigned char _u2a[128] = { - 1, 1, 2, 2, 3, 3, 4, 4, - 5, 5, 6, 6, 7, 7, 8, 8, - 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, - 25, 27, 29, 31, 33, 34, 35, 36, - 37, 38, 39, 40, 41, 42, 43, 44, - 46, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, 58, 59, 60, 61, 62, - 64, 65, 66, 67, 68, 69, 70, 71, - 72, 73, 74, 75, 76, 77, 78, 79, - 81, 82, 83, 84, 85, 86, 87, 88, - 89, 90, 91, 92, 93, 94, 95, 96, - 97, 98, 99, 100, 101, 102, 103, 104, - 105, 106, 107, 108, 109, 110, 111, 112, - 113, 114, 115, 116, 117, 118, 119, 120, - 121, 122, 123, 124, 125, 126, 127, 128 -}; - -/* A- to u-law conversions */ - -unsigned char _a2u[128] = { - 1, 3, 5, 7, 9, 11, 13, 15, - 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, - 32, 32, 33, 33, 34, 34, 35, 35, - 36, 37, 38, 39, 40, 41, 42, 43, - 44, 45, 46, 47, 48, 48, 49, 49, - 50, 51, 52, 53, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, 64, 64, - 65, 66, 67, 68, 69, 70, 71, 72, - 73, 74, 75, 76, 77, 78, 79, 79, - 80, 81, 82, 83, 84, 85, 86, 87, - 88, 89, 90, 91, 92, 93, 94, 95, - 96, 97, 98, 99, 100, 101, 102, 103, - 104, 105, 106, 107, 108, 109, 110, 111, - 112, 113, 114, 115, 116, 117, 118, 119, - 120, 121, 122, 123, 124, 125, 126, 127 -}; - -/* reverse bits (7->0, 6->1, 5->2 etc) for tx to / rx from ISDN */ - -unsigned char bitreverse[256] = { - 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, - 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, - 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, - 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, - 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, - 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, - 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, - 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, - 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, - 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, - 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, - 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, - 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, - 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, - 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, - 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff -}; - -/* A-law to u-law conversion */ - -unsigned char alaw2ulaw(unsigned char aval) -{ - aval &= 0xff; - return ((aval & 0x80) ? (0xFF ^ _a2u[aval ^ 0xD5]) : - (0x7F ^ _a2u[aval ^ 0x55])); -} - -/* u-law to A-law conversion */ - -unsigned char ulaw2alaw(unsigned char uval) -{ - uval &= 0xff; - return ((uval & 0x80) ? (0xD5 ^ (_u2a[0xFF ^ uval] - 1)) : - (0x55 ^ (_u2a[0x7F ^ uval] - 1))); -} - -void -usage(void) -{ - fprintf(stderr, "\n"); - fprintf(stderr, "g711conv - do conversions according to ITU G.711, (version %d.%d.%d)\n",VERSION, REL, STEP); - fprintf(stderr, "usage: g711conv -a -r -R -u -P\n"); - fprintf(stderr, " -a A-law to u-law conversion\n"); - fprintf(stderr, " -r reverse bits before conversion\n"); - fprintf(stderr, " -R reverse bits after conversion\n"); - fprintf(stderr, " -u u-law to A-law conversion\n"); - fprintf(stderr, " -P print conversion table as C source\n"); - fprintf(stderr, "\n"); - exit(1); -} - -int -main(int argc, char **argv) -{ - int i; - int c; - int opt_a = 0; - int opt_u = 0; - int opt_r = 0; - int opt_P = 0; - int opt_R = 0; - unsigned char uc; - - while ((c = getopt(argc, argv, "aurPR?")) != -1) - { - switch(c) - { - case 'a': - opt_a = 1; - break; - - case 'u': - opt_u = 1; - break; - - case 'r': - opt_r = 1; - break; - - case 'R': - opt_R = 1; - break; - - case 'P': - opt_P = 1; - break; - - case '?': - default: - usage(); - break; - } - } - - if((opt_a + opt_u) > 1) - usage(); - - if(opt_P) - { - printf("\n/* "); - - if((opt_a + opt_u) == 0) - printf("No Conversion"); - - if(opt_a) - printf("A-law to u-law conversion"); - - if(opt_u) - printf("u-law to A-law conversion"); - - if(opt_r) - printf(", reverse bits BEFORE conversion"); - - if(opt_R) - printf(", reverse bits AFTER conversion"); - - if(opt_a) - { - printf(" */\n\nunsigned char a2u_tab[256] = {"); - } - else if(opt_u) - { - printf(" */\n\nunsigned char u2a_tab[256] = {"); - } - else - { - printf(" */\n\nunsigned char table[256] = {"); - } - - for(i=0; i < 256; i++) - { - uc = i; - - if(!(i % 8)) - printf("\n/* %02x */\t", i); - - if(opt_r) - uc = bitreverse[uc]; - - if(opt_u) - uc = ulaw2alaw(uc); - - if(opt_a) - uc = alaw2ulaw(uc); - - if(opt_R) - uc = bitreverse[uc]; - - if(i == 255) - printf("0x%02x", uc); - else - printf("0x%02x, ", uc); - } - printf("\n};\n"); - } - else - { - unsigned char ib[1]; - - while(fread(ib, 1, 1, stdin) == 1) - { - if(opt_r) - ib[0] = bitreverse[ib[0]]; - - if(opt_u) - ib[0] = ulaw2alaw(ib[0]); - - if(opt_a) - ib[0] = alaw2ulaw(ib[0]); - - if(opt_R) - ib[0] = bitreverse[ib[0]]; - - fwrite(ib, 1, 1, stdout); - } - } - return(0); -} - -/* EOF */ diff --git a/usr.sbin/inetd/builtins.c b/usr.sbin/inetd/builtins.c deleted file mode 100644 index d5fa0bb5e485..000000000000 --- a/usr.sbin/inetd/builtins.c +++ /dev/null @@ -1,682 +0,0 @@ -/*- - * Copyright (c) 1983, 1991, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - * - */ - -#include <sys/filio.h> -#include <sys/ioccom.h> -#include <sys/param.h> -#include <sys/stat.h> -#include <sys/socket.h> -#include <sys/sysctl.h> -#include <sys/ucred.h> -#include <sys/uio.h> -#include <sys/utsname.h> - -#include <ctype.h> -#include <err.h> -#include <errno.h> -#include <limits.h> -#include <pwd.h> -#include <signal.h> -#include <stdlib.h> -#include <string.h> -#include <sysexits.h> -#include <syslog.h> -#include <unistd.h> - -#include "inetd.h" - -extern int debug; -extern struct servtab *servtab; - -char ring[128]; -char *endring; - -int check_loop __P((struct sockaddr_in *, struct servtab *sep)); -void inetd_setproctitle __P((char *, int)); - -struct biltin biltins[] = { - /* Echo received data */ - { "echo", SOCK_STREAM, 1, -1, echo_stream }, - { "echo", SOCK_DGRAM, 0, 1, echo_dg }, - - /* Internet /dev/null */ - { "discard", SOCK_STREAM, 1, -1, discard_stream }, - { "discard", SOCK_DGRAM, 0, 1, discard_dg }, - - /* Return 32 bit time since 1970 */ - { "time", SOCK_STREAM, 0, -1, machtime_stream }, - { "time", SOCK_DGRAM, 0, 1, machtime_dg }, - - /* Return human-readable time */ - { "daytime", SOCK_STREAM, 0, -1, daytime_stream }, - { "daytime", SOCK_DGRAM, 0, 1, daytime_dg }, - - /* Familiar character generator */ - { "chargen", SOCK_STREAM, 1, -1, chargen_stream }, - { "chargen", SOCK_DGRAM, 0, 1, chargen_dg }, - - { "tcpmux", SOCK_STREAM, 1, -1, (void (*)())tcpmux }, - - { "auth", SOCK_STREAM, 1, -1, ident_stream }, - - { NULL } -}; - -/* - * RFC864 Character Generator Protocol. Generates character data without - * any regard for input. - */ - -void -initring() -{ - int i; - - endring = ring; - - for (i = 0; i <= 128; ++i) - if (isprint(i)) - *endring++ = i; -} - -/* ARGSUSED */ -void -chargen_dg(s, sep) /* Character generator */ - int s; - struct servtab *sep; -{ - struct sockaddr_in sin; - static char *rs; - int len, size; - char text[LINESIZ+2]; - - if (endring == 0) { - initring(); - rs = ring; - } - - size = sizeof(sin); - if (recvfrom(s, text, sizeof(text), 0, - (struct sockaddr *)&sin, &size) < 0) - return; - - if (check_loop(&sin, sep)) - return; - - if ((len = endring - rs) >= LINESIZ) - memmove(text, rs, LINESIZ); - else { - memmove(text, rs, len); - memmove(text + len, ring, LINESIZ - len); - } - if (++rs == endring) - rs = ring; - text[LINESIZ] = '\r'; - text[LINESIZ + 1] = '\n'; - (void) sendto(s, text, sizeof(text), 0, - (struct sockaddr *)&sin, sizeof(sin)); -} - -/* ARGSUSED */ -void -chargen_stream(s, sep) /* Character generator */ - int s; - struct servtab *sep; -{ - int len; - char *rs, text[LINESIZ+2]; - - inetd_setproctitle(sep->se_service, s); - - if (!endring) { - initring(); - rs = ring; - } - - text[LINESIZ] = '\r'; - text[LINESIZ + 1] = '\n'; - for (rs = ring;;) { - if ((len = endring - rs) >= LINESIZ) - memmove(text, rs, LINESIZ); - else { - memmove(text, rs, len); - memmove(text + len, ring, LINESIZ - len); - } - if (++rs == endring) - rs = ring; - if (write(s, text, sizeof(text)) != sizeof(text)) - break; - } - exit(0); -} - -/* - * RFC867 Daytime Protocol. Sends the current date and time as an ascii - * character string without any regard for input. - */ - -/* ARGSUSED */ -void -daytime_dg(s, sep) /* Return human-readable time of day */ - int s; - struct servtab *sep; -{ - char buffer[256]; - time_t clock; - struct sockaddr_in sin; - int size; - - clock = time((time_t *) 0); - - size = sizeof(sin); - if (recvfrom(s, buffer, sizeof(buffer), 0, - (struct sockaddr *)&sin, &size) < 0) - return; - - if (check_loop(&sin, sep)) - return; - - (void) sprintf(buffer, "%.24s\r\n", ctime(&clock)); - (void) sendto(s, buffer, strlen(buffer), 0, - (struct sockaddr *)&sin, sizeof(sin)); -} - -/* ARGSUSED */ -void -daytime_stream(s, sep) /* Return human-readable time of day */ - int s; - struct servtab *sep; -{ - char buffer[256]; - time_t clock; - - clock = time((time_t *) 0); - - (void) sprintf(buffer, "%.24s\r\n", ctime(&clock)); - (void) write(s, buffer, strlen(buffer)); -} - -/* - * RFC863 Discard Protocol. Any data received is thrown away and no response - * is sent. - */ - -/* ARGSUSED */ -void -discard_dg(s, sep) /* Discard service -- ignore data */ - int s; - struct servtab *sep; -{ - char buffer[BUFSIZE]; - - (void) read(s, buffer, sizeof(buffer)); -} - -/* ARGSUSED */ -void -discard_stream(s, sep) /* Discard service -- ignore data */ - int s; - struct servtab *sep; -{ - int ret; - char buffer[BUFSIZE]; - - inetd_setproctitle(sep->se_service, s); - while (1) { - while ((ret = read(s, buffer, sizeof(buffer))) > 0) - ; - if (ret == 0 || errno != EINTR) - break; - } - exit(0); -} - -/* - * RFC862 Echo Protocol. Any data received is sent back to the sender as - * received. - */ - -/* ARGSUSED */ -void -echo_dg(s, sep) /* Echo service -- echo data back */ - int s; - struct servtab *sep; -{ - char buffer[BUFSIZE]; - int i, size; - struct sockaddr_in sin; - - size = sizeof(sin); - if ((i = recvfrom(s, buffer, sizeof(buffer), 0, - (struct sockaddr *)&sin, &size)) < 0) - return; - - if (check_loop(&sin, sep)) - return; - - (void) sendto(s, buffer, i, 0, (struct sockaddr *)&sin, - sizeof(sin)); -} - -/* ARGSUSED */ -void -echo_stream(s, sep) /* Echo service -- echo data back */ - int s; - struct servtab *sep; -{ - char buffer[BUFSIZE]; - int i; - - inetd_setproctitle(sep->se_service, s); - while ((i = read(s, buffer, sizeof(buffer))) > 0 && - write(s, buffer, i) > 0) - ; - exit(0); -} - -/* - * RFC1413 Identification Protocol. Given a TCP port number pair, return a - * character string which identifies the owner of that connection on the - * server's system. Extended to allow for ~/.fakeid support and ~/.noident - * support. - */ - -/* ARGSUSED */ -void -iderror(lport, fport, s, er) /* Generic ident_stream error-sending func */ - int lport, fport, s, er; -{ - char *p; - - asprintf(&p, "%d , %d : ERROR : %s\r\n", lport, fport, - er == -1 ? "HIDDEN-USER" : er ? strerror(er) : "UNKNOWN-ERROR"); - if (p == NULL) { - syslog(LOG_ERR, "asprintf: %m"); - exit(EX_OSERR); - } - write(s, p, strlen(p)); - free(p); - - exit(0); -} - -/* ARGSUSED */ -void -ident_stream(s, sep) /* Ident service (AKA "auth") */ - int s; - struct servtab *sep; -{ - struct utsname un; - struct stat sb; - struct sockaddr_in sin[2]; - struct ucred uc; - struct timeval tv = { - 10, - 0 - }; - struct passwd *pw; - fd_set fdset; - char buf[BUFSIZE], *cp = NULL, *p, **av, *osname = NULL; - int len, c, fflag = 0, nflag = 0, rflag = 0, argc = 0; - u_short lport, fport; - - inetd_setproctitle(sep->se_service, s); - /* - * Reset getopt() since we are a fork() but not an exec() from - * a parent which used getopt() already. - */ - optind = 1; - optreset = 1; - /* - * Take the internal argument vector and count it out to make an - * argument count for getopt. This can be used for any internal - * service to read arguments and use getopt() easily. - */ - for (av = sep->se_argv; *av; av++) - argc++; - if (argc) { - int sec, usec; - - while ((c = getopt(argc, sep->se_argv, "fno:rt:")) != -1) - switch (c) { - case 'f': - fflag = 1; - break; - case 'n': - nflag = 1; - break; - case 'o': - osname = optarg; - break; - case 'r': - rflag = 1; - break; - case 't': - switch (sscanf(optarg, "%d.%d", &sec, &usec)) { - case 2: - tv.tv_usec = usec; - case 1: - tv.tv_sec = sec; - break; - default: - if (debug) - warnx("bad -t argument"); - break; - } - break; - default: - break; - } - } - if (osname == NULL) { - if (uname(&un) == -1) - iderror(0, 0, s, errno); - osname = un.sysname; - } - len = sizeof(sin[0]); - if (getsockname(s, (struct sockaddr *)&sin[0], &len) == -1) - iderror(0, 0, s, errno); - len = sizeof(sin[1]); - if (getpeername(s, (struct sockaddr *)&sin[1], &len) == -1) - iderror(0, 0, s, errno); - /* - * We're going to prepare for and execute reception of a - * packet of data from the user. The data is in the format - * "local_port , foreign_port\r\n" (with local being the - * server's port and foreign being the client's.) - */ - FD_ZERO(&fdset); - FD_SET(s, &fdset); - if (select(s + 1, &fdset, NULL, NULL, &tv) == -1) - iderror(0, 0, s, errno); - if (ioctl(s, FIONREAD, &len) == -1) - iderror(0, 0, s, errno); - if (len >= sizeof(buf)) - len = sizeof(buf) - 1; - len = read(s, buf, len); - if (len == -1) - iderror(0, 0, s, errno); - buf[len] = '\0'; - if (sscanf(buf, "%hu , %hu", &lport, &fport) != 2) - iderror(0, 0, s, 0); - if (!rflag) /* Send HIDDEN-USER immediately if not "real" */ - iderror(lport, fport, s, -1); - /* - * We take the input and construct an array of two sockaddr_ins - * which contain the local address information and foreign - * address information, respectively, used to look up the - * credentials for the socket (which are returned by the - * sysctl "net.inet.tcp.getcred" when we call it.) The - * arrays have been filled in above via get{peer,sock}name(), - * so right here we are only setting the ports. - */ - sin[0].sin_port = htons(lport); - sin[1].sin_port = htons(fport); - len = sizeof(uc); - if (sysctlbyname("net.inet.tcp.getcred", &uc, &len, sin, - sizeof(sin)) == -1) - iderror(lport, fport, s, errno); - pw = getpwuid(uc.cr_uid); /* Look up the pw to get the username */ - if (pw == NULL) - iderror(lport, fport, s, errno); - /* - * If enabled, we check for a file named ".noident" in the user's - * home directory. If found, we return HIDDEN-USER. - */ - if (nflag) { - if (asprintf(&p, "%s/.noident", pw->pw_dir) == -1) - iderror(lport, fport, s, errno); - if (lstat(p, &sb) == 0) { - free(p); - iderror(lport, fport, s, -1); - } - free(p); - } - /* - * Here, if enabled, we read a user's ".fakeid" file in their - * home directory. It consists of a line containing the name - * they want. - */ - if (fflag) { - FILE *fakeid = NULL; - - if (asprintf(&p, "%s/.fakeid", pw->pw_dir) == -1) - iderror(lport, fport, s, errno); - /* - * Here we set ourself to effectively be the user, so we don't - * open any files we have no permission to open, especially - * symbolic links to sensitive root-owned files or devices. - */ - seteuid(pw->pw_uid); - setegid(pw->pw_gid); - /* - * If we were to lstat() here, it would do no good, since it - * would introduce a race condition and could be defeated. - * Therefore, we open the file we have permissions to open - * and if it's not a regular file, we close it and end up - * returning the user's real username. - */ - fakeid = fopen(p, "r"); - free(p); - if (fakeid != NULL && - fstat(fileno(fakeid), &sb) != -1 && S_ISREG(sb.st_mode)) { - buf[sizeof(buf) - 1] = '\0'; - if (fgets(buf, sizeof(buf), fakeid) == NULL) { - cp = pw->pw_name; - fclose(fakeid); - goto printit; - } - fclose(fakeid); - /* - * Usually, the file will have the desired identity - * in the form "identity\n", so we use strtok() to - * end the string (which fgets() doesn't do.) - */ - strtok(buf, "\r\n"); - /* User names of >16 characters are invalid */ - if (strlen(buf) > 16) - buf[16] = '\0'; - cp = buf; - /* Allow for beginning white space... */ - while (isspace(*cp)) - cp++; - /* ...and ending white space. */ - strtok(cp, " \t"); - /* - * If the name is a zero-length string or matches - * the name of another user, it's invalid, so - * we will return their real identity instead. - */ - - if (!*cp || getpwnam(cp)) - cp = getpwuid(uc.cr_uid)->pw_name; - } else - cp = pw->pw_name; - } else - cp = pw->pw_name; -printit: - /* Finally, we make and send the reply. */ - if (asprintf(&p, "%d , %d : USERID : %s : %s\r\n", lport, fport, osname, - cp) == -1) { - syslog(LOG_ERR, "asprintf: %m"); - exit(EX_OSERR); - } - write(s, p, strlen(p)); - free(p); - - exit(0); -} - -/* - * RFC738 Time Server. - * Return a machine readable date and time, in the form of the - * number of seconds since midnight, Jan 1, 1900. Since gettimeofday - * returns the number of seconds since midnight, Jan 1, 1970, - * we must add 2208988800 seconds to this figure to make up for - * some seventy years Bell Labs was asleep. - */ - -unsigned long -machtime() -{ - struct timeval tv; - - if (gettimeofday(&tv, (struct timezone *)NULL) < 0) { - if (debug) - warnx("unable to get time of day"); - return (0L); - } -#define OFFSET ((u_long)25567 * 24*60*60) - return (htonl((long)(tv.tv_sec + OFFSET))); -#undef OFFSET -} - -/* ARGSUSED */ -void -machtime_dg(s, sep) - int s; - struct servtab *sep; -{ - unsigned long result; - struct sockaddr_in sin; - int size; - - size = sizeof(sin); - if (recvfrom(s, (char *)&result, sizeof(result), 0, - (struct sockaddr *)&sin, &size) < 0) - return; - - if (check_loop(&sin, sep)) - return; - - result = machtime(); - (void) sendto(s, (char *) &result, sizeof(result), 0, - (struct sockaddr *)&sin, sizeof(sin)); -} - -/* ARGSUSED */ -void -machtime_stream(s, sep) - int s; - struct servtab *sep; -{ - unsigned long result; - - result = machtime(); - (void) write(s, (char *) &result, sizeof(result)); -} - -/* - * RFC1078 TCP Port Service Multiplexer (TCPMUX). Service connections to - * services based on the service name sent. - * - * Based on TCPMUX.C by Mark K. Lottor November 1988 - * sri-nic::ps:<mkl>tcpmux.c - */ - -#define MAX_SERV_LEN (256+2) /* 2 bytes for \r\n */ -#define strwrite(fd, buf) (void) write(fd, buf, sizeof(buf)-1) - -static int /* # of characters upto \r,\n or \0 */ -getline(fd, buf, len) - int fd; - char *buf; - int len; -{ - int count = 0, n; - struct sigaction sa; - - sa.sa_flags = 0; - sigemptyset(&sa.sa_mask); - sa.sa_handler = SIG_DFL; - sigaction(SIGALRM, &sa, (struct sigaction *)0); - do { - alarm(10); - n = read(fd, buf, len-count); - alarm(0); - if (n == 0) - return (count); - if (n < 0) - return (-1); - while (--n >= 0) { - if (*buf == '\r' || *buf == '\n' || *buf == '\0') - return (count); - count++; - buf++; - } - } while (count < len); - return (count); -} - -struct servtab * -tcpmux(s) - int s; -{ - struct servtab *sep; - char service[MAX_SERV_LEN+1]; - int len; - - /* Get requested service name */ - if ((len = getline(s, service, MAX_SERV_LEN)) < 0) { - strwrite(s, "-Error reading service name\r\n"); - return (NULL); - } - service[len] = '\0'; - - if (debug) - warnx("tcpmux: someone wants %s", service); - - /* - * Help is a required command, and lists available services, - * one per line. - */ - if (!strcasecmp(service, "help")) { - for (sep = servtab; sep; sep = sep->se_next) { - if (!ISMUX(sep)) - continue; - (void)write(s,sep->se_service,strlen(sep->se_service)); - strwrite(s, "\r\n"); - } - return (NULL); - } - - /* Try matching a service in inetd.conf with the request */ - for (sep = servtab; sep; sep = sep->se_next) { - if (!ISMUX(sep)) - continue; - if (!strcasecmp(service, sep->se_service)) { - if (ISMUXPLUS(sep)) { - strwrite(s, "+Go\r\n"); - } - return (sep); - } - } - strwrite(s, "-Service not available\r\n"); - return (NULL); -} diff --git a/usr.sbin/inetd/inetd.h b/usr.sbin/inetd/inetd.h deleted file mode 100644 index ab78c734c54e..000000000000 --- a/usr.sbin/inetd/inetd.h +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) 1983, 1991, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#include <sys/time.h> -#include <sys/socket.h> - -#include <netinet/in.h> - -#include <stdio.h> - -#define BUFSIZE 8192 -#define LINESIZ 72 - -#define NORM_TYPE 0 -#define MUX_TYPE 1 -#define MUXPLUS_TYPE 2 -#define TTCP_TYPE 3 -#define ISMUX(sep) (((sep)->se_type == MUX_TYPE) || \ - ((sep)->se_type == MUXPLUS_TYPE)) -#define ISMUXPLUS(sep) ((sep)->se_type == MUXPLUS_TYPE) -#define ISTTCP(sep) ((sep)->se_type == TTCP_TYPE) - -struct servtab { - char *se_service; /* name of service */ - int se_socktype; /* type of socket to use */ - char *se_proto; /* protocol used */ - int se_maxchild; /* max number of children */ - int se_maxcpm; /* max connects per IP per minute */ - int se_numchild; /* current number of children */ - pid_t *se_pids; /* array of child pids */ - char *se_user; /* user name to run as */ - char *se_group; /* group name to run as */ -#ifdef LOGIN_CAP - char *se_class; /* login class name to run with */ -#endif - struct biltin *se_bi; /* if built-in, description */ - char *se_server; /* server program */ - char *se_server_name; /* server program without path */ -#define MAXARGV 20 - char *se_argv[MAXARGV+1]; /* program arguments */ - int se_fd; /* open descriptor */ - struct sockaddr_in se_ctrladdr;/* bound address */ - u_char se_type; /* type: normal, mux, or mux+ */ - u_char se_checked; /* looked at during merge */ - u_char se_accept; /* i.e., wait/nowait mode */ - u_char se_rpc; /* ==1 if RPC service */ - int se_rpc_prog; /* RPC program number */ - u_int se_rpc_lowvers; /* RPC low version */ - u_int se_rpc_highvers; /* RPC high version */ - int se_count; /* number started since se_time */ - struct timeval se_time; /* start of se_count */ - struct servtab *se_next; -}; - -void chargen_dg __P((int, struct servtab *)); -void chargen_stream __P((int, struct servtab *)); -void close_sep __P((struct servtab *)); -void flag_signal __P((char)); -void flag_config __P((int)); -void config __P((void)); -void daytime_dg __P((int, struct servtab *)); -void daytime_stream __P((int, struct servtab *)); -void discard_dg __P((int, struct servtab *)); -void discard_stream __P((int, struct servtab *)); -void echo_dg __P((int, struct servtab *)); -void echo_stream __P((int, struct servtab *)); -void endconfig __P((void)); -struct servtab *enter __P((struct servtab *)); -void freeconfig __P((struct servtab *)); -struct servtab *getconfigent __P((void)); -void iderror __P((int, int, int, int)); -void ident_stream __P((int, struct servtab *)); -void machtime_dg __P((int, struct servtab *)); -void machtime_stream __P((int, struct servtab *)); -int matchservent __P((char *, char *, char *)); -char *newstr __P((char *)); -char *nextline __P((FILE *)); -void print_service __P((char *, struct servtab *)); -void addchild __P((struct servtab *, int)); -void flag_reapchild __P((int)); -void reapchild __P((void)); -void enable __P((struct servtab *)); -void disable __P((struct servtab *)); -void flag_retry __P((int)); -void retry __P((void)); -int setconfig __P((void)); -void setup __P((struct servtab *)); -char *sskip __P((char **)); -char *skip __P((char **)); -struct servtab *tcpmux __P((int)); -int cpmip __P((struct servtab *, int)); -void inetd_setproctitle __P((char *, int)); - -void unregisterrpc __P((register struct servtab *sep)); - -struct biltin { - char *bi_service; /* internally provided service name */ - int bi_socktype; /* type of socket supported */ - short bi_fork; /* 1 if should fork before call */ - int bi_maxchild; /* max number of children, -1=default */ - void (*bi_fn)(); /* function which performs it */ -}; diff --git a/usr.sbin/pkg_install/add/main.c b/usr.sbin/pkg_install/add/main.c index d549f8a1040f..d4cc6ae25c97 100644 --- a/usr.sbin/pkg_install/add/main.c +++ b/usr.sbin/pkg_install/add/main.c @@ -193,7 +193,7 @@ getpackagesite(void) strcpy(sitepath, u.machine); if (reldate == 330000) - strcat(sitepath, "/packages-3.3/"); + strcat(sitepath, "/packages-3.3-release/"); else if (330000 < reldate && reldate < 400000) strcat(sitepath, "/packages-3-stable/Latest/"); else diff --git a/usr.sbin/ppp/nat_cmd.c b/usr.sbin/ppp/nat_cmd.c deleted file mode 100644 index ebf13e7ca99a..000000000000 --- a/usr.sbin/ppp/nat_cmd.c +++ /dev/null @@ -1,434 +0,0 @@ -/*- - * The code in this file was written by Eivind Eklund <perhaps@yes.no>, - * who places it in the public domain without restriction. - * - * $FreeBSD$ - */ - -#include <sys/param.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <netdb.h> -#include <netinet/in_systm.h> -#include <netinet/in.h> -#include <netinet/ip.h> -#include <sys/un.h> - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <termios.h> - -#ifdef __FreeBSD__ -#include <alias.h> -#else -#include "alias.h" -#endif -#include "layer.h" -#include "proto.h" -#include "defs.h" -#include "command.h" -#include "log.h" -#include "nat_cmd.h" -#include "descriptor.h" -#include "prompt.h" -#include "timer.h" -#include "fsm.h" -#include "slcompress.h" -#include "throughput.h" -#include "iplist.h" -#include "mbuf.h" -#include "lqr.h" -#include "hdlc.h" -#include "ipcp.h" -#include "lcp.h" -#include "ccp.h" -#include "link.h" -#include "mp.h" -#include "filter.h" -#ifndef NORADIUS -#include "radius.h" -#endif -#include "bundle.h" - - -static int StrToAddr(const char *, struct in_addr *); -static int StrToPortRange(const char *, u_short *, u_short *, const char *); -static int StrToAddrAndPort(const char *, struct in_addr *, u_short *, - u_short *, const char *); - -static void -lowhigh(u_short *a, u_short *b) -{ - if (a > b) { - u_short c; - - c = *b; - *b = *a; - *a = c; - } -} - -int -nat_RedirectPort(struct cmdargs const *arg) -{ - if (!arg->bundle->NatEnabled) { - prompt_Printf(arg->prompt, "Alias not enabled\n"); - return 1; - } else if (arg->argc == arg->argn + 3 || arg->argc == arg->argn + 4) { - char proto_constant; - const char *proto; - struct in_addr localaddr; - u_short hlocalport, llocalport; - struct in_addr aliasaddr; - u_short haliasport, laliasport; - struct in_addr remoteaddr; - u_short hremoteport, lremoteport; - struct alias_link *link; - int error; - - proto = arg->argv[arg->argn]; - if (strcmp(proto, "tcp") == 0) { - proto_constant = IPPROTO_TCP; - } else if (strcmp(proto, "udp") == 0) { - proto_constant = IPPROTO_UDP; - } else { - prompt_Printf(arg->prompt, "port redirect: protocol must be" - " tcp or udp\n"); - return -1; - } - - error = StrToAddrAndPort(arg->argv[arg->argn+1], &localaddr, &llocalport, - &hlocalport, proto); - if (error) { - prompt_Printf(arg->prompt, "nat port: error reading localaddr:port\n"); - return -1; - } - - error = StrToPortRange(arg->argv[arg->argn+2], &laliasport, &haliasport, - proto); - if (error) { - prompt_Printf(arg->prompt, "nat port: error reading alias port\n"); - return -1; - } - aliasaddr.s_addr = INADDR_ANY; - - if (arg->argc == arg->argn + 4) { - error = StrToAddrAndPort(arg->argv[arg->argn+3], &remoteaddr, - &lremoteport, &hremoteport, proto); - if (error) { - prompt_Printf(arg->prompt, "nat port: error reading " - "remoteaddr:port\n"); - return -1; - } - } else { - remoteaddr.s_addr = INADDR_ANY; - lremoteport = hremoteport = 0; - } - - lowhigh(&llocalport, &hlocalport); - lowhigh(&laliasport, &haliasport); - lowhigh(&lremoteport, &hremoteport); - - if (haliasport - laliasport != hlocalport - llocalport) { - prompt_Printf(arg->prompt, "nat port: local & alias port ranges " - "are not equal\n"); - return -1; - } - - if (hremoteport && hremoteport - lremoteport != hlocalport - llocalport) { - prompt_Printf(arg->prompt, "nat port: local & remote port ranges " - "are not equal\n"); - return -1; - } - - while (laliasport <= haliasport) { - link = PacketAliasRedirectPort(localaddr, htons(llocalport), - remoteaddr, htons(lremoteport), - aliasaddr, htons(laliasport), - proto_constant); - - if (link == NULL) { - prompt_Printf(arg->prompt, "nat port: %d: error %d\n", laliasport, - error); - return 1; - } - llocalport++; - laliasport++; - if (hremoteport) - lremoteport++; - } - - return 0; - } - - return -1; -} - - -int -nat_RedirectAddr(struct cmdargs const *arg) -{ - if (!arg->bundle->NatEnabled) { - prompt_Printf(arg->prompt, "nat not enabled\n"); - return 1; - } else if (arg->argc == arg->argn+2) { - int error; - struct in_addr localaddr, aliasaddr; - struct alias_link *link; - - error = StrToAddr(arg->argv[arg->argn], &localaddr); - if (error) { - prompt_Printf(arg->prompt, "address redirect: invalid local address\n"); - return 1; - } - error = StrToAddr(arg->argv[arg->argn+1], &aliasaddr); - if (error) { - prompt_Printf(arg->prompt, "address redirect: invalid alias address\n"); - prompt_Printf(arg->prompt, "Usage: nat %s %s\n", arg->cmd->name, - arg->cmd->syntax); - return 1; - } - link = PacketAliasRedirectAddr(localaddr, aliasaddr); - if (link == NULL) { - prompt_Printf(arg->prompt, "address redirect: packet aliasing" - " engine error\n"); - prompt_Printf(arg->prompt, "Usage: nat %s %s\n", arg->cmd->name, - arg->cmd->syntax); - } - } else - return -1; - - return 0; -} - - -static int -StrToAddr(const char *str, struct in_addr *addr) -{ - struct hostent *hp; - - if (inet_aton(str, addr)) - return 0; - - hp = gethostbyname(str); - if (!hp) { - log_Printf(LogWARN, "StrToAddr: Unknown host %s.\n", str); - return -1; - } - *addr = *((struct in_addr *) hp->h_addr); - return 0; -} - - -static int -StrToPort(const char *str, u_short *port, const char *proto) -{ - struct servent *sp; - char *end; - - *port = strtol(str, &end, 10); - if (*end != '\0') { - sp = getservbyname(str, proto); - if (sp == NULL) { - log_Printf(LogWARN, "StrToAddr: Unknown port or service %s/%s.\n", - str, proto); - return -1; - } - *port = ntohs(sp->s_port); - } - - return 0; -} - -static int -StrToPortRange(const char *str, u_short *low, u_short *high, const char *proto) -{ - char *minus; - int res; - - minus = strchr(str, '-'); - if (minus) - *minus = '\0'; /* Cheat the const-ness ! */ - - res = StrToPort(str, low, proto); - - if (minus) - *minus = '-'; /* Cheat the const-ness ! */ - - if (res == 0) { - if (minus) - res = StrToPort(minus + 1, high, proto); - else - *high = *low; - } - - return res; -} - -static int -StrToAddrAndPort(const char *str, struct in_addr *addr, u_short *low, - u_short *high, const char *proto) -{ - char *colon; - int res; - - colon = strchr(str, ':'); - if (!colon) { - log_Printf(LogWARN, "StrToAddrAndPort: %s is missing port number.\n", str); - return -1; - } - - *colon = '\0'; /* Cheat the const-ness ! */ - res = StrToAddr(str, addr); - *colon = ':'; /* Cheat the const-ness ! */ - if (res != 0) - return -1; - - return StrToPortRange(colon + 1, low, high, proto); -} - -int -nat_ProxyRule(struct cmdargs const *arg) -{ - char cmd[LINE_LEN]; - int f, pos; - size_t len; - - if (arg->argn >= arg->argc) - return -1; - - for (f = arg->argn, pos = 0; f < arg->argc; f++) { - len = strlen(arg->argv[f]); - if (sizeof cmd - pos < len + (f ? 1 : 0)) - break; - if (f) - cmd[pos++] = ' '; - strcpy(cmd + pos, arg->argv[f]); - pos += len; - } - - return PacketAliasProxyRule(cmd); -} - -int -nat_Pptp(struct cmdargs const *arg) -{ - struct in_addr addr; - - if (arg->argc == arg->argn) { - addr.s_addr = INADDR_NONE; - PacketAliasPptp(addr); - return 0; - } - - if (arg->argc != arg->argn + 1) - return -1; - - addr = GetIpAddr(arg->argv[arg->argn]); - if (addr.s_addr == INADDR_NONE) { - log_Printf(LogWARN, "%s: invalid address\n", arg->argv[arg->argn]); - return 1; - } - - PacketAliasPptp(addr); - return 0; -} - -static struct mbuf * -nat_PadMbuf(struct mbuf *bp, int type) -{ - struct mbuf **last; - int len; - - mbuf_SetType(bp, type); - for (last = &bp, len = 0; *last != NULL; last = &(*last)->next) - len += (*last)->cnt; - - len = MAX_MRU - len; - *last = mbuf_Alloc(len, type); - - return bp; -} - -static struct mbuf * -nat_LayerPush(struct bundle *bundle, struct link *l, struct mbuf *bp, - int pri, u_short *proto) -{ - if (!bundle->NatEnabled || *proto != PROTO_IP) - return bp; - - log_Printf(LogDEBUG, "nat_LayerPush: PROTO_IP -> PROTO_IP\n"); - bp = mbuf_Contiguous(nat_PadMbuf(bp, MB_NATOUT)); - PacketAliasOut(MBUF_CTOP(bp), bp->cnt); - bp->cnt = ntohs(((struct ip *)MBUF_CTOP(bp))->ip_len); - - return bp; -} - -static struct mbuf * -nat_LayerPull(struct bundle *bundle, struct link *l, struct mbuf *bp, - u_short *proto) -{ - struct ip *pip, *piip; - int ret, len; - struct mbuf **last; - char *fptr; - - if (!bundle->NatEnabled || *proto != PROTO_IP) - return bp; - - log_Printf(LogDEBUG, "nat_LayerPull: PROTO_IP -> PROTO_IP\n"); - bp = mbuf_Contiguous(nat_PadMbuf(bp, MB_NATIN)); - pip = (struct ip *)MBUF_CTOP(bp); - piip = (struct ip *)((char *)pip + (pip->ip_hl << 2)); - - if (pip->ip_p == IPPROTO_IGMP || - (pip->ip_p == IPPROTO_IPIP && IN_CLASSD(ntohl(piip->ip_dst.s_addr)))) - return bp; - - ret = PacketAliasIn(MBUF_CTOP(bp), bp->cnt); - - bp->cnt = ntohs(pip->ip_len); - if (bp->cnt > MAX_MRU) { - log_Printf(LogWARN, "nat_LayerPull: Problem with IP header length (%d)\n", - bp->cnt); - mbuf_Free(bp); - return NULL; - } - - switch (ret) { - case PKT_ALIAS_OK: - break; - - case PKT_ALIAS_UNRESOLVED_FRAGMENT: - /* Save the data for later */ - fptr = malloc(bp->cnt); - bp = mbuf_Read(bp, fptr, bp->cnt); - PacketAliasSaveFragment(fptr); - break; - - case PKT_ALIAS_FOUND_HEADER_FRAGMENT: - /* Fetch all the saved fragments and chain them on the end of `bp' */ - last = &bp->pnext; - while ((fptr = PacketAliasGetFragment(MBUF_CTOP(bp))) != NULL) { - PacketAliasFragmentIn(MBUF_CTOP(bp), fptr); - len = ntohs(((struct ip *)fptr)->ip_len); - *last = mbuf_Alloc(len, MB_NATIN); - memcpy(MBUF_CTOP(*last), fptr, len); - free(fptr); - last = &(*last)->pnext; - } - break; - - default: - mbuf_Free(bp); - bp = NULL; - break; - } - - return bp; -} - -struct layer natlayer = - { LAYER_NAT, "nat", nat_LayerPush, nat_LayerPull }; diff --git a/usr.sbin/ppp/nat_cmd.h b/usr.sbin/ppp/nat_cmd.h deleted file mode 100644 index 1ce19d10c76d..000000000000 --- a/usr.sbin/ppp/nat_cmd.h +++ /dev/null @@ -1,15 +0,0 @@ -/*- - * The code in this file was written by Eivind Eklund <perhaps@yes.no>, - * who places it in the public domain without restriction. - * - * $FreeBSD$ - */ - -struct cmdargs; - -extern int nat_RedirectPort(struct cmdargs const *); -extern int nat_RedirectAddr(struct cmdargs const *); -extern int nat_ProxyRule(struct cmdargs const *); -extern int nat_Pptp(struct cmdargs const *); - -extern struct layer natlayer; diff --git a/usr.sbin/pw/pw_vpw.c b/usr.sbin/pw/pw_vpw.c deleted file mode 100644 index ef12437a15ef..000000000000 --- a/usr.sbin/pw/pw_vpw.c +++ /dev/null @@ -1,316 +0,0 @@ -/*- - * Copyright (C) 1996 - * David L. Nugent. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY DAVID L. NUGENT AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL DAVID L. NUGENT OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -#ifndef lint -static const char rcsid[] = - "$FreeBSD$"; -#endif /* not lint */ - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <sys/param.h> - -#include "pwupd.h" - -static FILE * pwd_fp = NULL; - -void -vendpwent(void) -{ - if (pwd_fp != NULL) { - fclose(pwd_fp); - pwd_fp = NULL; - } -} - -void -vsetpwent(void) -{ - vendpwent(); -} - -static struct passwd * -vnextpwent(char const * nam, uid_t uid, int doclose) -{ - struct passwd * pw = NULL; - static char pwtmp[1024]; - - strncpy(pwtmp, getpwpath(_MASTERPASSWD), sizeof pwtmp); - pwtmp[sizeof pwtmp - 1] = '\0'; - - if (pwd_fp != NULL || (pwd_fp = fopen(pwtmp, "r")) != NULL) { - int done = 0; - - static struct passwd pwd; - - while (!done && fgets(pwtmp, sizeof pwtmp, pwd_fp) != NULL) - { - int i, quickout = 0; - char * q; - char * p = strchr(pwtmp, '\n'); - - if (p == NULL) { - while (fgets(pwtmp, sizeof pwtmp, pwd_fp) != NULL && strchr(pwtmp, '\n')==NULL) - ; /* Skip long lines */ - continue; - } - - /* skip comments & empty lines */ - if (*pwtmp =='\n' || *pwtmp == '#') - continue; - - i = 0; - q = p = pwtmp; - bzero(&pwd, sizeof pwd); - while (!quickout && (p = strsep(&q, ":\n")) != NULL) { - switch (i++) - { - case 0: /* username */ - pwd.pw_name = p; - if (nam) { - if (strcmp(nam, p) == 0) - done = 1; - else - quickout = 1; - } - break; - case 1: /* password */ - pwd.pw_passwd = p; - break; - case 2: /* uid */ - pwd.pw_uid = atoi(p); - if (uid != (uid_t)-1) { - if (uid == pwd.pw_uid) - done = 1; - else - quickout = 1; - } - break; - case 3: /* gid */ - pwd.pw_gid = atoi(p); - break; - case 4: /* class */ - if (nam == NULL && uid == (uid_t)-1) - done = 1; - pwd.pw_class = p; - break; - case 5: /* change */ - pwd.pw_change = (time_t)atol(p); - break; - case 6: /* expire */ - pwd.pw_expire = (time_t)atol(p); - break; - case 7: /* gecos */ - pwd.pw_gecos = p; - break; - case 8: /* directory */ - pwd.pw_dir = p; - break; - case 9: /* shell */ - pwd.pw_shell = p; - break; - } - } - } - if (doclose) - vendpwent(); - if (done && pwd.pw_name) { - pw = &pwd; - - #define CKNULL(s) s = s ? s : "" - CKNULL(pwd.pw_passwd); - CKNULL(pwd.pw_class); - CKNULL(pwd.pw_gecos); - CKNULL(pwd.pw_dir); - CKNULL(pwd.pw_shell); - } - } - return pw; -} - -struct passwd * -vgetpwent(void) -{ - return vnextpwent(NULL, -1, 0); -} - -struct passwd * -vgetpwuid(uid_t uid) -{ - return vnextpwent(NULL, uid, 1); -} - -struct passwd * -vgetpwnam(const char * nam) -{ - return vnextpwent(nam, -1, 1); -} - -int vpwdb(char *arg, ...) -{ - arg=arg; - return 0; -} - - - -static FILE * grp_fp = NULL; - -void -vendgrent(void) -{ - if (grp_fp != NULL) { - fclose(grp_fp); - grp_fp = NULL; - } -} - -int -vsetgrent(void) -{ - vendgrent(); - return 0; -} - -static struct group * -vnextgrent(char const * nam, gid_t gid, int doclose) -{ - struct group * gr = NULL; - - static char * grtmp = NULL; - static int grlen = 0; - static char ** mems = NULL; - static int memlen = 0; - - extendline(&grtmp, &grlen, MAXPATHLEN); - strncpy(grtmp, getgrpath(_GROUP), MAXPATHLEN); - grtmp[MAXPATHLEN - 1] = '\0'; - - if (grp_fp != NULL || (grp_fp = fopen(grtmp, "r")) != NULL) { - int done = 0; - - static struct group grp; - - while (!done && fgets(grtmp, grlen, grp_fp) != NULL) - { - int i, quickout = 0; - int mno = 0; - char * q, * p; - char * sep = ":\n"; - - if ((p = strchr(grtmp, '\n')) == NULL) { - int l; - extendline(&grtmp, &grlen, grlen + PWBUFSZ); - l = strlen(grtmp); - if (fgets(grtmp + l, grlen - l, grp_fp) == NULL) - break; /* No newline terminator on last line */ - } - /* Skip comments and empty lines */ - if (*grtmp == '\n' || *grtmp == '#') - continue; - i = 0; - q = p = grtmp; - bzero(&grp, sizeof grp); - extendarray(&mems, &memlen, 200); - while (!quickout && (p = strsep(&q, sep)) != NULL) { - switch (i++) - { - case 0: /* groupname */ - grp.gr_name = p; - if (nam) { - if (strcmp(nam, p) == 0) - done = 1; - else - quickout = 1; - } - break; - case 1: /* password */ - grp.gr_passwd = p; - break; - case 2: /* gid */ - grp.gr_gid = atoi(p); - if (gid != (gid_t)-1) { - if (gid == (gid_t)grp.gr_gid) - done = 1; - else - quickout = 1; - } else if (nam == NULL) - done = 1; - break; - case 3: - q = p; - sep = ",\n"; - break; - default: - if (*p) { - extendarray(&mems, &memlen, mno + 2); - mems[mno++] = p; - } - break; - } - } - grp.gr_mem = mems; - mems[mno] = NULL; - } - if (doclose) - vendgrent(); - if (done && grp.gr_name) { - gr = &grp; - - CKNULL(grp.gr_passwd); - } - } - return gr; -} - -struct group * -vgetgrent(void) -{ - return vnextgrent(NULL, -1, 0); -} - - -struct group * -vgetgrgid(gid_t gid) -{ - return vnextgrent(NULL, gid, 1); -} - -struct group * -vgetgrnam(const char * nam) -{ - return vnextgrent(nam, -1, 1); -} - -int -vgrdb(char *arg, ...) -{ - arg=arg; - return 0; -} - |