diff options
| author | cvs2svn <cvs2svn@FreeBSD.org> | 1997-02-22 22:50:58 +0000 |
|---|---|---|
| committer | cvs2svn <cvs2svn@FreeBSD.org> | 1997-02-22 22:50:58 +0000 |
| commit | dd99818c307d07cfba061e4a45e0167038b5a6a3 (patch) | |
| tree | d345f6b110134837712799187b2b18f1f0676beb | |
| parent | 974c0777cc01f35b0fc8b228dc044f4a116f0fed (diff) | |
Notes
31 files changed, 3872 insertions, 0 deletions
diff --git a/gnu/lib/libreadline/doc/history/Makefile b/gnu/lib/libreadline/doc/history/Makefile new file mode 100644 index 000000000000..4b8112af618d --- /dev/null +++ b/gnu/lib/libreadline/doc/history/Makefile @@ -0,0 +1,14 @@ +# $Id$ + +SRCDIR= ${.CURDIR}/../../../../../contrib/libreadline/doc + +INFO = history + +INFOSECTION= "Programming & development tools." +INFOENTRY_history= "* History: (history). The GNU History library." + +SRCS= hist.texinfo + +history.info: hist.texinfo hstech.texinfo hsuser.texinfo + +.include <bsd.info.mk> diff --git a/gnu/lib/libreadline/doc/readline/Makefile b/gnu/lib/libreadline/doc/readline/Makefile new file mode 100644 index 000000000000..8e5104136239 --- /dev/null +++ b/gnu/lib/libreadline/doc/readline/Makefile @@ -0,0 +1,14 @@ +# $Id$ + +SRCDIR= ${.CURDIR}/../../../../../contrib/libreadline/doc + +INFO = readline + +INFOSECTION= "Programming & development tools." +INFOENTRY_readline= "* Readline: (readline). The GNU Readline library" + +SRCS= rlman.texinfo + +readline.info: rlman.texinfo rltech.texinfo rluser.texinfo + +.include <bsd.info.mk> diff --git a/lib/libc/net/inet_net_ntop.c b/lib/libc/net/inet_net_ntop.c new file mode 100644 index 000000000000..4c7893d417ff --- /dev/null +++ b/lib/libc/net/inet_net_ntop.c @@ -0,0 +1,140 @@ +/* + * Copyright (c) 1996 by Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static const char orig_rcsid[] = "From Id: inet_net_ntop.c,v 8.2 1996/08/08 06:54:44 vixie Exp"; +static const char rcsid[] = "$Id$"; +#endif + +#include <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> + +#include <errno.h> +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +#ifdef SPRINTF_CHAR +# define SPRINTF(x) strlen(sprintf/**/x) +#else +# define SPRINTF(x) ((size_t)sprintf x) +#endif + +static char * inet_net_ntop_ipv4 __P((const u_char *src, int bits, + char *dst, size_t size)); + +/* + * char * + * inet_net_ntop(af, src, bits, dst, size) + * convert network number from network to presentation format. + * generates CIDR style result always. + * return: + * pointer to dst, or NULL if an error occurred (check errno). + * author: + * Paul Vixie (ISC), July 1996 + */ +char * +inet_net_ntop(af, src, bits, dst, size) + int af; + const void *src; + int bits; + char *dst; + size_t size; +{ + switch (af) { + case AF_INET: + return (inet_net_ntop_ipv4(src, bits, dst, size)); + default: + errno = EAFNOSUPPORT; + return (NULL); + } +} + +/* + * static char * + * inet_net_ntop_ipv4(src, bits, dst, size) + * convert IPv4 network number from network to presentation format. + * generates CIDR style result always. + * return: + * pointer to dst, or NULL if an error occurred (check errno). + * note: + * network byte order assumed. this means 192.5.5.240/28 has + * 0x11110000 in its fourth octet. + * author: + * Paul Vixie (ISC), July 1996 + */ +static char * +inet_net_ntop_ipv4(src, bits, dst, size) + const u_char *src; + int bits; + char *dst; + size_t size; +{ + char *odst = dst; + char *t; + u_int m; + int b; + + if (bits < 0 || bits > 32) { + errno = EINVAL; + return (NULL); + } + if (bits == 0) { + if (size < sizeof "0") + goto emsgsize; + *dst++ = '0'; + *dst = '\0'; + } + + /* Format whole octets. */ + for (b = bits / 8; b > 0; b--) { + if (size < sizeof "255.") + goto emsgsize; + t = dst; + dst += SPRINTF((dst, "%u", *src++)); + if (b > 1) { + *dst++ = '.'; + *dst = '\0'; + } + size -= (size_t)(dst - t); + } + + /* Format partial octet. */ + b = bits % 8; + if (b > 0) { + if (size < sizeof ".255") + goto emsgsize; + t = dst; + if (dst != odst) + *dst++ = '.'; + m = ((1 << b) - 1) << (8 - b); + dst += SPRINTF((dst, "%u", *src & m)); + size -= (size_t)(dst - t); + } + + /* Format CIDR /width. */ + if (size < sizeof "/32") + goto emsgsize; + dst += SPRINTF((dst, "/%u", bits)); + return (odst); + + emsgsize: + errno = EMSGSIZE; + return (NULL); +} diff --git a/lib/libc/net/inet_net_pton.c b/lib/libc/net/inet_net_pton.c new file mode 100644 index 000000000000..6fd6a06c6da9 --- /dev/null +++ b/lib/libc/net/inet_net_pton.c @@ -0,0 +1,208 @@ +/* + * Copyright (c) 1996 by Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static const char orig_rcsid[] = "From Id: inet_net_pton.c,v 8.3 1996/11/11 06:36:52 vixie Exp"; +static const char rcsid[] = "$Id$"; +#endif + +#include <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> + +#include <assert.h> +#include <ctype.h> +#include <errno.h> +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +#ifdef SPRINTF_CHAR +# define SPRINTF(x) strlen(sprintf/**/x) +#else +# define SPRINTF(x) ((size_t)sprintf x) +#endif + +static int inet_net_pton_ipv4 __P((const char *src, u_char *dst, + size_t size)); + +/* + * static int + * inet_net_pton(af, src, dst, size) + * convert network number from presentation to network format. + * accepts hex octets, hex strings, decimal octets, and /CIDR. + * "size" is in bytes and describes "dst". + * return: + * number of bits, either imputed classfully or specified with /CIDR, + * or -1 if some failure occurred (check errno). ENOENT means it was + * not a valid network specification. + * author: + * Paul Vixie (ISC), June 1996 + */ +int +inet_net_pton(af, src, dst, size) + int af; + const char *src; + void *dst; + size_t size; +{ + switch (af) { + case AF_INET: + return (inet_net_pton_ipv4(src, dst, size)); + default: + errno = EAFNOSUPPORT; + return (-1); + } +} + +/* + * static int + * inet_net_pton_ipv4(src, dst, size) + * convert IPv4 network number from presentation to network format. + * accepts hex octets, hex strings, decimal octets, and /CIDR. + * "size" is in bytes and describes "dst". + * return: + * number of bits, either imputed classfully or specified with /CIDR, + * or -1 if some failure occurred (check errno). ENOENT means it was + * not an IPv4 network specification. + * note: + * network byte order assumed. this means 192.5.5.240/28 has + * 0x11110000 in its fourth octet. + * author: + * Paul Vixie (ISC), June 1996 + */ +static int +inet_net_pton_ipv4(src, dst, size) + const char *src; + u_char *dst; + size_t size; +{ + static const char + xdigits[] = "0123456789abcdef", + digits[] = "0123456789"; + int n, ch, tmp, dirty, bits; + const u_char *odst = dst; + + ch = *src++; + if (ch == '0' && (src[0] == 'x' || src[0] == 'X') + && isascii(src[1]) && isxdigit(src[1])) { + /* Hexadecimal: Eat nybble string. */ + if (size <= 0) + goto emsgsize; + *dst = 0, dirty = 0; + src++; /* skip x or X. */ + while ((ch = *src++) != '\0' && + isascii(ch) && isxdigit(ch)) { + if (isupper(ch)) + ch = tolower(ch); + n = strchr(xdigits, ch) - xdigits; + assert(n >= 0 && n <= 15); + *dst |= n; + if (!dirty++) + *dst <<= 4; + else if (size-- > 0) + *++dst = 0, dirty = 0; + else + goto emsgsize; + } + if (dirty) + size--; + } else if (isascii(ch) && isdigit(ch)) { + /* Decimal: eat dotted digit string. */ + for (;;) { + tmp = 0; + do { + n = strchr(digits, ch) - digits; + assert(n >= 0 && n <= 9); + tmp *= 10; + tmp += n; + if (tmp > 255) + goto enoent; + } while ((ch = *src++) != '\0' && + isascii(ch) && isdigit(ch)); + if (size-- <= 0) + goto emsgsize; + *dst++ = (u_char) tmp; + if (ch == '\0' || ch == '/') + break; + if (ch != '.') + goto enoent; + ch = *src++; + if (!isascii(ch) || !isdigit(ch)) + goto enoent; + } + } else + goto enoent; + + bits = -1; + if (ch == '/' && isascii(src[0]) && isdigit(src[0]) && dst > odst) { + /* CIDR width specifier. Nothing can follow it. */ + ch = *src++; /* Skip over the /. */ + bits = 0; + do { + n = strchr(digits, ch) - digits; + assert(n >= 0 && n <= 9); + bits *= 10; + bits += n; + } while ((ch = *src++) != '\0' && + isascii(ch) && isdigit(ch)); + if (ch != '\0') + goto enoent; + if (bits > 32) + goto emsgsize; + } + + /* Firey death and destruction unless we prefetched EOS. */ + if (ch != '\0') + goto enoent; + + /* If nothing was written to the destination, we found no address. */ + if (dst == odst) + goto enoent; + /* If no CIDR spec was given, infer width from net class. */ + if (bits == -1) { + if (*odst >= 240) /* Class E */ + bits = 32; + else if (*odst >= 224) /* Class D */ + bits = 4; + else if (*odst >= 192) /* Class C */ + bits = 24; + else if (*odst >= 128) /* Class B */ + bits = 16; + else /* Class A */ + bits = 8; + /* If imputed mask is narrower than specified octets, widen. */ + if (bits >= 8 && bits < ((dst - odst) * 8)) + bits = (dst - odst) * 8; + } + /* Extend network to cover the actual mask. */ + while (bits > ((dst - odst) * 8)) { + if (size-- <= 0) + goto emsgsize; + *dst++ = '\0'; + } + return (bits); + + enoent: + errno = ENOENT; + return (-1); + + emsgsize: + errno = EMSGSIZE; + return (-1); +} diff --git a/lib/libc/net/inet_neta.c b/lib/libc/net/inet_neta.c new file mode 100644 index 000000000000..15a1c70529ac --- /dev/null +++ b/lib/libc/net/inet_neta.c @@ -0,0 +1,83 @@ +/* + * Copyright (c) 1996 by Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static const char orig_rcsid[] = "From Id: inet_neta.c,v 8.2 1996/08/08 06:54:44 vixie Exp"; +static const char rcsid[] = "$Id$"; +#endif + +#include <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> + +#include <errno.h> +#include <stdio.h> + +#ifdef SPRINTF_CHAR +# define SPRINTF(x) strlen(sprintf/**/x) +#else +# define SPRINTF(x) ((size_t)sprintf x) +#endif + +/* + * char * + * inet_neta(src, dst, size) + * format a u_long network number into presentation format. + * return: + * pointer to dst, or NULL if an error occurred (check errno). + * note: + * format of ``src'' is as for inet_network(). + * author: + * Paul Vixie (ISC), July 1996 + */ +char * +inet_neta(src, dst, size) + u_long src; + char *dst; + size_t size; +{ + char *odst = dst; + char *tp; + + while (src & 0xffffffff) { + u_char b = (src & 0xff000000) >> 24; + + src <<= 8; + if (b) { + if (size < sizeof "255.") + goto emsgsize; + tp = dst; + dst += SPRINTF((dst, "%u", b)); + if (src != 0L) { + *dst++ = '.'; + *dst = '\0'; + } + size -= (size_t)(dst - tp); + } + } + if (dst == odst) { + if (size < sizeof "0.0.0.0") + goto emsgsize; + strcpy(dst, "0.0.0.0"); + } + return (odst); + + emsgsize: + errno = EMSGSIZE; + return (NULL); +} diff --git a/lib/libmd/md2.h b/lib/libmd/md2.h new file mode 100644 index 000000000000..ecdeaf7870ec --- /dev/null +++ b/lib/libmd/md2.h @@ -0,0 +1,40 @@ +/* MD2.H - header file for MD2C.C + * $Id$ + */ + +/* Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All + rights reserved. + + License to copy and use this software is granted for + non-commercial Internet Privacy-Enhanced Mail provided that it is + identified as the "RSA Data Security, Inc. MD2 Message Digest + Algorithm" in all material mentioning or referencing this software + or this function. + + RSA Data Security, Inc. makes no representations concerning either + the merchantability of this software or the suitability of this + software for any particular purpose. It is provided "as is" + without express or implied warranty of any kind. + + These notices must be retained in any copies of any part of this + documentation and/or software. + */ + +#ifndef _MD2_H_ +#define _MD2_H_ + +typedef struct MD2Context { + unsigned char state[16]; /* state */ + unsigned char checksum[16]; /* checksum */ + unsigned int count; /* number of bytes, modulo 16 */ + unsigned char buffer[16]; /* input buffer */ +} MD2_CTX; + +void MD2Init(MD2_CTX *); +void MD2Update(MD2_CTX *, const unsigned char *, unsigned int); +void MD2Final(unsigned char [16], MD2_CTX *); +char * MD2End(MD2_CTX *, char *); +char * MD2File(char *, char *); +char * MD2Data(const unsigned char *, unsigned int, char *); + +#endif /* _MD2_H_ */ diff --git a/lib/libmd/md2c.c b/lib/libmd/md2c.c new file mode 100644 index 000000000000..ebf9edcbfc43 --- /dev/null +++ b/lib/libmd/md2c.c @@ -0,0 +1,199 @@ +/* MD2C.C - RSA Data Security, Inc., MD2 message-digest algorithm + * $Id$ + */ + +/* Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All + rights reserved. + + License to copy and use this software is granted for + non-commercial Internet Privacy-Enhanced Mail provided that it is + identified as the "RSA Data Security, Inc. MD2 Message Digest + Algorithm" in all material mentioning or referencing this software + or this function. + + RSA Data Security, Inc. makes no representations concerning either + the merchantability of this software or the suitability of this + software for any particular purpose. It is provided "as is" + without express or implied warranty of any kind. + + These notices must be retained in any copies of any part of this + documentation and/or software. + */ + +#include "md2.h" +#include <string.h> +#include <sys/types.h> + + +typedef unsigned char *POINTER; +typedef u_int16_t UINT2; +typedef u_int32_t UINT4; + +#define PROTO_LIST(list) list + +static void MD2Transform PROTO_LIST + ((unsigned char [16], unsigned char [16], const unsigned char [16])); + +/* Permutation of 0..255 constructed from the digits of pi. It gives a + "random" nonlinear byte substitution operation. + */ +static unsigned char PI_SUBST[256] = { + 41, 46, 67, 201, 162, 216, 124, 1, 61, 54, 84, 161, 236, 240, 6, + 19, 98, 167, 5, 243, 192, 199, 115, 140, 152, 147, 43, 217, 188, + 76, 130, 202, 30, 155, 87, 60, 253, 212, 224, 22, 103, 66, 111, 24, + 138, 23, 229, 18, 190, 78, 196, 214, 218, 158, 222, 73, 160, 251, + 245, 142, 187, 47, 238, 122, 169, 104, 121, 145, 21, 178, 7, 63, + 148, 194, 16, 137, 11, 34, 95, 33, 128, 127, 93, 154, 90, 144, 50, + 39, 53, 62, 204, 231, 191, 247, 151, 3, 255, 25, 48, 179, 72, 165, + 181, 209, 215, 94, 146, 42, 172, 86, 170, 198, 79, 184, 56, 210, + 150, 164, 125, 182, 118, 252, 107, 226, 156, 116, 4, 241, 69, 157, + 112, 89, 100, 113, 135, 32, 134, 91, 207, 101, 230, 45, 168, 2, 27, + 96, 37, 173, 174, 176, 185, 246, 28, 70, 97, 105, 52, 64, 126, 15, + 85, 71, 163, 35, 221, 81, 175, 58, 195, 92, 249, 206, 186, 197, + 234, 38, 44, 83, 13, 110, 133, 40, 132, 9, 211, 223, 205, 244, 65, + 129, 77, 82, 106, 220, 55, 200, 108, 193, 171, 250, 36, 225, 123, + 8, 12, 189, 177, 74, 120, 136, 149, 139, 227, 99, 232, 109, 233, + 203, 213, 254, 59, 0, 29, 57, 242, 239, 183, 14, 102, 88, 208, 228, + 166, 119, 114, 248, 235, 117, 75, 10, 49, 68, 80, 180, 143, 237, + 31, 26, 219, 153, 141, 51, 159, 17, 131, 20 +}; + +static unsigned char *PADDING[] = { + (unsigned char *)"", + (unsigned char *)"\001", + (unsigned char *)"\002\002", + (unsigned char *)"\003\003\003", + (unsigned char *)"\004\004\004\004", + (unsigned char *)"\005\005\005\005\005", + (unsigned char *)"\006\006\006\006\006\006", + (unsigned char *)"\007\007\007\007\007\007\007", + (unsigned char *)"\010\010\010\010\010\010\010\010", + (unsigned char *)"\011\011\011\011\011\011\011\011\011", + (unsigned char *)"\012\012\012\012\012\012\012\012\012\012", + (unsigned char *)"\013\013\013\013\013\013\013\013\013\013\013", + (unsigned char *)"\014\014\014\014\014\014\014\014\014\014\014\014", + (unsigned char *) + "\015\015\015\015\015\015\015\015\015\015\015\015\015", + (unsigned char *) + "\016\016\016\016\016\016\016\016\016\016\016\016\016\016", + (unsigned char *) + "\017\017\017\017\017\017\017\017\017\017\017\017\017\017\017", + (unsigned char *) + "\020\020\020\020\020\020\020\020\020\020\020\020\020\020\020\020" +}; + +/* MD2 initialization. Begins an MD2 operation, writing a new context. + */ +void MD2Init (context) +MD2_CTX *context; /* context */ +{ + context->count = 0; + memset ((POINTER)context->state, 0, sizeof (context->state)); + memset + ((POINTER)context->checksum, 0, sizeof (context->checksum)); +} + +/* MD2 block update operation. Continues an MD2 message-digest + operation, processing another message block, and updating the + context. + */ +void MD2Update (context, input, inputLen) +MD2_CTX *context; /* context */ +const unsigned char *input; /* input block */ +unsigned int inputLen; /* length of input block */ +{ + unsigned int i, index, partLen; + + /* Update number of bytes mod 16 */ + index = context->count; + context->count = (index + inputLen) & 0xf; + + partLen = 16 - index; + + /* Transform as many times as possible. + */ + if (inputLen >= partLen) { + memcpy + ((POINTER)&context->buffer[index], (POINTER)input, partLen); + MD2Transform (context->state, context->checksum, context->buffer); + + for (i = partLen; i + 15 < inputLen; i += 16) + MD2Transform (context->state, context->checksum, &input[i]); + + index = 0; + } + else + i = 0; + + /* Buffer remaining input */ + memcpy + ((POINTER)&context->buffer[index], (POINTER)&input[i], + inputLen-i); +} + +/* MD2 finalization. Ends an MD2 message-digest operation, writing the + message digest and zeroizing the context. + */ +void MD2Final (digest, context) +unsigned char digest[16]; /* message digest */ +MD2_CTX *context; /* context */ +{ + unsigned int index, padLen; + + /* Pad out to multiple of 16. + */ + index = context->count; + padLen = 16 - index; + MD2Update (context, PADDING[padLen], padLen); + + /* Extend with checksum */ + MD2Update (context, context->checksum, 16); + + /* Store state in digest */ + memcpy ((POINTER)digest, (POINTER)context->state, 16); + + /* Zeroize sensitive information. + */ + memset ((POINTER)context, 0, sizeof (*context)); +} + +/* MD2 basic transformation. Transforms state and updates checksum + based on block. + */ +static void MD2Transform (state, checksum, block) +unsigned char state[16]; +unsigned char checksum[16]; +const unsigned char block[16]; +{ + unsigned int i, j, t; + unsigned char x[48]; + + /* Form encryption block from state, block, state ^ block. + */ + memcpy ((POINTER)x, (POINTER)state, 16); + memcpy ((POINTER)x+16, (POINTER)block, 16); + for (i = 0; i < 16; i++) + x[i+32] = state[i] ^ block[i]; + + /* Encrypt block (18 rounds). + */ + t = 0; + for (i = 0; i < 18; i++) { + for (j = 0; j < 48; j++) + t = x[j] ^= PI_SUBST[t]; + t = (t + i) & 0xff; + } + + /* Save new state */ + memcpy ((POINTER)state, (POINTER)x, 16); + + /* Update checksum. + */ + t = checksum[15]; + for (i = 0; i < 16; i++) + t = checksum[i] ^= PI_SUBST[block[i] ^ t]; + + /* Zeroize sensitive information. + */ + memset ((POINTER)x, 0, sizeof (x)); +} diff --git a/lib/libmd/md4.h b/lib/libmd/md4.h new file mode 100644 index 000000000000..5481bbda569e --- /dev/null +++ b/lib/libmd/md4.h @@ -0,0 +1,42 @@ +/* MD4.H - header file for MD4C.C + * $Id$ + */ + +/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All + rights reserved. + + License to copy and use this software is granted provided that it + is identified as the "RSA Data Security, Inc. MD4 Message-Digest + Algorithm" in all material mentioning or referencing this software + or this function. + License is also granted to make and use derivative works provided + that such works are identified as "derived from the RSA Data + Security, Inc. MD4 Message-Digest Algorithm" in all material + mentioning or referencing the derived work. + + RSA Data Security, Inc. makes no representations concerning either + the merchantability of this software or the suitability of this + software for any particular purpose. It is provided "as is" + without express or implied warranty of any kind. + + These notices must be retained in any copies of any part of this + documentation and/or software. + */ + +#ifndef _MD4_H_ +#define _MD4_H_ +/* MD4 context. */ +typedef struct MD4Context { + u_int32_t state[4]; /* state (ABCD) */ + u_int32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */ + unsigned char buffer[64]; /* input buffer */ +} MD4_CTX; + +void MD4Init(MD4_CTX *); +void MD4Update(MD4_CTX *, const unsigned char *, unsigned int); +void MD4Final(unsigned char [16], MD4_CTX *); +char * MD4End(MD4_CTX *, char *); +char * MD4File(char *, char *); +char * MD4Data(const unsigned char *, unsigned int, char *); + +#endif /* _MD4_H_ */ diff --git a/lib/libmd/md4c.c b/lib/libmd/md4c.c new file mode 100644 index 000000000000..a0eba4d8cf58 --- /dev/null +++ b/lib/libmd/md4c.c @@ -0,0 +1,279 @@ +/* MD4C.C - RSA Data Security, Inc., MD4 message-digest algorithm + * $Id$ + */ + +/* Copyright (C) 1990-2, RSA Data Security, Inc. All rights reserved. + + License to copy and use this software is granted provided that it + is identified as the "RSA Data Security, Inc. MD4 Message-Digest + Algorithm" in all material mentioning or referencing this software + or this function. + + License is also granted to make and use derivative works provided + that such works are identified as "derived from the RSA Data + Security, Inc. MD4 Message-Digest Algorithm" in all material + mentioning or referencing the derived work. + + RSA Data Security, Inc. makes no representations concerning either + the merchantability of this software or the suitability of this + software for any particular purpose. It is provided "as is" + without express or implied warranty of any kind. + + These notices must be retained in any copies of any part of this + documentation and/or software. + */ + +#include <sys/types.h> +#include <string.h> +#include "md4.h" + +typedef unsigned char *POINTER; +typedef u_int16_t UINT2; +typedef u_int32_t UINT4; + +#define PROTO_LIST(list) list + +/* Constants for MD4Transform routine. + */ +#define S11 3 +#define S12 7 +#define S13 11 +#define S14 19 +#define S21 3 +#define S22 5 +#define S23 9 +#define S24 13 +#define S31 3 +#define S32 9 +#define S33 11 +#define S34 15 + +static void MD4Transform PROTO_LIST ((UINT4 [4], const unsigned char [64])); +static void Encode PROTO_LIST + ((unsigned char *, UINT4 *, unsigned int)); +static void Decode PROTO_LIST + ((UINT4 *, const unsigned char *, unsigned int)); + +static unsigned char PADDING[64] = { + 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +/* F, G and H are basic MD4 functions. + */ +#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) +#define G(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z))) +#define H(x, y, z) ((x) ^ (y) ^ (z)) + +/* ROTATE_LEFT rotates x left n bits. + */ +#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) + +/* FF, GG and HH are transformations for rounds 1, 2 and 3 */ +/* Rotation is separate from addition to prevent recomputation */ +#define FF(a, b, c, d, x, s) { \ + (a) += F ((b), (c), (d)) + (x); \ + (a) = ROTATE_LEFT ((a), (s)); \ + } +#define GG(a, b, c, d, x, s) { \ + (a) += G ((b), (c), (d)) + (x) + (UINT4)0x5a827999; \ + (a) = ROTATE_LEFT ((a), (s)); \ + } +#define HH(a, b, c, d, x, s) { \ + (a) += H ((b), (c), (d)) + (x) + (UINT4)0x6ed9eba1; \ + (a) = ROTATE_LEFT ((a), (s)); \ + } + +/* MD4 initialization. Begins an MD4 operation, writing a new context. + */ +void MD4Init (context) +MD4_CTX *context; /* context */ +{ + context->count[0] = context->count[1] = 0; + + /* Load magic initialization constants. + */ + context->state[0] = 0x67452301; + context->state[1] = 0xefcdab89; + context->state[2] = 0x98badcfe; + context->state[3] = 0x10325476; +} + +/* MD4 block update operation. Continues an MD4 message-digest + operation, processing another message block, and updating the + context. + */ +void MD4Update (context, input, inputLen) +MD4_CTX *context; /* context */ +const unsigned char *input; /* input block */ +unsigned int inputLen; /* length of input block */ +{ + unsigned int i, index, partLen; + + /* Compute number of bytes mod 64 */ + index = (unsigned int)((context->count[0] >> 3) & 0x3F); + /* Update number of bits */ + if ((context->count[0] += ((UINT4)inputLen << 3)) + < ((UINT4)inputLen << 3)) + context->count[1]++; + context->count[1] += ((UINT4)inputLen >> 29); + + partLen = 64 - index; + /* Transform as many times as possible. + */ + if (inputLen >= partLen) { + memcpy + ((POINTER)&context->buffer[index], (POINTER)input, partLen); + MD4Transform (context->state, context->buffer); + + for (i = partLen; i + 63 < inputLen; i += 64) + MD4Transform (context->state, &input[i]); + + index = 0; + } + else + i = 0; + + /* Buffer remaining input */ + memcpy + ((POINTER)&context->buffer[index], (POINTER)&input[i], + inputLen-i); +} + +/* MD4 finalization. Ends an MD4 message-digest operation, writing the + the message digest and zeroizing the context. + */ +void MD4Final (digest, context) +unsigned char digest[16]; /* message digest */ +MD4_CTX *context; /* context */ +{ + unsigned char bits[8]; + unsigned int index, padLen; + + /* Save number of bits */ + Encode (bits, context->count, 8); + + /* Pad out to 56 mod 64. + */ + index = (unsigned int)((context->count[0] >> 3) & 0x3f); + padLen = (index < 56) ? (56 - index) : (120 - index); + MD4Update (context, PADDING, padLen); + + /* Append length (before padding) */ + MD4Update (context, bits, 8); + /* Store state in digest */ + Encode (digest, context->state, 16); + + /* Zeroize sensitive information. + */ + memset ((POINTER)context, 0, sizeof (*context)); +} + +/* MD4 basic transformation. Transforms state based on block. + */ +static void MD4Transform (state, block) +UINT4 state[4]; +const unsigned char block[64]; +{ + UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; + + Decode (x, block, 64); + + /* Round 1 */ + FF (a, b, c, d, x[ 0], S11); /* 1 */ + FF (d, a, b, c, x[ 1], S12); /* 2 */ + FF (c, d, a, b, x[ 2], S13); /* 3 */ + FF (b, c, d, a, x[ 3], S14); /* 4 */ + FF (a, b, c, d, x[ 4], S11); /* 5 */ + FF (d, a, b, c, x[ 5], S12); /* 6 */ + FF (c, d, a, b, x[ 6], S13); /* 7 */ + FF (b, c, d, a, x[ 7], S14); /* 8 */ + FF (a, b, c, d, x[ 8], S11); /* 9 */ + FF (d, a, b, c, x[ 9], S12); /* 10 */ + FF (c, d, a, b, x[10], S13); /* 11 */ + FF (b, c, d, a, x[11], S14); /* 12 */ + FF (a, b, c, d, x[12], S11); /* 13 */ + FF (d, a, b, c, x[13], S12); /* 14 */ + FF (c, d, a, b, x[14], S13); /* 15 */ + FF (b, c, d, a, x[15], S14); /* 16 */ + + /* Round 2 */ + GG (a, b, c, d, x[ 0], S21); /* 17 */ + GG (d, a, b, c, x[ 4], S22); /* 18 */ + GG (c, d, a, b, x[ 8], S23); /* 19 */ + GG (b, c, d, a, x[12], S24); /* 20 */ + GG (a, b, c, d, x[ 1], S21); /* 21 */ + GG (d, a, b, c, x[ 5], S22); /* 22 */ + GG (c, d, a, b, x[ 9], S23); /* 23 */ + GG (b, c, d, a, x[13], S24); /* 24 */ + GG (a, b, c, d, x[ 2], S21); /* 25 */ + GG (d, a, b, c, x[ 6], S22); /* 26 */ + GG (c, d, a, b, x[10], S23); /* 27 */ + GG (b, c, d, a, x[14], S24); /* 28 */ + GG (a, b, c, d, x[ 3], S21); /* 29 */ + GG (d, a, b, c, x[ 7], S22); /* 30 */ + GG (c, d, a, b, x[11], S23); /* 31 */ + GG (b, c, d, a, x[15], S24); /* 32 */ + + /* Round 3 */ + HH (a, b, c, d, x[ 0], S31); /* 33 */ + HH (d, a, b, c, x[ 8], S32); /* 34 */ + HH (c, d, a, b, x[ 4], S33); /* 35 */ + HH (b, c, d, a, x[12], S34); /* 36 */ + HH (a, b, c, d, x[ 2], S31); /* 37 */ + HH (d, a, b, c, x[10], S32); /* 38 */ + HH (c, d, a, b, x[ 6], S33); /* 39 */ + HH (b, c, d, a, x[14], S34); /* 40 */ + HH (a, b, c, d, x[ 1], S31); /* 41 */ + HH (d, a, b, c, x[ 9], S32); /* 42 */ + HH (c, d, a, b, x[ 5], S33); /* 43 */ + HH (b, c, d, a, x[13], S34); /* 44 */ + HH (a, b, c, d, x[ 3], S31); /* 45 */ + HH (d, a, b, c, x[11], S32); /* 46 */ + HH (c, d, a, b, x[ 7], S33); /* 47 */ + HH (b, c, d, a, x[15], S34); /* 48 */ + + state[0] += a; + state[1] += b; + state[2] += c; + state[3] += d; + + /* Zeroize sensitive information. + */ + memset ((POINTER)x, 0, sizeof (x)); +} + +/* Encodes input (UINT4) into output (unsigned char). Assumes len is + a multiple of 4. + */ +static void Encode (output, input, len) +unsigned char *output; +UINT4 *input; +unsigned int len; +{ + unsigned int i, j; + + for (i = 0, j = 0; j < len; i++, j += 4) { + output[j] = (unsigned char)(input[i] & 0xff); + output[j+1] = (unsigned char)((input[i] >> 8) & 0xff); + output[j+2] = (unsigned char)((input[i] >> 16) & 0xff); + output[j+3] = (unsigned char)((input[i] >> 24) & 0xff); + } +} + +/* Decodes input (unsigned char) into output (UINT4). Assumes len is + a multiple of 4. + */ +static void Decode (output, input, len) + +UINT4 *output; +const unsigned char *input; +unsigned int len; +{ + unsigned int i, j; + + for (i = 0, j = 0; j < len; i++, j += 4) + output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) | + (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24); +} diff --git a/lib/libmd/mddriver.c b/lib/libmd/mddriver.c new file mode 100644 index 000000000000..633442b5a9f7 --- /dev/null +++ b/lib/libmd/mddriver.c @@ -0,0 +1,67 @@ +/* MDDRIVER.C - test driver for MD2, MD4 and MD5 + * $Id$ + */ + +/* Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All + rights reserved. + + RSA Data Security, Inc. makes no representations concerning either + the merchantability of this software or the suitability of this + software for any particular purpose. It is provided "as is" + without express or implied warranty of any kind. + + These notices must be retained in any copies of any part of this + documentation and/or software. + */ + +/* The following makes MD default to MD5 if it has not already been + defined with C compiler flags. + */ +#ifndef MD +#define MD MD5 +#endif + +#include <stdio.h> +#include <time.h> +#include <string.h> +#if MD == 2 +#include "md2.h" +#define MDData MD2Data +#endif +#if MD == 4 +#include "md4.h" +#define MDData MD4Data +#endif +#if MD == 5 +#include "md5.h" +#define MDData MD5Data +#endif + +/* Digests a string and prints the result. + */ +static void MDString (string) +char *string; +{ + char buf[33]; + + printf ("MD%d (\"%s\") = %s\n", + MD, string, MDData(string,strlen(string),buf)); +} + +/* Digests a reference suite of strings and prints the results. + */ +main() +{ + printf ("MD%d test suite:\n", MD); + + MDString (""); + MDString ("a"); + MDString ("abc"); + MDString ("message digest"); + MDString ("abcdefghijklmnopqrstuvwxyz"); + MDString + ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"); + MDString + ("1234567890123456789012345678901234567890\ +1234567890123456789012345678901234567890"); +} diff --git a/lib/libutil/login.conf.5 b/lib/libutil/login.conf.5 new file mode 100644 index 000000000000..d56e94f59978 --- /dev/null +++ b/lib/libutil/login.conf.5 @@ -0,0 +1,364 @@ +.\" Copyright (c) 1996 David Nugent <davidn@blaze.net.au> +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, is permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice immediately at the beginning of the file, without modification, +.\" 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. This work was done expressly for inclusion into FreeBSD. Other use +.\" is permitted provided this notation is included. +.\" 4. Absolutely no warranty of function or purpose is made by the author +.\" David Nugent. +.\" 5. Modifications may be freely made to this file providing the above +.\" conditions are met. +.\" +.\" $Id$ +.\" +.Dd November 22, 1996 +.Dt LOGIN.CONF 5 +.Os FreeBSD +.Sh NAME +.Nm login.conf +.Nd login class capability database +.Sh SYNOPSIS +.Pa /etc/login.conf , +.Pa ~/.login_conf +.Sh DESCRIPTION +login.conf contains various attributes and capabilities of login classes. +A login class (an optional annotation against each record in the user +account database, +.Pa /etc/master.passwd ) +determines session accounting, resource limits and user environment settings. +It is used by various programs in the system to set up a user's login +environment and to enforce policy, accounting and administrative restrictions. +It also provides the means by which users are able to be +authenticated to the system and the types of authentication available. +.Pp +A special record "default" in the system user class capability database +.Pa /etc/login.conf +is used automatically for any +non-root user without a valid login class in +.Pa /etc/master.passwd . +A user with a uid of 0 without a valid login class will use the record +"root" if it exists, or "default" if not. +.Pp +In FreeBSD, users may individually create a file called +.Pa .login_conf +in their home directory using the same format, consisting of a single +entry with a record id of "me". +If present, this file is used by +.Xr login 1 +to set user-defined environment settings which override those specified +in the system login capabilities database. +Only a subset of login capabilities may be overridden, typically those +which do not involve authentication, resource limits and accounting. +.Pp +Records in a class capabilities database consist of a number of +colon-separated fields. +The first entry for each record gives one or more names that a record is +to be known by, each separated by a '|' character. +The first name is the most common abbreviation. +The last name given should be a long name that is more descriptive +of the capability entry, and all others are synonyms. +All names but the last should be in lower case and contain no blanks; +the last name may contain upper case characters and blanks for +readability. +.Pp +See +.Xr getcap 3 +for a more in-depth description of the format of a capability database. +.Sh CAPABILITIES +Fields within each record in the database follow the +.Xr getcap 3 +conventions for boolean, type string +.Ql \&= +and type numeric +.Ql \&# , +although type numeric is depreciated in favour of the string format and +either form is accepted for a numeric datum. +Values fall into the following categories: +.Bl -tag -width "program" +.It file +Path name to a data file +.It program +Path name to an executable file +.It list +A list of values (or pairs of values) separated by commas or spaces +.It path +A space or comma separated list of path names, following the usual csh +conventions (leading tilde with and without username being expanded to +home directories etc.) +.It number +A numeric value, either decimal (default), hexadecimal (with leading 0x), +or octal (with a leading 0). +With a numeric type, only one numeric value is allowed. +Numeric types may also be specified in string format (ie. the capability +tag being delimited from the value by '=' instead of '#'). +Whichever method is used, then all records in the database must use the +same method to allow values to be correctly overridden in interpolated +records. +.It size +A number which expresses a size. +The default interpretation of a value is the number of bytes, but a +suffix may specify alternate units: +.Bl -tag -offset indent -compact -width xxxx +.It b +explicitly selects 512-byte blocks +.It k +selects kilobytes (1024 bytes) +.It m +specifies a multiplier of 1 megabyte (1048576 bytes), +.It g +specifies units of gigabytes, and +.It t +represents terrabytes. +.El +A size value is a numeric quantity and case of the suffix is not significant. +Concatenated values are added together. +.It time +A period of time, by default in seconds. +A prefix may specify a different unit; +.Bl -tag -offset indent -compact -width xxxx +.It y +indicates the number of 365 day years, +.It w +indicates the number of weeks, +.It d +the number of days, +.It h +the number of minutes, and +.It s +the number of seconds. +.El +Concatenated values are added together. +For example, 2 hours and 40 minutes may be written either as +9600s, 160m or 2h40m. +.El +.Pp +The usual convention to interpolate capability entries using the special +.Em tc=value +notation may be used. +.Pp +.Sh RESOURCE LIMITS +.Bl -column coredumpsize indent indent +.Sy Name Type Notes Description +.It cputime time CPU usage limit. +.It filesize size Maximum file size limit. +.It datasize size Maximum data size limit. +.It stacksize size Maximum stack size limit. +.It coredumpsize size Maximum coredump size limit. +.It memoryuse size Maximum of core memory use size limit. +.It memorylocked size Maximum locked in core memory size limit. +.It maxproc number Maximum number of processes. +.It openfiles number Maximum number of open files per process. +.El +.Pp +These resource limit entries actually specify both the maximum +and current limits (see +.Xr getrlimit 2 ). +The current (soft) limit is the one normally used, although the user is permitted +to increase the current limit to the maximum (hard) limit. +The maximum and current limits may be specified individually by appending a +-max or -cur to the capability name. +.Pp +.Sh ENVIRONMENT +.Bl -column ignorenologin indent xbinxxusrxbin +.Sy Name Type Notes Description +.It charset string Set $MM_CHARSET environment variable to the specified +value. +.It hushlogin bool false Same as having a ~/.hushlogin file. +.It ignorenologin bool false Login not prevented by nologin. +.It lang string Set $LANG environment variable to the specified value. +.It manpath path Default search path for manpages. +.It nologin file If the file exists it will be displayed and +the login session will be terminated. +.It path path /bin /usr/bin Default search path. +.It priority number Initial priority (nice) level. +.It requirehome bool false Require a valid home directory to login. +.It setenv list A comma-separated list of environment variables and +values to which they are to be set. +.It shell prog Session shell to execute rather than the +shell specified in the passwd file. The SHELL environment variable will +contain the shell specified in the password file. +.It term string su Default terminal type if not able to determine from +other means. +.It timezone string Default value of $TZ environment variable. +.It umask number 022 Initial umask. Should always have a leading 0 to +ensure octal interpretation. +.It welcome file /etc/motd File containing welcome message. +.El +.Pp +.Sh AUTHENTICATION +.Bl -column minpasswordlen indent indent +.Sy Name Type Notes Description +.It minpasswordlen number 6 The minimum length a local password may be. +.\" .It approve program Program to approve login. +.It auth list passwd Allowed authentication styles. The first value is the +default style. +.It auth-<type> list Allowed authentication styles for the +authentication type 'type'. +.It copyright file File containing additional copyright information +.\".It widepasswords bool false Use the wide password format. The wide password +.\" format allows up to 128 significant characters in the password. +.It host.allow list List of remote host wildcards from which users in +the class may access. +.It host.deny list List of remote host wildcards from which users in +the class may not access. +.It times.allow list List of time periods during which +logins are allowed. +.It times.deny list List of time periods during which logins are +disallowed. +.It tty.allow list List of ttys and ttygroups which users +in the class may use for access. +.It tty.deny list List of ttys and ttygroups which users +in the class may not use for access. +.El +.Pp +These fields are intended to be used by +.Xr passwd 1 +and other programs in the login authentication system. +.Pp +Capabilities that set environment variables are scanned for both +.Ql \&~ +and +.Ql \&$ +characters, which are substituted for a user's home directory and name +respectively. +To pass these characters literally into the environment variable, escape +the character by preceding it with a backslash '\\'. +.Pp +The +.Em host.allow +and +.Em host.deny +entries are comma separated lists used for checking remote access to the system, +and consist of a list of hostnames and/or IP addresses against which remote +network logins are checked. +Items in these lists may contain wildcards in the form used by shell programs +for wildcard matching (See +.Xr fnmatch 3 +for details on the implementation). +The check on hosts is made against both the remote system's Internet address +and hostname (if available). +If both lists are empty or not specified, then logins from any remote host +are allowed. +If host.allow contains one or more hosts, then only remote systems matching +any of the items in that list are allowed to log in. +If host.deny contains one or more hosts, then a login from any matching hosts +will be disallowed. +.Pp +The +.Em times.allow +and +.Em times.deny +entries consist of a comma-separated list of time periods during which the users +in a class are allowed to be logged in. +These are expressed as one or more day codes followed by a start and end times +expressed in 24 hour format, separated by a hyphen or dash. +For example, MoThSa0200-1300 translates to Monday, Thursday and Saturday between +the hours of 2 am and 1 p.m.. +If both of these time lists are empty, users in the class are allowed access at +any time. +If +.Em times.allow +is specified, then logins are only allowed during the periods given. +If +.Em times.deny +is specified, then logins are denied during the periods given, regardless of whether +one of the periods specified in +.Em times.allow +applies. +.Pp +Note that +.Xr login 1 +enforces only that the actual login falls within periods allowed by these entries. +Further enforcement over the life of a session requires a separate daemon to +monitor transitions from an allowed period to a non-allowed one. +.Pp +The +.Em tty.allow +and +.Em tty.deny +entries contain a comma-separated list of tty devices (without the /dev/ prefix) +that a user in a class may use to access the system, and/or a list of ttygroups +(See +.Xr getttyent 3 +and +.Xr ttys 5 +for information on ttygroups). +If neither entry exists, then the choice of login device used by the user is +unrestricted. +If only +.Em tty.allow +is specified, then the user is restricted only to ttys in the given +group or device list. +If only +.Em tty.deny +is specified, then the user is prevented from using the specified devices or +devices in the group. +If both lists are given and are non-empty, the user is restricted to those +devices allowed by tty.allow that are not available by tty.deny. +.Sh ACCOUNTING LIMITS +.Bl -column passwordperiod indent indent +.Sy Name Type Notes Description +.It accounted bool false Enable session time accounting for all users +in this class. +.It autodelete time Time after expiry when account is auto-deleted. +.It bootfull bool false Enable 'boot only if ttygroup is full' strategy +when terminating sessions. +.It daytime time Maximum login time per day. +.It expireperiod time Time for expiry allocation. +.It graceexpire time Grace days for expired account. +.It gracetime time Additional grace login time allowed. +.It host.accounted list List of remote host wildcards from which +login sessions will be accounted. +.It host.exempt list List of remote host wildcards from which +login session accounting is exempted. +.It idletime time Maximum idle time before logout. +.It monthtime time Maximum login time per month. +.It passwordtime time Time for password expiry. +.It refreshtime time New time allowed on account refresh. +.It refreshperiod str How often account time is refreshed. +.It sessiontime time Maximum login time per session. +.It sessionlimit number Maximum number of concurrent +login sessions on ttys in any group. +.It tty.accounted list List of ttys and ttygroups for which +login accounting is active. +.It tty.exempt list List of ttys and ttygroups for which login accounting +is exempt. +.It warnexpire time Advance notice for pending account expiry. +.It warnpassword time Advance notice for pending password expiry. +.It warntime time Advance notice for pending out-of-time. +.It weektime time Maximum login time per week. +.El +.Pp +These fields are used by the time accounting system, which regulates, +controls and records user login access. +.Pp +The +.Em ttys.accounted +and +.Em ttys.exempt +fields operate in a similar manner to +.Em ttys.allow +and +.Em ttys.deny +as explained +above. +Similarly with the +.Em host.accounted +and +.Em host.exempt +lists. +.Sh SEE ALSO +.Xr login 1 , +.Xr getcap 3 , +.Xr getttyent 3 , +.Xr login_cap 3 , +.Xr login_class 3 , +.Xr ttys 5 diff --git a/lib/libutil/login_auth.3 b/lib/libutil/login_auth.3 new file mode 100644 index 000000000000..14a2a63fcf0f --- /dev/null +++ b/lib/libutil/login_auth.3 @@ -0,0 +1,71 @@ +.\" Copyright (c) 1995 David Nugent <davidn@blaze.net.au> +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, is permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice immediately at the beginning of the file, without modification, +.\" 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. This work was done expressly for inclusion into FreeBSD. Other use +.\" is permitted provided this notation is included. +.\" 4. Absolutely no warranty of function or purpose is made by the author +.\" David Nugent. +.\" 5. Modifications may be freely made to this file providing the above +.\" conditions are met. +.\" +.\" $Id$ +.\" +.Dd December 29, 1996 +.Os FreeBSD +.Dt LOGIN_AUTH 3 +.Sh NAME +.Nm authenticate +.Nm auth_script +.Nm auth_env +.Nm auth_scan +.Nm auth_rmfiles +.Nm auth_checknologin +.Nm auth_cat +.Nm auth_ttyok +.Nm auth_hostok +.Nm auth_timesok +.Nd Authentication style support library for login class capabilities database. +.Sh SYNOPSIS +.Fd #include <sys/types.h> +.Fd #include <login_cap.h> +.Ft int +.Fn authenticate "const char *name" "const char *classname" "const char *style" "const char *service" +.Ft int +.Fn auth_script "const char * path" ... +.Ft int +.Fn auth_env "void" +.Ft int +.Fn auth_scan "int ok" +.Ft int +.Fn auth_rmfiles "void" +.Ft int +.Fn auth_checknologin "login_cap_t *lc" +.Ft int +.Fn auth_cat "const char *file" +.Ft int +.Fn auth_ttyok "login_cap_t *lc" "const char *tty" +.Ft int +.Fn auth_hostok "login_cap_t *lc" "const char *hostname" "char const *ip" +.Ft int +.Fn auth_timesok "login_cap_t *lc" "time_t now" +.Sh DESCRIPTION +This set of functions support the login class authorisation style interface provided +by +.Xr login.conf 5 . + +.Sh RETURN VALUES +.Sh SEE ALSO +.Xr getcap 3 , +.Xr login_cap 3 , +.Xr login_class 3 , +.Xr login.conf 5 , +.Xr termcap 5 diff --git a/lib/libutil/login_ok.3 b/lib/libutil/login_ok.3 new file mode 100644 index 000000000000..f90710f56ad7 --- /dev/null +++ b/lib/libutil/login_ok.3 @@ -0,0 +1,138 @@ +.\" Copyright (c) 1995 David Nugent <davidn@blaze.net.au> +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, is permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice immediately at the beginning of the file, without modification, +.\" 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. This work was done expressly for inclusion into FreeBSD. Other use +.\" is permitted provided this notation is included. +.\" 4. Absolutely no warranty of function or purpose is made by the author +.\" David Nugent. +.\" 5. Modifications may be freely made to this file providing the above +.\" conditions are met. +.\" +.\" $Id$ +.\" +.Dd January 2, 1997 +.Os FreeBSD +.Dt LOGIN_OK 3 +.Sh NAME +.Nm auth_ttyok +.Nm auth_hostok +.Nm auth_timeok +.Nd Functions for checking login class based login restrictions +.Sh SYNOPSIS +.Fd #include <sys/types.h> +.Fd #include <time.h> +.Fd #include <login_cap.h> +.Ft int +.Fn auth_ttyok "login_cap_t *lc" "const char *tty" +.Ft int +.Fn auth_hostok "login_cap_t *lc" "const char *host" "char const *ip" +.Ft int +.Fn auth_timeok "login_cap_t *lc" "time_t t" +.Sh DESCRIPTION +This set of functions checks to see if login is allowed based on login +class capability entries in the login database, +.Xr login.conf 5 . +.Pp +.Fn auth_ttyok +checks to see if the named tty is available to users of a specific +class, and is either in the +.Em ttys.allow +access list, and not in +the +.Em ttys.deny +access list. +An empty +.Em ttys.allow +list (or if no such capability exists for +the give login class) logins via any tty device are allowed unless +the +.Em ttys.deny +list exists and is non-empty, and the device or its +tty group (see +.Xr ttys 5 ) +is not in the list. +Access to ttys may be allowed or restricted specifically by tty device +name, a device name which includes a wildcard (e.g. ttyD* or cuaD*), +or may name a ttygroup, when group=<name> tags have been assigned in +.Pa /etc/ttys . +Matching of ttys and ttygroups is case sensitive. +Passing a +.Dv NULL +or empty string as the +.Ar tty +parameter causes the function to return a non-zero value. +.Pp +.Fn auth_hostok +checks for any host restrictions for remote logins. +The function checks on both a host name and IP address (given in its +text form, typically n.n.n.n) against the +.Em host.allow +and +.Em host.deny +login class capabilities. +As with ttys and their groups, wildcards and character classes may be +used in the host allow and deny capability records. +The +.Xr fnmatch 3 +function is used for matching, and the matching on hostnames is case +insensitive. +Note that this function expects that the hostname is fully expanded +(i.e. the local domain name added if necessary) and the IP address +is in its canonical form. +No hostname or address lookups are attempted. +.Pp +It is possible to call this function with either the hostname or +the IP address missing (i.e. +.Dv NULL ) +and matching will be performed +only on the basis of the parameter given. +Passing +.Dv NULL +or empty strings in both parameters will result in +a non-zero return value. +.Pp +The +.Fn auth_timeok +function checks to see that a given time value is within the +.Em times.allow +login class capability and not within the +.Em times.deny +access lists. +An empty or non-existent +.Em times.allow +list allows access at any +time, except if a given time is falls within a period in the +.Em times.deny +list. +The format of time period records contained in both +.Em times.allow +and +.Em times.deny +capability fields is explained in detail in the +.Xr login_times 3 +manual page. +.Sh RETURN VALUES +A non-zero return value from any of these functions indicates that +login access is granted. +A zero return value means either that the item being tested is not +in the +.Em allow +access list, or is within the +.Em deny +access list. +.Sh SEE ALSO +.Xr getcap 3 , +.Xr login_cap 3 , +.Xr login_class 3 , +.Xr login_times 3 , +.Xr login.conf 5 , +.Xr termcap 5 diff --git a/lib/libutil/login_times.3 b/lib/libutil/login_times.3 new file mode 100644 index 000000000000..e2e7a3f88503 --- /dev/null +++ b/lib/libutil/login_times.3 @@ -0,0 +1,155 @@ +.\" Copyright (c) 1995 David Nugent <davidn@blaze.net.au> +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, is permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice immediately at the beginning of the file, without modification, +.\" 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. This work was done expressly for inclusion into FreeBSD. Other use +.\" is permitted provided this notation is included. +.\" 4. Absolutely no warranty of function or purpose is made by the author +.\" David Nugent. +.\" 5. Modifications may be freely made to this file providing the above +.\" conditions are met. +.\" +.\" $Id$ +.\" +.Dd January 2, 1997 +.Os FreeBSD +.Dt LOGIN_TIMES 3 +.Sh NAME +.Nm parse_lt +.Nm in_ltm +.Nm in_ltms +.Nd Functions for parsing and checking login time periods +.Sh SYNOPSIS +.Fd #include <sys/types.h> +.Fd #include <time.h> +.Fd #include <login_cap.h> +.Ft login_time_t +.Fn parse_lt "const char *str" +.Ft int +.Fn in_ltm "const login_time_t *lt" "struct tm *t" "time_t *ends" +.Ft int +.Fn in_ltms "const login_time_t *lt" "struct tm *t" "time_t *ends" +.Sh DESCRIPTION +This set of functions may be used for parsing and checking login and +session times against a predefined list of allowed login times as +used in +.Xr login.conf 5 . +.Pp +The format of allowed and disallowed session times specified in the +.Ar times.allow +and +.Ar times.deny +capability fields in a login class are comprised of a prefix which +specifies one or more 2- or 3-character day codes, followed by +a start and end time in 24 hour format separated by a hyphen. +Day codes may be concatenated together to select specific days, or +the special mnemonics "Any" and "All" (for any/all days of the week), +"Wk" for any day of the week (excluding Saturdays and Sundays) and +"Wd" for any weekend day may be used. +.Pp +For example, the following time period: +.Dl MoThFrSa1400-2200 +is interpreted as Monday, Thursday through Saturday between the hours +of 2pm and 10pm. +.Dl Wd0600-1800 +means Saturday and Sunday, between the hours of 6am through 6pm, and +.Dl Any0400-1600 +means any day of the week, between 4am and 4pm. +.Pp +Note that all time periods reference system local time. +.Pp +The +.Fn parse_lt +function converts the ascii representation of a time period into +a structure of type +.Ft login_time_t . +This is defined as: +.Bd -literal +typedef struct login_time +{ + u_short lt_start; /* Start time */ + u_short lt_end; /* End time */ + u_char lt_dow; /* Days of week */ +} login_time_t; +.Ed +.Pp +The +.Ar lt_start +and +.Ar lt_end +fields contain the number of minutes past midnight at which the +described period begins and ends. +The +.Ar lt_dow +field is a bit field, containing one bit for each day of the week +and one bit unused. +A series +.Em LTM_* +macros may be used for testing bits individually and in combination. +If no bits are set in this field - ie. it contains the value +.Em LTM_NONE - +then the entire period is assumed invalid. +This is used as a convention to mark the termination of an array +of login_time_t values. +If +.Fn parse_lt +returns a +.Ar login_time_t +with +.Ar lt_dow +equal to +.Em LTM_NONE +then a parsing error was encountered. +.Pp +The remaining functions provide the ability to test a given time_t or +struct tm value against a specific time period or array of time +periods. +.Fn in_ltm +determines whether the given time described by the struct tm +passed as the second parameter falls within the period described +by the first parameter. +A boolean value is returned, indicating whether or not the time +specified falls within the period. +If the time does fall within the time period, and the third +parameter to the function is not NULL, the time at which the +period ends relative to the time passed is returned. +.Pp +The +.Fn in_ltms +function is similar to +.Fn in_ltm +except that the first parameter must be a pointer to an array +of login_time_t objects, which is up to LC_MAXTIMES (64) +elements in length, and terminated by an element with its +.Ar lt_dow +field set to +.Em LTM_NONE. +.Sh RETURN VALUES +.Fn parse_lt +returns a filled in structure of type login_time_t containing the +parsed time period. +If a parsing error occurs, the lt_dow field is set to +.Em LTM_NONE +(i.e. 0). +.Pp +.Fn in_ltm +returns non-zero if the given time falls within the period described +by the login_time_t passed as the first parameter. +.Pp +.Fn in_ltms +returns the index of the first time period found in which the given +time falls, or -1 if none of them apply. +.Sh SEE ALSO +.Xr getcap 3 , +.Xr login_cap 3 , +.Xr login_class 3 , +.Xr login.conf 5 , +.Xr termcap 5 diff --git a/lib/msun/src/get_hw_float.c b/lib/msun/src/get_hw_float.c new file mode 100644 index 000000000000..fea5c89a81ec --- /dev/null +++ b/lib/msun/src/get_hw_float.c @@ -0,0 +1,50 @@ +/*- + * Copyright (c) 1997 Bruce D. Evans + * 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. + * + * $Id$ + */ + +#include <sys/types.h> +#include <sys/sysctl.h> + +int __get_hw_float __P((void)); + +static int hw_float = -1; + +int +__get_hw_float() +{ + size_t len; + int mib[2]; + + if (hw_float == -1) { + len = sizeof(hw_float); + mib[0] = CTL_HW; + mib[1] = HW_FLOATINGPT; + if (__sysctl(mib, 2, &hw_float, &len, (void *)0, 0) == -1) + hw_float = 0; /* shouldn't happen; assume the worst */ + } + return (hw_float); +} diff --git a/lib/msun/src/w_y0.c b/lib/msun/src/w_y0.c new file mode 100644 index 000000000000..91b9760a1d8b --- /dev/null +++ b/lib/msun/src/w_y0.c @@ -0,0 +1,50 @@ +/* from: @(#)w_j0.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#ifndef lint +static char rcsid[] = "$Id$"; +#endif + +/* + * wrapper y0(double x) + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + double y0(double x) /* wrapper y0 */ +#else + double y0(x) /* wrapper y0 */ + double x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_y0(x); +#else + double z; + z = __ieee754_y0(x); + if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z; + if(x <= 0.0){ + if(x==0.0) + /* d= -one/(x-x); */ + return __kernel_standard(x,x,8); + else + /* d = zero/(x-x); */ + return __kernel_standard(x,x,9); + } + if(x>X_TLOSS) { + return __kernel_standard(x,x,35); /* y0(x>X_TLOSS) */ + } else + return z; +#endif +} diff --git a/lib/msun/src/w_y0f.c b/lib/msun/src/w_y0f.c new file mode 100644 index 000000000000..52ed04113bb0 --- /dev/null +++ b/lib/msun/src/w_y0f.c @@ -0,0 +1,54 @@ +/* w_y0f.c -- float version of w_y0.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#ifndef lint +static char rcsid[] = "$Id$"; +#endif + +/* + * wrapper y0f(float x) + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + float y0f(float x) /* wrapper y0f */ +#else + float y0f(x) /* wrapper y0f */ + float x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_y0f(x); +#else + float z; + z = __ieee754_y0f(x); + if(_LIB_VERSION == _IEEE_ || isnanf(x) ) return z; + if(x <= (float)0.0){ + if(x==(float)0.0) + /* d= -one/(x-x); */ + return (float)__kernel_standard((double)x,(double)x,108); + else + /* d = zero/(x-x); */ + return (float)__kernel_standard((double)x,(double)x,109); + } + if(x>(float)X_TLOSS) { + /* y0(x>X_TLOSS) */ + return (float)__kernel_standard((double)x,(double)x,135); + } else + return z; +#endif +} diff --git a/lib/msun/src/w_y1.c b/lib/msun/src/w_y1.c new file mode 100644 index 000000000000..b46d81e9282c --- /dev/null +++ b/lib/msun/src/w_y1.c @@ -0,0 +1,50 @@ +/* from: @(#)w_j1.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#ifndef lint +static char rcsid[] = "$Id$"; +#endif + +/* + * wrapper of y1 + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + double y1(double x) /* wrapper y1 */ +#else + double y1(x) /* wrapper y1 */ + double x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_y1(x); +#else + double z; + z = __ieee754_y1(x); + if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z; + if(x <= 0.0){ + if(x==0.0) + /* d= -one/(x-x); */ + return __kernel_standard(x,x,10); + else + /* d = zero/(x-x); */ + return __kernel_standard(x,x,11); + } + if(x>X_TLOSS) { + return __kernel_standard(x,x,37); /* y1(x>X_TLOSS) */ + } else + return z; +#endif +} diff --git a/lib/msun/src/w_y1f.c b/lib/msun/src/w_y1f.c new file mode 100644 index 000000000000..b4e4633d68ac --- /dev/null +++ b/lib/msun/src/w_y1f.c @@ -0,0 +1,54 @@ +/* w_y1f.c -- float version of w_y1.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#ifndef lint +static char rcsid[] = "$Id$"; +#endif + +/* + * wrapper of y1f + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + float y1f(float x) /* wrapper y1f */ +#else + float y1f(x) /* wrapper y1f */ + float x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_y1f(x); +#else + float z; + z = __ieee754_y1f(x); + if(_LIB_VERSION == _IEEE_ || isnanf(x) ) return z; + if(x <= (float)0.0){ + if(x==(float)0.0) + /* d= -one/(x-x); */ + return (float)__kernel_standard((double)x,(double)x,110); + else + /* d = zero/(x-x); */ + return (float)__kernel_standard((double)x,(double)x,111); + } + if(x>(float)X_TLOSS) { + /* y1(x>X_TLOSS) */ + return (float)__kernel_standard((double)x,(double)x,137); + } else + return z; +#endif +} diff --git a/lib/msun/src/w_yn.c b/lib/msun/src/w_yn.c new file mode 100644 index 000000000000..af0337657bdd --- /dev/null +++ b/lib/msun/src/w_yn.c @@ -0,0 +1,50 @@ +/* from: @(#)w_jn.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#ifndef lint +static char rcsid[] = "$Id$"; +#endif + +/* + * wrapper yn(int n, double x) + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + double yn(int n, double x) /* wrapper yn */ +#else + double yn(n,x) /* wrapper yn */ + double x; int n; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_yn(n,x); +#else + double z; + z = __ieee754_yn(n,x); + if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z; + if(x <= 0.0){ + if(x==0.0) + /* d= -one/(x-x); */ + return __kernel_standard((double)n,x,12); + else + /* d = zero/(x-x); */ + return __kernel_standard((double)n,x,13); + } + if(x>X_TLOSS) { + return __kernel_standard((double)n,x,39); /* yn(x>X_TLOSS,n) */ + } else + return z; +#endif +} diff --git a/lib/msun/src/w_ynf.c b/lib/msun/src/w_ynf.c new file mode 100644 index 000000000000..0597b92ce2de --- /dev/null +++ b/lib/msun/src/w_ynf.c @@ -0,0 +1,50 @@ +/* w_ynf.c -- float version of w_yn.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#ifndef lint +static char rcsid[] = "$Id$"; +#endif + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + float ynf(int n, float x) /* wrapper ynf */ +#else + float ynf(n,x) /* wrapper ynf */ + float x; int n; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_ynf(n,x); +#else + float z; + z = __ieee754_ynf(n,x); + if(_LIB_VERSION == _IEEE_ || isnanf(x) ) return z; + if(x <= (float)0.0){ + if(x==(float)0.0) + /* d= -one/(x-x); */ + return (float)__kernel_standard((double)n,(double)x,112); + else + /* d = zero/(x-x); */ + return (float)__kernel_standard((double)n,(double)x,113); + } + if(x>(float)X_TLOSS) { + /* yn(x>X_TLOSS,n) */ + return (float)__kernel_standard((double)n,(double)x,139); + } else + return z; +#endif +} diff --git a/libexec/getty/chat.c b/libexec/getty/chat.c new file mode 100644 index 000000000000..24741950ae81 --- /dev/null +++ b/libexec/getty/chat.c @@ -0,0 +1,515 @@ +/*- + * Copyright (c) 1997 + * David L Nugent <davidn@blaze.net.au>. + * All rights reserved. + * + * + * Redistribution and use in source and binary forms, with or without + * modification, is permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice immediately at the beginning of the file, without modification, + * 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. This work was done expressly for inclusion into FreeBSD. Other use + * is permitted provided this notation is included. + * 4. Absolutely no warranty of function or purpose is made by the authors. + * 5. Modifications may be freely made to this file providing the above + * conditions are met. + * + * Modem chat module - send/expect style functions for getty + * For semi-intelligent modem handling. + * + * $Id$ + */ + +#include <sys/param.h> +#include <sys/stat.h> +#include <sys/ioctl.h> +#include <sys/resource.h> +#include <sys/ttydefaults.h> +#include <sys/utsname.h> +#include <errno.h> +#include <signal.h> +#include <fcntl.h> +#include <time.h> +#include <ctype.h> +#include <fcntl.h> +#include <libutil.h> +#include <locale.h> +#include <setjmp.h> +#include <signal.h> +#include <stdlib.h> +#include <string.h> +#include <syslog.h> +#include <termios.h> +#include <time.h> +#include <unistd.h> +#include <sys/socket.h> + +#include "extern.h" + +#define PAUSE_CH (unsigned char)'\xff' /* pause kludge */ + +#define CHATDEBUG_RECEIVE 0x01 +#define CHATDEBUG_SEND 0x02 +#define CHATDEBUG_EXPECT 0x04 +#define CHATDEBUG_MISC 0x08 + +#define CHATDEBUG_DEFAULT 0 +#define CHAT_DEFAULT_TIMEOUT 10 + + +static int chat_debug = CHATDEBUG_DEFAULT; +static int chat_alarm = CHAT_DEFAULT_TIMEOUT; /* Default */ + +static volatile int alarmed = 0; + + +static void chat_alrm __P((int)); +static int chat_unalarm __P((void)); +static int getdigit __P((unsigned char **, int, int)); +static char **read_chat __P((char **)); +static char *cleanchr __P((char **, unsigned char)); +static char *cleanstr __P((const unsigned char *, int)); +static const char *result __P((int)); +static int chat_expect __P((const char *)); +static int chat_send __P((char const *)); + + +/* + * alarm signal handler + * handle timeouts in read/write + * change stdin to non-blocking mode to prevent + * possible hang in read(). + */ + +static void +chat_alrm(signo) + int signo; +{ + int on = 1; + + alarm(1); + alarmed = 1; + signal(SIGALRM, chat_alrm); + ioctl(STDIN_FILENO, FIONBIO, &on); +} + + +/* + * Turn back on blocking mode reset by chat_alrm() + */ + +static int +chat_unalarm() +{ + int off = 0; + return ioctl(STDIN_FILENO, FIONBIO, &off); +} + + +/* + * convert a string of a given base (octal/hex) to binary + */ + +static int +getdigit(ptr, base, max) + unsigned char **ptr; + int base, max; +{ + int i, val = 0; + char * q; + + static const char xdigits[] = "0123456789abcdef"; + + for (i = 0, q = *ptr; i++ < max; ++q) { + int sval; + const char * s = strchr(xdigits, tolower(*q)); + + if (s == NULL || (sval = s - xdigits) >= base) + break; + val = (val * base) + sval; + } + *ptr = q; + return val; +} + + +/* + * read_chat() + * Convert a whitespace delimtied string into an array + * of strings, being expect/send pairs + */ + +static char ** +read_chat(chatstr) + char **chatstr; +{ + char *str = *chatstr; + char **res = NULL; + + if (str != NULL) { + char *tmp = NULL; + int l; + + if ((l=strlen(str)) > 0 && (tmp=malloc(l + 1)) != NULL && + (res=malloc((l / 2 + 1) * sizeof(char *))) != NULL) { + static char ws[] = " \t"; + char * p; + + for (l = 0, p = strtok(strcpy(tmp, str), ws); + p != NULL; + p = strtok(NULL, ws)) + { + unsigned char *q, *r; + + /* Read escapes */ + for (q = r = (unsigned char *)p; *r; ++q) + { + int val; + + if (*q == '\\') + { + /* handle special escapes */ + switch (*++q) + { + case 'a': /* bell */ + *r++ = '\a'; + break; + case 'r': /* cr */ + *r++ = '\r'; + break; + case 'n': /* nl */ + *r++ = '\n'; + break; + case 'f': /* ff */ + *r++ = '\f'; + break; + case 'b': /* bs */ + *r++ = '\b'; + break; + case 'e': /* esc */ + *r++ = 27; + break; + case 't': /* tab */ + *r++ = '\t'; + break; + case 'p': /* pause */ + *r++ = PAUSE_CH; + break; + case 's': + case 'S': /* space */ + *r++ = ' '; + break; + case 'x': /* hexdigit */ + ++q; + *r++ = getdigit(&q, 16, 2); + --q; + break; + case '0': /* octal */ + ++q; + *r++ = getdigit(&q, 8, 3); + --q; + break; + default: /* literal */ + *r++ = *q; + break; + case 0: /* not past eos */ + --q; + break; + } + } else { + /* copy standard character */ + *r++ == *q; + } + } + + /* Remove surrounding quotes, if any + */ + if (*p == '"' || *p == '\'') { + q = strrchr(p+1, *p); + if (q != NULL && *q == *p && q[1] == '\0') { + *q = '\0'; + strcpy(p, p+1); + } + } + + res[l++] = p; + } + res[l] = NULL; + *chatstr = tmp; + return res; + } + free(tmp); + } + return res; +} + + +/* + * clean a character for display (ctrl/meta character) + */ + +static char * +cleanchr(buf, ch) + char **buf; + unsigned char ch; +{ + int l; + static char tmpbuf[5]; + char * tmp = buf ? *buf : tmpbuf; + + if (ch & 0x80) { + strcpy(tmp, "M-"); + l = 2; + ch &= 0x7f; + } else + l = 0; + + if (ch < 32) { + tmp[l++] = '^'; + tmp[l++] = ch + '@'; + } else if (ch == 127) { + tmp[l++] = '^'; + tmp[l++] = '?'; + } else + tmp[l++] = ch; + tmp[l] = '\0'; + + if (buf) + *buf = tmp + l; + return tmp; +} + + +/* + * clean a string for display (ctrl/meta characters) + */ + +static char * +cleanstr(s, l) + const unsigned char *s; + int l; +{ + static unsigned char * tmp = NULL; + static int tmplen = 0; + + if (tmplen < l * 4 + 1) + tmp = realloc(tmp, tmplen = l * 4 + 1); + + if (tmp == NULL) { + tmplen = 0; + return (char *)"(mem alloc error)"; + } else { + int i = 0; + char * p = tmp; + + while (i < l) + cleanchr(&p, s[i++]); + *p = '\0'; + } + + return tmp; +} + + +/* + * return result as an pseudo-english word + */ + +static const char * +result(r) + int r; +{ + static const char * results[] = { + "OK", "MEMERROR", "IOERROR", "TIMEOUT" + }; + return results[r & 3]; +} + + +/* + * chat_expect() + * scan input for an expected string + */ + +static int +chat_expect(str) + const char *str; +{ + int len, r = 0; + + if (chat_debug & CHATDEBUG_EXPECT) + syslog(LOG_DEBUG, "chat_expect '%s'", cleanstr(str, strlen(str))); + + if ((len = strlen(str)) > 0) { + int i = 0; + char * got; + + if ((got = malloc(len + 1)) == NULL) + r = 1; + else { + + memset(got, 0, len+1); + alarm(chat_alarm); + alarmed = 0; + + while (r == 0 && i < len) { + if (alarmed) + r = 3; + else { + unsigned char ch; + + if (read(STDIN_FILENO, &ch, 1) == 1) { + + if (chat_debug & CHATDEBUG_RECEIVE) + syslog(LOG_DEBUG, "chat_recv '%s' m=%d", + cleanchr(NULL, ch), i); + + if (ch == str[i]) + got[i++] = ch; + else if (i > 0) { + int j = 1; + + /* See if we can resync on a + * partial match in our buffer + */ + while (j < i && memcmp(got + j, str, i - j) != NULL) + j++; + if (j < i) + memcpy(got, got + j, i - j); + i -= j; + } + } else + r = alarmed ? 3 : 2; + } + } + alarm(0); + chat_unalarm(); + alarmed = 0; + free(got); + } + } + + if (chat_debug & CHATDEBUG_EXPECT) + syslog(LOG_DEBUG, "chat_expect %s", result(r)); + + return r; +} + + +/* + * chat_send() + * send a chat string + */ + +static int +chat_send(str) + char const *str; +{ + int r = 0; + + if (chat_debug && CHATDEBUG_SEND) + syslog(LOG_DEBUG, "chat_send '%s'", cleanstr(str, strlen(str))); + + if (*str) { + alarm(chat_alarm); + alarmed = 0; + while (r == 0 && *str) + { + unsigned char ch = (unsigned char)*str++; + + if (alarmed) + r = 3; + else if (ch == PAUSE_CH) + usleep(500000); /* 1/2 second */ + else { + usleep(10000); /* be kind to modem */ + if (write(STDOUT_FILENO, &ch, 1) != 1) + r = alarmed ? 3 : 2; + } + } + alarm(0); + chat_unalarm(); + alarmed = 0; + } + + if (chat_debug & CHATDEBUG_SEND) + syslog(LOG_DEBUG, "chat_send %s", result(r)); + + return r; +} + + +/* + * getty_chat() + * + * Termination codes: + * -1 - no script supplied + * 0 - script terminated correctly + * 1 - invalid argument, expect string too large, etc. + * 2 - error on an I/O operation or fatal error condition + * 3 - timeout waiting for a simple string + * + * Parameters: + * char *scrstr - unparsed chat script + * timeout - seconds timeout + * debug - debug value (bitmask) + */ + +int +getty_chat(scrstr, timeout, debug) + char *scrstr; + int timeout, debug; +{ + int r = -1; + + chat_alarm = timeout ? timeout : CHAT_DEFAULT_TIMEOUT; + chat_debug = debug; + + if (scrstr != NULL) { + char **script; + + if (chat_debug & CHATDEBUG_MISC) + syslog(LOG_DEBUG, "getty_chat script='%s'", scrstr); + + if ((script = read_chat(&scrstr)) != NULL) { + int i = r = 0; + int off = 0; + sig_t old_alarm; + struct termios tneed; + + /* + * We need to be in raw mode for all this + * Rely on caller... + */ + + old_alarm = signal(SIGALRM, chat_alrm); + chat_unalarm(); /* Force blocking mode at start */ + + /* + * This is the send/expect loop + */ + while (r == 0 && script[i] != NULL) + if ((r = chat_expect(script[i++])) == 0 && script[i] != NULL) + r = chat_send(script[i++]); + + signal(SIGALRM, old_alarm); + free(script); + free(scrstr); + + /* + * Ensure stdin is in blocking mode + */ + ioctl(STDIN_FILENO, FIONBIO, &off); + } + + if (chat_debug & CHATDEBUG_MISC) + syslog(LOG_DEBUG, "getty_chat %s", result(r)); + + } + return r; +} diff --git a/share/man/man4/man4.i386/ex.4 b/share/man/man4/man4.i386/ex.4 new file mode 100644 index 000000000000..161522596723 --- /dev/null +++ b/share/man/man4/man4.i386/ex.4 @@ -0,0 +1,75 @@ +.\" +.\" Copyright (c) 1997 David E. O'Brien +.\" +.\" 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 DEVELOPERS ``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 DEVELOPERS 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. +.\" +.\" $Id$ +.\" +.Dd January 19, 1997 +.Dt EX 4 i386 +.Os FreeBSD +.Sh NAME +.Nm ex +.Nd +Ethernet device driver for the Intel EtherExpress Pro/10 +.Sh SYNOPSIS +.Cd "device ex0 at isa? port? net irq? vector exintr" +.Sh DESCRIPTION +The +.Nm +driver provides support for the 16-bit PCI Intel EtherExpress Pro/10 Ethernet +card based on the Intel i82595 chip. +.Pp +If the port start address isn't found, the card will be searched for in the +I/O address range 0x200 - 0x3a0. If the IRQ isn't specified, it will be +read from the EEPROM on the card. +.Pp +.Sh DIAGNOSTICS +.Bl -diag +.It "ex%d: Intel EtherExpress Pro/10, address %6D, connector %s" +The device probe found an installed card, and was able to correctly install +the device driver. +.It "ex%d: WARNING: board's EEPROM is configured for IRQ %d, using %d" +The device probe detected that the board is configured for a different +interrupt than the one specified in the kernel configuration file. +.It "ex%d: invalid IRQ." +The device probe detected an invalid IRQ setting. +.El +.Pp +.Sh BUGS +Currently the driver does not support multicast. +.Pp +.Sh SEE ALSO +.Xr arp 4 , +.Xr netintro 4 , +.Xr ifconfig 8 +.Sh HISTORY +The +.Nm +device driver first appeared in +.Fx 2.2 . +.Sh AUTHORS +The +.Nm +device driver was written by Javier Martín Rueda. +This manual page was written by David E. O'Brien. diff --git a/share/man/man4/man4.i386/sysmouse.4 b/share/man/man4/man4.i386/sysmouse.4 new file mode 100644 index 000000000000..a2e2cd619cc3 --- /dev/null +++ b/share/man/man4/man4.i386/sysmouse.4 @@ -0,0 +1,141 @@ +.\" Copyright (c) 1997 +.\" John-Mark Gurney. 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. Neither the name of the author nor the names of any co-contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY John-Mark Gurney 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. +.\" +.\" +.Dd February 14, 1997 +.Dt SYSMOUSE 4 +.Os +.Sh NAME +.Nm sysmouse +.Nd supplies mouse data from syscons for other applications +.Sh SYNOPSIS +.Fd #include <machine/console.h> +.Ft int +.Fn ioctl cfd CONS_MOUSECTL struct\ *mouse_info +.Sh DESCRIPTION +The +.Dv CONS_MOUSECTL +.Fn ioctl +call provides syscons with mouse information, which includes mouse movement +and button presses. The +.Fn ioctl +also provides a method for a process to receive a +.Xr signal 3 +when a button is pressed. +.Pp +.Xr moused 8 +uses this +.Fn ioctl +to inform the console of mouse actions. Applications +.Pq such as Tn X\ Windows +can use +.Pa /dev/sysmouse , +allowing syscons and the application to share the mouse. +.Pp +.Bd -literal -offset indent +struct mouse_info { + int operation; + union { + struct mouse_data data; + struct mouse_mode mode; + }u; +}; +.Ed +.Bl -tag -width operation +.It Dv operation +This can be one of +.Bl -tag -width MOUSE_MOVEABS +.It Dv MOUSE_SHOW +Enables and displays mouse cursor. +.It Dv MOUSE_HIDE +Disables and hides mouse cursor. +.It Dv MOUSE_MOVEABS +Moves mouse cursor to position supplied in +.Dv u.data . +.It Dv MOUSE_MOVEREL +Add position supplied in +.Dv u.data +to current position. +.It Dv MOUSE_GETINFO +Returns current mouse position and button status in +.Dv u.data . +.It Dv MOUSE_MODE +This sets the +.Xr signal 3 +to be delivered to the current process when a button is pressed. +The signal to be delivered is set in +.Dv u.mode . +.It Dv MOUSE_ACTION +This takes the information in +.Dv u.data +and acts upon it. It includes processing button presses if the current vty +is a text interface, and sending +.Tn Mouse System +protocol data to +.Pa /dev/sysmouse +if it is open. +.El +.It Dv u +This union is one of +.Bl -tag -width data +.It Dv data +.Bd -literal -offset indent +struct mouse_data { + int x; + int y; + int buttons; +}; +.Ed +.It Dv mode +.Bd -literal -offset indent +struct mouse_mode { + int mode; + int signal; +}; +.Ed +.El +.El +.Sh FILES +.Bl -tag -width /dev/consolectl -compact +.It Pa /dev/consolectl +device to control the console +.It Pa /dev/sysmouse +mouse action output +.El +.Sh SEE ALSO +.Xr vidcontrol 1 , +.Xr signal 3 , +.Xr moused 8 +.Sh HISTORY +The +.Nm +manual page example first appeared in +.Fx 3.0 . +.Sh AUTHOR +This +manual page was written by John-Mark Gurney +.Aq gurney_j@efn.org . diff --git a/tools/LibraryReport/LibraryReport.tcl b/tools/LibraryReport/LibraryReport.tcl new file mode 100755 index 000000000000..37b4379bf6c7 --- /dev/null +++ b/tools/LibraryReport/LibraryReport.tcl @@ -0,0 +1,289 @@ +#!/bin/sh +# tcl magic \ +exec tclsh $0 $* +################################################################################ +# Copyright (C) 1997 +# Michael Smith. 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. Neither the name of the author nor the names of any co-contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY Michael Smith 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 Michael Smith 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. +################################################################################ +# +# LibraryReport; produce a list of shared libraries on the system, and a list of +# all executables that use them. +# +################################################################################ +# +# Stage 1 looks for shared libraries; the output of 'ldconfig -r' is examined +# for hints as to where to look for libraries (but not trusted as a complete +# list). +# +# These libraries each get an entry in the global 'Libs()' array. +# +# Stage 2 walks the entire system directory heirachy looking for executable +# files, applies 'ldd' to them and attempts to determine which libraries are +# used. The path of the executable is then added to the 'Libs()' array +# for each library used. +# +# Stage 3 reports on the day's findings. +# +################################################################################ +# +# $Id$ +# + +######################################################################################### +# findLibs +# +# Ask ldconfig where it thinks libraries are to be found. Go look for them, and +# add an element to 'Libs' for everything that looks like a library. +# +proc findLibs {} { + + global Libs stats verbose; + + # Older ldconfigs return a junk value when asked for a report + if {[catch {set liblist [exec ldconfig -r]} err]} { # get ldconfig output + puts stderr "ldconfig returned nonzero, persevering."; + set liblist $err; # there's junk in this + } + + # remove hintsfile name, convert to list + set liblist [lrange [split $liblist "\n"] 1 end]; + + set libdirs ""; # no directories yet + foreach line $liblist { + # parse ldconfig output + if {[scan $line "%s => %s" junk libname] == 2} { + # find directory name + set libdir [file dirname $libname]; + # have we got this one already? + if {[lsearch -exact $libdirs $libdir] == -1} { + lappend libdirs $libdir; + } + } else { + puts stderr "Unparseable ldconfig output line :"; + puts stderr $line; + } + } + + # libdirs is now a list of directories that we might find libraries in + foreach dir $libdirs { + # get the names of anything that looks like a library + set libnames [glob -nocomplain "$dir/lib*.so.*"] + foreach lib $libnames { + set type [file type $lib]; # what is it? + switch $type { + file { # looks like a library + # may have already been referenced by a symlink + if {![info exists Libs($lib)]} { + set Libs($lib) ""; # add it to our list + if {$verbose} {puts "+ $lib";} + } + } + link { # symlink; probably to another library + # If the readlink fails, the symlink is stale + if {[catch {set ldest [file readlink $lib]}]} { + puts stderr "Symbolic link points to nothing : $lib"; + } else { + # may have already been referenced by another symlink + if {![info exists Libs($lib)]} { + set Libs($lib) ""; # add it to our list + if {$verbose} {puts "+ $lib";} + } + # list the symlink as a consumer of this library + lappend Libs($ldest) "($lib)"; + if {$verbose} {puts "-> $ldest";} + } + } + } + } + } + set stats(libs) [llength [array names Libs]]; +} + +################################################################################ +# findLibUsers +# +# Look in the directory (dir) for executables. If we find any, call +# examineExecutable to see if it uses any shared libraries. Call ourselves +# on any directories we find. +# +# Note that the use of "*" as a glob pattern means we miss directories and +# executables starting with '.'. This is a Feature. +# +proc findLibUsers {dir} { + + global stats verbose; + + if {[catch { + set ents [glob -nocomplain "$dir/*"]; + } msg]} { + if {$msg == ""} { + set msg "permission denied"; + } + puts stderr "Can't search under '$dir' : $msg"; + return ; + } + + if {$verbose} {puts "===>> $dir";} + incr stats(dirs); + + # files? + foreach f $ents { + # executable? + if {[file executable $f]} { + # really a file? + if {[file isfile $f]} { + incr stats(files); + examineExecutable $f; + } + } + } + # subdirs? + foreach f $ents { + # maybe a directory with more files? + # don't use 'file isdirectory' because that follows symlinks + if {[catch {set type [file type $f]}]} { + continue ; # may not be able to stat + } + if {$type == "directory"} { + findLibUsers $f; + } + } +} + +################################################################################ +# examineExecutable +# +# Look at (fname) and see if ldd thinks it references any shared libraries. +# If it does, update Libs with the information. +# +proc examineExecutable {fname} { + + global Libs stats verbose; + + # ask Mr. Ldd. + if {[catch {set result [exec ldd $fname]} msg]} { + return ; # not dynamic + } + + if {$verbose} {puts -nonewline "$fname : ";} + incr stats(execs); + + # For a non-shared executable, we get a single-line error message. + # For a shared executable, we get a heading line, so in either case + # we can discard the first line and any subsequent lines are libraries + # that are required. + set llist [lrange [split $result "\n"] 1 end]; + set uses ""; + + foreach line $llist { + if {[scan $line "%s => %s %s" junk1 lib junk2] == 3} { + if {$lib == "not"} { # "not found" error + set mlname [string range $junk1 2 end]; + puts stderr "$fname : library '$mlname' not known."; + } else { + lappend Libs($lib) $fname; + lappend uses $lib; + } + } else { + puts stderr "Unparseable ldd output line :"; + puts stderr $line; + } + } + if {$verbose} {puts "$uses";} +} + +################################################################################ +# emitLibDetails +# +# Emit a listing of libraries and the executables that use them. +# +proc emitLibDetails {} { + + global Libs; + + # divide into used/unused + set used ""; + set unused ""; + foreach lib [array names Libs] { + if {$Libs($lib) == ""} { + lappend unused $lib; + } else { + lappend used $lib; + } + } + + # emit used list + puts "== Current Shared Libraries =================================================="; + foreach lib [lsort $used] { + # sort executable names + set users [lsort $Libs($lib)]; + puts [format "%-30s %s" $lib $users]; + } + # emit unused + puts "== Stale Shared Libraries ===================================================="; + foreach lib [lsort $unused] { + # sort executable names + set users [lsort $Libs($lib)]; + puts [format "%-30s %s" $lib $users]; + } +} + +################################################################################ +# Run the whole shebang +# +proc main {} { + + global stats verbose argv; + + set verbose 0; + foreach arg $argv { + switch -- $arg { + -v { + set verbose 1; + } + default { + puts stderr "Unknown option '$arg'."; + exit ; + } + } + } + + set stats(libs) 0; + set stats(dirs) 0; + set stats(files) 0; + set stats(execs) 0 + + findLibs; + findLibUsers "/"; + emitLibDetails; + + puts [format "Searched %d directories, %d executables (%d dynamic) for %d libraries." \ + $stats(dirs) $stats(files) $stats(execs) $stats(libs)]; +} + +################################################################################ +main; diff --git a/tools/tools/epfe/epfe.pl b/tools/tools/epfe/epfe.pl new file mode 100644 index 000000000000..4afd824d4791 --- /dev/null +++ b/tools/tools/epfe/epfe.pl @@ -0,0 +1,38 @@ +#!/usr/bin/perl +# Copyright (c) 1996 Wolfram Schneider <wosch@FreeBSD.org>. Berlin. +# +# epfe - extract printing filter examples from printing.sgml +# +# usage: +# $ cd /usr/share/examples/printing +# $ epfe < ../../doc/handbook/printing.sgml +# +# $Id$ + +$in = 0; @a = (); +sub Print { s/\&\;/&/g; push(@a,$_); } +sub out { + local($name, *lines) = @_; + open(F, "> $name") || die "open $_[0]: $!\n"; + print F @lines; + close F; +} + +while(<>) { + if (/^<code>/) { + $in = 1; + } elsif (m%</code>% && $in > 0) { + if ($in > 1) { + $name = 'unknown' if !$name; + while(1) { if ($d{$name}) { $name .= 'X'; } else { last } } + &out("$name", *a); + $d{$name} = $name; + } + $in = 0; $name = ''; @a = (); + } elsif ($in == 1 && /^\#\s*!/) { + $in++; &Print; + } elsif ($in > 1) { + $name = $1 if (!$name && /^\#\s+(\S+)\s+-\s+/); + $in++; &Print; + } +} diff --git a/tools/tools/scsi-defects/scsi-defects.pl b/tools/tools/scsi-defects/scsi-defects.pl new file mode 100755 index 000000000000..5f48ec01c5a5 --- /dev/null +++ b/tools/tools/scsi-defects/scsi-defects.pl @@ -0,0 +1,94 @@ +#!/usr/bin/perl +# +# Copyright (C) 1997 +# Peter Dufault, Joerg Wunsch. 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 AUTHORS 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 AUTHORS 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. +# +# $Id$ +# + +# +# Read and decode a SCSI disk's primary or grown defect list. +# + +sub usage +{ + die "usage: scsi-defects raw-device-name [Glist|Plist]\n"; +} + + +# +# Main +# + +&usage if $#ARGV < 0 || $#ARGV > 1; + +$ENV{'PATH'} = "/bin:/usr/bin:/sbin:/usr/sbin"; + +$dev = $ARGV[0]; + +# generic device name given? +if ($dev =~ /^[so]d\d+$/) { $dev = "/dev/r${dev}.ctl"; } + +# +# Select what you want to read. PList include the primary defect list +# from the factory. GList is grown defects only. +# +if ($#ARGV > 0) { + if ($ARGV[1] =~ /^[Gg]/) { $glist = 1; $plist = 0; } + elsif ($ARGV[1] =~ /^[Pp]/) { $glist = 0; $plist = 1; } + else { &usage; } +} else { + $glist = 1; $plist = 0; +} + +open(PIPE, "scsi -f $dev " . + "-c '{ Op code} 37 0 0:3 v:1 v:1 5:3 0 0 0 0 4:i2 0' $plist $glist " . + "-i 4 '{ stuff } *i2 { Defect list length } i2' |") || + die "Cannot pipe to scsi(8)\n"; +chop($amnt = <PIPE>); +close(PIPE); + +if ($amnt == 0) { + print "There are no defects (in this list).\n"; + exit 0; +} + +print "There are " . $amnt / 8 . " defects in this list.\n"; + +$amnt += 4; + +open(PIPE, "scsi -f $dev " . + "-c '{ Op code} 37 0 0:3 v:1 v:1 5:3 0 0 0 0 v:i2 0' $plist $glist " . + "$amnt -i $amnt - |") || + die "Cannot pipe to scsi(8)\n"; + +read(PIPE, $buf, 4); # defect list header + +print "cylinder head sector\n"; + +while(read(PIPE, $buf, 8)) { + ($cylhi, $cyllo, $head, $sec) = unpack("CnCN", $buf); + printf "%8u %4u %6u\n", $cylhi*65536+$cyllo, $head, $sec; +} +close(PIPE); diff --git a/usr.bin/limits/limits.1 b/usr.bin/limits/limits.1 new file mode 100644 index 000000000000..64d3cbd0e208 --- /dev/null +++ b/usr.bin/limits/limits.1 @@ -0,0 +1,304 @@ +.\" Copyright (c) 1996 David Nugent <davidn@blaze.net.au> +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, is permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice immediately at the beginning of the file, without modification, +.\" 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. This work was done expressly for inclusion into FreeBSD. Other use +.\" is permitted provided this notation is included. +.\" 4. Absolutely no warranty of function or purpose is made by the author +.\" David Nugent. +.\" 5. Modifications may be freely made to this file providing the above +.\" conditions are met. +.\" +.\" $Id$ +.\" +.Dd January 15, 1996 +.Dt LIMITS 1 +.Os FreeBSD +.Sh NAME +.Nm limits +.Nd Set or display process resource limits +.Sh SYNOPSIS +.Nm limits +.Op Fl C Ar class | Fl U Ar user +.Op Fl SHB +.Op Fl e +.Op Fl cdflmnstu Op val +.Nm limits +.Op Fl C Ar class | Fl U Ar user +.Op Fl SHB +.Op Fl cdflmnstu Op val +.Op Fl E +.Op Ar name=value ... +.Op Ar command +.Sh DESCRIPTION +.Nm Limits +ether prints or sets kernel resource limits, and may optionally set +environment variables like +.Xr env 1 +and run a program with the selected resources. +Three uses of the +.Nm limits +command are possible: +.Pp +.Bl -hang -width indent +.It Nm limits Op Ar limitflags +.Op Ar name=value +.Ar command +.Pp +This usage sets limits according to +.Ar limitflags , +optionally sets environment variables given as +.Ar name=value +pairs, and then runs the specified command. +.It Nm limits Op Ar limitflags +.Pp +This usage determines values of resource settings according to +.Ar limitflags , +does not attempt to set them and outputs these values to +standard output. +By default, this will output the current kernel resource settings +active for the calling process. +Using the +.Fl C Ar class +or +.Fl U Ar user +flags, you may also display the current resource settings modified +by the the appropriate login class resource limit entries from +the +.Xr login.conf 5 +login capabilities database. +.It Nm limits Fl e Op Ar limitflags +.Pp +This usage determines values of resource settings according to +.Ar limitflags , +but does not set them itself. +Like the previous usage it outputs these values to standard +output, except that it will emit them in +.Em eval +format, suitable for the calling shell. +The calling shell is determined by examining the entries in the +.Pa /proc +filesystem for the parent process. +If the shell is known (ie. it is one of sh, csh, bash, tcsh, ksh, +pdksh or rc), +.Nm limits +emits 'limit' or 'ulimit' commands in the format understood by +that shell. +If the name of the shell cannot be determined, then the 'ulimit' +format used by +.Pa /bin/sh +is used. +.Pp +This is very useful for setting limits used by scripts, or prior +launching of daemons and other background tasks with specific +resource limit settings, and provides the benefit of allowing +global configuration of maximum resource usage by maintaining a +central database of settings in the login class database. +.Pp +Within a shell script, +.Nm limits +will normally be used with eval within backticks as follows: +.Pp +.Dl eval `limits -e -C daemon` +.Pp +which causes the output of +.Nm limits +to be evaluated and set by the current shell. +.El +.Pp +The value of limitflags specified in the above contains one or more of the +following options: +.Pp +.Bl -tag -width "-d [limit]" +.It Fl C Ar class +Use current resource values, modified by the resource entries applicable +for the login class "class". +.It Fl U Ar user +Use current resource values, modified by the resource entries applicable +to the login class which "user" belongs to. +If the user does not belong to a class, then the resource capabilities +for the "default" class are used, if it exists, or the "root" class if +the user is a superuser account. +.It Fl S +Selects display or setting of "soft" (or current) resource limits. +If specific limits settings follow this switch, only soft limits are +affected unless overridden later with either the +.Fl H +or +.Fl B +flags. +.It Fl H +Selects display or setting of "hard" (or maximum) resource limits. +If specific limits settings follow this switch, only hard limits are +affected until overridden later with either the +.Fl S +or +.Fl B +flags. +.It Fl B +Selects display or setting of both "soft" (current) or "hard" (maximum) +resource limits. +If specific limits settings follow this switch, both soft and hard +limits are affected until overridden later with either the +.Fl S +or +.Fl H +flags. +.Fl e +Selects "eval mode" formatting for output. +This is valid only on display mode and cannot be used when running a +command. +The exact syntax used for output depeneds upon the type of shell from +which +.Nm limits +is invoked. +.It Fl c Op Ar limit +Selects or sets (if 'limit' is specified) the +.Em coredumsize +resource limit. +A value of 0 disables core dumps. +.It Fl d Op Ar limit +Selects or sets (if 'limit' is specified) the +.Em datasize +resource limit. +.It Fl f Op Ar limit +Selects or sets the +.Em filesize +resource limit. +.It Fl l Op Ar limit +Selects or sets the +.Em memorylocked +resource limit. +.It Fl m Op Ar limit +Selects or sets the +.Em memoryuse +size limit +.It Fl n Op Ar limit +Selects or sets the +.Em openfiles +resource limit. +.It Fl s Op Ar limit +Selects or sets the +.Em stacksize +resource limit. +.It Fl t Op Ar limit +Selects or sets the +.Em cputime +resource limit. +.It Fl u Op Ar limit +Selects or sets the +.Em maxproc +resource limit. +.Pp +Valid values for 'limit' in the above set of flags consist of either the +string 'infinity' or 'inf' for an infinite (or kernel-defined maximum) +limit, or a numeric value maybe followed by a suffix. +Values which relate to size default to a value in bytes, or one of the +following suffixes may be used as a multiplier: +.Pp +.Bl -tag -offset indent -width "xxxx" -compact +.It b +512 byte blocks. +.It k +kilobytes (1024 bytes). +.It m +megabytes (1024*1024 bytes). +.It g +gigabytes. +.It t +terrabytes. +.El +.Pp +The +.Em cputime +resource defaults to a number of seconds, but a multiplier may be +used, and as with size values, multiple values separated by a valid +suffix are added together: +.Bl -tag -offset indent -width "xxxx" -compact +.It s +seconds. +.It m +minutes. +.It h +hours. +.It d +days. +.It w +weeks. +.It y +365 day years. +.El +.Pp +.It Fl E +The option +.Sq Fl E +causes +.Nm limits +to completely ignore the environment it inherits. +.It Fl a +This option forces all resource settings to be displayed even if +other specific resource settings have been specified. +For example, if you wish to disable core dumps when starting up +the usenet news system, but wish to set all other resource settings +as well that apply to the 'news' account, you might use: +.Pp +.Dl eval `limits -U news -aBec 0` +.Pp +As with the +.Xr setrlimit 3 +call, only the superuser may raise process "hard" resource limits. +Non-root users may, however, lower them or change "soft" resource limits +within to any value below the hard limit. +When invoked to execute a program, the failure of +.Nm limits +to raise a hard limit is considered a fatal error. +.El +.Sh DIAGNOSTICS +.Nm Limits +exits with EXIT_FAILURE if usage is incorrect in any way; ie. an invalid +option, or set/display options are selected in the same invocation, +.Fl e +is used when running a program, etc. +When run in display or eval mode, +.Nm limits +exits with with a status of EXIT_SUCCESS. +When run in command mode and execution of the command succeeds, the exit status +will be whatever the executed program returns. +.Sh SEE ALSO +.Xr csh 1 , +.Xr env 1 , +.Xr limit 1 , +.Xr sh 1 , +.Xr ulimit 1 , +.Xr getrlimit 3 , +.Xr setrlimit 3 , +.Xr login_cap 3 , +.Xr login.conf 5 +.Sh BUGS +.Nm Limits +does not handle commands with equal (``='') signs in their +names, for obvious reasons. +.Pp +When eval output is selected, the /proc filesystem must be installed +and mounted for the shell to be correctly determined, and therefore +output syntax correct for the running shell. +The default output is valid for /bin/sh, so this means that any +usage of +.Nm limits +in eval mode prior mounting /proc may only occur in standard bourne +shell scripts. +.Pp +.Nm Limits +makes no effort to ensure that resource settings emitted or displayed +are valid and settable by the current user. +Only a superuser account may raise hard limits, and and when doing so +the FreeBSD kernel will silently lower limits to values less than +specified if the values given are too high. diff --git a/usr.bin/mklocale/data/ko_KR.EUC.src b/usr.bin/mklocale/data/ko_KR.EUC.src new file mode 100644 index 000000000000..48a249394642 --- /dev/null +++ b/usr.bin/mklocale/data/ko_KR.EUC.src @@ -0,0 +1,114 @@ +/* + * Korean LOCALE_CTYPE definitions using EUC-KR character sets + * + * Choi Jun Ho, junker@vishnu.snu.ac.kr + * NARAE, Seoul National Univ., CS Dept. + * 96.12.3 + * + * It is based on manpage mklocale(1), euc(4). + * + */ + +ENCODING "EUC" + +/* EUC-KR + * 0xa1a1-0xfefe + * byte 1: 0xa1-0xfe + * byte 2: 0xa1-0xfe + */ + +VARIABLE 1 0x0000 2 0x8080 2 0x0080 3 0x8000 0x8080 + +/* + * Code Set 1, US-ASCII equivalent + */ +ALPHA 'A' - 'Z' 'a' - 'z' +CONTROL 0x00 - 0x1f 0x7f +DIGIT '0' - '9' +GRAPH 0x21 - 0x7e +LOWER 'a' - 'z' +PUNCT 0x21 - 0x2f 0x3a - 0x40 0x5b - 0x60 0x7b - 0x7e +SPACE 0x09 - 0x0d 0x20 +UPPER 'A' - 'Z' +XDIGIT 'a' - 'f' 'A' - 'F' +BLANK ' ' +PRINT 0x20 - 0x7e + +MAPLOWER < 'A' - 'Z' : 'a' > < 'a' - 'z' : 'a' > +MAPUPPER < 'A' - 'Z' : 'A' > < 'a' - 'z' : 'A' > +TODIGIT < '0' - '9' : 0 > +TODIGIT < 'A' - 'F' : 10 > < 'a' - 'f' : 10 > + +/* + * Code Set 2, EUC-KR + */ +ALPHA 0xa3c1 - 0xa3da 0xa3e1 - 0xa3fa +DIGIT 0xa3b0 - 0xa3b9 +UPPER 0xa3c1 - 0xa3da +LOWER 0xa3e1 - 0xa3fa +PUNCT 0xa3a1 - 0xa3af 0xa3ba - 0xa3c0 0xa3db - 0xa3e0 0xa3fb - 0xa3fe +SPACE 0xa1a1 +XDIGIT 0xa3c1 - 0xa3c6 0xa3e1 - 0xa3e6 +BLANK 0xa1a1 +PRINT 0xa1a1 - 0xfefe +SPECIAL 0xa1a2 - 0xa2e5 + +MAPLOWER < 0xa3c1 - 0xa3da : 0xa3e1 > < 0xa3e1 - 0xa3fa : 0xa3e1 > +MAPUPPER < 0xa3c1 - 0xa3da : 0xa3c1 > < 0xa3b0 - 0xa3b9 : 0xa3c1 > +TODIGIT < 0xa3b1 - 0xa3b9 : 0 > +TODIGIT < 0xa3c1 - 0xa3c6 : 10 > < 0xa3e1 - 0xa3e6 : 10 > + + +UPPER 0xa5c1 - 0xa5d8 /* Greek */ +LOWER 0xa5e1 - 0xa5f8 /* Greek */ +MAPLOWER < 0xa5c1 - 0xa5d8 : 0xa5e1 > < 0xa5e1 - 0xa5f8 : 0xa5e1 > +MAPUPPER < 0xa5c1 - 0xa5d8 : 0xa5c1 > < 0xa5e1 - 0xa5f8 : 0xa5c1 > + +UPPER 0xaca1 - 0xacc1 /* Cyrillic */ +LOWER 0xacd1 - 0xacf1 /* Cyrillic */ +MAPLOWER < 0xaca1 - 0xacc1 : 0xacd1 > < 0xacd1 - 0xacf1 : 0xacd1 > +MAPUPPER < 0xaca1 - 0xacc1 : 0xaca1 > < 0xacd1 - 0xacf1 : 0xaca1 > + +SPECIAL 0xa5a1 - 0xa5aa 0xa5b0 - 0xa5b9 /* greek digit */ +SPECIAL 0xa6a1 - 0xa6e4 0xa7a1 - 0xa7ef /* symbols */ +SPECIAL 0xa8a1 - 0xa8fe 0xa9a1 - 0xa9fe /* circle symbols */ + +PHONOGRAM 0xa4a1 - 0xa4fe /* no combined hangul */ +PHONOGRAM 0xaaa1 - 0xaaf3 /* hirakana */ +PHONOGRAM 0xaba1 - 0xabf3 /* katakana */ + +PHONOGRAM 0xb0a1 - 0xb0fe 0xb1a1 - 0xb1fe 0xb2a1 - 0xb2fe +PHONOGRAM 0xb3a1 - 0xb3fe 0xb4a1 - 0xb4fe 0xb5a1 - 0xb5fe +PHONOGRAM 0xb6a1 - 0xb6fe 0xb7a1 - 0xb7fe 0xb8a1 - 0xb8fe +PHONOGRAM 0xb9a1 - 0xb9fe 0xbaa1 - 0xbafe 0xbba1 - 0xbbfe +PHONOGRAM 0xbca1 - 0xbcfe 0xbda1 - 0xbdfe 0xbea1 - 0xbefe +PHONOGRAM 0xbfa1 - 0xbffe 0xc0a1 - 0xc0fe 0xc1a1 - 0xc1fe +PHONOGRAM 0xc2a1 - 0xc2fe 0xc3a1 - 0xc3fe 0xc4a1 - 0xc4fe +PHONOGRAM 0xc5a1 - 0xc5fe 0xc6a1 - 0xc6fe 0xc7a1 - 0xc7fe +PHONOGRAM 0xc8a1 - 0xc8fe /* hangul composed */ + +IDEOGRAM 0xcaa1 - 0xcafe 0xcba1 - 0xcbfe 0xcca1 - 0xccfe +IDEOGRAM 0xcda1 - 0xcdfe 0xcea1 - 0xcefe 0xcfa1 - 0xcffe +IDEOGRAM 0xd0a1 - 0xd0fe 0xd1a1 - 0xd1fe 0xd2a1 - 0xd2fe +IDEOGRAM 0xd3a1 - 0xd3fe 0xd4a1 - 0xd4fe 0xd5a1 - 0xd5fe +IDEOGRAM 0xd6a1 - 0xd6fe 0xd7a1 - 0xd7fe 0xd8a1 - 0xd8fe +IDEOGRAM 0xd9a1 - 0xd9fe 0xdaa1 - 0xdafe 0xdba1 - 0xdbfe +IDEOGRAM 0xdca1 - 0xdcfe 0xdda1 - 0xddfe 0xdea1 - 0xdefe +IDEOGRAM 0xdfa1 - 0xdffe 0xe0a1 - 0xe0fe 0xe1a1 - 0xe1fe +IDEOGRAM 0xe2a1 - 0xe2fe 0xe3a1 - 0xe3fe 0xe4a1 - 0xe4fe +IDEOGRAM 0xe5a1 - 0xe5fe 0xe6a1 - 0xe6fe 0xe7a1 - 0xe7fe +IDEOGRAM 0xe8a1 - 0xe8fe 0xe9a1 - 0xe9fe 0xeaa1 - 0xeafe +IDEOGRAM 0xeba1 - 0xebfe 0xeca1 - 0xecfe 0xeda1 - 0xedfe +IDEOGRAM 0xeea1 - 0xeefe 0xefa1 - 0xeffe 0xf0a1 - 0xf0fe +IDEOGRAM 0xf1a1 - 0xf1fe 0xf2a1 - 0xf2fe 0xf3a1 - 0xf3fe +IDEOGRAM 0xf4a1 - 0xf4fe 0xf5a1 - 0xf5fe 0xf6a1 - 0xf6fe +IDEOGRAM 0xf7a1 - 0xf7fe 0xf8a1 - 0xf8fe 0xf9a1 - 0xf9fe +IDEOGRAM 0xfaa1 - 0xfafe 0xfba1 - 0xfbfe 0xfca1 - 0xfcfe +IDEOGRAM 0xfda1 - 0xfdfe /* hanja */ + +/* + * We have no Codeset 3, it is dummy + */ +SPECIAL 0xa1 - 0xfe +PHONOGRAM 0xa1 - 0xfe +PRINT 0xa1 - 0xfe diff --git a/usr.sbin/ppp/sig.c b/usr.sbin/ppp/sig.c new file mode 100644 index 000000000000..3442538e0c3b --- /dev/null +++ b/usr.sbin/ppp/sig.c @@ -0,0 +1,89 @@ +/*- + * Copyright (c) 1997 + * Brian Somers <brian@awfulhak.demon.co.uk>. 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. 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 ``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. + * + * $Id$ + * + * TODO: + * + */ + +#include "sig.h" +#include <sys/types.h> +#include "mbuf.h" +#include "log.h" + +#define __MAXSIG (32) /* Sizeof u_long: Make life convenient.... */ +static u_long caused; /* A mask of pending signals */ +static __sighandler_t *handler[ __MAXSIG ]; /* all start at SIG_DFL */ + + +/* Record a signal in the "caused" mask */ + +static void signal_recorder(int sig) { + if (sig > 0 && sig <= __MAXSIG) + caused |= (1<<(sig-1)); +} + + +/* + set up signal_recorder, and record handler as the function to ultimately + call in handle_signal() +*/ + +__sighandler_t *pending_signal(int sig,__sighandler_t *fn) { + __sighandler_t *Result; + + if (sig <= 0 || sig > __MAXSIG) { + /* Oops - we must be a bit out of date (too many sigs ?) */ + logprintf("Eeek! %s:%s: I must be out of date!\n",__FILE__,__LINE__); + return signal(sig,fn); + } + + Result = handler[sig-1]; + if (fn == SIG_DFL || fn == SIG_IGN) { + handler[sig-1] = (__sighandler_t *)0; + signal(sig,fn); + } else { + handler[sig-1] = fn; + signal(sig,signal_recorder); + } + caused &= ~(1<<(sig-1)); + return Result; +} + + +/* Call the handlers for any pending signals */ + +void handle_signals() { + int sig; + + if (caused) + for (sig=0; sig<__MAXSIG; sig++, caused>>=1) + if (caused&1) + (*handler[sig])(sig+1); +} diff --git a/usr.sbin/ppp/sig.h b/usr.sbin/ppp/sig.h new file mode 100644 index 000000000000..5194ea64cbac --- /dev/null +++ b/usr.sbin/ppp/sig.h @@ -0,0 +1,41 @@ +/*- + * Copyright (c) 1997 + * Brian Somers <brian@awfulhak.demon.co.uk>. 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. 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 ``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. + * + * $Id$ + * + * TODO: + * + */ + +#include <sys/signal.h> + +/* Call this instead of signal() */ +extern __sighandler_t *pending_signal __P((int, __sighandler_t *)); + +/* Call this when you want things to *actually* happen */ +extern void handle_signals __P((void)); |
