Update Term::ReadKey to 2.38
In order to better support the pkg tools we include Term::ReadKey with the base system, that means I totally forgot about it. So, this picks up a few years of updates. This patch updates the 2.33 we have in-tree to the current 2.38. https://metacpan.org/changes/distribution/TermReadKey Comments? OK? Index: gnu/usr.bin/perl/MANIFEST === RCS file: /cvs/src/gnu/usr.bin/perl/MANIFEST,v retrieving revision 1.56 diff -u -p -r1.56 MANIFEST --- gnu/usr.bin/perl/MANIFEST 30 Dec 2019 02:16:39 - 1.56 +++ gnu/usr.bin/perl/MANIFEST 25 Feb 2020 01:27:42 - @@ -2024,8 +2024,8 @@ cpan/Term-ReadKey/example/test.pl Term: cpan/Term-ReadKey/genchars.pl Term::ReadKey cpan/Term-ReadKey/Makefile.PL Term::ReadKey cpan/Term-ReadKey/ppport.h Term::ReadKey -cpan/Term-ReadKey/ReadKey.pm Term::ReadKey cpan/Term-ReadKey/ReadKey.xs Term::ReadKey +cpan/Term-ReadKey/ReadKey.pm.PLTerm::ReadKey cpan/Term-ReadKey/README Term::ReadKey cpan/Term-ReadKey/t/01_basic.t Term::ReadKey cpan/Term-ReadKey/t/02_terminal_functions.tTerm::ReadKey Index: gnu/usr.bin/perl/cpan/Term-ReadKey/Changes === RCS file: /cvs/src/gnu/usr.bin/perl/cpan/Term-ReadKey/Changes,v retrieving revision 1.1.1.1 diff -u -p -r1.1.1.1 Changes --- gnu/usr.bin/perl/cpan/Term-ReadKey/Changes 7 May 2016 16:03:09 - 1.1.1.1 +++ gnu/usr.bin/perl/cpan/Term-ReadKey/Changes 25 Feb 2020 01:27:42 - @@ -1,240 +1,123 @@ -2015-06-04 Jonathan Stowe +2.38- 2019-01-05 + * Bundle up various changes including: + * Indexing improvements + * Makefile improvements for some make utils + * Various code cleanups and modernizations - * .gitignore, Changes, META.yml, README, ReadKey.pm: Up version +2.37- 2016-10-07 -2015-06-04 Jonathan Stowe + * Make minimum version of ExtUtils::MakeMaker 6.58 + * Better support parallel builds by making 'dynamic' a dependency of the ReadKey.pm + * Add a 'provides' META section to help indexing - * .gitignore: Add .bs file to .gitignore +2.36- 2016-10-07 -2015-06-04 Jonathan Stowe + * Add a package declaration to the ReadKey_pm.PL to aid indexing - * : Merge pull request #6 from ntyni/master Make genchars.pl output reproducible by sorting hash keys +2.35- 2016-10-06 -2015-04-30 Jonathan Stowe + * Use FULLPERLRUNINST to run the ReadKey_pm.PL to get the 'blib' - * Makefile.PL: Fix for "[rt.cpan.org #100932] Parallel build fails" - from Petr Pisar +2.34- 2016-10-06 -2015-04-30 Jonathan Stowe + * Fix GetTerminalSize() argument handling + * Fix miniperl build on Win32 + * Remove unused Cwd + * Fix TAP output + * Fix warnings in XS file + * Don't attempt some tests if STDIN is not a terminal + * Generate ReadKey.pm from ReadKey_pm.PL to expand blockoptions + * demand-load Carp, + * remove unneeded AutoLoader, + * Improve genchars.pl, support make -s silence. + * Improve Makefile.PL add SIGN, fix pure_site_install, support dual-life, fix realclean - * MANIFEST.SKIP: Add .git directory to the MANIFEST.SKIP +2.33- 2015-06-04 -2015-04-13 Jonathan Stowe + * Make genchars.pl output reproducible by sorting hash keys + * Fix for "[rt.cpan.org #100932] Parallel build fails" from Petr Pisar + * Move tests to t directory from Sébastien Deseille + * Move original test to example directory + * Don't use 'resize' or 'stty' on MS Windows - * MANIFEST, MANIFEST.SKIP: Add new artefacts - -2015-04-13 Jonathan Stowe - - * .travis.yml: Add travis-ci testing - -2015-04-13 Jonathan Stowe - - * .gitignore: Add .gitignore - -2015-04-13 Jonathan Stowe - - * : Merge pull request #5 from - sdeseille/Create_T_directory_and_split_test.pl Create t directory and split test.pl - -2015-04-11 Sébastien Deseille - - * README: Update README to reflect the move of test.pl in example - subdirectory - -2015-04-11 Sébastien Deseille - - * README: Revert "Update README to reflect the move of test.pl in - example subdirectory" This reverts commit 09402dcd68d8d0417e0eb2f9ea0aeaf4b4c72e9a. - -2015-04-11 Sébastien Deseille - - * README: Update README to reflect the move of test.pl in example - subdirectory - -2015-04-11 Sébastien Deseille - - * example/test.pl, test.pl: Move test.pl in example's subdirectory - in order to keep the possibility to use its interactive mode - -2015-04-11 Sébastien Deseille - - * t/02_terminal_functions.t: Finished to implement all tests from - test.pl - -2015-04-11 Sébastien Deseille - -
Re: [patch] smtpd: fix for ctype casts
I am much happier with the [] array derefs. I surprised this snuck in, time for a ctype re-audit of the entire tree
Re: [patch] smtpd: fix for ctype casts
> On 24. Feb 2020, at 20:31, Todd C. Miller wrote: > > I have a mostly-identical patch in my tree, though I tried to improve > readability a bit. ok jung@ > - todd > > Index: usr.sbin/smtpd/mta_session.c > === > RCS file: /cvs/src/usr.sbin/smtpd/mta_session.c,v > retrieving revision 1.132 > diff -u -p -u -r1.132 mta_session.c > --- usr.sbin/smtpd/mta_session.c 24 Feb 2020 16:16:07 - 1.132 > +++ usr.sbin/smtpd/mta_session.c 24 Feb 2020 18:19:22 - > @@ -1295,13 +1295,12 @@ mta_io(struct io *io, int evt, void *arg > if (s->replybuf[0] == '\0') > (void)strlcat(s->replybuf, line, sizeof > s->replybuf); > else if (len > 4) { > - line = line + 4; > - if (isdigit((int)*line) && *(line + 1) == '.' && > - isdigit((int)*line+2) && *(line + 3) == '.' > && > - isdigit((int)*line+4) && > isspace((int)*(line + 5))) > - (void)strlcat(s->replybuf, line+5, > sizeof s->replybuf); > - else > - (void)strlcat(s->replybuf, line, sizeof > s->replybuf); > + p = line + 4; > + if (isdigit((unsigned char)p[0]) && p[1] == '.' > && > + isdigit((unsigned char)p[2]) && p[3] == '.' > && > + isdigit((unsigned char)p[4]) && > isspace((unsigned char)p[5])) > + p += 5; > + (void)strlcat(s->replybuf, p, sizeof > s->replybuf); > } > goto nextline; > } > @@ -1313,9 +1312,9 @@ mta_io(struct io *io, int evt, void *arg > (void)strlcat(s->replybuf, line, sizeof s->replybuf); > else if (len > 4) { > p = line + 4; > - if (isdigit((int)*p) && *(p + 1) == '.' && > - isdigit((int)*p+2) && *(p + 3) == '.' && > - isdigit((int)*p+4) && isspace((int)*(p + 5))) > + if (isdigit((unsigned char)p[0]) && p[1] == '.' && > + isdigit((unsigned char)p[2]) && p[3] == '.' && > + isdigit((unsigned char)p[4]) && isspace((unsigned > char)p[5])) > p += 5; > if (strlcat(s->replybuf, p, sizeof s->replybuf) >= > sizeof s->replybuf) > (void)strlcpy(s->replybuf, line, sizeof > s->replybuf); > Index: usr.sbin/smtpd/parse.y > === > RCS file: /cvs/src/usr.sbin/smtpd/parse.y,v > retrieving revision 1.276 > diff -u -p -u -r1.276 parse.y > --- usr.sbin/smtpd/parse.y3 Feb 2020 15:41:22 - 1.276 > +++ usr.sbin/smtpd/parse.y24 Feb 2020 18:19:51 - > @@ -529,7 +529,7 @@ SMTP LIMIT limits_smtp > free($3); > YYERROR; > } > - if (isspace((int)*$3) || !isprint((int)*$3) || *$3== '@') { > + if (isspace((unsigned char)*$3) || !isprint((unsigned char)*$3) || *$3 > == '@') { > yyerror("sub-addr-delim uses invalid character"); > free($3); > YYERROR; > Index: usr.sbin/smtpd/smtp_client.c > === > RCS file: /cvs/src/usr.sbin/smtpd/smtp_client.c,v > retrieving revision 1.12 > diff -u -p -u -r1.12 smtp_client.c > --- usr.sbin/smtpd/smtp_client.c 10 Sep 2019 12:08:26 - 1.12 > +++ usr.sbin/smtpd/smtp_client.c 24 Feb 2020 18:21:43 - > @@ -779,9 +779,10 @@ smtp_client_replycat(struct smtp_client > line += 3; > if (line[0]) { > line += 1; > - if (isdigit((int)line[0]) && line[1] == '.' && > - isdigit((int)line[2]) && line[3] == '.' && > - isdigit((int)line[4]) && isspace((int)line[5])) > + if (isdigit((unsigned char)line[0]) && line[1] == '.' && > + isdigit((unsigned char)line[2]) && line[3] == '.' && > + isdigit((unsigned char)line[4]) && > + isspace((unsigned char)line[5])) > line += 5; > } > } else > Index: usr.sbin/smtpd/util.c > === > RCS file: /cvs/src/usr.sbin/smtpd/util.c,v > retrieving revision 1.150 > diff -u -p -u -r1.150 util.c > --- usr.sbin/smtpd/util.c 3 Oct 2019 04:49:12 - 1.150 > +++ usr.sbin/smtpd/util.c 24 Feb 2020 19:17:12 - > @@ -462,7 +462,7 @@ valid_domainpart(const char *s) >
Re: librthread sem_t opaqueness, storage & unnamed semaphore sharing
Martin Pieuchot wrote: > On 24/02/20(Mon) 11:29, Lauri Tirkkonen wrote: > > On Mon, Feb 24 2020 10:24:53 +0100, Martin Pieuchot wrote: > > > On 23/02/20(Sun) 14:48, Lauri Tirkkonen wrote: > > > > I was working on a make jobserver implementation that uses POSIX > > > > semaphores as job tokens instead of a complicated socket-based approach. > > > > Initially I used named semaphores, which work fine, except if child > > > > processes with less privileges need to also open the named semaphore > > > > (eg. 'make build' as root executing 'su build -c make'). For that reason > > > > I wanted to use an unnamed semaphore (sem_init()) which is stored in shm > > > > -- that way I could leave the shm fd open and pass it to children. > > > > > > > > But unfortunately, sem_t is currently just a pointer to the opaque > > > > struct __sem, and sem_int() always calloc()s the storage for the struct. > > > > > > That's by design. > > > > Ok - could you elaborate what the design is? > > If the size of a descriptor change, because some fields are added and/or > removed, it doesn't matter for the application because it only manipulates > pointers. That means we can change the data types without creating an ABI > break. I think we are approaching the point where we can settle on fixed sized types now. If we want to be cautious, we can add a reserved padding field, too. But there are some edge cases which I think can be removed by eliminating the dynamic allocation paths. > > See the followup patch -- sharing the semaphore between processes does > > work with it. > > Well ignoring the `pshared' argument is questionable. Why don't you > remove the "#if notyet" and start playing with the existing code and > try to figure out if something is missing for your use case? I'm not sure the code in notyet will work. It was based on a misunderstanding I had of the requirements. Returning control of the sem_t placement to the application is the right approach.
Re: ieee80211: handle SIOCSIFLLADDR in ifioctl()
On Mon, Feb 24, 2020 at 07:54:09PM +0100, Tobias Heider wrote: > Hi, > > I noticed that my iwm(4) device does not send RTM_IFINFO messages > when the lladdr is changed with ifconfig. > For other interface types ifioctl() handles the lladdr change in > if_setlladdr() and ifnewlladdr(). > I attached a diff that seems to fix this. > > Is there a specific reason IFT_IEEE80211 is not in the list of > if_types handled in ifioctl()? I don't think IFT_IEEE80211 is actually used. Aren't wifi interfaces IFT_ETHER? > Index: if.c > === > RCS file: /cvs/src/sys/net/if.c,v > retrieving revision 1.600 > diff -u -p -r1.600 if.c > --- if.c 24 Jan 2020 05:14:51 - 1.600 > +++ if.c 24 Feb 2020 18:50:28 - > @@ -2189,6 +2189,7 @@ ifioctl(struct socket *so, u_long cmd, c > case IFT_CARP: > case IFT_XETHER: > case IFT_ISO88025: > + case IFT_IEEE80211: > error = (*ifp->if_ioctl)(ifp, cmd, data); > if (error == ENOTTY) > error = 0; > >
Re: [patch] smtpd: fix for ctype casts
I have a mostly-identical patch in my tree, though I tried to improve readability a bit. - todd Index: usr.sbin/smtpd/mta_session.c === RCS file: /cvs/src/usr.sbin/smtpd/mta_session.c,v retrieving revision 1.132 diff -u -p -u -r1.132 mta_session.c --- usr.sbin/smtpd/mta_session.c24 Feb 2020 16:16:07 - 1.132 +++ usr.sbin/smtpd/mta_session.c24 Feb 2020 18:19:22 - @@ -1295,13 +1295,12 @@ mta_io(struct io *io, int evt, void *arg if (s->replybuf[0] == '\0') (void)strlcat(s->replybuf, line, sizeof s->replybuf); else if (len > 4) { - line = line + 4; - if (isdigit((int)*line) && *(line + 1) == '.' && - isdigit((int)*line+2) && *(line + 3) == '.' && - isdigit((int)*line+4) && isspace((int)*(line + 5))) - (void)strlcat(s->replybuf, line+5, sizeof s->replybuf); - else - (void)strlcat(s->replybuf, line, sizeof s->replybuf); + p = line + 4; + if (isdigit((unsigned char)p[0]) && p[1] == '.' && + isdigit((unsigned char)p[2]) && p[3] == '.' && + isdigit((unsigned char)p[4]) && isspace((unsigned char)p[5])) + p += 5; + (void)strlcat(s->replybuf, p, sizeof s->replybuf); } goto nextline; } @@ -1313,9 +1312,9 @@ mta_io(struct io *io, int evt, void *arg (void)strlcat(s->replybuf, line, sizeof s->replybuf); else if (len > 4) { p = line + 4; - if (isdigit((int)*p) && *(p + 1) == '.' && - isdigit((int)*p+2) && *(p + 3) == '.' && - isdigit((int)*p+4) && isspace((int)*(p + 5))) + if (isdigit((unsigned char)p[0]) && p[1] == '.' && + isdigit((unsigned char)p[2]) && p[3] == '.' && + isdigit((unsigned char)p[4]) && isspace((unsigned char)p[5])) p += 5; if (strlcat(s->replybuf, p, sizeof s->replybuf) >= sizeof s->replybuf) (void)strlcpy(s->replybuf, line, sizeof s->replybuf); Index: usr.sbin/smtpd/parse.y === RCS file: /cvs/src/usr.sbin/smtpd/parse.y,v retrieving revision 1.276 diff -u -p -u -r1.276 parse.y --- usr.sbin/smtpd/parse.y 3 Feb 2020 15:41:22 - 1.276 +++ usr.sbin/smtpd/parse.y 24 Feb 2020 18:19:51 - @@ -529,7 +529,7 @@ SMTP LIMIT limits_smtp free($3); YYERROR; } - if (isspace((int)*$3) || !isprint((int)*$3) || *$3== '@') { + if (isspace((unsigned char)*$3) || !isprint((unsigned char)*$3) || *$3 == '@') { yyerror("sub-addr-delim uses invalid character"); free($3); YYERROR; Index: usr.sbin/smtpd/smtp_client.c === RCS file: /cvs/src/usr.sbin/smtpd/smtp_client.c,v retrieving revision 1.12 diff -u -p -u -r1.12 smtp_client.c --- usr.sbin/smtpd/smtp_client.c10 Sep 2019 12:08:26 - 1.12 +++ usr.sbin/smtpd/smtp_client.c24 Feb 2020 18:21:43 - @@ -779,9 +779,10 @@ smtp_client_replycat(struct smtp_client line += 3; if (line[0]) { line += 1; - if (isdigit((int)line[0]) && line[1] == '.' && - isdigit((int)line[2]) && line[3] == '.' && - isdigit((int)line[4]) && isspace((int)line[5])) + if (isdigit((unsigned char)line[0]) && line[1] == '.' && + isdigit((unsigned char)line[2]) && line[3] == '.' && + isdigit((unsigned char)line[4]) && + isspace((unsigned char)line[5])) line += 5; } } else Index: usr.sbin/smtpd/util.c === RCS file: /cvs/src/usr.sbin/smtpd/util.c,v retrieving revision 1.150 diff -u -p -u -r1.150 util.c --- usr.sbin/smtpd/util.c 3 Oct 2019 04:49:12 - 1.150 +++ usr.sbin/smtpd/util.c 24 Feb 2020 19:17:12 - @@ -462,7 +462,7 @@ valid_domainpart(const char *s) if (strlcpy(domain, p, sizeof domain) >= sizeof domain) return 0; - c = strchr(domain, (int)']'); +
ieee80211: handle SIOCSIFLLADDR in ifioctl()
Hi, I noticed that my iwm(4) device does not send RTM_IFINFO messages when the lladdr is changed with ifconfig. For other interface types ifioctl() handles the lladdr change in if_setlladdr() and ifnewlladdr(). I attached a diff that seems to fix this. Is there a specific reason IFT_IEEE80211 is not in the list of if_types handled in ifioctl()? Index: if.c === RCS file: /cvs/src/sys/net/if.c,v retrieving revision 1.600 diff -u -p -r1.600 if.c --- if.c24 Jan 2020 05:14:51 - 1.600 +++ if.c24 Feb 2020 18:50:28 - @@ -2189,6 +2189,7 @@ ifioctl(struct socket *so, u_long cmd, c case IFT_CARP: case IFT_XETHER: case IFT_ISO88025: + case IFT_IEEE80211: error = (*ifp->if_ioctl)(ifp, cmd, data); if (error == ENOTTY) error = 0;
fix ifconfig join with invalid hex -> join ""
This command: # ifconfig iwm0 join 0x61626163a ifconfig: bad hexadecimal digits ends up adding "" to the joinlist, i.e. it has the same effect as ifconfig iwm0 join "" This happens because A_JOIN gets set even on invalid input. setifjoin sets this flag after validating input, but we also ask ifconfig's generic command machinery to set it, which causes this bug. ok? diff c20bd74017ceeadb2db0f78a352ed1f1e2b77c2b /usr/src blob - e1dc9dbb07bf109c3ec7f5fd4d851a7dbb5692f1 file + sbin/ifconfig/ifconfig.c --- sbin/ifconfig/ifconfig.c +++ sbin/ifconfig/ifconfig.c @@ -400,7 +400,7 @@ const structcmd { { "mtu",NEXTARG,0, setifmtu }, { "nwid", NEXTARG,0, setifnwid }, { "-nwid", -1, 0, setifnwid }, - { "join", NEXTARG,A_JOIN, setifjoin }, + { "join", NEXTARG,0, setifjoin }, { "-join", NEXTARG,0, delifjoin }, { "joinlist", NEXTARG0, 0, showjoin }, { "-joinlist", -1, 0, delifjoinlist },
simplify ifconfig's len_string and print_string
These functions will compute the wrong display width for input which is already a hex string. This bug doesn't trigger because we never actually pass an ASCII hex string in, but it is still a bug. ASCII hex strings are printable ASCII, so there's no reason to have a special case for them. This special case for "0x" was added in r1.60 of ifconfig.c ("Add support for nwkey and powersave; from NetBSD") by millert. At that time, the print_string function did not compute a length, and ifconfig was still using print_string to print WEP keys to stdout, which seems to be why the check for "0x" existed. WEP keys could be either printable ASCII or ASCII hex. Later on, phessler and I copied the same check to len_string which is based on print_string. We don't print keys nowadays, and these functions are used only to print binary data SSIDs (ASCII hex is an output, never an input). So we can simplify this. ok? diff c20bd74017ceeadb2db0f78a352ed1f1e2b77c2b /usr/src blob - e1dc9dbb07bf109c3ec7f5fd4d851a7dbb5692f1 file + sbin/ifconfig/ifconfig.c --- sbin/ifconfig/ifconfig.c +++ sbin/ifconfig/ifconfig.c @@ -1681,16 +1681,13 @@ get_string(const char *val, const char *sep, u_int8_t int len_string(const u_int8_t *buf, int len) { - int i = 0, hasspc = 0; + int i, hasspc = 0; - if (len < 2 || buf[0] != '0' || tolower(buf[1]) != 'x') { - for (; i < len; i++) { - /* Only print 7-bit ASCII keys */ - if (buf[i] & 0x80 || !isprint(buf[i])) - break; - if (isspace(buf[i])) - hasspc++; - } + for (i = 0; i < len; i++) { + if (buf[i] & 0x80 || !isprint(buf[i])) + break; + if (isspace(buf[i])) + hasspc++; } if (i == len) { if (hasspc || len == 0) @@ -1704,16 +1701,14 @@ len_string(const u_int8_t *buf, int len) int print_string(const u_int8_t *buf, int len) { - int i = 0, hasspc = 0; + int i, hasspc = 0; - if (len < 2 || buf[0] != '0' || tolower(buf[1]) != 'x') { - for (; i < len; i++) { - /* Only print 7-bit ASCII keys */ - if (buf[i] & 0x80 || !isprint(buf[i])) - break; - if (isspace(buf[i])) - hasspc++; - } + for (i = 0; i < len; i++) { + /* Only print 7-bit ASCII printable characters. */ + if (buf[i] & 0x80 || !isprint(buf[i])) + break; + if (isspace(buf[i])) + hasspc++; } if (i == len) { if (hasspc || len == 0) {
Re: librthread sem_t opaqueness, storage & unnamed semaphore sharing
On Mon, Feb 24 2020 10:42:22 +0100, Martin Pieuchot wrote: > > Yes, that's what I'm trying to do. Yes, I've seen the current > > implementation -- that's why I started this thread, in an attempt to > > make them supported. :) > > > > See the followup patch -- sharing the semaphore between processes does > > work with it. > > Well ignoring the `pshared' argument is questionable. It does feel strange, but a fully userspace implementation of semaphores (ie. using only mmap MAP_SHARED files for communication with other thread/processes) doesn't really have a meaningful distinction whether sharing happens between threads or processes. The other semaphore implementations I glanced at all had some kind of 'kernel semaphore'. I suppose a userspace implementation like this could store the pid of the process allowed to access the semaphore in struct __sem if pshared=0, and check that on every access, but I'm honestly not sure what value it brings for a userspace library to essentially prevent access to userspace memory if the application went through the effort to share that memory between processes anyway. -- Lauri Tirkkonen | lotheac @ IRCnet
Re: librthread sem_t opaqueness, storage & unnamed semaphore sharing
On Mon, Feb 24 2020 10:42:22 +0100, Martin Pieuchot wrote: > On 24/02/20(Mon) 11:29, Lauri Tirkkonen wrote: > > On Mon, Feb 24 2020 10:24:53 +0100, Martin Pieuchot wrote: > > > On 23/02/20(Sun) 14:48, Lauri Tirkkonen wrote: > > > > I was working on a make jobserver implementation that uses POSIX > > > > semaphores as job tokens instead of a complicated socket-based approach. > > > > Initially I used named semaphores, which work fine, except if child > > > > processes with less privileges need to also open the named semaphore > > > > (eg. 'make build' as root executing 'su build -c make'). For that reason > > > > I wanted to use an unnamed semaphore (sem_init()) which is stored in shm > > > > -- that way I could leave the shm fd open and pass it to children. > > > > > > > > But unfortunately, sem_t is currently just a pointer to the opaque > > > > struct __sem, and sem_int() always calloc()s the storage for the struct. > > > > > > That's by design. > > > > Ok - could you elaborate what the design is? > > If the size of a descriptor change, because some fields are added and/or > removed, it doesn't matter for the application because it only manipulates > pointers. That means we can change the data types without creating an ABI > break. I understand this, that's why I bumped the major and build-tested it. What I don't understand is how an application could ever share a semaphore with another process without sharing the userspace structure that contains the important bits. As I mentioned, NetBSD works around that in the pshared case by stuffing a kernel semaphore identifier into the sem_t* returned by sem_init -- essentially, that identifier becomes the only important bit and no storage is allocated, but from the application point of view, sem_t must still be shared with another process through shm otherwise (only now it's only a pointer that is used to hold an integer value). > > > > This means the application cannot control where unnamed semaphores are > > > > stored, so I can't put it in shm. > > > > > > Are you trying to use semaphore shared between process? Did you called > > > sem_init() with pshared=1? Have you seen that the current implementation > > > doesn't support them? > > > > Yes, that's what I'm trying to do. Yes, I've seen the current > > implementation -- that's why I started this thread, in an attempt to > > make them supported. :) > > > > See the followup patch -- sharing the semaphore between processes does > > work with it. > > Well ignoring the `pshared' argument is questionable. Why don't you > remove the "#if notyet" and start playing with the existing code and > try to figure out if something is missing for your use case? I did read the existing code behind the #ifdef notyet, and even found a commit from 2013 disabling the code (by adding the #ifdef) "until it really works". It seems to me that time has not come. I don't understand how the pshared case under #ifdef notyet was even supposed to work. It seems to just turn an unnamed semaphore into a randomly-named semaphore, but provides no way for the application to share it with another process; if the application puts sem_t in shm, only a pointer is now in shm -- the struct __sem is not. Named semaphores at least can be opened by other processes if they know the name, but randomly-named semaphores that are unlinked after creation can certainly not. -- Lauri Tirkkonen | lotheac @ IRCnet
Re: ifconfig with UTF-8 nwid
On Sun, Feb 23, 2020 at 04:19:39PM -0800, Andrew Hewus Fresh wrote: > This removes any characters that are not marked as "printable", which I > expect is what folks want. Still doesn't always help since I still > haven't figured out font fallback in xterm so some chars don't exist in > my current font. We do have some fonts that cover large chunks of Unicode, but there will always be code points which lack glyphs. That's a general UTF-8 issue which applies to any application, not just this case. The placeholder glyphs (which usually display the code point value) won't do any harm.
Re: librthread sem_t opaqueness, storage & unnamed semaphore sharing
On 24/02/20(Mon) 11:29, Lauri Tirkkonen wrote: > On Mon, Feb 24 2020 10:24:53 +0100, Martin Pieuchot wrote: > > On 23/02/20(Sun) 14:48, Lauri Tirkkonen wrote: > > > I was working on a make jobserver implementation that uses POSIX > > > semaphores as job tokens instead of a complicated socket-based approach. > > > Initially I used named semaphores, which work fine, except if child > > > processes with less privileges need to also open the named semaphore > > > (eg. 'make build' as root executing 'su build -c make'). For that reason > > > I wanted to use an unnamed semaphore (sem_init()) which is stored in shm > > > -- that way I could leave the shm fd open and pass it to children. > > > > > > But unfortunately, sem_t is currently just a pointer to the opaque > > > struct __sem, and sem_int() always calloc()s the storage for the struct. > > > > That's by design. > > Ok - could you elaborate what the design is? If the size of a descriptor change, because some fields are added and/or removed, it doesn't matter for the application because it only manipulates pointers. That means we can change the data types without creating an ABI break. > > > This means the application cannot control where unnamed semaphores are > > > stored, so I can't put it in shm. > > > > Are you trying to use semaphore shared between process? Did you called > > sem_init() with pshared=1? Have you seen that the current implementation > > doesn't support them? > > Yes, that's what I'm trying to do. Yes, I've seen the current > implementation -- that's why I started this thread, in an attempt to > make them supported. :) > > See the followup patch -- sharing the semaphore between processes does > work with it. Well ignoring the `pshared' argument is questionable. Why don't you remove the "#if notyet" and start playing with the existing code and try to figure out if something is missing for your use case?
Re: Audio control API, part 1: libsndio, sndiod bits
On Thu, Feb 13, 2020 at 05:15:34AM +, Raf Czlonka wrote: > On Sun, Feb 09, 2020 at 12:13:02PM GMT, Alexandre Ratchov wrote: > > +++ lib/libsndio/sioctl_aucat.c 8 Feb 2020 14:49:37 - > > [...] > > + * Copyright (c) 2010-2011 Alexandre Ratchov > > > > [...] > > > > +++ lib/libsndio/sioctl_open.3 8 Feb 2020 14:49:37 - > > [...] > > +.\" Copyright (c) 2011 Alexandre Ratchov > > > > [...] > > > > +++ lib/libsndio/sioctl_priv.h 8 Feb 2020 14:49:38 - > > [...] > > + * Copyright (c) 2008 Alexandre Ratchov > > > > [...] > > > > +++ lib/libsndio/sioctl_sun.c 8 Feb 2020 14:49:38 - > > [...] > > + * Copyright (c) 2010-2011 Alexandre Ratchov > > > > [...] > > > > +++ lib/libsndio/sioctl.c 8 Feb 2020 14:49:37 - > > [...] > > + * Copyright (c) 2008 Alexandre Ratchov > > > > [...] > > > > +++ usr.bin/sndioctl/sndioctl.1 9 Feb 2020 11:05:02 - > > [...] > > +.\" Copyright (c) 2007 Alexandre Ratchov > > > > [...] > > > > +++ usr.bin/sndioctl/sndioctl.c 9 Feb 2020 11:05:02 - > > [...] > > + * Copyright (c) 2007-2011 Alexandre Ratchov > > > > [...] > > > > +++ usr.bin/sndiod/dev_sioctl.c 8 Feb 2020 14:49:38 - > > [...] > > + * Copyright (c) 2014 Alexandre Ratchov > > > > [...] > > > > +++ usr.bin/sndiod/dev_sioctl.h 8 Feb 2020 14:49:38 - > > [...] > > + * Copyright (c) 2014 Alexandre Ratchov > > > > [...] > > > > Hi Alexandre, > > Shouldn't all of these dates be adjusted? > Sure; added 2020 as copyright year. Thanks.
Re: librthread sem_t opaqueness, storage & unnamed semaphore sharing
On Mon, Feb 24 2020 10:24:53 +0100, Martin Pieuchot wrote: > On 23/02/20(Sun) 14:48, Lauri Tirkkonen wrote: > > I was working on a make jobserver implementation that uses POSIX > > semaphores as job tokens instead of a complicated socket-based approach. > > Initially I used named semaphores, which work fine, except if child > > processes with less privileges need to also open the named semaphore > > (eg. 'make build' as root executing 'su build -c make'). For that reason > > I wanted to use an unnamed semaphore (sem_init()) which is stored in shm > > -- that way I could leave the shm fd open and pass it to children. > > > > But unfortunately, sem_t is currently just a pointer to the opaque > > struct __sem, and sem_int() always calloc()s the storage for the struct. > > That's by design. Ok - could you elaborate what the design is? > > This means the application cannot control where unnamed semaphores are > > stored, so I can't put it in shm. > > Are you trying to use semaphore shared between process? Did you called > sem_init() with pshared=1? Have you seen that the current implementation > doesn't support them? Yes, that's what I'm trying to do. Yes, I've seen the current implementation -- that's why I started this thread, in an attempt to make them supported. :) See the followup patch -- sharing the semaphore between processes does work with it. -- Lauri Tirkkonen | lotheac @ IRCnet
Re: librthread sem_t opaqueness, storage & unnamed semaphore sharing
On 23/02/20(Sun) 14:48, Lauri Tirkkonen wrote: > I was working on a make jobserver implementation that uses POSIX > semaphores as job tokens instead of a complicated socket-based approach. > Initially I used named semaphores, which work fine, except if child > processes with less privileges need to also open the named semaphore > (eg. 'make build' as root executing 'su build -c make'). For that reason > I wanted to use an unnamed semaphore (sem_init()) which is stored in shm > -- that way I could leave the shm fd open and pass it to children. > > But unfortunately, sem_t is currently just a pointer to the opaque > struct __sem, and sem_int() always calloc()s the storage for the struct. That's by design. > This means the application cannot control where unnamed semaphores are > stored, so I can't put it in shm. Are you trying to use semaphore shared between process? Did you called sem_init() with pshared=1? Have you seen that the current implementation doesn't support them?
Re: [patch] smtpd: fix for ctype casts
*ping* Any feedback for the below patch is appreciated. Thanks, On Sat, Feb 01, 2020 at 05:01:48PM +0100, Hiltjo Posthuma wrote: > Hi, > > This (pedantic) patch fixes a few casts for ctype functions/macros, like > isspace, isalpha and isdigit. > > The isspace(3) man page says: > > "CAVEATS > The argument c must be EOF or representable as an unsigned char; > otherwise, the result is undefined." > > > POSIX says: > > "The c argument is an int, the value of which the application shall ensure is > a > character representable as an unsigned char or equal to the value of the macro > EOF. If the argument has any other value, the behavior is undefined." > > Reference: > https://pubs.opengroup.org/onlinepubs/9699919799/functions/isspace.html > > > In practise this might affect the portable version for NetBSD. I think most > other implementations (OpenBSD, FreeBSD, Linux glibc, musl) (according to my > testing) do an implicit cast already. > > > To do a quick grep for similar cases: > grep -E > '(isalnum|isascii|isblank|iscntrl|isdigit|isgraph|islower|isprint|ispunct|isspace|isupper|isxdigit|tolower|toupper)' > *.{c,h} | grep '(int' > > > Patch below: > > > diff --git usr.sbin/smtpd/mta_session.c usr.sbin/smtpd/mta_session.c > index 9459d69275f..afd379b794c 100644 > --- usr.sbin/smtpd/mta_session.c > +++ usr.sbin/smtpd/mta_session.c > @@ -1296,9 +1296,9 @@ mta_io(struct io *io, int evt, void *arg) > (void)strlcat(s->replybuf, line, sizeof > s->replybuf); > else { > line = line + 4; > - if (isdigit((int)*line) && *(line + 1) == '.' && > - isdigit((int)*line+2) && *(line + 3) == '.' > && > - isdigit((int)*line+4) && > isspace((int)*(line + 5))) > + if (isdigit((unsigned char)*line) && *(line + > 1) == '.' && > + isdigit((unsigned char)*line+2) && *(line + > 3) == '.' && > + isdigit((unsigned char)*line+4) && > isspace((unsigned char)*(line + 5))) > (void)strlcat(s->replybuf, line+5, > sizeof s->replybuf); > else > (void)strlcat(s->replybuf, line, sizeof > s->replybuf); > @@ -1311,9 +1311,9 @@ mta_io(struct io *io, int evt, void *arg) >*/ > if (s->replybuf[0] != '\0') { > p = line + 4; > - if (isdigit((int)*p) && *(p + 1) == '.' && > - isdigit((int)*p+2) && *(p + 3) == '.' && > - isdigit((int)*p+4) && isspace((int)*(p + 5))) > + if (isdigit((unsigned char)*p) && *(p + 1) == '.' && > + isdigit((unsigned char)*p+2) && *(p + 3) == '.' && > + isdigit((unsigned char)*p+4) && isspace((unsigned > char)*(p + 5))) > p += 5; > if (strlcat(s->replybuf, p, sizeof s->replybuf) >= > sizeof s->replybuf) > (void)strlcpy(s->replybuf, line, sizeof > s->replybuf); > diff --git usr.sbin/smtpd/parse.y usr.sbin/smtpd/parse.y > index eaa465ae83a..5cfd41092ee 100644 > --- usr.sbin/smtpd/parse.y > +++ usr.sbin/smtpd/parse.y > @@ -529,7 +529,7 @@ SMTP LIMIT limits_smtp > free($3); > YYERROR; > } > - if (isspace((int)*$3) || !isprint((int)*$3) || *$3== '@') { > + if (isspace((unsigned char)*$3) || !isprint((unsigned char)*$3) || > *$3== '@') { > yyerror("sub-addr-delim uses invalid character"); > free($3); > YYERROR; > diff --git usr.sbin/smtpd/smtp_client.c usr.sbin/smtpd/smtp_client.c > index 22e798900cf..48ec3e1d8c7 100644 > --- usr.sbin/smtpd/smtp_client.c > +++ usr.sbin/smtpd/smtp_client.c > @@ -779,9 +779,9 @@ smtp_client_replycat(struct smtp_client *proto, const > char *line) > line += 3; > if (line[0]) { > line += 1; > - if (isdigit((int)line[0]) && line[1] == '.' && > - isdigit((int)line[2]) && line[3] == '.' && > - isdigit((int)line[4]) && isspace((int)line[5])) > + if (isdigit((unsigned char)line[0]) && line[1] == '.' && > + isdigit((unsigned char)line[2]) && line[3] == '.' && > + isdigit((unsigned char)line[4]) && > isspace((unsigned char)line[5])) > line += 5; > } > } else > diff --git usr.sbin/smtpd/util.c usr.sbin/smtpd/util.c > index f59ad1e4690..77efe690336 100644 > --- usr.sbin/smtpd/util.c > +++ usr.sbin/smtpd/util.c > @@ -489,7 +489,7 @@ valid_domainpart(const char *s) > return res_hnok(s); > } > > -#define LABELCHR(c) ((c) == '-' ||