Re: random malloc junk
A nice security property of 0xdf filling is that a use-after-free of a pointer is guaranteed to fault in a typical environment since it ends up pointing outside userspace (I assume that's the case on OpenBSD). A heap spray could potentially allow exploiting a random pointer. Perhaps it would be better if only the byte range guaranteeing faults for pointers was used? Less random, but strictly better than the current situation rather than losing a nice guarantee.
Re: random malloc junk
> BTW, we should revisit canaries and work further on moving them > closer to requested size. There's a chance this diff wil complicate > that. Can switch the canary code to memcpy/memcmp (to handle unaligned canaries) and could then use the last byte as an index to the start of the canary. For larger movement, it could have a special value (like 255) meaning that there's a 4 byte length at an 8 byte offset. If you really wanted you could micro-optimize to lose only 1 canary bit, but that seems too complicated to save 7 bits of the canary. It could also sanity check the offsets based on the known minimum size of a chunk in that size class.
Re: random malloc junk
On Wed, 2016-09-07 at 18:29 -0400, Ted Unangst wrote: > Instead of always using a fixed byte pattern, I think malloc should > use a > random pattern. Now, this sometimes means it's harder to identify > exactly > what's used after free, so we should provide a means to get the old > 0xdf > pattern back. > > Since we already have two junk modes, I thought I'd carry on along > those > lines. The default junk behavior, for free chunks only, is more of a > security > measure. I think this means we want random junk. The second level 'J' > junk is > more of a debugging tool, so that retains 0xdf. A bit off-topic: 'J' enables junk-on-init which is for debugging, but it also currently has security improvements for large allocations. There's only partial junk-on-free by default (half a page), and 'U' disables large allocation junk-on-free without 'J'. I think it would make sense to remove those optimizations since it's fine if the cost scales up with larger allocations and losing the guarantee of not leaking data via uninitialized memory with 'U' is not great. Using 'U' is quite expensive regardless, and adds some pathological performance cases for small size allocations which is more important. I ended up removing both of those optimizations for the CopperheadOS port.
ports; why I removed SIGNING_PARAMETERS
It used to make some kind of sense when pkg_create could indeed create the signed package in one pass. Now, the new signing mode means you have to build the package and copy it anyway. Heck, the code is not even inside pkg_sign proper, pkg_sign is going to become a shell that just keeps the "run things in parallel thingie". As for personal use, there's often little sense in signing your own packages. If you stream them on a private network, nobody can read them. If you stream them over the internet, you can probably use scp fairly often. Production systems did do after-the-fact signing. Especially since creating packages no longer requires root (the official packages never used SIGNING_PARAMETERS). Signing packages requires access to the private key, something that is best completely separated from building the packages... (paranoia ? err, we're talking about signing packages there. OF COURSE you have to be paranoid) I'm actually surprised that a few people were using SIGNING_PARAMETERS. I don't think it's going to be complicated to move to pkg_sign. The final switch is going to happen reasonably soon... as soon as all the production machines know about new signing, which gives me yet a few more days to run a few more tests.
reduce double caching in mfs
Currently, the bufcache doesn't know that mfs is backed by memory. All i/o to mfs ends up being double cached, once in the userland process and again in the kernel bufcache. This is wasteful. In particular, it means one can't use mfs to increase the effective size of the buffer cache. Reading or writing to mfs will push out buffers used for disk caching. (I think you can even end up with triple buffering when mfs starts swapping...) This is mostly inherent to the design of mfs. But with a small tweak to the buffer cache, we can improve the situation. This introduces the concept of 'cheap' buffers, a hint to the buffer cache that they are easily replaced. (There's a 'nocache' flag already, but it's not suitable here.) When mfs finishes with a buf, it marks it cheap. Then it goes onto a special queue that gets chewed up before we start looking at the regular caches. We still cache some number of cheap buffers to prevent constant memory copying. With this diff, I've confirmed that reading/writing large files to mfs doesn't flush the cache, but performance appears about the same. (Of particular note, my bufcache is big enough to cache all of src/, but not src/ and obj/. With obj/ on mfs, src never gets flushed.) Index: kern/vfs_bio.c === RCS file: /cvs/src/sys/kern/vfs_bio.c,v retrieving revision 1.176 diff -u -p -r1.176 vfs_bio.c --- kern/vfs_bio.c 4 Sep 2016 10:51:24 - 1.176 +++ kern/vfs_bio.c 8 Sep 2016 18:31:52 - @@ -93,7 +93,10 @@ int bd_req; /* Sleep point for cleaner #define NUM_CACHES 2 #define DMA_CACHE 0 +#define CHEAP_LIMIT 256 struct bufcache cleancache[NUM_CACHES]; +struct bufqueue cheapqueue; +u_int cheapqueuelen; struct bufqueue dirtyqueue; void @@ -1297,6 +1300,7 @@ bufcache_init(void) TAILQ_INIT(&cleancache[i].coldqueue); TAILQ_INIT(&cleancache[i].warmqueue); } + TAILQ_INIT(&cheapqueue); TAILQ_INIT(&dirtyqueue); } @@ -1329,6 +1333,12 @@ bufcache_getcleanbuf(int cachenum, int d splassert(IPL_BIO); + /* try cheap queue if over limit */ + if (discard || cheapqueuelen > CHEAP_LIMIT) { + if ((bp = TAILQ_FIRST(&cheapqueue))) + return bp; + } + /* try cold queue */ while ((bp = TAILQ_FIRST(&cache->coldqueue))) { if ((!discard) && @@ -1356,6 +1366,8 @@ bufcache_getcleanbuf(int cachenum, int d /* buffer is cold - give it up */ return bp; } + if ((bp = TAILQ_FIRST(&cheapqueue))) + return bp; if ((bp = TAILQ_FIRST(&cache->warmqueue))) return bp; if ((bp = TAILQ_FIRST(&cache->hotqueue))) @@ -1410,6 +1422,13 @@ bufcache_take(struct buf *bp) pages = atop(bp->b_bufsize); struct bufcache *cache = &cleancache[bp->cache]; if (!ISSET(bp->b_flags, B_DELWRI)) { + if (ISSET(bp->b_flags, B_CHEAP)) { + TAILQ_REMOVE(&cheapqueue, bp, b_freelist); + cheapqueuelen--; + CLR(bp->b_flags, B_CHEAP); + return; + } + if (ISSET(bp->b_flags, B_COLD)) { queue = &cache->coldqueue; } else if (ISSET(bp->b_flags, B_WARM)) { @@ -1462,11 +1481,17 @@ bufcache_release(struct buf *bp) struct bufqueue *queue; int64_t pages; struct bufcache *cache = &cleancache[bp->cache]; + pages = atop(bp->b_bufsize); KASSERT(ISSET(bp->b_flags, B_BC)); KASSERT((ISSET(bp->b_flags, B_DMA) && bp->cache == 0) || ((!ISSET(bp->b_flags, B_DMA)) && bp->cache > 0)); if (!ISSET(bp->b_flags, B_DELWRI)) { + if (ISSET(bp->b_flags, B_CHEAP)) { + TAILQ_INSERT_TAIL(&cheapqueue, bp, b_freelist); + cheapqueuelen++; + return; + } int64_t *queuepages; if (ISSET(bp->b_flags, B_WARM | B_COLD)) { SET(bp->b_flags, B_WARM); Index: sys/buf.h === RCS file: /cvs/src/sys/sys/buf.h,v retrieving revision 1.103 diff -u -p -r1.103 buf.h --- sys/buf.h 23 May 2016 09:31:28 - 1.103 +++ sys/buf.h 8 Sep 2016 17:20:12 - @@ -221,12 +221,14 @@ struct bufcache { #defineB_COLD 0x0100 /* buffer is on the cold queue */ #defineB_BC0x0200 /* buffer is managed by the cache */ #defineB_DMA 0x0400 /* buffer is DMA reachable */ +#defineB_CHEAP 0x0800 /* buffer is cheap to refetch */ #defineB_BITS "\20\001AGE\002NEEDCOMMIT\003ASYNC\004BAD\005BUSY" \ "\006CACHE\007CALL\010DELWRI\011DONE\012EINTR\013ERROR" \ "\014IN
Re: Fix Wacom Intuos S 2 descriptor and make wsmouse work
Maybe one day I'll get it right: s/wsmouse_input_sync()/wsmouse_input_sync(ms->sc_wsmousedev)/ On 09/07/2016 12:12 AM, Ulf Brosziewski wrote: > Hi, I was a bit hasty, I should have mentioned that calling > wsmouse_input_sync is required here. The equivalent of your > code would would be this: > > if (x != 0 || y != 0 || buttons != ms->sc_buttons) { > wsmouse_position(ms->sc_wsmousedev, x, y); > /* ignore proximity, it will cause invalid button 2 events */ > if ((data[0] & 0xf0) != 0xc0) > wsmouse_buttons(ms->sc_wsmousedev, buttons); > wsmouse_input_sync(); > } > > The WSMOUSE_INPUT macro - a substitute for the old wsmouse_input > function - does include that call (see wsmousevar.h). > > There is a set of functions for reporting input states: > wsmouse_buttons, wsmouse_motion, wsmouse_position, wsmouse_touch, > and wsmouse_mtstate (and the somewhat special wsmouse_set and > wsmouse_mtframe). A driver can call them in any order, and it > doesn't need to check whether there are deltas, wsmouse does > this anyway. However, a frame must be finished by a call to > wsmouse_input_sync. It is this function that generates the > wscons events. > > The new interface has been introduced in 6.0. > > On 09/06/2016 09:00 PM, Frank Groeneveld wrote: >> On Tue, Sep 06, 2016 at 02:19:28PM +0200, Ulf Brosziewski wrote: >>> Just a remark on your use of the wsmouse interface (which isn't well >>> known and documented yet): wsmouse_set is a function for uncommon >>> cases. To report a pair of absolute coordinates use wsmouse_position, >>> that is, instead of >>> wsmouse_set(ms->sc_wsmousedev, WSMOUSE_ABS_X, x, 0); >>> wsmouse_set(ms->sc_wsmousedev, WSMOUSE_ABS_Y, y, 0); >>> you should use >>> wsmouse_position(ms->sc_wsmousedev, x, y); >>> Likewise, for reporting the button state there is >>> wsmouse_buttons(ms->sc_wsmousedev, buttons); >>> There is no need for the WSMOUSE_INPUT macro here. >> >> Seems like a cleaner API indeed, but those functions don't seem to work >> for me. Both mouse movement and button reporting stop functioning when >> replaced by those calls. How old is this API, might it be some outdated >> sources on my side? Something else I'm doing wrong? >> >> Frank >> >> > >
Installer: get nameserver from rebound.conf
If you have set up a machine to use rebound(8), then boot the install media to perform an upgrade, you won't be able to fetch the sets over the network because there is no nameserver in resolv.conf and rebound isn't running. The diff below adds the nameserver from rebound.conf to the ramdisk's resolv.conf if no other nameserver has been configured. All the code is from rpe@. I just moved the main chunk to the end of enable_network() so it is executed after dhclient. rpe@ wrote this before the recent unpriv changes, but it still works. It works for me... Index: distrib/miniroot/install.sub === RCS file: /cvs/src/distrib/miniroot/install.sub,v retrieving revision 1.912 diff -u -p -r1.912 install.sub --- distrib/miniroot/install.sub4 Sep 2016 12:36:33 - 1.912 +++ distrib/miniroot/install.sub8 Sep 2016 11:39:44 - @@ -2081,7 +2081,7 @@ ifstart () { # Configure the network during upgrade based on the on-disk configuration. enable_network() { - local _f _gw _trunks _svlans _vlans + local _f _gw _ip _ns _no_ns=1 _only_lh=1 _rest _trunks _svlans _vlans # Copy any network configuration files. N.B.: hosts already copied. for _f in dhclient.conf resolv.conf resolv.conf.tail; do @@ -2134,6 +2134,23 @@ enable_network() { done route -qn add -net 127 127.0.0.1 -reject >/dev/null + + # If resolv.conf does not have a nameserver config, or only one for + # localhost, add the nameserver from rebound.conf if that file exists. + if [[ -s /etc/resolv.conf ]]; then + while read _ns _ip _rest; do + [[ $_ns == nameserver ]] && _no_ns=0 || continue + [[ $_ip != @(127.0.0.1|localhost) ]] && _only_lh=0 + done >/etc/resolv.conf + elif ((_only_lh)); then + sed -i "s/^nameserver.*$/nameserver $_ns/" \ + /etc/resolv.conf + fi + fi + fi } # Fetch the list of mirror servers and installer choices from previous runs if -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: remove /dev/sound*
On Thu, Sep 08, 2016 at 08:22:16AM +0100, Stuart Henderson wrote: > On 2016/09/08 13:47, Michael W. Bombardieri wrote: > > Hi Alexandre, > > > > Do you know if any applications in ports use /dev/sound as default audio > > device. > > Maybe they are not smart enough to try /dev/audio if /dev/sound fails. > > Here are search results - there are false positoves from /dev/sound/XX > from Linux, and possibly others from Solaris, so needs further checking. > Thanks for the list; indeed the /dev/sound/xxx don't matter. The one that metter are all false positives as well. > $ ag /dev/sound > ports/x11/mplayer/patches/patch-stream_tvi_bsdbt848_c > 82: priv->dspdev = strdup("/dev/sound"); this one is disabled with #ifdef > u/libmikmod-3.3.8/libmikmod-3.3.8/drivers/drv_sun.c > 83:#define SOUNDDEVICE "/dev/sound" this is the sun backend but we use sndio > u/sidplay-1.0.9/sidplay-base-1.0.9/audio/oss/audiodrv.cpp > 10:const char audioDriver::AUDIODEVICE[] = "/dev/sound"; this is the oss backend, we use sndio > u/soundtracker-0.6.8/soundtracker-0.6.8.gtk2/Makefile.am same here > u/xmp-4.0.10/xmp-4.0.10/src/sound_bsd.c > 39: if ((audio_fd = open("/dev/sound", O_WRONLY)) == -1) same here > u/ptlib-2.12.9/ptlib-2.12.9/plugins/sound_oss/sound_oss.cxx > 220: PDirectory devdir = "/dev/sound"; same here > u/sdl2-2.0.4/SDL2-2.0.4/src/audio/SDL_audiodev.c > 43:#define _PATH_DEV_DSP24 "/dev/sound/dsp" > 92:/* Added support for /dev/sound/\* in Linux 2.4 */ > 93:if (((stat("/dev/sound", &sb) == 0) && S_ISDIR(sb.st_mode)) same here > u/frotz-2.44/frotz-2.44/Makefile > 51:#SOUND_DEV = /dev/sound uses oss, sound disabled > u/ufoai-2.5-source/ufoai-2.5-source/src/libs/SDL/src/audio/SDL_audiodev.c > 91:if (((stat("/dev/sound", &sb) == 0) && S_ISDIR(sb.st_mode)) > comes with its own copy of sdl (which contains sndio) > u/uhexen2-1.5.6/hexen2source-1.5.6/engine/h2shared/snd_sun.c > 106: snddev = "/dev/sound"; this is the sun backend, but we use sdl > u/warmux-11.04.1/warmux-11.04/build/android/jni/sdl/src/audio/SDL_audiodev.c > 43:#define _PATH_DEV_DSP24 "/dev/sound/dsp" > 64: /* Added support for /dev/sound/\* in Linux 2.4 */ > 65: if ( ((stat("/dev/sound", &sb) == 0) && > S_ISDIR(sb.st_mode)) && comes with a copy of sdl for android; we use OpenBSD sdl port > u/mpv-0.17.0/mpv-0.17.0/wscript > 536: defines=['PATH_DEV_DSP="/dev/sound"', this is the script to detect oss, we use sndio > u/arts-1.5.10/arts-1.5.10/flow/audioiooss.cc > 103: "/dev/sound", /* NetBSD*/ this is oss backend, we use sndio > u/mplayer-20160306/mplayer-20160306/configure > 5821: def_ossaudio_devdsp='#define PATH_DEV_DSP "/dev/sound"' same here
Re: ksh(1): manual says $PPID is read-only
I've committed my fix to make "typeset -ir PPID" work and adjusted the PPID line in initcoms[] accordingly. - todd
Re: ksh(1): manual says $PPID is read-only
On Thu, 08 Sep 2016 17:33:37 +0200, Theo Buehler wrote: > Your fix looks correct to me and accomplishes the desired effect. Should > we perhaps introduce > > #define NO_RO_CHECK 0x4 > > and replace the 5 occurrences of the magic number in var.c? Yes, I would like that. - todd
Re: ksh(1): manual says $PPID is read-only
On Thu, Sep 08, 2016 at 09:22:28AM -0600, Todd C. Miller wrote: > On Thu, 08 Sep 2016 10:08:23 -0400, Anthony Coulter wrote: > > > We can fix either the manual or ksh itself; this diff takes the latter > > approach. It is tempting to do this with "typeset -ir PPID" but that > > actually doesn't work: > > > > $ FOO=123 > > $ typeset -ir FOO > > ksh: FOO: is read only > > Perhaps we should fix the above issue as well, other ksh versions > don't throw an error there. Below is a simple fix, though a bit > gross due to the magic 0x4. Your fix looks correct to me and accomplishes the desired effect. Should we perhaps introduce #define NO_RO_CHECK 0x4 and replace the 5 occurrences of the magic number in var.c?
Re: ksh tab completion: ^_: unexpected `^'
This is incoherent and I don't see what it has to do with the issue, you will need to provide a diff yourself. On Thu, Sep 08, 2016 at 09:18:19AM -0400, sven falempin wrote: > This does not include UTF8 basic character, > > so if someone do > > And it want to do it again for that file ... svik , does not work. > > This problem should be address in isalnum, i guess, i think some c++ > lib did it already, > and i have a headache everytime i want to use \w in a regexp. > > current $ ./a.out ??lol > NOP > _ > ~ > current $ ./a.out elol > elol_ > ~ > current $ cat /tmp/foo.c > #include > > int main(int argc, char** argv) { > if (isalnum(argv[1][0] )) printf("%s", argv[1]); else printf ("NOP\n"); > } > > On Thu, Sep 8, 2016 at 6:08 AM, Stuart Henderson wrote: > > On 2016/09/08 10:45, Nicholas Marriott wrote: > >> Yeah we probably shouldn't bother to look for commands that aren't > >> [A-Za-z0-9_-]: > > > > I don't think - is necessary, it's not a valid character for an array > > name so it can't be used here anyway. Otherwise OK. > > > >> Index: edit.c > >> === > >> RCS file: /cvs/src/bin/ksh/edit.c,v > >> retrieving revision 1.56 > >> diff -u -p -r1.56 edit.c > >> --- edit.c7 Sep 2016 04:42:31 - 1.56 > >> +++ edit.c8 Sep 2016 09:45:21 - > >> @@ -584,9 +584,8 @@ x_try_array(const char *buf, int buflen, > >> int *nwords, char ***words) > >> { > >> const char *cmd, *cp; > >> - int cmdlen, n; > >> + int cmdlen, n, i, slen; > >> char *name, *s; > >> - size_t slen; > >> struct tbl *v, *vp; > >> > >> *nwords = 0; > >> @@ -604,6 +603,10 @@ x_try_array(const char *buf, int buflen, > >> cmdlen = 0; > >> while (cmd + cmdlen < want && !isspace((u_char)cmd[cmdlen])) > >> cmdlen++; > >> + for (i = 0; i < cmdlen; i++) { > >> + if (!isalnum((u_char)cmd[i]) && cmd[i] != '_' && cmd[i] != > >> '-') > >> + return 0; > >> + } > >> > >> /* Take a stab at argument count from here. */ > >> n = 1; > >> > >> > >> On Thu, Sep 08, 2016 at 09:43:53AM +0100, Stuart Henderson wrote: > >> > I just ran into this which was introduced with custom completions > >> > (I haven't setup any complete_* arrays). > >> > > >> > $ ag "(foo)[^_]" /u > >> > > >> > results in > > > > > > -- > - > () ascii ribbon campaign - against html e-mail > /\
Re: ksh(1): manual says $PPID is read-only
On Thu, 08 Sep 2016 10:08:23 -0400, Anthony Coulter wrote: > We can fix either the manual or ksh itself; this diff takes the latter > approach. It is tempting to do this with "typeset -ir PPID" but that > actually doesn't work: > > $ FOO=123 > $ typeset -ir FOO > ksh: FOO: is read only Perhaps we should fix the above issue as well, other ksh versions don't throw an error there. Below is a simple fix, though a bit gross due to the magic 0x4. - todd Index: bin/ksh/var.c === RCS file: /cvs/src/bin/ksh/var.c,v retrieving revision 1.55 diff -u -p -u -r1.55 var.c --- bin/ksh/var.c 30 Dec 2015 09:07:00 - 1.55 +++ bin/ksh/var.c 8 Sep 2016 15:20:20 - @@ -661,6 +661,7 @@ typeset(const char *var, int set, int cl */ for (t = vpbase; t; t = t->u.array) { int fake_assign; + int error_ok = KSH_RETURN_ERROR; char *s = NULL; char *free_me = NULL; @@ -683,6 +684,10 @@ typeset(const char *var, int set, int cl t->type = 0; t->flag &= ~ALLOC; } + if (!(t->flag & RDONLY) && (set & RDONLY)) { + /* allow var to be initialized read-only */ + error_ok |= 0x4; + } t->flag = (t->flag | set) & ~clr; /* Don't change base if assignment is to be done, * in case assignment fails. @@ -692,7 +697,7 @@ typeset(const char *var, int set, int cl if (set & (LJUST|RJUST|ZEROFIL)) t->u2.field = field; if (fake_assign) { - if (!setstr(t, s, KSH_RETURN_ERROR)) { + if (!setstr(t, s, error_ok)) { /* Somewhat arbitrary action here: * zap contents of variable, but keep * the flag settings.
Re: ksh(1): manual says $PPID is read-only
On Thu, Sep 08, 2016 at 10:08:23AM -0400, Anthony Coulter wrote: [..] > We can fix either the manual or ksh itself; this diff takes the latter > approach. It is tempting to do this with "typeset -ir PPID" but that > actually doesn't work: > > $ FOO=123 > $ typeset -ir FOO > ksh: FOO: is read only $ echo $FOO $ This looks like a bug to me. Note that $ typeset -ir BAR=123 does the expected thing: $ BAR=1 ksh: BAR: is read only $ echo $BAR 123 So, while I agree that PPID should be read-only and your patch appears to accomplish the desired effect, I think we should try to fix the underlying problem, not work around it.
Re: ps -o etime
On Thu, 08 Sep 2016 23:15:01 +1200, Carlin Bingham wrote: > The "etime" keyword is currently an alias for "start". posix says it > should be the amount of time since the program started running, in the > format [[dd-]hh:]mm:ss, I've encountered some code that doesn't work on > openbsd because that's what it expects. The commit that added this in > '97 says it was for XPG4 compat, but XPG4 gives the same definition of > etime as posix does now. > > Given that the alias is old enough to vote, too late to change this? Yes, we should fix this, diff looks good. - todd
ksh(1): manual says $PPID is read-only
The ksh(1) manual says that PPID should be read-only. But: $ man ksh | grep PPID PPID The process ID of the shell's parent (read-only). $ echo ${PPID} 5967 $ PPID=123 $ echo ${PPID} 123 We can fix either the manual or ksh itself; this diff takes the latter approach. It is tempting to do this with "typeset -ir PPID" but that actually doesn't work: $ FOO=123 $ typeset -ir FOO ksh: FOO: is read only So we fix this by putting "typeset -r PPID" on its own line. One could imagine shortening the section below with something like: "typeset", "-i", "PPID", "OPTIND=1", NULL, "typeset", "-r", "KSH_VERSION", "PPID", NULL, "typeset", "-x", "SHELL", "PATH", "HOME", NULL, but that involves some reordering: the -i's MUST come before the -r's. Index: bin/ksh/main.c === RCS file: /open/anoncvs/cvs/src/bin/ksh/main.c,v retrieving revision 1.79 diff -u -p -r1.79 main.c --- main.c 4 Mar 2016 15:11:06 - 1.79 +++ main.c 8 Sep 2016 13:17:29 - @@ -85,6 +85,7 @@ static const char *initcoms [] = { "typeset", "-r", "KSH_VERSION", NULL, "typeset", "-x", "SHELL", "PATH", "HOME", NULL, "typeset", "-i", "PPID", NULL, + "typeset", "-r", "PPID", NULL, "typeset", "-i", "OPTIND=1", NULL, "eval", "typeset -i RANDOM MAILCHECK=\"${MAILCHECK-600}\" SECONDS=\"${SECONDS-0}\" TMOUT=\"${TMOUT-0}\"", NULL, "alias",
Re: ksh tab completion: ^_: unexpected `^'
This does not include UTF8 basic character, so if someone do And it want to do it again for that file ... sviňák , does not work. This problem should be address in isalnum, i guess, i think some c++ lib did it already, and i have a headache everytime i want to use \w in a regexp. current $ ./a.out élol NOP _ ~ current $ ./a.out elol elol_ ~ current $ cat /tmp/foo.c #include int main(int argc, char** argv) { if (isalnum(argv[1][0] )) printf("%s", argv[1]); else printf ("NOP\n"); } On Thu, Sep 8, 2016 at 6:08 AM, Stuart Henderson wrote: > On 2016/09/08 10:45, Nicholas Marriott wrote: >> Yeah we probably shouldn't bother to look for commands that aren't >> [A-Za-z0-9_-]: > > I don't think - is necessary, it's not a valid character for an array > name so it can't be used here anyway. Otherwise OK. > >> Index: edit.c >> === >> RCS file: /cvs/src/bin/ksh/edit.c,v >> retrieving revision 1.56 >> diff -u -p -r1.56 edit.c >> --- edit.c7 Sep 2016 04:42:31 - 1.56 >> +++ edit.c8 Sep 2016 09:45:21 - >> @@ -584,9 +584,8 @@ x_try_array(const char *buf, int buflen, >> int *nwords, char ***words) >> { >> const char *cmd, *cp; >> - int cmdlen, n; >> + int cmdlen, n, i, slen; >> char *name, *s; >> - size_t slen; >> struct tbl *v, *vp; >> >> *nwords = 0; >> @@ -604,6 +603,10 @@ x_try_array(const char *buf, int buflen, >> cmdlen = 0; >> while (cmd + cmdlen < want && !isspace((u_char)cmd[cmdlen])) >> cmdlen++; >> + for (i = 0; i < cmdlen; i++) { >> + if (!isalnum((u_char)cmd[i]) && cmd[i] != '_' && cmd[i] != '-') >> + return 0; >> + } >> >> /* Take a stab at argument count from here. */ >> n = 1; >> >> >> On Thu, Sep 08, 2016 at 09:43:53AM +0100, Stuart Henderson wrote: >> > I just ran into this which was introduced with custom completions >> > (I haven't setup any complete_* arrays). >> > >> > $ ag "(foo)[^_]" /u >> > >> > results in > -- - () ascii ribbon campaign - against html e-mail /\
Re: ps -o etime
Carlin Bingham wrote: > The "etime" keyword is currently an alias for "start". posix says it > should be the amount of time since the program started running, in the > format [[dd-]hh:]mm:ss, I've encountered some code that doesn't work on > openbsd because that's what it expects. The commit that added this in > '97 says it was for XPG4 compat, but XPG4 gives the same definition of > etime as posix does now. > > Given that the alias is old enough to vote, too late to change this? I don't think so. The alias was added in a half-hearted effort at compliance, but we should make the output do the right thing. That's obviously what people and scripts expect. The traditional output of 'start' shouldn't be changed, but you've got that covered.
ps -o etime
The "etime" keyword is currently an alias for "start". posix says it should be the amount of time since the program started running, in the format [[dd-]hh:]mm:ss, I've encountered some code that doesn't work on openbsd because that's what it expects. The commit that added this in '97 says it was for XPG4 compat, but XPG4 gives the same definition of etime as posix does now. Given that the alias is old enough to vote, too late to change this? -- Carlin Index: bin/ps/extern.h === RCS file: /cvs/src/bin/ps/extern.h,v retrieving revision 1.19 diff -u -p -u -r1.19 extern.h --- bin/ps/extern.h 10 Jan 2016 14:04:16 - 1.19 +++ bin/ps/extern.h 8 Sep 2016 10:59:32 - @@ -48,6 +48,7 @@ void command(const struct kinfo_proc *, voidcputime(const struct kinfo_proc *, VARENT *); int donlist(void); voidemulname(const struct kinfo_proc *, VARENT *); +voidelapsed(const struct kinfo_proc *, VARENT *); double getpcpu(const struct kinfo_proc *); double getpmem(const struct kinfo_proc *); voidgname(const struct kinfo_proc *, VARENT *); Index: bin/ps/keyword.c === RCS file: /cvs/src/bin/ps/keyword.c,v retrieving revision 1.43 diff -u -p -u -r1.43 keyword.c --- bin/ps/keyword.c30 Dec 2015 14:59:10 - 1.43 +++ bin/ps/keyword.c8 Sep 2016 10:59:32 - @@ -101,7 +101,7 @@ VAR var[] = { {"cwd", "CWD", NULL, LJUST, curwd, CWDLEN}, {"dsiz", "DSIZ", NULL, 0, dsize, 4}, {"emul", "EMUL", NULL, LJUST, emulname, KI_EMULNAMELEN - 1}, - {"etime", "ELAPSED", "start"}, + {"etime", "ELAPSED", NULL, USER, elapsed, 12}, {"f", "F", NULL, 0, pvar, 7, 0, POFF(p_flag), INT32, "x"}, {"flags", "", "f"}, GID("gid", "GID", pvar, POFF(p_gid)), Index: bin/ps/print.c === RCS file: /cvs/src/bin/ps/print.c,v retrieving revision 1.68 diff -u -p -u -r1.68 print.c --- bin/ps/print.c 1 Sep 2016 09:44:06 - 1.68 +++ bin/ps/print.c 8 Sep 2016 10:59:32 - @@ -439,6 +439,50 @@ lstarted(const struct kinfo_proc *kp, VA (void)printf("%-*s", v->width, buf); } +void elapsed(const struct kinfo_proc *kp, VARENT *ve) +{ + VAR *v; + static time_t now; + time_t secs; + char buf[64]; + long days, hours, minutes, seconds; + + v = ve->var; + if (!kp->p_uvalid) { + (void)printf("%*s", v->width, "-"); + return; + } + + if (!now) + (void)time(&now); + secs = now - kp->p_ustart_sec; + + if (secs < 0) { + (void)printf("%*s", v->width, "-"); + return; + } + + days = secs / SECSPERDAY; + secs %= SECSPERDAY; + + hours = secs / SECSPERHOUR; + secs %= SECSPERHOUR; + + minutes = secs / 60; + seconds = secs % 60; + + if (days > 0) + (void)snprintf(buf, sizeof(buf), "%ld-%02ld:%02ld:%02ld", + days, hours, minutes, seconds); + else if (hours > 0) + (void)snprintf(buf, sizeof(buf), "%02ld:%02ld:%02ld", + hours, minutes, seconds); + else + (void)snprintf(buf, sizeof(buf), "%02ld:%02ld", + minutes, seconds); + (void)printf("%*s", v->width, buf); +} + void wchan(const struct kinfo_proc *kp, VARENT *ve) { Index: bin/ps/ps.1 === RCS file: /cvs/src/bin/ps/ps.1,v retrieving revision 1.106 diff -u -p -u -r1.106 ps.1 --- bin/ps/ps.1 25 Apr 2016 20:34:55 - 1.106 +++ bin/ps/ps.1 8 Sep 2016 10:59:32 - @@ -211,6 +211,8 @@ Current working directory. Data size, in Kilobytes. .It Cm emul Name of system call emulation environment. +.It Cm etime +Elapsed time since the process was started. .It Cm flags Alias: .Cm f . @@ -386,8 +388,6 @@ Sleep time (in seconds; 127 = infinity). .It Cm ssiz Stack size, in Kilobytes. .It Cm start -Alias: -.Cm etime . The time the command started. If the command started less than 24 hours ago, the start time is displayed using the
Re: Bridge broken in 6.0?
* Aaron Riekenberg [2016-09-05 13:04]: > Thanks for the explanation. > > I am curious though - is dhclient really the right place to fix this? I > might use some other dhcp client (dhcpcd in ports for example) or some > other application that uses BPF. Should every userland program using BPF > have to worry whether or not it is breaking bridging? no, the key is the dropping in BPF, which is an OpenBSD extension. [I don't know whether others have similiar schemes or followed our lead, and that's NOT THE TOPIC HERE. point is, it is nonstandard and not in widespread use by 3rd party code if at all] strictly speaking, the bpf filters in the base dhcp programs have been matching (and thus eating) too much forever since we added them, it just didn't show up because it was covered by the behaviour (strictly speaking, I'd say misbehaviour) of the stack with bridge so far. -- Henning Brauer, h...@bsws.de, henn...@openbsd.org BS Web Services GmbH, http://bsws.de, Full-Service ISP Secure Hosting, Mail and DNS. Virtual & Dedicated Servers, Root to Fully Managed Henning Brauer Consulting, http://henningbrauer.com/
Re: ksh tab completion: ^_: unexpected `^'
On 2016/09/08 10:45, Nicholas Marriott wrote: > Yeah we probably shouldn't bother to look for commands that aren't > [A-Za-z0-9_-]: I don't think - is necessary, it's not a valid character for an array name so it can't be used here anyway. Otherwise OK. > Index: edit.c > === > RCS file: /cvs/src/bin/ksh/edit.c,v > retrieving revision 1.56 > diff -u -p -r1.56 edit.c > --- edit.c7 Sep 2016 04:42:31 - 1.56 > +++ edit.c8 Sep 2016 09:45:21 - > @@ -584,9 +584,8 @@ x_try_array(const char *buf, int buflen, > int *nwords, char ***words) > { > const char *cmd, *cp; > - int cmdlen, n; > + int cmdlen, n, i, slen; > char *name, *s; > - size_t slen; > struct tbl *v, *vp; > > *nwords = 0; > @@ -604,6 +603,10 @@ x_try_array(const char *buf, int buflen, > cmdlen = 0; > while (cmd + cmdlen < want && !isspace((u_char)cmd[cmdlen])) > cmdlen++; > + for (i = 0; i < cmdlen; i++) { > + if (!isalnum((u_char)cmd[i]) && cmd[i] != '_' && cmd[i] != '-') > + return 0; > + } > > /* Take a stab at argument count from here. */ > n = 1; > > > On Thu, Sep 08, 2016 at 09:43:53AM +0100, Stuart Henderson wrote: > > I just ran into this which was introduced with custom completions > > (I haven't setup any complete_* arrays). > > > > $ ag "(foo)[^_]" /u > > > > results in
Re: ksh tab completion: ^_: unexpected `^'
Yeah we probably shouldn't bother to look for commands that aren't [A-Za-z0-9_-]: Index: edit.c === RCS file: /cvs/src/bin/ksh/edit.c,v retrieving revision 1.56 diff -u -p -r1.56 edit.c --- edit.c 7 Sep 2016 04:42:31 - 1.56 +++ edit.c 8 Sep 2016 09:45:21 - @@ -584,9 +584,8 @@ x_try_array(const char *buf, int buflen, int *nwords, char ***words) { const char *cmd, *cp; - int cmdlen, n; + int cmdlen, n, i, slen; char *name, *s; - size_t slen; struct tbl *v, *vp; *nwords = 0; @@ -604,6 +603,10 @@ x_try_array(const char *buf, int buflen, cmdlen = 0; while (cmd + cmdlen < want && !isspace((u_char)cmd[cmdlen])) cmdlen++; + for (i = 0; i < cmdlen; i++) { + if (!isalnum((u_char)cmd[i]) && cmd[i] != '_' && cmd[i] != '-') + return 0; + } /* Take a stab at argument count from here. */ n = 1; On Thu, Sep 08, 2016 at 09:43:53AM +0100, Stuart Henderson wrote: > I just ran into this which was introduced with custom completions > (I haven't setup any complete_* arrays). > > $ ag "(foo)[^_]" /u > > results in > > ksh: ^_: unexpected `^' >
Re: remove /dev/sound*
On Thu, Sep 08, 2016 at 01:47:02PM +0800, Michael W. Bombardieri wrote: > Hi Alexandre, > > Do you know if any applications in ports use /dev/sound as default audio > device. > Maybe they are not smart enough to try /dev/audio if /dev/sound fails. > Hi, I'm not aware of any port using /dev/sound* or /dev/audio*; all use libsndio, which in turn uses /dev/audio* If you're aware of anything possibly using this, I'm interested.
ksh tab completion: ^_: unexpected `^'
I just ran into this which was introduced with custom completions (I haven't setup any complete_* arrays). $ ag "(foo)[^_]" /u results in ksh: ^_: unexpected `^'
Re: mg: region.c:preadin() - Also check for read() error
Haha OK florian@ On Thu, Sep 08, 2016 at 07:58:29AM +, Mark Lumsden wrote: > Source Joachim Nilsson: > > Coverity Scan found this interesting buglet. If read() fails the code, > before this patch, would trigger a "Negative array index write". > > ok? > > Index: region.c > === > RCS file: /cvs/src/usr.bin/mg/region.c,v > retrieving revision 1.36 > diff -u -p -u -p -r1.36 region.c > --- region.c 8 Sep 2016 07:50:09 - 1.36 > +++ region.c 8 Sep 2016 07:56:14 - > @@ -650,7 +650,7 @@ preadin(int fd, struct buffer *bp) > int len; > char buf[BUFSIZ], *p, *q; > > - if ((len = read(fd, buf, BUFSIZ - 1)) == 0) > + if ((len = read(fd, buf, BUFSIZ - 1)) <= 0) > return (FALSE); > > buf[len] = '\0'; > -- I'm not entirely sure you are real.
mg: region.c:preadin() - Also check for read() error
Source Joachim Nilsson: Coverity Scan found this interesting buglet. If read() fails the code, before this patch, would trigger a "Negative array index write". ok? Index: region.c === RCS file: /cvs/src/usr.bin/mg/region.c,v retrieving revision 1.36 diff -u -p -u -p -r1.36 region.c --- region.c8 Sep 2016 07:50:09 - 1.36 +++ region.c8 Sep 2016 07:56:14 - @@ -650,7 +650,7 @@ preadin(int fd, struct buffer *bp) int len; char buf[BUFSIZ], *p, *q; - if ((len = read(fd, buf, BUFSIZ - 1)) == 0) + if ((len = read(fd, buf, BUFSIZ - 1)) <= 0) return (FALSE); buf[len] = '\0';
Re: remove unreachable code from all audio drivers
On Wed, 7 Sep 2016, Alexandre Ratchov wrote: > This diff deletes unreachable code in low-level audio drivers. As > this touches all archs, tests (a quick kernel build is enough) are > welcome on anything but amd64 and i386. > > OK? Kernel builds and boots and a file recorded with aucat -o plays correctly on both loongson and macppc. Kernel builds and boots on armv7, but no audio devices to test again. Philip Guuenther
Re: remove /dev/sound*
On 2016/09/08 13:47, Michael W. Bombardieri wrote: > Hi Alexandre, > > Do you know if any applications in ports use /dev/sound as default audio > device. > Maybe they are not smart enough to try /dev/audio if /dev/sound fails. Here are search results - there are false positoves from /dev/sound/XX from Linux, and possibly others from Solaris, so needs further checking. $ ag /dev/sound ports/x11/mplayer/patches/patch-stream_tvi_bsdbt848_c 82: priv->dspdev = strdup("/dev/sound"); u/akode-2.0.2/akode-2.0.2/akode/plugins/oss_sink/oss_sink.cpp 59:"/dev/sound/dsp0", u/cmus-2.7.1/cmus-2.7.1/mixer_oss.c 131: const char *new_mixer_dev = "/dev/sound/mixer"; u/cmus-2.7.1/cmus-2.7.1/oss.c 145: const char *new_dsp_dev = "/dev/sound/dsp"; u/libao-1.2.0/libao-1.2.0/src/plugins/sun/ao_sun.c 163: sprintf(buf,"/dev/sound/%d",internal->id); u/libao-1.2.0/libao-1.2.0/src/plugins/oss/ao_oss.c 93: sprintf(buf,"/dev/sound/dsp%d",id); 97: if(!(*dev_path = strdup("/dev/sound/dsp"))) u/libmikmod-3.3.8/libmikmod-3.3.8/drivers/drv_oss.c 148: sprintf(sounddevice,"/dev/sound/dsp%d",card); 150: strcpy(sounddevice,"/dev/sound/dsp"); u/libmikmod-3.3.8/libmikmod-3.3.8/drivers/drv_sun.c 83:#define SOUNDDEVICE "/dev/sound" u/libsndfile-1.0.26/libsndfile-1.0.26/ChangeLog 5624:using devfs which used /dev/sound/dsp instead of /dev/dsp. u/libsndfile-1.0.26/libsndfile-1.0.26/programs/sndfile-play.c 437: (fd = open ("/dev/sound/dsp", O_WRONLY, 0)) == -1) u/madplay-0.15.2b/madplay-0.15.2b/audio_oss.c 77:# define AUDIO_DEVICE1"/dev/sound/dsp" u/madplay-0.15.2b/madplay-0.15.2b/CREDITS 135: - Suggested trying /dev/sound/dsp before /dev/dsp. u/mpd-0.19.15/mpd-0.19.15/src/output/plugins/OssOutputPlugin.cxx 127:static const char *default_devices[] = { "/dev/sound/dsp", "/dev/dsp" }; u/mpg123-1.23.4/mpg123-1.23.4/src/libout123/modules/oss.c 171: dev = "/dev/sound/dsp"; u/mpg321-0.3.2/mpg321-0.3.2-orig/mpg321.1 40:(or the default system device) to use for output (i.e. \fB/dev/sound/dsp1\fP). u/schismtracker-20150425/schismtracker-20150425/sys/oss/volume-oss.c 61:ptr = "/dev/sound/mixer"; u/sidplay-1.0.9/sidplay-base-1.0.9/audio/oss/audiodrv.cpp 10:const char audioDriver::AUDIODEVICE[] = "/dev/sound"; u/snack2.2.10/snack2.2.10/unix/jkAudIO_oss.c 433:defaultDeviceName = "/dev/sound/dsp"; 1000: glob("/dev/sound/dsp*", GLOB_APPEND, NULL, &globt); 1001: glob("/dev/sound/audio*", GLOB_APPEND, NULL, &globt); 1020: glob("/dev/sound/mixer*", GLOB_APPEND, NULL, &globt); u/soundtracker-0.6.8/soundtracker-0.6.8.gtk2/Makefile.am 37: cp soundtracker-$(VERSION).tar.gz /home/rawstyle/dev/soundtracker-WWW/dl/v0.6/ 39:# cp soundtracker-$(VERSION)-bin.tar.gz /home/rawstyle/dev/soundtracker-WWW/dl/v0.6/ 40: /home/rawstyle/dev/soundtracker/bin/rpm -tb soundtracker-$(VERSION).tar.gz 41: cp /usr/src/packages/RPMS/i386/soundtracker-$(VERSION)-* /home/rawstyle/dev/soundtracker-WWW/dl/v0.6/ 42: chown -R rawstyle.users /home/rawstyle/dev/soundtracker/* 43: chown -R rawstyle.users /home/rawstyle/dev/soundtracker-WWW/* u/xmms-1.2.11/xmms-1.2.11/Output/solaris/configure.c 116: gchar *devname = g_strdup_printf("/dev/sound/%d", index); u/xmp-4.0.10/xmp-4.0.10/src/sound_bsd.c 39: if ((audio_fd = open("/dev/sound", O_WRONLY)) == -1) u/xmp-4.0.10/xmp-4.0.10/src/sound_oss.c 10: * devfs /dev/sound/dsp support by Dirk Jagdmann 112: static const char *dev_audio[] = { "/dev/dsp", "/dev/sound/dsp" }; u/xmp-4.0.10/xmp-4.0.10/src/sound_netbsd.c 39: if ((audio_fd = open("/dev/sound", O_WRONLY)) == -1) u/jdk-1.7.0.80/openjdk/jdk/src/solaris/native/com/sun/media/sound/PLATFORM_API_SolarisOS_Utils.c 106:// then go through all of the /dev/sound/? devices 108:sprintf(devsound, "/dev/sound/%d", i); u/jdk-1.7.0.80/openjdk/jdk/src/solaris/native/com/sun/media/sound/PLATFORM_API_SolarisOS_Utils.c.orig.u80 106:// then go through all of the /dev/sound/? devices 108:sprintf(devsound, "/dev/sound/%d", i); u/jdk-1.8.0.72/openjdk-8u72b15-bsd-port-20160220/jdk/src/solaris/native/com/sun/media/sound/PLATFORM_API_SolarisOS_Utils.c 106:// then go through all of the /dev/sound/? devices 108:sprintf(devsound, "/dev/sound/%d", i); u/ptlib-2.12.9/ptlib-2.12.9/plugins/sound_oss/sound_oss.cxx 220: PDirectory devdir = "/dev/sound"; 222:CollectSoundDevices("/dev/sound", dsp, mixer, true); // use names (devfs) u/sdl-1.2.15/SDL-1.2.15/src/audio/SDL_audiodev.c 43:#define _PATH_DEV_DSP24 "/dev/sound/dsp" 64: /* Added support for /dev/sound/\* in Linux 2.4 */ 65: if ( ((stat("/dev/sound", &sb) == 0) && S_ISDIR(sb.st_mode)) && u/sdl2-2.0.4/SDL2-2.0.4/src/audio/SDL_audiodev.c 43:#define _PATH_DEV_DSP24 "/dev/sound/dsp" 92:/* Added support for /dev/sound/\* in Linux 2.4 */ 93:if (((stat("/dev/sound", &sb) == 0) && S_ISDIR(sb.st_mode)) u/sdl2-