From owner-freebsd-audit Sun Feb 9 2:48:52 2003 Delivered-To: freebsd-audit@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2C3FB37B401; Sun, 9 Feb 2003 02:48:38 -0800 (PST) Received: from perrin.int.nxad.com (internal.ext.nxad.com [66.250.180.251]) by mx1.FreeBSD.org (Postfix) with ESMTP id 89C1943FA3; Sun, 9 Feb 2003 02:48:37 -0800 (PST) (envelope-from sean@perrin.int.nxad.com) Received: by perrin.int.nxad.com (Postfix, from userid 1001) id 2139D20F01; Sun, 9 Feb 2003 02:47:28 -0800 (PST) Date: Sun, 9 Feb 2003 02:47:27 -0800 From: Sean Chittenden To: audit@FreeBSD.org Subject: Making random(6) actually useful... Message-ID: <20030209104727.GO15936@perrin.int.nxad.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="9wgEzdE/cOoYWTWe" Content-Disposition: inline User-Agent: Mutt/1.4i X-PGP-Key: finger seanc@FreeBSD.org X-PGP-Fingerprint: 6CEB 1B06 BFD3 70F6 95BE 7E4D 8E85 2E0A 5F5B 3ECB X-Web-Homepage: http://sean.chittenden.org/ Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --9wgEzdE/cOoYWTWe Content-Type: multipart/mixed; boundary="FIfSo9pyi3Jhph90" Content-Disposition: inline --FIfSo9pyi3Jhph90 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable There isn't much useful functionality that I'm aware of that comes out of random(6) as its implemented currently. What I was originally out to do was to randomize the search order of dist sites for ports/packages and didn't find anything that did what I wanted and was BSD licensed (or small). The new random(6) functionality allows for: 1) randomizing the order of downloads from a mirrors list. For example, in a Makefile: DOWNLOAD_SITES=3D `echo -n "${MASTER_SITE_RUBY} "| random -wf -` DOWNLOAD_SITES+=3D MASTER_SITE_LOCAL 2) randomizing playlists for MP3s: find ~/mp3s -name '*.mp3' | random -f - > play_list.m3u 3) being WARNS 5 compliant The biggest use though is for the ports downloads. If there aren't any objections to this, I'd like approval to commit it that way it can possibly MFC'ed into 4.8 before the freeze and used to help distribute the load of download sites more evenly. This hasn't been optimized for large files, but it does work quite well for anything under 50K lines/words. I've tested this locally with the following script: #BEGIN ruby for file in `locate '.'|egrep -i '\.(c|txt|sgml|h|conf|[1-9]|rb)$'` file.chomp! orig =3D `cat #{file}|sort|md5`.chomp new =3D `random -f #{file}|sort|md5`.chomp raise "#{file} different!" if orig !=3D new end #END The biggest bug with this right now is performance in that I haven't done anything special for handling large files. If it's a problem, I can do it and have a few ways of making it near O(N), but I don't have the energy or desire to do so unless it's needed. Comments/suggestions? -sc --=20 Sean Chittenden --FIfSo9pyi3Jhph90 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=patch Content-Transfer-Encoding: quoted-printable Index: Makefile =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/ncvs/src/games/random/Makefile,v retrieving revision 1.3 diff -u -r1.3 Makefile --- Makefile 26 Mar 2001 14:20:59 -0000 1.3 +++ Makefile 9 Feb 2003 10:41:42 -0000 @@ -3,5 +3,7 @@ =20 PROG=3D random MAN=3D random.6 +SRCS=3D random.c randomize_fd.c +WARNS=3D 5 =20 .include Index: random.6 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/ncvs/src/games/random/random.6,v retrieving revision 1.5 diff -u -r1.5 random.6 --- random.6 10 Jul 2001 10:32:00 -0000 1.5 +++ random.6 9 Feb 2003 10:41:42 -0000 @@ -10,7 +10,7 @@ .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this softwa= re -.\" must display the following acknowledgement: +.\" must display the following acknowledgment: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors @@ -32,7 +32,7 @@ .\" @(#)random.6 8.2 (Berkeley) 3/31/94 .\" $FreeBSD: src/games/random/random.6,v 1.5 2001/07/10 10:32:00 ru Exp $ .\" -.Dd March 31, 1994 +.Dd February 8, 2003 .Dt RANDOM 6 .Os .Sh NAME @@ -41,14 +41,31 @@ .Sh SYNOPSIS .Nm .Op Fl er +.Op Fl f Ar filename .Op Ar denominator .Sh DESCRIPTION .Nm Random -reads lines from the standard input and copies them to the standard -output with a probability of 1/denominator. -The default value for +has two distinct modes of operations. The default is to read in lines +from stdin and randomly write them out to stdout with a probability of +1 / +.Ar denominator . +The default .Ar denominator -is 2. +for this mode of operation is 2, giving each line a 50/50 chance of +being displayed. +.Pp +The second mode of operation is to read in a file from +.Ar filename +and randomize the contents of the file and send it back out to stdout. +The contents can be randomized based off of newlines or based off of +space characters as determined by +.Xr isspace 3 . +The default +.Ar denominator +for this mode of operation is 1, which gives each line a chance to be +displayed, but in a +.Xr random 3 +order. .Pp The options are as follows: .Bl -tag -width Ds @@ -61,10 +78,40 @@ exit value of 0 to .Ar denominator \&- 1, inclusive. +.It Fl f Ar filename +The +.Fl f +option is used to specify the +.Ar filename +to read from. stdin is used if the filename is set to "-". +.It Fl l +Randomize the input via newlines (the default). .It Fl r The .Fl r option guarantees that the output is unbuffered. +.It Fl u +Tells +.Xr random 6 +not to select the same line or word from a file more than once (the +default). This does not guarantee uniqueness if there are two of the +same tokens from the input, but it does prevent selecting the same +token more than once. +.It Fl U +Tells +.Xr random 6 +that it is okay for it to reuse any given line or word when creating a +randomized output. +.It Fl w +Randomize words separated by +.Xr isspace 3 +instead of newlines. .El .Sh SEE ALSO -.Xr fortune 6 +.Xr fortune 6 , +.Xr random 3 +.Sh BUGS +There is no index used when printing out tokens from the list which +makes rather slow for large files (10MB+). If this were used in +performance sensitive areas, I'd do something about it. For smaller +files, however, it should still be quite fast and efficient. Index: random.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/ncvs/src/games/random/random.c,v retrieving revision 1.12 diff -u -r1.12 random.c --- random.c 18 Feb 2002 05:15:18 -0000 1.12 +++ random.c 9 Feb 2003 10:41:42 -0000 @@ -52,13 +52,16 @@ =20 #include #include +#include #include #include #include #include #include +#include "randomize_fd.h" =20 void usage(void); +int main(int argc, char**argv); =20 int main(argc, argv) @@ -66,19 +69,46 @@ char *argv[]; { double denom; - int ch, random_exit, selected, unbuffer_output; - char *ep; + int ch, fd, random_exit, randomize_lines, random_type, ret, + selected, unique_output, unbuffer_output; + char *ep, *filename; =20 - random_exit =3D unbuffer_output =3D 0; denom =3D 0; - while ((ch =3D getopt(argc, argv, "er")) !=3D -1) + filename =3D NULL; + random_type =3D RANDOM_TYPE_UNSET; + random_exit =3D randomize_lines =3D random_type =3D unbuffer_output =3D 0; + unique_output =3D 1; + while ((ch =3D getopt(argc, argv, "ef:lruUw")) !=3D -1) switch (ch) { case 'e': random_exit =3D 1; break; + case 'f': + randomize_lines =3D 1; + if (!strcmp(optarg, "-")) + filename =3D strdup("/dev/fd/0"); + else + filename =3D optarg; + break; + case 'l': + randomize_lines =3D 1; + random_type =3D RANDOM_TYPE_LINES; + break; case 'r': unbuffer_output =3D 1; break; + case 'u': + randomize_lines =3D 1; + unique_output =3D 1; + break; + case 'U': + randomize_lines =3D 1; + unique_output =3D 0; + break; + case 'w': + randomize_lines =3D 1; + random_type =3D RANDOM_TYPE_WORDS; + break; default: case '?': usage(); @@ -90,7 +120,7 @@ =20 switch (argc) { case 0: - denom =3D 2; + denom =3D (randomize_lines ? 1 : 2); break; case 1: errno =3D 0; @@ -109,16 +139,28 @@ =20 srandomdev(); =20 - /* Compute a random exit status between 0 and denom - 1. */ - if (random_exit) - return ((denom * random()) / LONG_MAX); - /* * Act as a filter, randomly choosing lines of the standard input * to write to the standard output. */ if (unbuffer_output) setbuf(stdout, NULL); + + /* + * Act as a filter, randomizing lines read in from a given file + * descriptor and write the output to standard output. + */ + if (randomize_lines) { + if ((fd =3D open(filename, O_RDONLY, 0)) < 0) + err(1, "%s", optarg); + ret =3D randomize_fd(fd, random_type, unique_output, denom); + if (!random_exit) + return(ret); + } + + /* Compute a random exit status between 0 and denom - 1. */ + if (random_exit) + return ((denom * random()) / LONG_MAX); =20 /* * Select whether to print the first line. (Prime the pump.) --- /dev/null Sun Feb 9 02:39:46 2003 +++ randomize_fd.h Sun Feb 9 00:57:27 2003 @@ -0,0 +1,30 @@ +/* $FreeBSD$ */ + +#ifndef __RANDOMIZE_FD__ +#define __RANDOMIZE_FD__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define RANDOM_TYPE_UNSET 0 +#define RANDOM_TYPE_LINES 1 +#define RANDOM_TYPE_WORDS 2 + +/* The multiple instance single integer key */ +struct rand_node { + u_char *cp; + u_int len; + struct rand_node *next; +}; + +int randomize_fd(int fd, int type, int unique, double denom); + +#endif --- /dev/null Sun Feb 9 02:39:46 2003 +++ randomize_fd.c Sun Feb 9 02:20:54 2003 @@ -0,0 +1,193 @@ +/* $FreeBSD$ */ + +#include "randomize_fd.h" + +struct rand_node *rand_root; +struct rand_node *rand_tail; + + +static +struct rand_node *rand_node_allocate(void) +{ + struct rand_node *n; + + n =3D (struct rand_node *)malloc(sizeof(struct rand_node)); + if (n =3D=3D NULL) + err(1, "malloc"); + + n->len =3D 0; + n->cp =3D NULL; + n->next =3D NULL; + return(n); +} + + +static +void rand_node_free(struct rand_node *n) +{ + if (n !=3D NULL) { + if (n->cp !=3D NULL) + free(n->cp); + + free(n); + } +} + + +static +void rand_node_free_rec(struct rand_node *n) +{ + if (n !=3D NULL) { + if (n->next !=3D NULL) + rand_node_free_rec(n->next); + + rand_node_free(n); + } +} + + +static +struct rand_node *rand_node_append(struct rand_node *n) +{ + if (rand_root =3D=3D NULL) { + rand_root =3D rand_tail =3D n; + return(n); + } else { + rand_tail->next =3D n; + rand_tail =3D n; + + return(n); + } +} + + +int randomize_fd(int fd, int type, int unique, double denom) +{ + u_char *buf, *p; + u_int numnode, j, selected, slen; + struct rand_node *n, *prev; + int bufc, bufleft, buflen, eof, fndstr, i, len, ret; + + rand_root =3D rand_tail =3D NULL; + bufc =3D bufleft =3D eof =3D fndstr =3D numnode =3D 0; + + if (type =3D=3D RANDOM_TYPE_UNSET) + type =3D RANDOM_TYPE_LINES; + + buflen =3D sizeof(u_char) * MAXBSIZE; + buf =3D (u_char *)malloc(buflen); + if (buf =3D=3D NULL) + err(1, "malloc"); + + while (!eof) { + /* Check to see if we have bits in the buffer */ + if (bufleft =3D=3D 0) { + len =3D read(fd, buf, buflen); + if (len =3D=3D -1) + err(1, "read"); + else if (len =3D=3D 0) + break; + else if (len < buflen) { + buflen =3D len; + eof++; + } + + bufleft =3D len; + } + + /* Look for a newline */ + for (i =3D bufc; i <=3D buflen; i++, bufleft--) { + if (i =3D=3D buflen) { + if (fndstr) { + if (!eof) { + memmove(buf, &buf[bufc], i - bufc); + i =3D i - bufc; + bufc =3D 0; + len =3D read(fd, &buf[i], buflen - i); + if (len =3D=3D -1) + err(1, "read"); + else if (len =3D=3D 0) { + eof++; + break; + } else if (len < buflen -i ) + buflen =3D i + len; + + bufleft =3D len; + fndstr =3D 0; + } + } else { + p =3D (u_char *)realloc(buf, buflen * 2); + if (p =3D=3D NULL) + err(1, "realloc"); + + buf =3D p; + if (!eof) { + len =3D read(fd, &buf[i], buflen); + if (len =3D=3D -1) + err(1, "read"); + else if (len =3D=3D 0) { + eof++; + break; + } else if (len < buflen -i ) + buflen =3D len; + + bufleft =3D len; + } + + buflen *=3D 2; + } + } + + if ((type =3D=3D RANDOM_TYPE_LINES && buf[i] =3D=3D '\n') || + (type =3D=3D RANDOM_TYPE_WORDS && isspace((int)buf[i])) || + (eof && i =3D=3D buflen - 1)) { + n =3D rand_node_allocate(); + slen =3D i - bufc; + n->len =3D slen + 2; + n->cp =3D (u_char *)malloc(slen + 2); + if (n->cp =3D=3D NULL) + err(1, "malloc"); + + memmove(n->cp, &buf[bufc], slen); + n->cp[slen] =3D buf[i]; + n->cp[slen + 1] =3D '\0'; + bufc =3D i + 1; + fndstr =3D 1; + rand_node_append(n); + numnode++; + } + } + } + + (void)close(fd); + + for (i =3D numnode; i > 0; i--) { + selected =3D ((int)denom * random())/(((double)RAND_MAX + 1) / numnode); + + for (j =3D 0, prev =3D n =3D rand_root; n !=3D NULL; j++, prev =3D n, n = =3D n->next) { + if (j =3D=3D selected) { + ret =3D printf("%.*s", n->len - 1, n->cp); + if (ret < 0) + err(1, "printf"); + if (unique) { + if (n =3D=3D rand_root) + rand_root =3D n->next; + if (n =3D=3D rand_tail) + rand_tail =3D prev; + + prev->next =3D n->next; + rand_node_free(n); + numnode--; + break; + } + } + } + } + + fflush(stdout); + + if (!unique) + rand_node_free_rec(rand_root); + + return(0); +} --FIfSo9pyi3Jhph90-- --9wgEzdE/cOoYWTWe Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Comment: Sean Chittenden iD8DBQE+RjG/joUuCl9bPssRAsmxAJ910Yg6Ros75O7qtk0ND6uizZAnbgCgoOdZ SkBTsM8+OT8Q7zNL5lFztpw= =jbsi -----END PGP SIGNATURE----- --9wgEzdE/cOoYWTWe-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Sun Feb 9 3:10: 9 2003 Delivered-To: freebsd-audit@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3E18B37B401 for ; Sun, 9 Feb 2003 03:09:59 -0800 (PST) Received: from perrin.int.nxad.com (internal.ext.nxad.com [66.250.180.251]) by mx1.FreeBSD.org (Postfix) with ESMTP id BC50F43F85 for ; Sun, 9 Feb 2003 03:09:58 -0800 (PST) (envelope-from sean@perrin.int.nxad.com) Received: by perrin.int.nxad.com (Postfix, from userid 1001) id E18A620F01; Sun, 9 Feb 2003 03:08:53 -0800 (PST) Date: Sun, 9 Feb 2003 03:08:53 -0800 From: Sean Chittenden To: audit@FreeBSD.org Subject: WARNS = 2, sbin/ping... Message-ID: <20030209110853.GP15936@perrin.int.nxad.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="+/c+wG9PuVDVAlsu" Content-Disposition: inline User-Agent: Mutt/1.4i X-PGP-Key: finger seanc@FreeBSD.org X-PGP-Fingerprint: 6CEB 1B06 BFD3 70F6 95BE 7E4D 8E85 2E0A 5F5B 3ECB X-Web-Homepage: http://sean.chittenden.org/ Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --+/c+wG9PuVDVAlsu Content-Type: multipart/mixed; boundary="uLcrxnkzOGy8pA6s" Content-Disposition: inline --uLcrxnkzOGy8pA6s Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Speaking of WARNS2, here's a patch that bumps ping(8) to WARNS2. Once upon a tie it used to be WARNS5, but the patch has rotted some. The biggie in this one was collisions with sin(3) and sockaddr_in variable sin. -sc =20 --=20 Sean Chittenden --uLcrxnkzOGy8pA6s Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=patch Content-Transfer-Encoding: quoted-printable Index: Makefile =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/ncvs/src/sbin/ping/Makefile,v retrieving revision 1.17 diff -u -r1.17 Makefile --- Makefile 4 Dec 2001 02:19:55 -0000 1.17 +++ Makefile 9 Feb 2003 11:09:17 -0000 @@ -8,7 +8,7 @@ .if ${MACHINE_ARCH} =3D=3D "alpha" CFLAGS+=3D-fno-builtin # GCC's builtin memcpy doesn't do unaligned copies .endif -WARNS=3D 0 +WARNS=3D 2 DPADD=3D ${LIBM} LDADD=3D -lm =20 Index: ping.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/ncvs/src/sbin/ping/ping.c,v retrieving revision 1.83 diff -u -r1.83 ping.c --- ping.c 29 Jan 2003 20:42:42 -0000 1.83 +++ ping.c 9 Feb 2003 11:09:17 -0000 @@ -203,7 +203,7 @@ int argc; char *const *argv; { - struct sockaddr_in from, sin; + struct sockaddr_in from, sock_in; struct in_addr ifaddr; struct timeval last, intvl; struct iovec iov; @@ -230,7 +230,7 @@ #endif unsigned char loop, mttl; =20 - source =3D NULL; + payload =3D source =3D NULL; #ifdef IPSEC_POLICY_IPSEC policy_in =3D policy_out =3D NULL; #endif @@ -431,9 +431,9 @@ fill((char *)datap, payload); } if (source) { - bzero((char *)&sin, sizeof(sin)); - sin.sin_family =3D AF_INET; - if (inet_aton(source, &sin.sin_addr) !=3D 0) { + bzero((char *)&sock_in, sizeof(sock_in)); + sock_in.sin_family =3D AF_INET; + if (inet_aton(source, &sock_in.sin_addr) !=3D 0) { shostname =3D source; } else { hp =3D gethostbyname2(source, AF_INET); @@ -441,18 +441,18 @@ errx(EX_NOHOST, "cannot resolve %s: %s", source, hstrerror(h_errno)); =20 - sin.sin_len =3D sizeof sin; - if (hp->h_length > sizeof(sin.sin_addr) || + sock_in.sin_len =3D sizeof sock_in; + if ((unsigned)hp->h_length > sizeof(sock_in.sin_addr) || hp->h_length < 0) errx(1, "gethostbyname2: illegal address"); - memcpy(&sin.sin_addr, hp->h_addr_list[0], - sizeof(sin.sin_addr)); + memcpy(&sock_in.sin_addr, hp->h_addr_list[0], + sizeof(sock_in.sin_addr)); (void)strncpy(snamebuf, hp->h_name, sizeof(snamebuf) - 1); snamebuf[sizeof(snamebuf) - 1] =3D '\0'; shostname =3D snamebuf; } - if (bind(s, (struct sockaddr *)&sin, sizeof sin) =3D=3D -1) + if (bind(s, (struct sockaddr *)&sock_in, sizeof sock_in) =3D=3D -1) err(1, "bind"); } =20 @@ -468,7 +468,7 @@ errx(EX_NOHOST, "cannot resolve %s: %s", target, hstrerror(h_errno)); =20 - if (hp->h_length > sizeof(to->sin_addr)) + if ((unsigned)hp->h_length > sizeof(to->sin_addr)) errx(1, "gethostbyname2 returned an illegal address"); memcpy(&to->sin_addr, hp->h_addr_list[0], sizeof to->sin_addr); (void)strncpy(hnamebuf, hp->h_name, sizeof(hnamebuf) - 1); @@ -557,7 +557,7 @@ ip->ip_off =3D df ? IP_DF : 0; ip->ip_ttl =3D ttl; ip->ip_p =3D IPPROTO_ICMP; - ip->ip_src.s_addr =3D source ? sin.sin_addr.s_addr : INADDR_ANY; + ip->ip_src.s_addr =3D source ? sock_in.sin_addr.s_addr : INADDR_ANY; ip->ip_dst =3D to->sin_addr; } /* record route option */ @@ -701,7 +701,7 @@ int cc, n; =20 check_status(); - if (s >=3D FD_SETSIZE) + if ((unsigned)s >=3D FD_SETSIZE) errx(EX_OSERR, "descriptor too large"); FD_ZERO(&rfds); FD_SET(s, &rfds); @@ -722,7 +722,7 @@ if (n < 0) continue; /* Must be EINTR. */ if (n =3D=3D 1) { - struct timeval *t =3D NULL; + struct timeval *tv =3D NULL; #ifdef SO_TIMESTAMP struct cmsghdr *cmsg =3D (struct cmsghdr *)&ctrl; =20 @@ -738,19 +738,19 @@ #ifdef SO_TIMESTAMP if (cmsg->cmsg_level =3D=3D SOL_SOCKET && cmsg->cmsg_type =3D=3D SCM_TIMESTAMP && - cmsg->cmsg_len =3D=3D CMSG_LEN(sizeof *t)) { + cmsg->cmsg_len =3D=3D CMSG_LEN(sizeof *tv)) { /* Copy to avoid alignment problems: */ memcpy(&now, CMSG_DATA(cmsg), sizeof(now)); - t =3D &now; + tv =3D &now; } #endif - if (t =3D=3D NULL) { + if (tv =3D=3D NULL) { (void)gettimeofday(&now, NULL); - t =3D &now; + tv =3D &now; } - pr_pack((char *)packet, cc, &from, t); - if (options & F_ONCE && nreceived || - npackets && nreceived >=3D npackets) + pr_pack((char *)packet, cc, &from, tv); + if ((options & F_ONCE && nreceived) || + (npackets && nreceived >=3D npackets)) break; } if (n =3D=3D 0 || options & F_FLOOD) { @@ -910,7 +910,7 @@ #else tp =3D icp->icmp_data; #endif - tp+=3DMASKLEN; + tp +=3D MASKLEN; =20 /* Copy to avoid alignment problems: */ memcpy(&tv1, tp, sizeof(tv1)); --uLcrxnkzOGy8pA6s-- --+/c+wG9PuVDVAlsu Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Comment: Sean Chittenden iD8DBQE+RjbEjoUuCl9bPssRAuBEAJ4uB1zsLtKdmL+dB9hzUvYbh7idPQCgrLmB fXSOGG9/Yrt4lpHgjUc0Vq4= =5r9P -----END PGP SIGNATURE----- --+/c+wG9PuVDVAlsu-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Sun Feb 9 3:27:59 2003 Delivered-To: freebsd-audit@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 77E6B37B401; Sun, 9 Feb 2003 03:27:49 -0800 (PST) Received: from storm.FreeBSD.org.uk (storm.FreeBSD.org.uk [194.242.157.42]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6DDD643FA3; Sun, 9 Feb 2003 03:27:48 -0800 (PST) (envelope-from mark@grondar.org) Received: from storm.FreeBSD.org.uk (Ugrondar@localhost [127.0.0.1]) by storm.FreeBSD.org.uk (8.12.6/8.12.6) with ESMTP id h19BRlja061425; Sun, 9 Feb 2003 11:27:47 GMT (envelope-from mark@grondar.org) Received: (from Ugrondar@localhost) by storm.FreeBSD.org.uk (8.12.6/8.12.6/Submit) with UUCP id h19BRlQY061424; Sun, 9 Feb 2003 11:27:47 GMT X-Authentication-Warning: storm.FreeBSD.org.uk: Ugrondar set sender to mark@grondar.org using -f Received: from grondar.org (localhost [127.0.0.1]) by grimreaper.grondar.org (8.12.6/8.12.6) with ESMTP id h19BLMaX031051; Sun, 9 Feb 2003 13:21:22 +0200 (SAST) (envelope-from mark@grondar.org) From: Mark Murray Message-Id: <200302091121.h19BLMaX031051@grimreaper.grondar.org> To: Sean Chittenden Cc: audit@FreeBSD.ORG Subject: Re: Making random(6) actually useful... In-Reply-To: Your message of "Sun, 09 Feb 2003 02:47:27 PST." <20030209104727.GO15936@perrin.int.nxad.com> Date: Sun, 09 Feb 2003 11:21:22 +0000 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Sean Chittenden writes: > There isn't much useful functionality that I'm aware of that comes out > of random(6) as its implemented currently. What I was originally out > to do was to randomize the search order of dist sites for > ports/packages and didn't find anything that did what I wanted and was > BSD licensed (or small). The new random(6) functionality allows for: Looks good to me! Nits: o Please put BSD copyrights onto new files. o Please use "new-style" function declarations where possible; this will obviate the need for (at least) the main() prototype. M -- Mark Murray iumop ap!sdn w,I idlaH To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Sun Feb 9 4:47: 3 2003 Delivered-To: freebsd-audit@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BF7F337B401 for ; Sun, 9 Feb 2003 04:47:02 -0800 (PST) Received: from falcon.midgard.homeip.net (h76n3fls20o913.telia.com [213.67.148.76]) by mx1.FreeBSD.org (Postfix) with SMTP id 8567C43F85 for ; Sun, 9 Feb 2003 04:46:59 -0800 (PST) (envelope-from ertr1013@student.uu.se) Received: (qmail 35338 invoked by uid 1001); 9 Feb 2003 12:46:54 -0000 Date: Sun, 9 Feb 2003 13:46:54 +0100 From: Erik Trulsson To: Sean Chittenden Cc: audit@FreeBSD.org Subject: Re: Making random(6) actually useful... Message-ID: <20030209124654.GA35137@falcon.midgard.homeip.net> References: <20030209104727.GO15936@perrin.int.nxad.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030209104727.GO15936@perrin.int.nxad.com> User-Agent: Mutt/1.5.3i Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sun, Feb 09, 2003 at 02:47:27AM -0800, Sean Chittenden wrote: > There isn't much useful functionality that I'm aware of that comes out > of random(6) as its implemented currently. What I was originally out > to do was to randomize the search order of dist sites for > ports/packages and didn't find anything that did what I wanted and was > BSD licensed (or small). The new random(6) functionality allows for: > > 1) randomizing the order of downloads from a mirrors list. For > example, in a Makefile: > > DOWNLOAD_SITES= `echo -n "${MASTER_SITE_RUBY} "| random -wf -` > DOWNLOAD_SITES+= MASTER_SITE_LOCAL > > 2) randomizing playlists for MP3s: > > find ~/mp3s -name '*.mp3' | random -f - > play_list.m3u Have you looked at misc/shuffle from the ports collection? It seems to do what you want, is small and is BSD-licensed. -- Erik Trulsson ertr1013@student.uu.se To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Sun Feb 9 5:31: 2 2003 Delivered-To: freebsd-audit@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0021237B401; Sun, 9 Feb 2003 05:31:01 -0800 (PST) Received: from flood.ping.uio.no (flood.ping.uio.no [129.240.78.31]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6E53743FAF; Sun, 9 Feb 2003 05:31:01 -0800 (PST) (envelope-from des@ofug.org) Received: by flood.ping.uio.no (Postfix, from userid 2602) id 7C5A4536E; Sun, 9 Feb 2003 14:30:58 +0100 (CET) X-URL: http://www.ofug.org/~des/ X-Disclaimer: The views expressed in this message do not necessarily coincide with those of any organisation or company with which I am or have been affiliated. To: Sean Chittenden Cc: audit@FreeBSD.org Subject: Re: WARNS = 2, sbin/ping... From: Dag-Erling Smorgrav Date: Sun, 09 Feb 2003 14:30:58 +0100 In-Reply-To: <20030209110853.GP15936@perrin.int.nxad.com> (Sean Chittenden's message of "Sun, 9 Feb 2003 03:08:53 -0800") Message-ID: User-Agent: Gnus/5.090014 (Oort Gnus v0.14) Emacs/21.2 (i386--freebsd) References: <20030209110853.GP15936@perrin.int.nxad.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Sean Chittenden writes: > Speaking of WARNS2, here's a patch that bumps ping(8) to WARNS2. Once > upon a tie it used to be WARNS5, but the patch has rotted some. The > biggie in this one was collisions with sin(3) and sockaddr_in variable > sin. That's a compiler bug (unless is in scope). The correct solution is not to rename the variable, but to add -fno-builtin to CFLAGS globally, and fix those parts of the tree that break due to missing includes. Who knows, we might even uncover libc bugs that have been hitherto been masked by the compiler. DES -- Dag-Erling Smorgrav - des@ofug.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Sun Feb 9 7:44:18 2003 Delivered-To: freebsd-audit@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6AC8137B401; Sun, 9 Feb 2003 07:44:17 -0800 (PST) Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id 424CF43F75; Sun, 9 Feb 2003 07:44:16 -0800 (PST) (envelope-from bde@zeta.org.au) Received: from katana.zip.com.au (katana.zip.com.au [61.8.7.246]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id CAA02615; Mon, 10 Feb 2003 02:44:05 +1100 Date: Mon, 10 Feb 2003 02:44:08 +1100 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Dag-Erling Smorgrav Cc: Sean Chittenden , Subject: Re: WARNS = 2, sbin/ping... In-Reply-To: Message-ID: <20030210024135.N997-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sun, 9 Feb 2003, Dag-Erling Smorgrav wrote: > Sean Chittenden writes: > > Speaking of WARNS2, here's a patch that bumps ping(8) to WARNS2. Once > > upon a tie it used to be WARNS5, but the patch has rotted some. The > > biggie in this one was collisions with sin(3) and sockaddr_in variable > > sin. > > That's a compiler bug (unless is in scope). The correct > solution is not to rename the variable, but to add -fno-builtin to > CFLAGS globally, and fix those parts of the tree that break due to > missing includes. Who knows, we might even uncover libc bugs that > have been hitherto been masked by the compiler. Script started on Mon Feb 10 02:42:09 2003 ttyp0:bde@besplex:/tmp> grep math.h /usr/src/sbin/ping/ping.c #include ttyp0:bde@besplex:/tmp> exit Script done on Mon Feb 10 02:42:22 2003 [wollman added this include long ago to support printing standard deviations.] Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Sun Feb 9 10:42:54 2003 Delivered-To: freebsd-audit@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DCB4637B401; Sun, 9 Feb 2003 10:42:53 -0800 (PST) Received: from storm.FreeBSD.org.uk (storm.FreeBSD.org.uk [194.242.157.42]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0577443FAF; Sun, 9 Feb 2003 10:42:53 -0800 (PST) (envelope-from mark@grondar.org) Received: from storm.FreeBSD.org.uk (Ugrondar@localhost [127.0.0.1]) by storm.FreeBSD.org.uk (8.12.6/8.12.6) with ESMTP id h19Igpja065136; Sun, 9 Feb 2003 18:42:51 GMT (envelope-from mark@grondar.org) Received: (from Ugrondar@localhost) by storm.FreeBSD.org.uk (8.12.6/8.12.6/Submit) with UUCP id h19Igp5B065135; Sun, 9 Feb 2003 18:42:51 GMT X-Authentication-Warning: storm.FreeBSD.org.uk: Ugrondar set sender to mark@grondar.org using -f Received: from grondar.org (localhost [127.0.0.1]) by grimreaper.grondar.org (8.12.6/8.12.6) with ESMTP id h19IctaX035218; Sun, 9 Feb 2003 20:38:55 +0200 (SAST) (envelope-from mark@grondar.org) From: Mark Murray Message-Id: <200302091838.h19IctaX035218@grimreaper.grondar.org> To: Erik Trulsson Cc: Sean Chittenden , audit@FreeBSD.ORG Subject: Re: Making random(6) actually useful... In-Reply-To: Your message of "Sun, 09 Feb 2003 13:46:54 +0100." <20030209124654.GA35137@falcon.midgard.homeip.net> Date: Sun, 09 Feb 2003 18:38:55 +0000 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Erik Trulsson writes: > > find ~/mp3s -name '*.mp3' | random -f - > play_list.m3u > > Have you looked at misc/shuffle from the ports collection? It seems to > do what you want, is small and is BSD-licensed. We don't need a new tool if an existing tool will work. :-) The above can be done with a (nasty looking) one-liner using jot, wc, paste, sort and awk: $ ${do_stuff} > file && jot -r `wc -l file` 1 | paste /dev/stdin file | sort | awk '{print $2}' > file. && mv file. file Modifying random(6) to do this makes sense, in that it is generalising a tool. Using a whole new tool makes less sense. M -- Mark Murray iumop ap!sdn w,I idlaH To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Mon Feb 10 14:46:22 2003 Delivered-To: freebsd-audit@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F12CB37B440; Mon, 10 Feb 2003 14:46:20 -0800 (PST) Received: from mailsrv.otenet.gr (mailsrv.otenet.gr [195.170.0.5]) by mx1.FreeBSD.org (Postfix) with ESMTP id 03AA043FEA; Mon, 10 Feb 2003 14:46:08 -0800 (PST) (envelope-from keramida@freebsd.org) Received: from gothmog.gr (patr530-b121.otenet.gr [212.205.244.129]) by mailsrv.otenet.gr (8.12.6/8.12.6) with ESMTP id h1AMjplI022454; Tue, 11 Feb 2003 00:45:54 +0200 (EET) Received: from gothmog.gr (gothmog [127.0.0.1]) by gothmog.gr (8.12.7/8.12.7) with ESMTP id h1AMjmIE096570; Tue, 11 Feb 2003 00:45:48 +0200 (EET) (envelope-from keramida@freebsd.org) Received: (from giorgos@localhost) by gothmog.gr (8.12.7/8.12.7/Submit) id h1ALSmgi011604; Mon, 10 Feb 2003 23:28:48 +0200 (EET) (envelope-from keramida@freebsd.org) Date: Mon, 10 Feb 2003 23:28:48 +0200 From: Giorgos Keramidas To: phk@freebsd.org, freebsd-audit@freebsd.org Subject: share/man/{cat,man}n dirs Message-ID: <20030210212848.GA11444@gothmog.gr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; x-action=pgp-signed Content-Disposition: inline Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 After a question from Roman Neuhauser , I looked in the CVS logs of mtree/BSD.usr.dist and found out that mann and catn were added for TCL manpages in revision 1.60 (1996). I vaguely remember that TCL was part of the FreeBSD base system, but this is no longer true. Should we delete these dirs from our mtree files now? - - Giorgos -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (FreeBSD) iD8DBQE+SBmQ1g+UGjGGA7YRApiiAKCZLcue2oajnDaBtMqJUqQFN6no+wCgn5JA H3hksyaSCOl1pnXg+vbKv1c= =FBb5 -----END PGP SIGNATURE----- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu Feb 13 20:27:50 2003 Delivered-To: freebsd-audit@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1224B37B401; Thu, 13 Feb 2003 20:27:48 -0800 (PST) Received: from obsecurity.dyndns.org (adsl-67-119-52-8.dsl.lsan03.pacbell.net [67.119.52.8]) by mx1.FreeBSD.org (Postfix) with ESMTP id A200B43F75; Thu, 13 Feb 2003 20:27:47 -0800 (PST) (envelope-from kris@obsecurity.org) Received: from rot13.obsecurity.org (rot13.obsecurity.org [10.0.0.5]) by obsecurity.dyndns.org (Postfix) with ESMTP id 4774B679DE; Thu, 13 Feb 2003 20:27:47 -0800 (PST) Received: by rot13.obsecurity.org (Postfix, from userid 1000) id 390AEF6E; Thu, 13 Feb 2003 20:27:47 -0800 (PST) Date: Thu, 13 Feb 2003 20:27:47 -0800 From: Kris Kennaway To: Giorgos Keramidas Cc: phk@freebsd.org, freebsd-audit@freebsd.org Subject: Re: share/man/{cat,man}n dirs Message-ID: <20030214042747.GA2917@rot13.obsecurity.org> References: <20030210212848.GA11444@gothmog.gr> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Nq2Wo0NMKNjxTN9z" Content-Disposition: inline In-Reply-To: <20030210212848.GA11444@gothmog.gr> User-Agent: Mutt/1.4i Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --Nq2Wo0NMKNjxTN9z Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Feb 10, 2003 at 11:28:48PM +0200, Giorgos Keramidas wrote: > After a question from Roman Neuhauser , I > looked in the CVS logs of mtree/BSD.usr.dist and found out that mann > and catn were added for TCL manpages in revision 1.60 (1996). >=20 > I vaguely remember that TCL was part of the FreeBSD base system, but > this is no longer true. Should we delete these dirs from our mtree > files now? Yes, I think so. Kris --Nq2Wo0NMKNjxTN9z Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (FreeBSD) iD8DBQE+THBCWry0BWjoQKURApV2AKCXVlFsdVSgtXKk9dhsSQvi50pwnQCgqfU6 4fxIOHfEWNFuH55DjlrVcXU= =Fg8d -----END PGP SIGNATURE----- --Nq2Wo0NMKNjxTN9z-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message