Rdistd can dump core with cmdspecial
Problem - rdistd can dump core when a distfile contains cmdspecial. For example: # mkdir /tmp/rdist.demo && cd /tmp/rdist.demo # cat /root/Distfile.demo /usr/bin -> localhost install /tmp/rdist.demo/files ; cmdspecial "echo The files were: ${FILES:-*-empty-*} > DONE" ; # rdist -f /root/Distfile.demo localhost: updating host localhost ... [deleted lines] localhost: cmdspecial "echo The files were: ${FILES:-*-empty-*} > DONE" localhost: worm: REMOTE ERROR: shell returned 32512 ... [deleted lines] localhost: updating of localhost finished # ls filesrdistd.core This occurs since the buffer cmd in dospecial() [rdistd/server.c] overflows. The purpose of this buffer is to store the string 'FILES=...; " which is passed to an invocation of execl() in runcommand() [rdist/common.c]. The actual invocation is 'sh -c ', so maybe a few extra characters should get lopped off the buffer to prevent an overflow in kern/kern_exec.c... The patch (hack?) for this is simple (noting that the preconditions of strunvis() are not explicitly checked...): Index: server.c === RCS file: /cvs/src/usr.bin/rdistd/server.c,v retrieving revision 1.33 diff -u -p -r1.33 server.c --- server.c12 Jul 2014 03:10:03 -1.33 +++ server.c8 Nov 2014 02:57:37 - @@ -462,7 +462,7 @@ clean(char *cp) static void dospecial(char *xcmd) { -char cmd[BUFSIZ]; +char cmd[ARG_MAX]; if (DECODE(cmd, xcmd) == -1) { error("dospecial: Cannot decode command."); return; However, the fundamental mechanism of passing the full list of updated files via the environment variable FILES is broken - a long list of updated files will still overflow this buffer. It's not a real solution. The patch below changes the behaviour of cmdspecial in a distfile, allowing '-' to be used in the optional name list to indicate that the list of updated filenames should not be put into the FILES environment variable. This patch meets my needs, but I can see the value of having the list of updated files available (just not via the environment). If there are some good ideas and consensus on what should be done I'm willing to code them up. For example, to write the list of updated files into a temporary file and pass the name of the file via the FILELIST environemnt variable, or to pipe the contents of the file list to stdin...). Let me know and I'll do it. Index: client.c === RCS file: /cvs/src/usr.bin/rdist/client.c,v retrieving revision 1.31 diff -u -p -r1.31 client.c --- client.c12 Jul 2014 03:48:04 -1.31 +++ client.c8 Nov 2014 03:00:06 - @@ -250,17 +250,19 @@ runcmdspecial(struct cmd *cmd, opt_t opt message(MT_CHANGE, "cmdspecial \"%s\"", sc->sc_name); if (IS_ON(opts, DO_VERIFY)) continue; -/* Send all the file names */ -for (f = updfilelist; f != NULL; f = f->n_next) { -if (first) { -(void) sendcmd(C_CMDSPECIAL, NULL); +if (sc->sc_args != nofilelist) { +/* Send all the file names */ +for (f = updfilelist; f != NULL; f = f->n_next) { +if (first) { +(void) sendcmd(C_CMDSPECIAL, NULL); +if (response() < 0) +return; +first = FALSE; +} +(void) sendcmd(RC_FILE, "%s", f->n_name); if (response() < 0) return; -first = FALSE; } -(void) sendcmd(RC_FILE, "%s", f->n_name); -if (response() < 0) -return; } if (first) { (void) sendcmd(C_CMDSPECIAL, NULL); Index: defs.h === RCS file: /cvs/src/usr.bin/rdist/defs.h,v retrieving revision 1.31 diff -u -p -r1.31 defs.h --- defs.h12 Jul 2014 03:48:04 -1.31 +++ defs.h8 Nov 2014 03:00:07 - @@ -280,6 +280,7 @@ extern struct passwd *pw;/* pointer t extern char defowner[64];/* Default owner */ extern char defgroup[64];/* Default group */ extern volatile sig_atomic_t contimedout; /* Connection timed out */ +extern struct namelist *nofilelist;/* Sentinel for explicit no file list */ /* * Our own declarations. Index: docmd.c === RCS file: /cvs/src/usr.bin/rdist/docmd.c,v retrieving revision 1.31 diff -u -p -r1.31 docmd.c --- docmd.c12 Jul 2014 03:48:04 -1.31 +++ docmd.c8 Nov 2014 03:00:08 - @@ -46,6 +46,10 @@ struct namelist *filelist;/* li extern struct cmd *cmds;/* Initialized by yyparse() */ time_tlastmod;/* Last modify time */ +/* Marker for cmdspecial - don't send FILES */ +static struct namelist _sentinel = { "
Re: LibreSSL: GOWindows support
On Fri, Nov 7, 2014 at 11:07 PM, Brent Cook wrote: > >> On Nov 7, 2014, at 8:21 AM, Dongsheng Song wrote: >> >> I need some code changes for Windows support. >> e.g. >> >> --- a/src/lib/libssl/src/crypto/bio/bss_dgram.c >> +++ b/src/lib/libssl/src/crypto/bio/bss_dgram.c >> @@ -57,13 +57,17 @@ >> * >> */ >> >> +#ifdef _WIN32 >> +#include >> +#else >> #include >> -#include >> - >> #include >> +#include >> +#endif >> + >> +#include >> >> #include >> -#include >> #include >> #include >> #include > > Thanks for the first set of patches on the portable tree! > > I would think the #ifdef _WIN32 is probably the lesser of two evils. > > Hopefully this will be largely confined to bio and the openssl app? > yes, I can generate openssl.exe with my local patches. I use #ifdef _WIN32 to guard headres, socket functions, signal functions, tty functions. fork is more painful, so I defined OPENSSL_NO_SPEED. maybe I'll write a Windows version speed_main. > You'll also need to audit file descriptor usage carefully, so they > are closed properly: > Thanks.
Re: tetris(6): fix select() -> poll() conversion
On Wed, Nov 05, 2014 at 02:44:54PM -0800, patrick keshishian wrote: > On Wed, Nov 05, 2014 at 08:45:07PM +0100, Theo Buehler wrote: > > Pausing a tetris game currently causes a segfault due to a a null > > pointer dereference. > > > > Fix this by checking that s is non-NULL before accessing its members. > > > > A number of comments and an error message still refer to select() > > instead of poll(). Correct this as well. > > > > > > Index: input.c > > === > > RCS file: /cvs/src/games/tetris/input.c,v > > retrieving revision 1.13 > > diff -u -p -r1.13 input.c > > --- input.c 3 Nov 2014 22:14:54 - 1.13 > > +++ input.c 5 Nov 2014 19:39:30 - > > @@ -64,12 +64,12 @@ > > } > > > > /* > > - * Do a `read wait': select for reading from stdin, with timeout *tvp. > > + * Do a `read wait': poll for reading from stdin, with timeout *tvp. > > * On return, modify *tvp to reflect the amount of time spent waiting. > > * It will be positive only if input appeared before the time ran out; > > * otherwise it will be zero or perhaps negative. > > * > > - * If tvp is nil, wait forever, but return if select is interrupted. > > + * If tvp is nil, wait forever, but return if poll is interrupted. > > * > > * Return 0 => no input, 1 => can read() from stdin > > */ > > @@ -90,14 +90,15 @@ rwait(struct timeval *tvp) > > again: > > pfd[0].fd = STDIN_FILENO; > > pfd[0].events = POLLIN; > > - switch (poll(pfd, 1, s->tv_sec * 1000 + s->tv_usec / 1000)) { > > + switch (poll(pfd, 1, s ? s->tv_sec * 1000 + s->tv_usec / 1000 : > > > I propose getting rid of the s pointer all together as such: After replacing select() with poll(), not removing `struct timeval *s' seems an oversight; Its use was solely for select()'s benefit. Once more, proposing removal of `struct timeval *s' and using an `int timo' for the time-out value, that gets fed into poll(). It also improves readability of the code; rumors floating around that that is a good thing. Index: input.c === RCS file: /cvs/obsd/src/games/tetris/input.c,v retrieving revision 1.14 diff -u -p -u -r1.14 input.c --- input.c 5 Nov 2014 20:23:38 - 1.14 +++ input.c 7 Nov 2014 19:37:07 - @@ -76,7 +76,8 @@ int rwait(struct timeval *tvp) { - struct timeval starttv, endtv, *s; + int timo = INFTIM; + struct timeval starttv, endtv; struct pollfd pfd[1]; #defineNILTZ ((struct timezone *)0) @@ -84,15 +85,12 @@ rwait(struct timeval *tvp) if (tvp) { (void) gettimeofday(&starttv, NILTZ); endtv = *tvp; - s = &endtv; - } else - s = NULL; + timo = endtv.tv_sec * 1000 + endtv.tv_usec / 1000; + } again: pfd[0].fd = STDIN_FILENO; pfd[0].events = POLLIN; - switch (poll(pfd, 1, s ? s->tv_sec * 1000 + s->tv_usec / 1000 : - INFTIM)) { - + switch (poll(pfd, 1, timo)) { case -1: if (tvp == 0) return (-1); > > Index: input.c > === > RCS file: /cvs/obsd/src/games/tetris/input.c,v > retrieving revision 1.13 > diff -u -p -u -p -r1.13 input.c > --- input.c 3 Nov 2014 22:14:54 - 1.13 > +++ input.c 5 Nov 2014 22:40:47 - > @@ -64,19 +64,20 @@ > } > > /* > - * Do a `read wait': select for reading from stdin, with timeout *tvp. > + * Do a `read wait': poll for reading from stdin, with timeout *tvp. > * On return, modify *tvp to reflect the amount of time spent waiting. > * It will be positive only if input appeared before the time ran out; > * otherwise it will be zero or perhaps negative. > * > - * If tvp is nil, wait forever, but return if select is interrupted. > + * If tvp is nil, wait forever, but return if poll is interrupted. > * > * Return 0 => no input, 1 => can read() from stdin > */ > int > rwait(struct timeval *tvp) > { > - struct timeval starttv, endtv, *s; > + int timo = INFTIM; > + struct timeval starttv, endtv; > struct pollfd pfd[1]; > > #define NILTZ ((struct timezone *)0) > @@ -84,20 +85,19 @@ rwait(struct timeval *tvp) > if (tvp) { > (void) gettimeofday(&starttv, NILTZ); > endtv = *tvp; > - s = &endtv; > - } else > - s = NULL; > + timo = endtv.tv_sec * 1000 + endtv.tv_usec / 1000; > + } > again: > pfd[0].fd = STDIN_FILENO; > pfd[0].events = POLLIN; > - switch (poll(pfd, 1, s->tv_sec * 1000 + s->tv_usec / 1000)) { > + switch (poll(pfd, 1, timo)) { > > case -1: > if (tvp == 0) > return (-1); > if (errno == EINTR) > goto again; > - stop("select failed, help"); > +
Re: LibreSSL: GOWindows support
> On Nov 7, 2014, at 8:21 AM, Dongsheng Song wrote: > > I need some code changes for Windows support. > e.g. > > --- a/src/lib/libssl/src/crypto/bio/bss_dgram.c > +++ b/src/lib/libssl/src/crypto/bio/bss_dgram.c > @@ -57,13 +57,17 @@ > * > */ > > +#ifdef _WIN32 > +#include > +#else > #include > -#include > - > #include > +#include > +#endif > + > +#include > > #include > -#include > #include > #include > #include Thanks for the first set of patches on the portable tree! I would think the #ifdef _WIN32 is probably the lesser of two evils. Hopefully this will be largely confined to bio and the openssl app? You'll also need to audit file descriptor usage carefully, so they are closed properly: static void conn_close_socket(BIO *bio) { BIO_CONNECT *c; c = (BIO_CONNECT *)bio->ptr; if (bio->num != -1) { /* Only do a shutdown if things were established */ if (c->state == BIO_CONN_S_OK) shutdown(bio->num, SHUT_RDWR); #ifdef _WIN32 closesocket(bio->num); #else close(bio->num); #endif bio->num = -1; } } > I think the following patch is ugly: > > +#ifdef HAVE_WS2TCPIP_h > +#include > +#endif > > +#ifdef HAVE_NETDB_H > +#include > +#endif > > +#ifdef HAVE_NETINET_IN_H > +#include > +#endif > > +#ifdef HAVE_SYS_SOCKET_H > +#include > +#endif > > > Which patch format acceptable, guard _WIN32 or every header file which > not all platform have ? Or there have another approach ? >
LibreSSL: GOWindows support
I need some code changes for Windows support. e.g. --- a/src/lib/libssl/src/crypto/bio/bss_dgram.c +++ b/src/lib/libssl/src/crypto/bio/bss_dgram.c @@ -57,13 +57,17 @@ * */ +#ifdef _WIN32 +#include +#else #include -#include - #include +#include +#endif + +#include #include -#include #include #include #include I think the following patch is ugly: +#ifdef HAVE_WS2TCPIP_h +#include +#endif +#ifdef HAVE_NETDB_H +#include +#endif +#ifdef HAVE_NETINET_IN_H +#include +#endif +#ifdef HAVE_SYS_SOCKET_H +#include +#endif Which patch format acceptable, guard _WIN32 or every header file which not all platform have ? Or there have another approach ?
Re: tmux.1: V is a vi key. Use alphabetical order
whoops, applied thanks On Fri, Nov 07, 2014 at 11:09:53AM +0100, Theo Buehler wrote: > The new `select line' key 'V' in copy mode is a vi key, not an emacs > key. Move the entry from the emacs column to the vi column in the > manual. > > The table of copy mode keys is mostly sorted in alphabetical order with > a few exceptions that make some sense and a few that don't. I seems > most reasonable to me to stick to a strict alphabetical order. > > > Index: tmux.1 > === > RCS file: /cvs/src/usr.bin/tmux/tmux.1,v > retrieving revision 1.406 > diff -u -p -r1.406 tmux.1 > --- tmux.16 Nov 2014 09:17:25 - 1.406 > +++ tmux.17 Nov 2014 10:08:48 - > @@ -14,7 +14,7 @@ > .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING > .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. > .\" > -.Dd $Mdocdate: November 6 2014 $ > +.Dd $Mdocdate: November 7 2014 $ > .Dt TMUX 1 > .Os > .Sh NAME > @@ -875,10 +875,10 @@ The following keys are supported as appr > .It Sy "Function" Ta Sy "vi" Ta Sy "emacs" > .It Li "Append selection" Ta "A" Ta "" > .It Li "Back to indentation" Ta "^" Ta "M-m" > -.It Li "Copy to named buffer" Ta \&" Ta "" > .It Li "Bottom of history" Ta "G" Ta "M-<" > .It Li "Clear selection" Ta "Escape" Ta "C-g" > .It Li "Copy selection" Ta "Enter" Ta "M-w" > +.It Li "Copy to named buffer" Ta \&" Ta "" > .It Li "Cursor down" Ta "j" Ta "Down" > .It Li "Cursor left" Ta "h" Ta "Left" > .It Li "Cursor right" Ta "l" Ta "Right" > @@ -892,12 +892,12 @@ The following keys are supported as appr > .It Li "Go to line" Ta ":" Ta "g" > .It Li "Half page down" Ta "C-d" Ta "M-Down" > .It Li "Half page up" Ta "C-u" Ta "M-Up" > -.It Li "Jump forward" Ta "f" Ta "f" > -.It Li "Jump to forward" Ta "t" Ta "" > -.It Li "Jump backward" Ta "F" Ta "F" > -.It Li "Jump to backward" Ta "T" Ta "" > .It Li "Jump again" Ta ";" Ta ";" > .It Li "Jump again in reverse" Ta "," Ta "," > +.It Li "Jump backward" Ta "F" Ta "F" > +.It Li "Jump forward" Ta "f" Ta "f" > +.It Li "Jump to backward" Ta "T" Ta "" > +.It Li "Jump to forward" Ta "t" Ta "" > .It Li "Next page" Ta "C-f" Ta "Page down" > .It Li "Next space" Ta "W" Ta "" > .It Li "Next space, end of word" Ta "E" Ta "" > @@ -906,17 +906,17 @@ The following keys are supported as appr > .It Li "Other end of selection" Ta "o" Ta "" > .It Li "Paste buffer" Ta "p" Ta "C-y" > .It Li "Previous page" Ta "C-b" Ta "Page up" > -.It Li "Previous word" Ta "b" Ta "M-b" > .It Li "Previous space" Ta "B" Ta "" > +.It Li "Previous word" Ta "b" Ta "M-b" > .It Li "Quit mode" Ta "q" Ta "Escape" > .It Li "Rectangle toggle" Ta "v" Ta "R" > .It Li "Scroll down" Ta "C-Down or C-e" Ta "C-Down" > .It Li "Scroll up" Ta "C-Up or C-y" Ta "C-Up" > -.It Li "Select line" Ta "" Ta "V" > .It Li "Search again" Ta "n" Ta "n" > .It Li "Search again in reverse" Ta "N" Ta "N" > .It Li "Search backward" Ta "?" Ta "C-r" > .It Li "Search forward" Ta "/" Ta "C-s" > +.It Li "Select line" Ta "V" Ta "" > .It Li "Start of line" Ta "0" Ta "C-a" > .It Li "Start selection" Ta "Space" Ta "C-Space" > .It Li "Top of history" Ta "g" Ta "M->" >
tmux.1: V is a vi key. Use alphabetical order
The new `select line' key 'V' in copy mode is a vi key, not an emacs key. Move the entry from the emacs column to the vi column in the manual. The table of copy mode keys is mostly sorted in alphabetical order with a few exceptions that make some sense and a few that don't. I seems most reasonable to me to stick to a strict alphabetical order. Index: tmux.1 === RCS file: /cvs/src/usr.bin/tmux/tmux.1,v retrieving revision 1.406 diff -u -p -r1.406 tmux.1 --- tmux.1 6 Nov 2014 09:17:25 - 1.406 +++ tmux.1 7 Nov 2014 10:08:48 - @@ -14,7 +14,7 @@ .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: November 6 2014 $ +.Dd $Mdocdate: November 7 2014 $ .Dt TMUX 1 .Os .Sh NAME @@ -875,10 +875,10 @@ The following keys are supported as appr .It Sy "Function" Ta Sy "vi" Ta Sy "emacs" .It Li "Append selection" Ta "A" Ta "" .It Li "Back to indentation" Ta "^" Ta "M-m" -.It Li "Copy to named buffer" Ta \&" Ta "" .It Li "Bottom of history" Ta "G" Ta "M-<" .It Li "Clear selection" Ta "Escape" Ta "C-g" .It Li "Copy selection" Ta "Enter" Ta "M-w" +.It Li "Copy to named buffer" Ta \&" Ta "" .It Li "Cursor down" Ta "j" Ta "Down" .It Li "Cursor left" Ta "h" Ta "Left" .It Li "Cursor right" Ta "l" Ta "Right" @@ -892,12 +892,12 @@ The following keys are supported as appr .It Li "Go to line" Ta ":" Ta "g" .It Li "Half page down" Ta "C-d" Ta "M-Down" .It Li "Half page up" Ta "C-u" Ta "M-Up" -.It Li "Jump forward" Ta "f" Ta "f" -.It Li "Jump to forward" Ta "t" Ta "" -.It Li "Jump backward" Ta "F" Ta "F" -.It Li "Jump to backward" Ta "T" Ta "" .It Li "Jump again" Ta ";" Ta ";" .It Li "Jump again in reverse" Ta "," Ta "," +.It Li "Jump backward" Ta "F" Ta "F" +.It Li "Jump forward" Ta "f" Ta "f" +.It Li "Jump to backward" Ta "T" Ta "" +.It Li "Jump to forward" Ta "t" Ta "" .It Li "Next page" Ta "C-f" Ta "Page down" .It Li "Next space" Ta "W" Ta "" .It Li "Next space, end of word" Ta "E" Ta "" @@ -906,17 +906,17 @@ The following keys are supported as appr .It Li "Other end of selection" Ta "o" Ta "" .It Li "Paste buffer" Ta "p" Ta "C-y" .It Li "Previous page" Ta "C-b" Ta "Page up" -.It Li "Previous word" Ta "b" Ta "M-b" .It Li "Previous space" Ta "B" Ta "" +.It Li "Previous word" Ta "b" Ta "M-b" .It Li "Quit mode" Ta "q" Ta "Escape" .It Li "Rectangle toggle" Ta "v" Ta "R" .It Li "Scroll down" Ta "C-Down or C-e" Ta "C-Down" .It Li "Scroll up" Ta "C-Up or C-y" Ta "C-Up" -.It Li "Select line" Ta "" Ta "V" .It Li "Search again" Ta "n" Ta "n" .It Li "Search again in reverse" Ta "N" Ta "N" .It Li "Search backward" Ta "?" Ta "C-r" .It Li "Search forward" Ta "/" Ta "C-s" +.It Li "Select line" Ta "V" Ta "" .It Li "Start of line" Ta "0" Ta "C-a" .It Li "Start selection" Ta "Space" Ta "C-Space" .It Li "Top of history" Ta "g" Ta "M->"