Re: [patch] less: filename globbing/expansion

2010-04-06 Thread Matthew Haub
Hello,

On Fri, Apr 02, 2010 at 07:08:43PM -0700, Philip Guenther wrote:
 are we still tracking the upstream less(1) and if so, is the
 behavioral change acceptable there?

On Sat, Apr 03, 2010 at 03:37:46PM +1030, Matthew Haub wrote:
 We no longer track upstream less(1). The last sync was 7 years ago.

On Sat, Apr 03, 2010 at 07:34:40AM +0100, Nicholas Marriott wrote:
 Yes, but is that for a reason or just because nobody has updated it?

Todd Miller would be the person to ask. Either way I've emailed the less
maintainer to see whether he would be interested in using wordexp over
lessecho on systems that support it.

On Fri, Apr 02, 2010 at 07:08:43PM -0700, Philip Guenther wrote:
 if you want this, you should just implement wordexp(3) in libc and
 then use that.

Done. This patch uses wordexp as a drop in replacement for glob when
available.

Matthew

Index: configure
===
RCS file: /cvs/src/usr.bin/less/configure,v
retrieving revision 1.3
diff -u configure
--- configure   13 Apr 2003 18:26:25 -  1.3
+++ configure   6 Apr 2010 04:26:47 -
@@ -4456,7 +4456,7 @@
 
 
 
-for ac_func in fsync memcpy popen _setjmp sigprocmask sigsetmask stat strchr 
strstr system
+for ac_func in fsync memcpy popen _setjmp sigprocmask sigsetmask stat strchr 
strstr system wordexp
 do
 as_ac_var=`echo ac_cv_func_$ac_func | $as_tr_sh`
 echo $as_me:$LINENO: checking for $ac_func 5
Index: configure.ac
===
RCS file: /cvs/src/usr.bin/less/configure.ac,v
retrieving revision 1.1.1.1
diff -u configure.ac
--- configure.ac13 Apr 2003 18:21:21 -  1.1.1.1
+++ configure.ac6 Apr 2010 04:26:48 -
@@ -211,7 +211,7 @@
 
 # Checks for library functions.
 AC_TYPE_SIGNAL
-AC_CHECK_FUNCS([fsync memcpy popen _setjmp sigprocmask sigsetmask stat strchr 
strstr system])
+AC_CHECK_FUNCS([fsync memcpy popen _setjmp sigprocmask sigsetmask stat strchr 
strstr system wordexp])
 
 # Some systems have termios.h but not the corresponding functions.
 AC_CHECK_FUNC(tcgetattr, AC_DEFINE(HAVE_TERMIOS_FUNCS))
Index: defines.h.in
===
RCS file: /cvs/src/usr.bin/less/defines.h.in,v
retrieving revision 1.2
diff -u defines.h.in
--- defines.h.in14 Apr 2003 14:33:57 -  1.2
+++ defines.h.in6 Apr 2010 04:26:48 -
@@ -346,6 +346,9 @@
 /* Define HAVE_VOID if your compiler supports the void type. */
 #undef HAVE_VOID
 
+/* Define to 1 if you have the `wordexp' function. */
+#undef HAVE_WORDEXP
+
 /* Define to 1 if you have the `_setjmp' function. */
 #undef HAVE__SETJMP
 
Index: filename.c
===
RCS file: /cvs/src/usr.bin/less/filename.c,v
retrieving revision 1.13
diff -u filename.c
--- filename.c  6 Dec 2006 05:03:29 -   1.13
+++ filename.c  6 Apr 2010 04:26:48 -
@@ -37,6 +37,9 @@
 #include signal.h
 #endif
 
+#if HAVE_WORDEXP
+#include wordexp.h
+#endif
 #if HAVE_STAT
 #include sys/stat.h
 #ifndef S_ISDIR
Index: lglob.h
===
RCS file: /cvs/src/usr.bin/less/lglob.h,v
retrieving revision 1.3
diff -u lglob.h
--- lglob.h 22 Apr 2003 22:57:13 -  1.3
+++ lglob.h 6 Apr 2010 04:26:48 -
@@ -23,7 +23,18 @@
  */
 
 #include glob.h
+#include defines.h
 
+#if HAVE_WORDEXP
+#defineGLOB_FLAGS  (WRDE_NOCMD)
+#defineDECL_GLOB_LIST(list)wordexp_t list; int i; int 
list##error;
+#defineGLOB_LIST_FAILED(list)  list##error != 0
+#defineSCAN_GLOB_LIST(list,p)  i = 0; i  list.we_wordc; i++
+#defineINIT_GLOB_LIST(list,p)  p = list.we_wordv[i]
+#defineGLOB_LIST_DONE(list)wordfree(list)
+#defineGLOB_LIST(path,list)list##error = \
+   wordexp(path,list,GLOB_FLAGS)
+#else
 #define GLOB_FLAGS (GLOB_NOCHECK|GLOB_BRACE|GLOB_TILDE)
 #defineDECL_GLOB_LIST(list)glob_t list;  int i;
 #defineGLOB_LIST(filename,list)
glob(filename,GLOB_FLAGS,0,list)
@@ -31,3 +42,4 @@
 #defineSCAN_GLOB_LIST(list,p)  i = 0;  i  list.gl_pathc;  i++
 #defineINIT_GLOB_LIST(list,p)  p = list.gl_pathv[i]
 #defineGLOB_LIST_DONE(list)globfree(list)
+#endif



Re: which ISO for a VM?

2010-04-06 Thread matteo filippetto
2010/4/5 Richard Stride f...@nexxus.net:
 Sean Kennedy wrote:

 I concur, B it was a Valid question on running OpenBSD in a VM.

 Unless someone has answered directly, I'll short-run it here.



 Just to add my 2 cents, I run OpenBSD-current (i386) under VirtualBox 3.0.4
 r50677 64-bit. The host operating system is Slackware 13 64 bit.
 I got to -current by installing OpenBSD 4.3 from the ISO image, and
followed
 the upgrade guide from the OpenBSD website.
 Be warned, all I use that VM for is to compile the OpenBSD sources, it does
 nothing else.

 I have tried running OpenBSD under other versions of VirtualBox using
 different host operating systems, however there were always issues which
 would generally lead to various issues including kernel panics.

 My advice is to not run it virtualized.

 Rich



I run 3 openbsd 4.6 virtualized with VBox (3.1.6 ) on a MacBook
and I have no problem running services as DHCP, HTTP, DNS
and others.

Best regards

--
Matteo Filippetto



usb_quirks tidying

2010-04-06 Thread Stuart Henderson
this brings the UQ_BAD_HID entries together, lines up the
columns a bit better, and adds a short description for some
of the quirks.

any comments? ok?


Index: usb_quirks.c
===
RCS file: /cvs/src/sys/dev/usb/usb_quirks.c,v
retrieving revision 1.53
diff -u -p -r1.53 usb_quirks.c
--- usb_quirks.c17 Oct 2009 07:10:38 -  1.53
+++ usb_quirks.c6 Apr 2010 09:46:28 -
@@ -79,7 +79,7 @@ const struct usbd_quirk_entry {
0x001, { UQ_ASSUME_CM_OVER_DATA }},
  { USB_VENDOR_EICON, USB_PRODUCT_EICON_DIVA852,
0x100, { UQ_ASSUME_CM_OVER_DATA }},
- /* YAMAHA router's ucdDevice is the version of farmware and often changes. */
+ /* YAMAHA router's ucdDevice is the version of firmware and often changes. */
  { USB_VENDOR_YAMAHA, USB_PRODUCT_YAMAHA_RTA54I,
ANY, { UQ_ASSUME_CM_OVER_DATA }},
  { USB_VENDOR_YAMAHA, USB_PRODUCT_YAMAHA_RTA55I,
@@ -106,9 +106,9 @@ const struct usbd_quirk_entry {
  { USB_VENDOR_TI, USB_PRODUCT_TI_UTUSB41,  0x110, { UQ_POWER_CLAIM }},
  { USB_VENDOR_TELEX, USB_PRODUCT_TELEX_MIC1,   0x009, { UQ_AU_NO_FRAC }},
 
- { USB_VENDOR_TERRATEC, USB_PRODUCT_TERRATEC_AUREON,
-   ANY, { UQ_BAD_HID }},
-
+ /*
+  * UQ_BROKEN_BIDIR: ulpt(4) devices which don't handle reading.
+  */
  /* XXX These should have a revision number, but I don't know what they are. */
  { USB_VENDOR_HP, USB_PRODUCT_HP_895C, ANY,   { UQ_BROKEN_BIDIR }},
  { USB_VENDOR_HP, USB_PRODUCT_HP_880C, ANY,   { UQ_BROKEN_BIDIR }},
@@ -120,39 +120,47 @@ const struct usbd_quirk_entry {
  { USB_VENDOR_HP, USB_PRODUCT_HP_816C, ANY,   { UQ_BROKEN_BIDIR }},
  { USB_VENDOR_HP, USB_PRODUCT_HP_959C, ANY,   { UQ_BROKEN_BIDIR }},
  { USB_VENDOR_HP, USB_PRODUCT_HP_1220C,ANY,   { 
UQ_BROKEN_BIDIR }},
- { USB_VENDOR_ITUNER, USB_PRODUCT_ITUNER_USBLCD20x2,   ANY,   { UQ_BAD_HID 
}},
  { USB_VENDOR_NEC, USB_PRODUCT_NEC_PICTY900,   ANY,   { UQ_BROKEN_BIDIR }},
  { USB_VENDOR_NEC, USB_PRODUCT_NEC_PICTY760,   ANY,   { UQ_BROKEN_BIDIR }},
  { USB_VENDOR_NEC, USB_PRODUCT_NEC_PICTY920,   ANY,   { UQ_BROKEN_BIDIR }},
  { USB_VENDOR_NEC, USB_PRODUCT_NEC_PICTY800,   ANY,   { UQ_BROKEN_BIDIR }},
- { USB_VENDOR_MECANIQUE, USB_PRODUCT_MECANIQUE_WISPY, ANY,   { UQ_BAD_HID }},
- { USB_VENDOR_OMRON, USB_PRODUCT_OMRON_BX35F,   ANY,   { UQ_BAD_HID }},
- { USB_VENDOR_OMRON, USB_PRODUCT_OMRON_BX50F,   ANY,   { UQ_BAD_HID }},
- { USB_VENDOR_TENX, USB_PRODUCT_TENX_MISSILE,  ANY,   { UQ_BAD_HID }},
- { USB_VENDOR_APC, USB_PRODUCT_APC_UPSPRO500,  ANY,   { UQ_BAD_HID }},
- { USB_VENDOR_BELKIN, USB_PRODUCT_BELKIN_F6C550AVR, ANY,   { UQ_BAD_HID }},
- { USB_VENDOR_BELKIN, USB_PRODUCT_BELKIN_F6C1500EITWRK,ANY,{ 
UQ_BAD_HID }},
- { USB_VENDOR_MGE, USB_PRODUCT_MGE_UPS1,   ANY,   { UQ_BAD_HID }},
- { USB_VENDOR_MGE, USB_PRODUCT_MGE_UPS2,   ANY,   { UQ_BAD_HID }},
- { USB_VENDOR_CYBERPOWER, USB_PRODUCT_CYBERPOWER_1500, ANY,{ UQ_BAD_HID }},
- { USB_VENDOR_MUSTEK2, USB_PRODUCT_MUSTEK2_PM800,  ANY,{ UQ_BAD_HID }},
+
+ /*
+  * UQ_BAD_HID: HID-class devices which must attach to ugen(4)
+  * to interact with software to control them.
+  */
+ { USB_VENDOR_APC, USB_PRODUCT_APC_UPSPRO500,  ANY,   { UQ_BAD_HID }},
+ { USB_VENDOR_BELKIN, USB_PRODUCT_BELKIN_F6C550AVR, ANY,   { UQ_BAD_HID }},
+ { USB_VENDOR_BELKIN, USB_PRODUCT_BELKIN_F6C1500EITWRK, ANY,   { UQ_BAD_HID }},
+ { USB_VENDOR_CYBERPOWER, USB_PRODUCT_CYBERPOWER_1500, ANY,   { UQ_BAD_HID }},
+ { USB_VENDOR_CYPRESS, USB_PRODUCT_CYPRESS_SISPM_OLD,  ANY,   { UQ_BAD_HID }},
+ { USB_VENDOR_CYPRESS, USB_PRODUCT_CYPRESS_SISPM,  ANY,   { UQ_BAD_HID }},
+ { USB_VENDOR_CYPRESS, USB_PRODUCT_CYPRESS_SISPM_FLASH,ANY,   { 
UQ_BAD_HID }},
+ { USB_VENDOR_ITUNER, USB_PRODUCT_ITUNER_USBLCD20x2,   ANY,   { UQ_BAD_HID }},
  { USB_VENDOR_LIEBERT, USB_PRODUCT_LIEBERT_POWERSURE_PXT, ANY, { UQ_BAD_HID }},
+ { USB_VENDOR_MECANIQUE, USB_PRODUCT_MECANIQUE_WISPY,   ANY,   { UQ_BAD_HID }},
+ { USB_VENDOR_MGE, USB_PRODUCT_MGE_UPS1,   ANY,   { UQ_BAD_HID }},
+ { USB_VENDOR_MGE, USB_PRODUCT_MGE_UPS2,   ANY,   { UQ_BAD_HID }},
+ { USB_VENDOR_MUSTEK2, USB_PRODUCT_MUSTEK2_PM800,  ANY,   { UQ_BAD_HID }},
+ { USB_VENDOR_OMRON, USB_PRODUCT_OMRON_BX35F,   ANY,   { UQ_BAD_HID }},
+ { USB_VENDOR_OMRON, USB_PRODUCT_OMRON_BX50F,   ANY,   { UQ_BAD_HID }},
+ { USB_VENDOR_TENX, USB_PRODUCT_TENX_MISSILE,  ANY,   { UQ_BAD_HID }},
+ { USB_VENDOR_TERRATEC, USB_PRODUCT_TERRATEC_AUREON,ANY,   { UQ_BAD_HID }},
+
+ /*
+  * UQ_NO_STRINGS: suppress printing strings from the device in
+  * attach lines; use for devices with bad strings to avoid broken
+  * dmesg output.
+  */
+ { USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_E220, ANY,{ UQ_NO_STRINGS }},
 
-  /* MS keyboards do weird things */
-  { USB_VENDOR_MICROSOFT, 

Re: usb_quirks tidying

2010-04-06 Thread Stuart Henderson
On 2010/04/06 10:47, Stuart Henderson wrote:
 this brings the UQ_BAD_HID entries together, lines up the
 columns a bit better, and adds a short description for some
 of the quirks.
 
 any comments? ok?

better with some spaces-tabs (prompted by mail from halex).

Index: usb_quirks.c
===
RCS file: /cvs/src/sys/dev/usb/usb_quirks.c,v
retrieving revision 1.53
diff -u -p -r1.53 usb_quirks.c
--- usb_quirks.c17 Oct 2009 07:10:38 -  1.53
+++ usb_quirks.c6 Apr 2010 10:20:24 -
@@ -79,7 +79,7 @@ const struct usbd_quirk_entry {
0x001, { UQ_ASSUME_CM_OVER_DATA }},
  { USB_VENDOR_EICON, USB_PRODUCT_EICON_DIVA852,
0x100, { UQ_ASSUME_CM_OVER_DATA }},
- /* YAMAHA router's ucdDevice is the version of farmware and often changes. */
+ /* YAMAHA router's ucdDevice is the version of firmware and often changes. */
  { USB_VENDOR_YAMAHA, USB_PRODUCT_YAMAHA_RTA54I,
ANY, { UQ_ASSUME_CM_OVER_DATA }},
  { USB_VENDOR_YAMAHA, USB_PRODUCT_YAMAHA_RTA55I,
@@ -106,9 +106,9 @@ const struct usbd_quirk_entry {
  { USB_VENDOR_TI, USB_PRODUCT_TI_UTUSB41,  0x110, { UQ_POWER_CLAIM }},
  { USB_VENDOR_TELEX, USB_PRODUCT_TELEX_MIC1,   0x009, { UQ_AU_NO_FRAC }},
 
- { USB_VENDOR_TERRATEC, USB_PRODUCT_TERRATEC_AUREON,
-   ANY, { UQ_BAD_HID }},
-
+ /*
+  * UQ_BROKEN_BIDIR: ulpt(4) devices which don't handle reading.
+  */
  /* XXX These should have a revision number, but I don't know what they are. */
  { USB_VENDOR_HP, USB_PRODUCT_HP_895C, ANY,   { UQ_BROKEN_BIDIR }},
  { USB_VENDOR_HP, USB_PRODUCT_HP_880C, ANY,   { UQ_BROKEN_BIDIR }},
@@ -120,39 +120,47 @@ const struct usbd_quirk_entry {
  { USB_VENDOR_HP, USB_PRODUCT_HP_816C, ANY,   { UQ_BROKEN_BIDIR }},
  { USB_VENDOR_HP, USB_PRODUCT_HP_959C, ANY,   { UQ_BROKEN_BIDIR }},
  { USB_VENDOR_HP, USB_PRODUCT_HP_1220C,ANY,   { 
UQ_BROKEN_BIDIR }},
- { USB_VENDOR_ITUNER, USB_PRODUCT_ITUNER_USBLCD20x2,   ANY,   { UQ_BAD_HID 
}},
  { USB_VENDOR_NEC, USB_PRODUCT_NEC_PICTY900,   ANY,   { UQ_BROKEN_BIDIR }},
  { USB_VENDOR_NEC, USB_PRODUCT_NEC_PICTY760,   ANY,   { UQ_BROKEN_BIDIR }},
  { USB_VENDOR_NEC, USB_PRODUCT_NEC_PICTY920,   ANY,   { UQ_BROKEN_BIDIR }},
  { USB_VENDOR_NEC, USB_PRODUCT_NEC_PICTY800,   ANY,   { UQ_BROKEN_BIDIR }},
- { USB_VENDOR_MECANIQUE, USB_PRODUCT_MECANIQUE_WISPY, ANY,   { UQ_BAD_HID }},
- { USB_VENDOR_OMRON, USB_PRODUCT_OMRON_BX35F,   ANY,   { UQ_BAD_HID }},
- { USB_VENDOR_OMRON, USB_PRODUCT_OMRON_BX50F,   ANY,   { UQ_BAD_HID }},
- { USB_VENDOR_TENX, USB_PRODUCT_TENX_MISSILE,  ANY,   { UQ_BAD_HID }},
- { USB_VENDOR_APC, USB_PRODUCT_APC_UPSPRO500,  ANY,   { UQ_BAD_HID }},
- { USB_VENDOR_BELKIN, USB_PRODUCT_BELKIN_F6C550AVR, ANY,   { UQ_BAD_HID }},
- { USB_VENDOR_BELKIN, USB_PRODUCT_BELKIN_F6C1500EITWRK,ANY,{ 
UQ_BAD_HID }},
- { USB_VENDOR_MGE, USB_PRODUCT_MGE_UPS1,   ANY,   { UQ_BAD_HID }},
- { USB_VENDOR_MGE, USB_PRODUCT_MGE_UPS2,   ANY,   { UQ_BAD_HID }},
+
+ /*
+  * UQ_BAD_HID: HID-class devices which must attach to ugen(4)
+  * to interact with software to control them.
+  */
+ { USB_VENDOR_APC, USB_PRODUCT_APC_UPSPRO500,  ANY,{ UQ_BAD_HID }},
+ { USB_VENDOR_BELKIN, USB_PRODUCT_BELKIN_F6C550AVR,ANY,{ UQ_BAD_HID }},
+ { USB_VENDOR_BELKIN, USB_PRODUCT_BELKIN_F6C1500EITWRK,ANY,{ 
UQ_BAD_HID }},
  { USB_VENDOR_CYBERPOWER, USB_PRODUCT_CYBERPOWER_1500, ANY,{ UQ_BAD_HID }},
+ { USB_VENDOR_CYPRESS, USB_PRODUCT_CYPRESS_SISPM_OLD,  ANY,{ UQ_BAD_HID }},
+ { USB_VENDOR_CYPRESS, USB_PRODUCT_CYPRESS_SISPM,  ANY,{ UQ_BAD_HID }},
+ { USB_VENDOR_CYPRESS, USB_PRODUCT_CYPRESS_SISPM_FLASH,ANY,{ 
UQ_BAD_HID }},
+ { USB_VENDOR_ITUNER, USB_PRODUCT_ITUNER_USBLCD20x2,   ANY,{ UQ_BAD_HID }},
+ { USB_VENDOR_LIEBERT, USB_PRODUCT_LIEBERT_POWERSURE_PXT, ANY, { UQ_BAD_HID }},
+ { USB_VENDOR_MECANIQUE, USB_PRODUCT_MECANIQUE_WISPY,  ANY,{ UQ_BAD_HID }},
+ { USB_VENDOR_MGE, USB_PRODUCT_MGE_UPS1,   ANY,{ UQ_BAD_HID }},
+ { USB_VENDOR_MGE, USB_PRODUCT_MGE_UPS2,   ANY,{ UQ_BAD_HID }},
  { USB_VENDOR_MUSTEK2, USB_PRODUCT_MUSTEK2_PM800,  ANY,{ UQ_BAD_HID }},
- { USB_VENDOR_LIEBERT, USB_PRODUCT_LIEBERT_POWERSURE_PXT, ANY, { UQ_BAD_HID }},
+ { USB_VENDOR_OMRON, USB_PRODUCT_OMRON_BX35F,  ANY,{ UQ_BAD_HID }},
+ { USB_VENDOR_OMRON, USB_PRODUCT_OMRON_BX50F,  ANY,{ UQ_BAD_HID }},
+ { USB_VENDOR_TENX, USB_PRODUCT_TENX_MISSILE,  ANY,{ UQ_BAD_HID }},
+ { USB_VENDOR_TERRATEC, USB_PRODUCT_TERRATEC_AUREON,   ANY,{ UQ_BAD_HID }},
+
+ /*
+  * UQ_NO_STRINGS: suppress printing strings from the device in
+  * attach lines; use for devices with bad strings to avoid broken
+  * dmesg output.
+  */
+ { USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_E220, ANY,{ UQ_NO_STRINGS }},
 
-  /* MS keyboards do 

Re: which ISO for a VM?

2010-04-06 Thread Gleydson Soares
On Mon, Apr 5, 2010 at 11:38 AM, Sean Kennedy woodentu...@hotmail.com
wrote:
 I concur,  it was a Valid question on running OpenBSD in a VM.

really, i was very radical in the last email. really. shut it up and
hack. maybe starting helping the virtualbox guys to close the related
bug at  http://www.virtualbox.org/ticket/639. i think, it hasn't been
fixed.



[patch] openssl: pr/6282

2010-04-06 Thread Matthew Haub
Hello,

The openssl command line tool treats the non-null terminated buffer
mbuf as a C string when using the pop3 s_client feature. This causes
a segmentation fault with malloc.conf option J set when BIO_printf()
runs off the end of the buffer. The following patch fixes PR 6282.

Matthew

Index: s_client.c
===
RCS file: /cvs/src/lib/libssl/src/apps/s_client.c,v
retrieving revision 1.19
diff -u s_client.c
--- s_client.c  30 Jan 2009 03:56:05 -  1.19
+++ s_client.c  6 Apr 2010 13:26:17 -
@@ -1074,7 +1074,7 @@
 
if (starttls_proto)
{
-   BIO_printf(bio_err,%s,mbuf);
+   BIO_write(bio_err, mbuf, mbuf_len);
/* We don't need to know any more */
starttls_proto = PROTO_OFF;
}



Re: [patch] libc: wordexp support

2010-04-06 Thread Ted Unangst
On Tue, Apr 6, 2010 at 1:53 AM, Matthew Haub
matthew.h...@alumni.adelaide.edu.au wrote:
 This patch adds support for wordexp(3) and wordfree(3) to libc. These
 functions conform to IEEE Std 1003.1-2001 (POSIX). The implementation
 comes from NetBSD and uses a shell builtin, wordexp, to perform the
 expansion in line with the methods suggested in the specification[1].

 [1] http://www.opengroup.org/onlinepubs/9699919799/functions/wordexp.html

Therefore, the application shall ensure that words does not contain
an unquoted newline character or any of the unquoted shell special
characters '|' , '' , ';' , '' , '' except in the context of
command substitution as specified in XCU Command Substitution . It
also shall not contain unquoted parentheses or braces, except in the
context of command or variable substitution. The application shall
ensure that every member of words which it expects to have expanded by
wordexp() does not contain an unquoted initial comment character. The
application shall also ensure that any words which it intends to be
ignored (because they begin or continue a comment) are deleted from
words.

What a load of crap.

 +.Sh BUGS
 +Do not pass untrusted user data to
 +.Fn wordexp ,
 +regardless of whether the
 +.Dv WRDE_NOCMD
 +flag is set.
 +The
 +.Fn wordexp
 +function attempts to detect input that would cause commands to be
 +executed before passing it to the shell
 +but it does not use the same parser so it may be fooled.

I'm sorry, but this is terrible.  (Not your effort, which is
appreciated, but the whole function.)  I do not like the idea of
adding a be extra careful or you will introduce a backdoor function
to libc.

Also, a libc function that doesn't work in chroot?  What use is that?



Re: [patch] libc: wordexp support

2010-04-06 Thread Theo de Raadt
I think we should stand up to crap and not ever impliment it.

 On Tue, Apr 6, 2010 at 1:53 AM, Matthew Haub
 matthew.h...@alumni.adelaide.edu.au wrote:
  This patch adds support for wordexp(3) and wordfree(3) to libc. These
  functions conform to IEEE Std 1003.1-2001 (POSIX). The implementation
  comes from NetBSD and uses a shell builtin, wordexp, to perform the
  expansion in line with the methods suggested in the specification[1].
 
  [1] http://www.opengroup.org/onlinepubs/9699919799/functions/wordexp.html
 
 Therefore, the application shall ensure that words does not contain
 an unquoted newline character or any of the unquoted shell special
 characters '|' , '' , ';' , '' , '' except in the context of
 command substitution as specified in XCU Command Substitution . It
 also shall not contain unquoted parentheses or braces, except in the
 context of command or variable substitution. The application shall
 ensure that every member of words which it expects to have expanded by
 wordexp() does not contain an unquoted initial comment character. The
 application shall also ensure that any words which it intends to be
 ignored (because they begin or continue a comment) are deleted from
 words.
 
 What a load of crap.
 
  +.Sh BUGS
  +Do not pass untrusted user data to
  +.Fn wordexp ,
  +regardless of whether the
  +.Dv WRDE_NOCMD
  +flag is set.
  +The
  +.Fn wordexp
  +function attempts to detect input that would cause commands to be
  +executed before passing it to the shell
  +but it does not use the same parser so it may be fooled.
 
 I'm sorry, but this is terrible.  (Not your effort, which is
 appreciated, but the whole function.)  I do not like the idea of
 adding a be extra careful or you will introduce a backdoor function
 to libc.
 
 Also, a libc function that doesn't work in chroot?  What use is that?



Re: [patch] less: filename globbing/expansion

2010-04-06 Thread Nicholas Marriott
Hi

You'll have to implement wordexp(3) in libc too before this does us any
good.


On Tue, Apr 06, 2010 at 03:49:58PM +0930, Matthew Haub wrote:
 Hello,
 
 On Fri, Apr 02, 2010 at 07:08:43PM -0700, Philip Guenther wrote:
  are we still tracking the upstream less(1) and if so, is the
  behavioral change acceptable there?
 
 On Sat, Apr 03, 2010 at 03:37:46PM +1030, Matthew Haub wrote:
  We no longer track upstream less(1). The last sync was 7 years ago.
 
 On Sat, Apr 03, 2010 at 07:34:40AM +0100, Nicholas Marriott wrote:
  Yes, but is that for a reason or just because nobody has updated it?
 
 Todd Miller would be the person to ask. Either way I've emailed the less
 maintainer to see whether he would be interested in using wordexp over
 lessecho on systems that support it.
 
 On Fri, Apr 02, 2010 at 07:08:43PM -0700, Philip Guenther wrote:
  if you want this, you should just implement wordexp(3) in libc and
  then use that.
 
 Done. This patch uses wordexp as a drop in replacement for glob when
 available.
 
 Matthew
 
 Index: configure
 ===
 RCS file: /cvs/src/usr.bin/less/configure,v
 retrieving revision 1.3
 diff -u configure
 --- configure 13 Apr 2003 18:26:25 -  1.3
 +++ configure 6 Apr 2010 04:26:47 -
 @@ -4456,7 +4456,7 @@
  
  
  
 -for ac_func in fsync memcpy popen _setjmp sigprocmask sigsetmask stat strchr 
 strstr system
 +for ac_func in fsync memcpy popen _setjmp sigprocmask sigsetmask stat strchr 
 strstr system wordexp
  do
  as_ac_var=`echo ac_cv_func_$ac_func | $as_tr_sh`
  echo $as_me:$LINENO: checking for $ac_func 5
 Index: configure.ac
 ===
 RCS file: /cvs/src/usr.bin/less/configure.ac,v
 retrieving revision 1.1.1.1
 diff -u configure.ac
 --- configure.ac  13 Apr 2003 18:21:21 -  1.1.1.1
 +++ configure.ac  6 Apr 2010 04:26:48 -
 @@ -211,7 +211,7 @@
  
  # Checks for library functions.
  AC_TYPE_SIGNAL
 -AC_CHECK_FUNCS([fsync memcpy popen _setjmp sigprocmask sigsetmask stat 
 strchr strstr system])
 +AC_CHECK_FUNCS([fsync memcpy popen _setjmp sigprocmask sigsetmask stat 
 strchr strstr system wordexp])
  
  # Some systems have termios.h but not the corresponding functions.
  AC_CHECK_FUNC(tcgetattr, AC_DEFINE(HAVE_TERMIOS_FUNCS))
 Index: defines.h.in
 ===
 RCS file: /cvs/src/usr.bin/less/defines.h.in,v
 retrieving revision 1.2
 diff -u defines.h.in
 --- defines.h.in  14 Apr 2003 14:33:57 -  1.2
 +++ defines.h.in  6 Apr 2010 04:26:48 -
 @@ -346,6 +346,9 @@
  /* Define HAVE_VOID if your compiler supports the void type. */
  #undef HAVE_VOID
  
 +/* Define to 1 if you have the `wordexp' function. */
 +#undef HAVE_WORDEXP
 +
  /* Define to 1 if you have the `_setjmp' function. */
  #undef HAVE__SETJMP
  
 Index: filename.c
 ===
 RCS file: /cvs/src/usr.bin/less/filename.c,v
 retrieving revision 1.13
 diff -u filename.c
 --- filename.c6 Dec 2006 05:03:29 -   1.13
 +++ filename.c6 Apr 2010 04:26:48 -
 @@ -37,6 +37,9 @@
  #include signal.h
  #endif
  
 +#if HAVE_WORDEXP
 +#include wordexp.h
 +#endif
  #if HAVE_STAT
  #include sys/stat.h
  #ifndef S_ISDIR
 Index: lglob.h
 ===
 RCS file: /cvs/src/usr.bin/less/lglob.h,v
 retrieving revision 1.3
 diff -u lglob.h
 --- lglob.h   22 Apr 2003 22:57:13 -  1.3
 +++ lglob.h   6 Apr 2010 04:26:48 -
 @@ -23,7 +23,18 @@
   */
  
  #include glob.h
 +#include defines.h
  
 +#if HAVE_WORDEXP
 +#define  GLOB_FLAGS  (WRDE_NOCMD)
 +#define  DECL_GLOB_LIST(list)wordexp_t list; int i; int 
 list##error;
 +#define  GLOB_LIST_FAILED(list)  list##error != 0
 +#define  SCAN_GLOB_LIST(list,p)  i = 0; i  list.we_wordc; i++
 +#define  INIT_GLOB_LIST(list,p)  p = list.we_wordv[i]
 +#define  GLOB_LIST_DONE(list)wordfree(list)
 +#define  GLOB_LIST(path,list)list##error = \
 + wordexp(path,list,GLOB_FLAGS)
 +#else
  #define GLOB_FLAGS   (GLOB_NOCHECK|GLOB_BRACE|GLOB_TILDE)
  #define  DECL_GLOB_LIST(list)glob_t list;  int i;
  #define  GLOB_LIST(filename,list)
 glob(filename,GLOB_FLAGS,0,list)
 @@ -31,3 +42,4 @@
  #define  SCAN_GLOB_LIST(list,p)  i = 0;  i  list.gl_pathc;  i++
  #define  INIT_GLOB_LIST(list,p)  p = list.gl_pathv[i]
  #define  GLOB_LIST_DONE(list)globfree(list)
 +#endif



Re: [patch] less: filename globbing/expansion

2010-04-06 Thread Nicholas Marriott
Whoops, reading too slow.


On Tue, Apr 06, 2010 at 05:41:59PM +0100, Nicholas Marriott wrote:
 Hi
 
 You'll have to implement wordexp(3) in libc too before this does us any
 good.
 
 
 On Tue, Apr 06, 2010 at 03:49:58PM +0930, Matthew Haub wrote:
  Hello,
  
  On Fri, Apr 02, 2010 at 07:08:43PM -0700, Philip Guenther wrote:
   are we still tracking the upstream less(1) and if so, is the
   behavioral change acceptable there?
  
  On Sat, Apr 03, 2010 at 03:37:46PM +1030, Matthew Haub wrote:
   We no longer track upstream less(1). The last sync was 7 years ago.
  
  On Sat, Apr 03, 2010 at 07:34:40AM +0100, Nicholas Marriott wrote:
   Yes, but is that for a reason or just because nobody has updated it?
  
  Todd Miller would be the person to ask. Either way I've emailed the less
  maintainer to see whether he would be interested in using wordexp over
  lessecho on systems that support it.
  
  On Fri, Apr 02, 2010 at 07:08:43PM -0700, Philip Guenther wrote:
   if you want this, you should just implement wordexp(3) in libc and
   then use that.
  
  Done. This patch uses wordexp as a drop in replacement for glob when
  available.
  
  Matthew
  
  Index: configure
  ===
  RCS file: /cvs/src/usr.bin/less/configure,v
  retrieving revision 1.3
  diff -u configure
  --- configure   13 Apr 2003 18:26:25 -  1.3
  +++ configure   6 Apr 2010 04:26:47 -
  @@ -4456,7 +4456,7 @@
   
   
   
  -for ac_func in fsync memcpy popen _setjmp sigprocmask sigsetmask stat 
  strchr strstr system
  +for ac_func in fsync memcpy popen _setjmp sigprocmask sigsetmask stat 
  strchr strstr system wordexp
   do
   as_ac_var=`echo ac_cv_func_$ac_func | $as_tr_sh`
   echo $as_me:$LINENO: checking for $ac_func 5
  Index: configure.ac
  ===
  RCS file: /cvs/src/usr.bin/less/configure.ac,v
  retrieving revision 1.1.1.1
  diff -u configure.ac
  --- configure.ac13 Apr 2003 18:21:21 -  1.1.1.1
  +++ configure.ac6 Apr 2010 04:26:48 -
  @@ -211,7 +211,7 @@
   
   # Checks for library functions.
   AC_TYPE_SIGNAL
  -AC_CHECK_FUNCS([fsync memcpy popen _setjmp sigprocmask sigsetmask stat 
  strchr strstr system])
  +AC_CHECK_FUNCS([fsync memcpy popen _setjmp sigprocmask sigsetmask stat 
  strchr strstr system wordexp])
   
   # Some systems have termios.h but not the corresponding functions.
   AC_CHECK_FUNC(tcgetattr, AC_DEFINE(HAVE_TERMIOS_FUNCS))
  Index: defines.h.in
  ===
  RCS file: /cvs/src/usr.bin/less/defines.h.in,v
  retrieving revision 1.2
  diff -u defines.h.in
  --- defines.h.in14 Apr 2003 14:33:57 -  1.2
  +++ defines.h.in6 Apr 2010 04:26:48 -
  @@ -346,6 +346,9 @@
   /* Define HAVE_VOID if your compiler supports the void type. */
   #undef HAVE_VOID
   
  +/* Define to 1 if you have the `wordexp' function. */
  +#undef HAVE_WORDEXP
  +
   /* Define to 1 if you have the `_setjmp' function. */
   #undef HAVE__SETJMP
   
  Index: filename.c
  ===
  RCS file: /cvs/src/usr.bin/less/filename.c,v
  retrieving revision 1.13
  diff -u filename.c
  --- filename.c  6 Dec 2006 05:03:29 -   1.13
  +++ filename.c  6 Apr 2010 04:26:48 -
  @@ -37,6 +37,9 @@
   #include signal.h
   #endif
   
  +#if HAVE_WORDEXP
  +#include wordexp.h
  +#endif
   #if HAVE_STAT
   #include sys/stat.h
   #ifndef S_ISDIR
  Index: lglob.h
  ===
  RCS file: /cvs/src/usr.bin/less/lglob.h,v
  retrieving revision 1.3
  diff -u lglob.h
  --- lglob.h 22 Apr 2003 22:57:13 -  1.3
  +++ lglob.h 6 Apr 2010 04:26:48 -
  @@ -23,7 +23,18 @@
*/
   
   #include glob.h
  +#include defines.h
   
  +#if HAVE_WORDEXP
  +#defineGLOB_FLAGS  (WRDE_NOCMD)
  +#defineDECL_GLOB_LIST(list)wordexp_t list; int i; int 
  list##error;
  +#defineGLOB_LIST_FAILED(list)  list##error != 0
  +#defineSCAN_GLOB_LIST(list,p)  i = 0; i  list.we_wordc; i++
  +#defineINIT_GLOB_LIST(list,p)  p = list.we_wordv[i]
  +#defineGLOB_LIST_DONE(list)wordfree(list)
  +#defineGLOB_LIST(path,list)list##error = \
  +   wordexp(path,list,GLOB_FLAGS)
  +#else
   #define GLOB_FLAGS (GLOB_NOCHECK|GLOB_BRACE|GLOB_TILDE)
   #defineDECL_GLOB_LIST(list)glob_t list;  int i;
   #defineGLOB_LIST(filename,list)
  glob(filename,GLOB_FLAGS,0,list)
  @@ -31,3 +42,4 @@
   #defineSCAN_GLOB_LIST(list,p)  i = 0;  i  list.gl_pathc;  i++
   #defineINIT_GLOB_LIST(list,p)  p = list.gl_pathv[i]
   #defineGLOB_LIST_DONE(list)globfree(list)
  +#endif



Re: [patch] libc: wordexp support

2010-04-06 Thread Theo de Raadt
 On Tue, Apr 6, 2010 at 1:53 AM, Matthew Haub
 matthew.h...@alumni.adelaide.edu.au wrote:
  This patch adds support for wordexp(3) and wordfree(3) to libc. These
  functions conform to IEEE Std 1003.1-2001 (POSIX). The implementation
  comes from NetBSD and uses a shell builtin, wordexp, to perform the
  expansion in line with the methods suggested in the specification[1].
 
  [1] http://www.opengroup.org/onlinepubs/9699919799/functions/wordexp.html
 
 Therefore, the application shall ensure that words does not contain
 an unquoted newline character or any of the unquoted shell special
 characters '|' , '' , ';' , '' , '' except in the context of
 command substitution as specified in XCU Command Substitution . It
 also shall not contain unquoted parentheses or braces, except in the
 context of command or variable substitution. The application shall
 ensure that every member of words which it expects to have expanded by
 wordexp() does not contain an unquoted initial comment character. The
 application shall also ensure that any words which it intends to be
 ignored (because they begin or continue a comment) are deleted from
 words.
 
 What a load of crap.

I've done a bit of digging myself, during a long discussion we had about
this.

I find very little open source software using this API.  Of those that
I find which are using it, many are using it wrong.  Some are exposing
themselves to risk.

Almost 10 years ago we found security holes in glob(), and they were
pretty important because of what used the code.  Yet, glob() is a lot
simpler than what this is trying to do.  wordexp() is diseased.

  +.Sh BUGS
  +Do not pass untrusted user data to
  +.Fn wordexp ,
  +regardless of whether the
  +.Dv WRDE_NOCMD
  +flag is set.
  +The
  +.Fn wordexp
  +function attempts to detect input that would cause commands to be
  +executed before passing it to the shell
  +but it does not use the same parser so it may be fooled.
 
 I'm sorry, but this is terrible.  (Not your effort, which is
 appreciated, but the whole function.)  I do not like the idea of
 adding a be extra careful or you will introduce a backdoor function
 to libc.

No kidding.  I agree with Ted; thanks for the effort but the code you
borrowed is bad, and it is was designed by people who the unabomber
should have gotten to first.

 Also, a libc function that doesn't work in chroot?  What use is that?

I found a piece of code out there that as wrapping the calls to wordexp()
like this:

sigemptyset(nset);
sigaddset(nset, SIGCHLD);
sigprocmask(SIG_BLOCK, nset, NULL);
i = wordexp(name, we, 0);
sigprocmask(SIG_UNBLOCK, nset, NULL);

Any function which requires that does not belong in libc.

If I continue to have say in this, wordexp() will never be in
OpenBSD's libc.  Perhaps if there is one open source project which
refuses to have it, coders will continue avoiding use of wordexp().



Re: usb_quirks tidying

2010-04-06 Thread Stuart Henderson
hopefully this is the last round;

- don't duplicate documentation from .h in .c
- move .h documentation to the same line as the #define for easier grepping
- reword .h doc slightly, mostly to fit on 1 line where possible, change
text for UQ_EHCI_NEEDTO_DISOWN to something that seems easier-reading to me

Index: usb_quirks.c
===
RCS file: /cvs/src/sys/dev/usb/usb_quirks.c,v
retrieving revision 1.53
diff -u -p -r1.53 usb_quirks.c
--- usb_quirks.c17 Oct 2009 07:10:38 -  1.53
+++ usb_quirks.c6 Apr 2010 23:04:00 -
@@ -79,7 +79,7 @@ const struct usbd_quirk_entry {
0x001, { UQ_ASSUME_CM_OVER_DATA }},
  { USB_VENDOR_EICON, USB_PRODUCT_EICON_DIVA852,
0x100, { UQ_ASSUME_CM_OVER_DATA }},
- /* YAMAHA router's ucdDevice is the version of farmware and often changes. */
+ /* YAMAHA router's ucdDevice is the version of firmware and often changes. */
  { USB_VENDOR_YAMAHA, USB_PRODUCT_YAMAHA_RTA54I,
ANY, { UQ_ASSUME_CM_OVER_DATA }},
  { USB_VENDOR_YAMAHA, USB_PRODUCT_YAMAHA_RTA55I,
@@ -106,9 +106,6 @@ const struct usbd_quirk_entry {
  { USB_VENDOR_TI, USB_PRODUCT_TI_UTUSB41,  0x110, { UQ_POWER_CLAIM }},
  { USB_VENDOR_TELEX, USB_PRODUCT_TELEX_MIC1,   0x009, { UQ_AU_NO_FRAC }},
 
- { USB_VENDOR_TERRATEC, USB_PRODUCT_TERRATEC_AUREON,
-   ANY, { UQ_BAD_HID }},
-
  /* XXX These should have a revision number, but I don't know what they are. */
  { USB_VENDOR_HP, USB_PRODUCT_HP_895C, ANY,   { UQ_BROKEN_BIDIR }},
  { USB_VENDOR_HP, USB_PRODUCT_HP_880C, ANY,   { UQ_BROKEN_BIDIR }},
@@ -120,39 +117,38 @@ const struct usbd_quirk_entry {
  { USB_VENDOR_HP, USB_PRODUCT_HP_816C, ANY,   { UQ_BROKEN_BIDIR }},
  { USB_VENDOR_HP, USB_PRODUCT_HP_959C, ANY,   { UQ_BROKEN_BIDIR }},
  { USB_VENDOR_HP, USB_PRODUCT_HP_1220C,ANY,   { 
UQ_BROKEN_BIDIR }},
- { USB_VENDOR_ITUNER, USB_PRODUCT_ITUNER_USBLCD20x2,   ANY,   { UQ_BAD_HID 
}},
  { USB_VENDOR_NEC, USB_PRODUCT_NEC_PICTY900,   ANY,   { UQ_BROKEN_BIDIR }},
  { USB_VENDOR_NEC, USB_PRODUCT_NEC_PICTY760,   ANY,   { UQ_BROKEN_BIDIR }},
  { USB_VENDOR_NEC, USB_PRODUCT_NEC_PICTY920,   ANY,   { UQ_BROKEN_BIDIR }},
  { USB_VENDOR_NEC, USB_PRODUCT_NEC_PICTY800,   ANY,   { UQ_BROKEN_BIDIR }},
- { USB_VENDOR_MECANIQUE, USB_PRODUCT_MECANIQUE_WISPY, ANY,   { UQ_BAD_HID }},
- { USB_VENDOR_OMRON, USB_PRODUCT_OMRON_BX35F,   ANY,   { UQ_BAD_HID }},
- { USB_VENDOR_OMRON, USB_PRODUCT_OMRON_BX50F,   ANY,   { UQ_BAD_HID }},
- { USB_VENDOR_TENX, USB_PRODUCT_TENX_MISSILE,  ANY,   { UQ_BAD_HID }},
- { USB_VENDOR_APC, USB_PRODUCT_APC_UPSPRO500,  ANY,   { UQ_BAD_HID }},
- { USB_VENDOR_BELKIN, USB_PRODUCT_BELKIN_F6C550AVR, ANY,   { UQ_BAD_HID }},
- { USB_VENDOR_BELKIN, USB_PRODUCT_BELKIN_F6C1500EITWRK,ANY,{ 
UQ_BAD_HID }},
- { USB_VENDOR_MGE, USB_PRODUCT_MGE_UPS1,   ANY,   { UQ_BAD_HID }},
- { USB_VENDOR_MGE, USB_PRODUCT_MGE_UPS2,   ANY,   { UQ_BAD_HID }},
+
+ { USB_VENDOR_APC, USB_PRODUCT_APC_UPSPRO500,  ANY,{ UQ_BAD_HID }},
+ { USB_VENDOR_BELKIN, USB_PRODUCT_BELKIN_F6C550AVR,ANY,{ UQ_BAD_HID }},
+ { USB_VENDOR_BELKIN, USB_PRODUCT_BELKIN_F6C1500EITWRK,ANY,{ 
UQ_BAD_HID }},
  { USB_VENDOR_CYBERPOWER, USB_PRODUCT_CYBERPOWER_1500, ANY,{ UQ_BAD_HID }},
+ { USB_VENDOR_CYPRESS, USB_PRODUCT_CYPRESS_SISPM_OLD,  ANY,{ UQ_BAD_HID }},
+ { USB_VENDOR_CYPRESS, USB_PRODUCT_CYPRESS_SISPM,  ANY,{ UQ_BAD_HID }},
+ { USB_VENDOR_CYPRESS, USB_PRODUCT_CYPRESS_SISPM_FLASH,ANY,{ 
UQ_BAD_HID }},
+ { USB_VENDOR_ITUNER, USB_PRODUCT_ITUNER_USBLCD20x2,   ANY,{ UQ_BAD_HID }},
+ { USB_VENDOR_LIEBERT, USB_PRODUCT_LIEBERT_POWERSURE_PXT, ANY, { UQ_BAD_HID }},
+ { USB_VENDOR_MECANIQUE, USB_PRODUCT_MECANIQUE_WISPY,  ANY,{ UQ_BAD_HID }},
+ { USB_VENDOR_MGE, USB_PRODUCT_MGE_UPS1,   ANY,{ UQ_BAD_HID }},
+ { USB_VENDOR_MGE, USB_PRODUCT_MGE_UPS2,   ANY,{ UQ_BAD_HID }},
  { USB_VENDOR_MUSTEK2, USB_PRODUCT_MUSTEK2_PM800,  ANY,{ UQ_BAD_HID }},
- { USB_VENDOR_LIEBERT, USB_PRODUCT_LIEBERT_POWERSURE_PXT, ANY, { UQ_BAD_HID }},
+ { USB_VENDOR_OMRON, USB_PRODUCT_OMRON_BX35F,  ANY,{ UQ_BAD_HID }},
+ { USB_VENDOR_OMRON, USB_PRODUCT_OMRON_BX50F,  ANY,{ UQ_BAD_HID }},
+ { USB_VENDOR_TENX, USB_PRODUCT_TENX_MISSILE,  ANY,{ UQ_BAD_HID }},
+ { USB_VENDOR_TERRATEC, USB_PRODUCT_TERRATEC_AUREON,   ANY,{ UQ_BAD_HID }},
+
+ { USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_E220, ANY,{ UQ_NO_STRINGS }},
 
-  /* MS keyboards do weird things */
-  { USB_VENDOR_MICROSOFT, USB_PRODUCT_MICROSOFT_WLNOTEBOOK,
+ /* MS keyboards do weird things */
+ { USB_VENDOR_MICROSOFT, USB_PRODUCT_MICROSOFT_WLNOTEBOOK,
ANY, { UQ_MS_BAD_CLASS | UQ_MS_LEADING_BYTE }},
-  { USB_VENDOR_MICROSOFT, USB_PRODUCT_MICROSOFT_WLNOTEBOOK2,
+ { USB_VENDOR_MICROSOFT, 

Re: ahci(4) Intel RAID mode pci ids diff.

2010-04-06 Thread Brad
On Mon, Mar 15, 2010 at 10:19:18PM -0400, Brad wrote:
 The following diff adds the remaining PCI ids for the Intel AHCI
 controllers with a RAID mode to the existing ICH8 / ICH10 PCI ids.
 
 
 Add the Intel ICH7 (82801GHM / GR), ICH9 (82801I) and ICH10 (82801JD),
 6321ESB and PCH (3400) RAID mode PCI ids.

Updated for the latest rev of ahci.c.


Index: ahci.c
===
RCS file: /cvs/src/sys/dev/pci/ahci.c,v
retrieving revision 1.161
diff -u -p -r1.161 ahci.c
--- ahci.c  6 Apr 2010 13:59:37 -   1.161
+++ ahci.c  7 Apr 2010 00:40:18 -
@@ -440,11 +440,25 @@ static const struct ahci_device ahci_dev
{ PCI_VENDOR_ATI,   PCI_PRODUCT_ATI_SBX00_SATA_1,
NULL,   ahci_ati_sb600_attach },
 
+   { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_RAID_1,
+   NULL,   NULL },
+   { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_RAID_2,
+   NULL,   NULL },
+   { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6321ESB_RAID_1,
+   NULL,   NULL },
+   { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6321ESB_RAID_2,
+   NULL,   NULL },
+   { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801GHM_RAID,
+   NULL,   NULL },
{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801GR_RAID,
NULL,   NULL },
{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801H_RAID,
NULL,   NULL },
{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801HBM_RAID,
+   NULL,   NULL },
+   { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801I_RAID,
+   NULL,   NULL },
+   { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JD_RAID,
NULL,   NULL },
{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JI_RAID,
NULL,   NULL },

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.



bnx(4) BCM5709S fiber support.

2010-04-06 Thread Brad
Please test the following diff if you have a system utilizing the
BCM5709S chipset. This diff adds support for the fiber PHY coupled
with the BCM5709S controller.


Index: pci/if_bnx.c
===
RCS file: /cvs/src/sys/dev/pci/if_bnx.c,v
retrieving revision 1.86
diff -u -p -r1.86 if_bnx.c
--- pci/if_bnx.c23 Nov 2009 10:54:43 -  1.86
+++ pci/if_bnx.c28 Mar 2010 21:45:11 -
@@ -42,6 +42,7 @@ __FBSDID($FreeBSD: src/sys/dev/bce/if_b
  *   BCM5708C B1, B2
  *   BCM5708S B1, B2
  *   BCM5709C A1, C0
+ *   BCM5709S A1, C0
  *   BCM5716  C0
  *
  * The following controllers are not supported by this driver:
@@ -50,7 +51,7 @@ __FBSDID($FreeBSD: src/sys/dev/bce/if_b
  *   BCM5708C A0, B0
  *   BCM5708S A0, B0
  *   BCM5709C A0  B0, B1, B2 (pre-production)
- *   BCM5709S A0, A1, B0, B1, B2, C0 (pre-production)
+ *   BCM5709S A0, B0, B1, B2 (pre-production)
  */
 
 #include dev/pci/if_bnxreg.h
@@ -340,6 +341,7 @@ int bnx_nvram_write(struct bnx_softc *, 
 /*  */
 //
 void   bnx_get_media(struct bnx_softc *);
+void   bnx_init_media(struct bnx_softc *);
 intbnx_dma_alloc(struct bnx_softc *);
 void   bnx_dma_free(struct bnx_softc *);
 void   bnx_release_resources(struct bnx_softc *);
@@ -905,6 +907,9 @@ bnx_attachhook(void *xsc)
sc-bnx_mii.mii_writereg = bnx_miibus_write_reg;
sc-bnx_mii.mii_statchg = bnx_miibus_statchg;
 
+   /* Handle any special PHY initialization for SerDes PHYs. */
+   bnx_init_media(sc);
+
/* Look for our PHY. */
ifmedia_init(sc-bnx_mii.mii_media, 0, bnx_ifmedia_upd,
bnx_ifmedia_sts);
@@ -1120,6 +1125,16 @@ bnx_miibus_read_reg(struct device *dev, 
return(0);
}
 
+   /*
+* The BCM5709S PHY is an IEEE Clause 45 PHY
+* with special mappings to work with IEEE
+* Clause 22 register accesses.
+*/
+   if ((sc-bnx_phy_flags  BNX_PHY_IEEE_CLAUSE_45_FLAG) != 0) {
+   if (reg = MII_BMCR  reg = MII_ANLPRNP)
+   reg += 0x10;
+   }
+
if (sc-bnx_phy_flags  BNX_PHY_INT_MODE_AUTO_POLLING_FLAG) {
val = REG_RD(sc, BNX_EMAC_MDIO_MODE);
val = ~BNX_EMAC_MDIO_MODE_AUTO_POLL;
@@ -1199,6 +1214,16 @@ bnx_miibus_write_reg(struct device *dev,
val = 0x%04X\n, __FUNCTION__,
phy, (u_int16_t) reg  0x, (u_int16_t) val  0x);
 
+   /*
+* The BCM5709S PHY is an IEEE Clause 45 PHY
+* with special mappings to work with IEEE
+* Clause 22 register accesses.
+*/
+   if ((sc-bnx_phy_flags  BNX_PHY_IEEE_CLAUSE_45_FLAG) != 0) {
+   if (reg = MII_BMCR  reg = MII_ANLPRNP)
+   reg += 0x10;
+   }
+
if (sc-bnx_phy_flags  BNX_PHY_INT_MODE_AUTO_POLLING_FLAG) {
val1 = REG_RD(sc, BNX_EMAC_MDIO_MODE);
val1 = ~BNX_EMAC_MDIO_MODE_AUTO_POLL;
@@ -2179,6 +2204,7 @@ bnx_get_media(struct bnx_softc *sc)
DBPRINT(sc, BNX_INFO_LOAD, 
BCM5709 s/w configured for SerDes.\n);
sc-bnx_phy_flags |= BNX_PHY_SERDES_FLAG;
+   break;
default:
DBPRINT(sc, BNX_INFO_LOAD, 
BCM5709 s/w configured for Copper.\n);
@@ -2191,6 +2217,7 @@ bnx_get_media(struct bnx_softc *sc)
DBPRINT(sc, BNX_INFO_LOAD, 
BCM5709 s/w configured for SerDes.\n);
sc-bnx_phy_flags |= BNX_PHY_SERDES_FLAG;
+   break;
default:
DBPRINT(sc, BNX_INFO_LOAD, 
BCM5709 s/w configured for Copper.\n);
@@ -2202,6 +2229,14 @@ bnx_get_media(struct bnx_softc *sc)
 
if (sc-bnx_phy_flags  BNX_PHY_SERDES_FLAG) {
sc-bnx_flags |= BNX_NO_WOL_FLAG;
+
+   if (BNX_CHIP_NUM(sc) == BNX_CHIP_NUM_5709)
+   sc-bnx_phy_flags |= BNX_PHY_IEEE_CLAUSE_45_FLAG;
+
+   /*
+* The BCM5708S, BCM5709S, and BCM5716S controllers use a
+* separate PHY for SerDes.
+*/
if (BNX_CHIP_NUM(sc) != BNX_CHIP_NUM_5706) {
sc-bnx_phy_addr = 2;
val = REG_RD_IND(sc, sc-bnx_shmem_base +
@@ -2219,6 +2254,36 @@ bnx_get_media(struct bnx_softc *sc)
 bnx_get_media_exit:
DBPRINT(sc, (BNX_INFO_LOAD | BNX_INFO_PHY), 
Using PHY address %d.\n, sc-bnx_phy_addr);
+}
+
+//
+/* Performs PHY 

Re: ahci(4) Intel RAID mode pci ids diff.

2010-04-06 Thread Marco Peereboom
Why?

RAID mode is NOT a valid ID for ahci.

On Tue, Apr 06, 2010 at 09:09:47PM -0400, Brad wrote:
 On Mon, Mar 15, 2010 at 10:19:18PM -0400, Brad wrote:
  The following diff adds the remaining PCI ids for the Intel AHCI
  controllers with a RAID mode to the existing ICH8 / ICH10 PCI ids.
  
  
  Add the Intel ICH7 (82801GHM / GR), ICH9 (82801I) and ICH10 (82801JD),
  6321ESB and PCH (3400) RAID mode PCI ids.
 
 Updated for the latest rev of ahci.c.
 
 
 Index: ahci.c
 ===
 RCS file: /cvs/src/sys/dev/pci/ahci.c,v
 retrieving revision 1.161
 diff -u -p -r1.161 ahci.c
 --- ahci.c6 Apr 2010 13:59:37 -   1.161
 +++ ahci.c7 Apr 2010 00:40:18 -
 @@ -440,11 +440,25 @@ static const struct ahci_device ahci_dev
   { PCI_VENDOR_ATI,   PCI_PRODUCT_ATI_SBX00_SATA_1,
   NULL,   ahci_ati_sb600_attach },
  
 + { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_RAID_1,
 + NULL,   NULL },
 + { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_RAID_2,
 + NULL,   NULL },
 + { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6321ESB_RAID_1,
 + NULL,   NULL },
 + { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6321ESB_RAID_2,
 + NULL,   NULL },
 + { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801GHM_RAID,
 + NULL,   NULL },
   { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801GR_RAID,
   NULL,   NULL },
   { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801H_RAID,
   NULL,   NULL },
   { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801HBM_RAID,
 + NULL,   NULL },
 + { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801I_RAID,
 + NULL,   NULL },
 + { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JD_RAID,
   NULL,   NULL },
   { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JI_RAID,
   NULL,   NULL },
 
 -- 
 This message has been scanned for viruses and
 dangerous content by MailScanner, and is
 believed to be clean.



Re: bnx(4) BCM5709S fiber support.

2010-04-06 Thread Theo de Raadt
 Please test the following diff if you have a system utilizing the
 BCM5709S chipset. This diff adds support for the fiber PHY coupled
 with the BCM5709S controller.

This is wrong.  Test if you have *any* bnx.  When a diff of this nasty
complexity and size goes by, noone could give a rats ass if it helps
support the new chip.

Everyone cares that it doesn't break an existing chipset.

If you have a bnx, test it.  Report all failures to brad.  He might
care to hear that it helps new chips, but what he really needs to hear
is that it breaks other chips, that people have.

Always approach all big diffs like that.  We don't care as much if
they help new chips people don't have.  We care that they don't break
things people have lots of.  When they break things people have, that
is embarrasing because it so preventable.

And honestly.. this is a simple diff compared to the others recently
floating around.

 Index: pci/if_bnx.c
 ===
 RCS file: /cvs/src/sys/dev/pci/if_bnx.c,v
 retrieving revision 1.86
 diff -u -p -r1.86 if_bnx.c
 --- pci/if_bnx.c  23 Nov 2009 10:54:43 -  1.86
 +++ pci/if_bnx.c  28 Mar 2010 21:45:11 -
 @@ -42,6 +42,7 @@ __FBSDID($FreeBSD: src/sys/dev/bce/if_b
   *   BCM5708C B1, B2
   *   BCM5708S B1, B2
   *   BCM5709C A1, C0
 + *   BCM5709S A1, C0
   *   BCM5716  C0
   *
   * The following controllers are not supported by this driver:
 @@ -50,7 +51,7 @@ __FBSDID($FreeBSD: src/sys/dev/bce/if_b
   *   BCM5708C A0, B0
   *   BCM5708S A0, B0
   *   BCM5709C A0  B0, B1, B2 (pre-production)
 - *   BCM5709S A0, A1, B0, B1, B2, C0 (pre-production)
 + *   BCM5709S A0, B0, B1, B2 (pre-production)
   */
  
  #include dev/pci/if_bnxreg.h
 @@ -340,6 +341,7 @@ int   bnx_nvram_write(struct bnx_softc *, 
  /*  
 */
  
 //
  void bnx_get_media(struct bnx_softc *);
 +void bnx_init_media(struct bnx_softc *);
  int  bnx_dma_alloc(struct bnx_softc *);
  void bnx_dma_free(struct bnx_softc *);
  void bnx_release_resources(struct bnx_softc *);
 @@ -905,6 +907,9 @@ bnx_attachhook(void *xsc)
   sc-bnx_mii.mii_writereg = bnx_miibus_write_reg;
   sc-bnx_mii.mii_statchg = bnx_miibus_statchg;
  
 + /* Handle any special PHY initialization for SerDes PHYs. */
 + bnx_init_media(sc);
 +
   /* Look for our PHY. */
   ifmedia_init(sc-bnx_mii.mii_media, 0, bnx_ifmedia_upd,
   bnx_ifmedia_sts);
 @@ -1120,6 +1125,16 @@ bnx_miibus_read_reg(struct device *dev, 
   return(0);
   }
  
 + /*
 +  * The BCM5709S PHY is an IEEE Clause 45 PHY
 +  * with special mappings to work with IEEE
 +  * Clause 22 register accesses.
 +  */
 + if ((sc-bnx_phy_flags  BNX_PHY_IEEE_CLAUSE_45_FLAG) != 0) {
 + if (reg = MII_BMCR  reg = MII_ANLPRNP)
 + reg += 0x10;
 + }
 +
   if (sc-bnx_phy_flags  BNX_PHY_INT_MODE_AUTO_POLLING_FLAG) {
   val = REG_RD(sc, BNX_EMAC_MDIO_MODE);
   val = ~BNX_EMAC_MDIO_MODE_AUTO_POLL;
 @@ -1199,6 +1214,16 @@ bnx_miibus_write_reg(struct device *dev,
   val = 0x%04X\n, __FUNCTION__,
   phy, (u_int16_t) reg  0x, (u_int16_t) val  0x);
  
 + /*
 +  * The BCM5709S PHY is an IEEE Clause 45 PHY
 +  * with special mappings to work with IEEE
 +  * Clause 22 register accesses.
 +  */
 + if ((sc-bnx_phy_flags  BNX_PHY_IEEE_CLAUSE_45_FLAG) != 0) {
 + if (reg = MII_BMCR  reg = MII_ANLPRNP)
 + reg += 0x10;
 + }
 +
   if (sc-bnx_phy_flags  BNX_PHY_INT_MODE_AUTO_POLLING_FLAG) {
   val1 = REG_RD(sc, BNX_EMAC_MDIO_MODE);
   val1 = ~BNX_EMAC_MDIO_MODE_AUTO_POLL;
 @@ -2179,6 +2204,7 @@ bnx_get_media(struct bnx_softc *sc)
   DBPRINT(sc, BNX_INFO_LOAD, 
   BCM5709 s/w configured for SerDes.\n);
   sc-bnx_phy_flags |= BNX_PHY_SERDES_FLAG;
 + break;
   default:
   DBPRINT(sc, BNX_INFO_LOAD, 
   BCM5709 s/w configured for Copper.\n);
 @@ -2191,6 +2217,7 @@ bnx_get_media(struct bnx_softc *sc)
   DBPRINT(sc, BNX_INFO_LOAD, 
   BCM5709 s/w configured for SerDes.\n);
   sc-bnx_phy_flags |= BNX_PHY_SERDES_FLAG;
 + break;
   default:
   DBPRINT(sc, BNX_INFO_LOAD, 
   BCM5709 s/w configured for Copper.\n);
 @@ -2202,6 +2229,14 @@ bnx_get_media(struct bnx_softc *sc)
  
   if (sc-bnx_phy_flags  BNX_PHY_SERDES_FLAG) {
   sc-bnx_flags |= BNX_NO_WOL_FLAG;
 +
 + if