patch: fix top
either that, or we have to remove (and undocument) the 'k' command. Personally, I find it incredibly useful Index: top.c === RCS file: /data/openbsd/cvs/src/usr.bin/top/top.c,v retrieving revision 1.87 diff -u -p -r1.87 top.c --- top.c 4 Nov 2015 21:28:27 - 1.87 +++ top.c 5 Nov 2015 09:41:21 - @@ -328,7 +328,7 @@ main(int argc, char *argv[]) preset_argc = 0; } while (i != 0); - if (pledge("stdio rpath getpw tty id ps vminfo", NULL) == -1) + if (pledge("stdio rpath getpw tty proc id ps vminfo", NULL) == -1) err(1, "pledge"); /* set constants for username/uid display correctly */
Re: [patch] cvs: retire xfree()
Applied, thanks. I don't know why cvs and rcs xmalloc.c has ended up so different. On Thu, Nov 05, 2015 at 11:50:51AM +0800, Michael W. Bombardieri wrote: > Hi tech@, > > Function xfree() was previously removed from rcs, so drop it from > opencvs too... > > http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/rcs/xmalloc.c?f=h#rev1.9 > > Footnote: > I noticed that rcsnum_free() is just free() so maybe that could be > removed also (not included in this patch). > > - Michael > > > Index: add.c > === > RCS file: /cvs/src/usr.bin/cvs/add.c,v > retrieving revision 1.111 > diff -u -p -u -r1.111 add.c > --- add.c 16 Jan 2015 06:40:06 - 1.111 > +++ add.c 5 Nov 2015 02:49:20 - > @@ -20,6 +20,7 @@ > > #include > #include > +#include > #include > #include > > @@ -146,7 +147,7 @@ cvs_add_entry(struct cvs_file *cf) > entlist = cvs_ent_open(cf->file_wd); > cvs_ent_add(entlist, entry); > > - xfree(entry); > + free(entry); > } else { > add_entry(cf); > } > @@ -252,7 +253,7 @@ cvs_add_tobranch(struct cvs_file *cf, ch > (void)xsnprintf(attic, PATH_MAX, "%s/%s/%s%s", repo, > CVS_PATH_ATTIC, cf->file_name, RCS_FILE_EXT); > > - xfree(cf->file_rpath); > + free(cf->file_rpath); > cf->file_rpath = xstrdup(attic); > > cf->repo_fd = open(cf->file_rpath, O_CREAT|O_RDONLY); > @@ -277,7 +278,7 @@ cvs_add_tobranch(struct cvs_file *cf, ch > if (rcs_rev_add(cf->file_rcs, RCS_HEAD_REV, msg, -1, NULL) == -1) > fatal("cvs_add_tobranch: failed to create first branch " > "revision"); > - xfree(msg); > + free(msg); > > if (rcs_findrev(cf->file_rcs, cf->file_rcs->rf_head) == NULL) > fatal("cvs_add_tobranch: cannot find newly added revision"); > @@ -359,7 +360,7 @@ add_directory(struct cvs_file *cf) > > entlist = cvs_ent_open(cf->file_wd); > cvs_ent_add(entlist, p); > - xfree(p); > + free(p); > } > } > > @@ -381,10 +382,8 @@ add_directory(struct cvs_file *cf) > } > cvs_printf("%s\n", msg); > > - if (tag != NULL) > - xfree(tag); > - if (date != NULL) > - xfree(date); > + free(tag); > + free(date); > > cvs_get_repository_name(cf->file_path, repo, PATH_MAX); > line_list = cvs_trigger_getlines(CVS_PATH_LOGINFO, repo); > @@ -400,8 +399,7 @@ add_directory(struct cvs_file *cf) > > cvs_trigger_freeinfo(&files_info); > cvs_trigger_freelist(line_list); > - if (loginfo != NULL) > - xfree(loginfo); > + free(loginfo); > } > } > > @@ -564,5 +562,5 @@ add_entry(struct cvs_file *cf) > entlist = cvs_ent_open(cf->file_wd); > cvs_ent_add(entlist, entry); > } > - xfree(entry); > + free(entry); > } > Index: admin.c > === > RCS file: /cvs/src/usr.bin/cvs/admin.c,v > retrieving revision 1.65 > diff -u -p -u -r1.65 admin.c > --- admin.c 16 Jan 2015 06:40:06 - 1.65 > +++ admin.c 5 Nov 2015 02:49:20 - > @@ -23,6 +23,7 @@ > #include > #include > #include > +#include > #include > #include > > @@ -304,8 +305,8 @@ cvs_admin_local(struct cvs_file *cf) > while (!TAILQ_EMPTY(&(cf->file_rcs->rf_access))) { > rap = TAILQ_FIRST(&(cf->file_rcs->rf_access)); > TAILQ_REMOVE(&(cf->file_rcs->rf_access), rap, ra_list); > - xfree(rap->ra_name); > - xfree(rap); > + free(rap->ra_name); > + free(rap); > } > /* no synced anymore */ > cf->file_rcs->rf_flags &= ~RCS_SYNCED; > Index: annotate.c > === > RCS file: /cvs/src/usr.bin/cvs/annotate.c,v > retrieving revision 1.64 > diff -u -p -u -r1.64 annotate.c > --- annotate.c16 Jan 2015 06:40:06 - 1.64 > +++ annotate.c5 Nov 2015 02:49:20 - > @@ -235,7 +235,7 @@ cvs_annotate_local(struct cvs_file *cf) > p[line->l_len] = '\0'; > > if (line->l_needsfree) > - xfree(line->l_line); > + free(line->l_line); > line->l_line = p; > line->l_len++; > line->l_needsfree = 1; > @@ -244,9 +244,9 @@ cvs_annotate_local(struct cvs_file *cf) > line->l_delta->rd_author, date, line->l_line); > > i
Re: [patch] tail(1) follow multiple files
On 5 November 2015 at 00:29, Martijn van Duren wrote: > > I got somewhat annoyed by the fact that OpenBSD's tail can't follow multiple > files and since the last attempt at it was from 2008 I thought I'd give it a > shot. Thank you for sharing this, hope it gets accepted. > (void)printf("%s==> %s <==\n", first ? "" : "\n", fname); I've recently encountered a problem where I wanted to execute some code for every new line in a set of files, but the code would be different for each file. This "==> name <==" format is standard across systems, but it's awkward to parse. Would OpenBSD be open to a different, non-standard and optional output format that prefixes each line with "fname:" if there are multiple input files, much like grep does? -- The best the little guy can do is what the little guy does right
Re: patch: fix top
On Thu, Nov 05, 2015 at 10:42:54AM +0100, Marc Espie wrote: > - if (pledge("stdio rpath getpw tty id ps vminfo", NULL) == -1) > + if (pledge("stdio rpath getpw tty proc id ps vminfo", NULL) == -1) > err(1, "pledge"); I think both "proc" and "id" are too much: "id" was added to enable renicing, but "proc" is good enough for that: Index: usr.bin/top/top.c === RCS file: /cvs/src/usr.bin/top/top.c,v retrieving revision 1.87 diff -u -p -r1.87 top.c --- usr.bin/top/top.c 4 Nov 2015 21:28:27 - 1.87 +++ usr.bin/top/top.c 5 Nov 2015 09:54:04 - @@ -328,7 +328,7 @@ main(int argc, char *argv[]) preset_argc = 0; } while (i != 0); - if (pledge("stdio rpath getpw tty id ps vminfo", NULL) == -1) + if (pledge("stdio rpath getpw tty proc ps vminfo", NULL) == -1) err(1, "pledge"); /* set constants for username/uid display correctly */
Re: patch: fix top
On Thu, Nov 05, 2015 at 10:54:32AM +0100, Theo Buehler wrote: > On Thu, Nov 05, 2015 at 10:42:54AM +0100, Marc Espie wrote: > > - if (pledge("stdio rpath getpw tty id ps vminfo", NULL) == -1) > > + if (pledge("stdio rpath getpw tty proc id ps vminfo", NULL) == -1) > > err(1, "pledge"); > > I think both "proc" and "id" are too much: "id" was added to enable > renicing, but "proc" is good enough for that: > > Index: usr.bin/top/top.c > === > RCS file: /cvs/src/usr.bin/top/top.c,v > retrieving revision 1.87 > diff -u -p -r1.87 top.c > --- usr.bin/top/top.c 4 Nov 2015 21:28:27 - 1.87 > +++ usr.bin/top/top.c 5 Nov 2015 09:54:04 - > @@ -328,7 +328,7 @@ main(int argc, char *argv[]) > preset_argc = 0; > } while (i != 0); > > - if (pledge("stdio rpath getpw tty id ps vminfo", NULL) == -1) > + if (pledge("stdio rpath getpw tty proc ps vminfo", NULL) == -1) > err(1, "pledge"); > > /* set constants for username/uid display correctly */ WHAT ? I don't see setpriority in the list of syscalls that proc enables.
Re: patch: fix top
On Thu, Nov 05, 2015 at 11:33:56AM +0100, Marc Espie wrote: > On Thu, Nov 05, 2015 at 10:54:32AM +0100, Theo Buehler wrote: > > On Thu, Nov 05, 2015 at 10:42:54AM +0100, Marc Espie wrote: > > > - if (pledge("stdio rpath getpw tty id ps vminfo", NULL) == -1) > > > + if (pledge("stdio rpath getpw tty proc id ps vminfo", NULL) == -1) > > > err(1, "pledge"); > > > > I think both "proc" and "id" are too much: "id" was added to enable > > renicing, but "proc" is good enough for that: > > > > Index: usr.bin/top/top.c > > === > > RCS file: /cvs/src/usr.bin/top/top.c,v > > retrieving revision 1.87 > > diff -u -p -r1.87 top.c > > --- usr.bin/top/top.c 4 Nov 2015 21:28:27 - 1.87 > > +++ usr.bin/top/top.c 5 Nov 2015 09:54:04 - > > @@ -328,7 +328,7 @@ main(int argc, char *argv[]) > > preset_argc = 0; > > } while (i != 0); > > > > - if (pledge("stdio rpath getpw tty id ps vminfo", NULL) == -1) > > + if (pledge("stdio rpath getpw tty proc ps vminfo", NULL) == -1) > > err(1, "pledge"); > > > > /* set constants for username/uid display correctly */ > > WHAT ? I don't see setpriority in the list of syscalls that proc enables. > That's right. Nevertheless /src/sys/kern/kern_pledge.c, line 234: 229 [SYS_setsid] = PLEDGE_PROC, 230 231 [SYS_setrlimit] = PLEDGE_PROC | PLEDGE_ID, 232 [SYS_getpriority] = PLEDGE_PROC | PLEDGE_ID, 233 234 [SYS_setpriority] = PLEDGE_PROC | PLEDGE_ID, 235 236 [SYS_setuid] = PLEDGE_ID, This was added to enable csh's nice builtin without adding "id" to csh's promises.
mpe(4) and rt_ifp
Stop using rt_ifp in mpe(4), ok? Index: net/if_mpe.c === RCS file: /cvs/src/sys/net/if_mpe.c,v retrieving revision 1.49 diff -u -p -r1.49 if_mpe.c --- net/if_mpe.c22 Oct 2015 17:48:34 - 1.49 +++ net/if_mpe.c5 Nov 2015 10:58:07 - @@ -139,17 +139,18 @@ struct sockaddr_storagempedst; * Start output on the mpe interface. */ void -mpestart(struct ifnet *ifp) +mpestart(struct ifnet *ifp0) { struct mbuf *m; struct sockaddr *sa = (struct sockaddr *)&mpedst; int s; sa_family_t af; struct rtentry *rt; + struct ifnet*ifp; for (;;) { s = splnet(); - IFQ_DEQUEUE(&ifp->if_snd, m); + IFQ_DEQUEUE(&ifp0->if_snd, m); splx(s); if (m == NULL) @@ -172,19 +173,25 @@ mpestart(struct ifnet *ifp) } rt = rtalloc(sa, RT_REPORT|RT_RESOLVE, 0); - if (rt == NULL) { - /* no route give up */ + if (!rtisvalid(rt)) { m_freem(m); continue; } + ifp = if_get(rt->rt_ifidx); + if (ifp == NULL) { + m_freem(m); + rtfree(rt); + continue; + } + #if NBPFILTER > 0 - if (ifp->if_bpf) { + if (ifp0->if_bpf) { /* remove MPLS label before passing packet to bpf */ m->m_data += sizeof(struct shim_hdr); m->m_len -= sizeof(struct shim_hdr); m->m_pkthdr.len -= sizeof(struct shim_hdr); - bpf_mtap_af(ifp->if_bpf, af, m, BPF_DIRECTION_OUT); + bpf_mtap_af(ifp0->if_bpf, af, m, BPF_DIRECTION_OUT); m->m_data -= sizeof(struct shim_hdr); m->m_len += sizeof(struct shim_hdr); m->m_pkthdr.len += sizeof(struct shim_hdr); @@ -193,7 +200,8 @@ mpestart(struct ifnet *ifp) /* XXX lie, but mpls_output will only look at sa_family */ sa->sa_family = AF_MPLS; - mpls_output(rt->rt_ifp, m, sa, rt); + mpls_output(ifp, m, sa, rt); + if_put(ifp); rtfree(rt); } }
nd6_nud_hint and rt_ifp
Change nd6_nud_hint() to no longer use rt_ifp directly. While here remove unused argument and convert the route check to rtisvalid(9). ok? Index: netinet/tcp_input.c === RCS file: /cvs/src/sys/netinet/tcp_input.c,v retrieving revision 1.307 diff -u -p -r1.307 tcp_input.c --- netinet/tcp_input.c 28 Oct 2015 12:14:25 - 1.307 +++ netinet/tcp_input.c 5 Nov 2015 10:47:29 - @@ -144,10 +144,9 @@ struct timeval tcp_ackdrop_ppslim_last; #ifdef INET6 #define ND6_HINT(tp) \ do { \ - if (tp && tp->t_inpcb && (tp->t_inpcb->inp_flags & INP_IPV6) && \ - tp->t_inpcb->inp_route6.ro_rt) { \ - nd6_nud_hint(tp->t_inpcb->inp_route6.ro_rt, \ - tp->t_inpcb->inp_rtableid); \ + if (tp && tp->t_inpcb && (tp->t_inpcb->inp_flags & INP_IPV6) && \ + rtisvalid(tp->t_inpcb->inp_route6.ro_rt)) { \ + nd6_nud_hint(tp->t_inpcb->inp_route6.ro_rt);\ } \ } while (0) #else Index: netinet6/nd6.c === RCS file: /cvs/src/sys/netinet6/nd6.c,v retrieving revision 1.171 diff -u -p -r1.171 nd6.c --- netinet6/nd6.c 2 Nov 2015 12:51:16 - 1.171 +++ netinet6/nd6.c 5 Nov 2015 10:49:44 - @@ -847,25 +847,26 @@ nd6_free(struct rtentry *rt, int gc) * XXX cost-effective methods? */ void -nd6_nud_hint(struct rtentry *rt, u_int rtableid) +nd6_nud_hint(struct rtentry *rt) { struct llinfo_nd6 *ln; + struct ifnet *ifp; - if (rt == NULL) { + ifp = if_get(rt->rt_ifidx); + if (ifp == NULL) return; - } if ((rt->rt_flags & RTF_GATEWAY) != 0 || (rt->rt_flags & RTF_LLINFO) == 0 || rt->rt_llinfo == NULL || rt->rt_gateway == NULL || rt->rt_gateway->sa_family != AF_LINK) { /* This is not a host route. */ - return; + goto out; } ln = (struct llinfo_nd6 *)rt->rt_llinfo; if (ln->ln_state < ND6_LLINFO_REACHABLE) - return; + goto out; /* * if we get upper-layer reachability confirmation many times, @@ -873,13 +874,13 @@ nd6_nud_hint(struct rtentry *rt, u_int r */ ln->ln_byhint++; if (ln->ln_byhint > nd6_maxnudhint) - return; + goto out; ln->ln_state = ND6_LLINFO_REACHABLE; - if (!ND6_LLINFO_PERMANENT(ln)) { - nd6_llinfo_settimer(ln, - (long)ND_IFINFO(rt->rt_ifp)->reachable * hz); - } + if (!ND6_LLINFO_PERMANENT(ln)) + nd6_llinfo_settimer(ln, (long)ND_IFINFO(ifp)->reachable * hz); +out: + if_put(ifp); } void Index: netinet6/nd6.h === RCS file: /cvs/src/sys/netinet6/nd6.h,v retrieving revision 1.54 diff -u -p -r1.54 nd6.h --- netinet6/nd6.h 2 Nov 2015 12:51:16 - 1.54 +++ netinet6/nd6.h 5 Nov 2015 10:42:51 - @@ -258,7 +258,7 @@ void nd6_setmtu(struct ifnet *); void nd6_llinfo_settimer(struct llinfo_nd6 *, long); void nd6_timer(void *); void nd6_purge(struct ifnet *); -void nd6_nud_hint(struct rtentry *, u_int); +void nd6_nud_hint(struct rtentry *); int nd6_resolve(struct ifnet *, struct rtentry *, struct mbuf *, struct sockaddr *, u_char *); void nd6_rtrequest(struct ifnet *, int, struct rtentry *);
Re: Possible em(4) fix
> From: Alexis VACHETTE > Date: Thu, 5 Nov 2015 10:24:27 +0100 > > Hi Mark, > > If you need a box for testing purpose on this issue. > > I can provide you bug reports when I will get a spare box which trigger > the watchdog timeout. Time is the scarce resource here. Of which I won't have any until after November 8.
Re: [patch] tcpdump gre sre segfault
Stuart Henderson writes: > On 2015/11/03 20:04, Kevin Reay wrote: >> Fix a segfault in the GRE printer when a GRE packet SRE length >> extends past the actual captured length (but not the packet's >> original length). > > That's OK with me.. Committed, thanks Kevin. >> gre_print() now checks if the length extends past snapend and, if so, >> uses the snapend to determine the usable length. >> >> Also includes a small change to use the already defined GRE_VERS >> instead of a hardcoded mask. >> >> Note that the GRE printer does its own length testing. It would >> probably be better to migrate it to use the TCHECK* functions instead >> of the manual length check logic it's doing now. Sounds right. >> Index: print-gre.c >> === >> RCS file: /cvs/src/usr.sbin/tcpdump/print-gre.c,v >> retrieving revision 1.9 >> diff -u -p -r1.9 print-gre.c >> --- print-gre.c 16 Jan 2015 06:40:21 - 1.9 >> +++ print-gre.c 4 Nov 2015 02:52:41 - >> @@ -73,11 +73,14 @@ gre_print(const u_char *bp, u_int length >> { >> u_int len = length, vers; >> >> +if (bp + len > snapend) >> +len = snapend - bp; >> + >> if (len < 2) { >> printf("[|gre]"); >> return; >> } >> -vers = EXTRACT_16BITS(bp) & 7; >> +vers = EXTRACT_16BITS(bp) & GRE_VERS; >> >> if (vers == 0) >> gre_print_0(bp, len); > -- jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE
Re: [patch] tcpdump print-tcp printf format tweaks
Kevin Reay writes: >> > Attempted to match printf formating of unsigned 32bits to rest of >> > file. >> >> I don't think this is the good direction. "seq" and "length" are 32bits >> integers. Why cast them to long, and then print them as unsigned long? >> Let's just print them as unsigned int. > > That sounds good to me. I'll create another patch. > > Do you think it's worth cleaning up the existing long cast/print > formats that exist elsewhere in the file? As discussed, the patch was in the previous mail. I just committed it. Thanks! -- jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE
tls_init.3 add small info
Hi, I'm playing around with client-side certificates[1] and saw that the manpage of tls_init.3 recommend to uses the functions: tls_config_set_ca_{file,path,mem} only in client context. But to check client-side certificates its also useful in server context. bye, Jan [1]: https://github.com/younix/ucspi/blob/master/tests.mk Index: tls_init.3 === RCS file: /cvs/src/lib/libtls/tls_init.3,v retrieving revision 1.53 diff -u -p -r1.53 tls_init.3 --- tls_init.3 16 Oct 2015 13:49:53 - 1.53 +++ tls_init.3 5 Nov 2015 12:48:17 - @@ -289,16 +289,16 @@ Configuration options may apply to only .Fn tls_config_set_ca_file sets the filename used to load a file containing the root certificates. -.Em (Client) +.Em (Client and Server) .It .Fn tls_config_set_ca_path sets the path (directory) which should be searched for root certificates. -.Em (Client) +.Em (Client and Server) .It .Fn tls_config_set_ca_mem sets the root certificates directly from memory. -.Em (Client) +.Em (Client and Server) .It .Fn tls_config_set_cert_file sets file from which the public certificate will be read.
Re: mpe(4) and rt_ifp
On Thu, Nov 05, 2015 at 11:59:45AM +0100, Martin Pieuchot wrote: > Stop using rt_ifp in mpe(4), ok? Looks good untested but just move on. OK claudio > Index: net/if_mpe.c > === > RCS file: /cvs/src/sys/net/if_mpe.c,v > retrieving revision 1.49 > diff -u -p -r1.49 if_mpe.c > --- net/if_mpe.c 22 Oct 2015 17:48:34 - 1.49 > +++ net/if_mpe.c 5 Nov 2015 10:58:07 - > @@ -139,17 +139,18 @@ struct sockaddr_storage mpedst; > * Start output on the mpe interface. > */ > void > -mpestart(struct ifnet *ifp) > +mpestart(struct ifnet *ifp0) > { > struct mbuf *m; > struct sockaddr *sa = (struct sockaddr *)&mpedst; > int s; > sa_family_t af; > struct rtentry *rt; > + struct ifnet*ifp; > > for (;;) { > s = splnet(); > - IFQ_DEQUEUE(&ifp->if_snd, m); > + IFQ_DEQUEUE(&ifp0->if_snd, m); > splx(s); > > if (m == NULL) > @@ -172,19 +173,25 @@ mpestart(struct ifnet *ifp) > } > > rt = rtalloc(sa, RT_REPORT|RT_RESOLVE, 0); > - if (rt == NULL) { > - /* no route give up */ > + if (!rtisvalid(rt)) { > m_freem(m); > continue; > } > > + ifp = if_get(rt->rt_ifidx); > + if (ifp == NULL) { > + m_freem(m); > + rtfree(rt); > + continue; > + } > + > #if NBPFILTER > 0 > - if (ifp->if_bpf) { > + if (ifp0->if_bpf) { > /* remove MPLS label before passing packet to bpf */ > m->m_data += sizeof(struct shim_hdr); > m->m_len -= sizeof(struct shim_hdr); > m->m_pkthdr.len -= sizeof(struct shim_hdr); > - bpf_mtap_af(ifp->if_bpf, af, m, BPF_DIRECTION_OUT); > + bpf_mtap_af(ifp0->if_bpf, af, m, BPF_DIRECTION_OUT); > m->m_data -= sizeof(struct shim_hdr); > m->m_len += sizeof(struct shim_hdr); > m->m_pkthdr.len += sizeof(struct shim_hdr); > @@ -193,7 +200,8 @@ mpestart(struct ifnet *ifp) > /* XXX lie, but mpls_output will only look at sa_family */ > sa->sa_family = AF_MPLS; > > - mpls_output(rt->rt_ifp, m, sa, rt); > + mpls_output(ifp, m, sa, rt); > + if_put(ifp); > rtfree(rt); > } > } -- :wq Claudio
Re: patch: fix top
On Thu, Nov 05, 2015 at 11:52:32AM +0100, Theo Buehler wrote: > On Thu, Nov 05, 2015 at 11:33:56AM +0100, Marc Espie wrote: > > On Thu, Nov 05, 2015 at 10:54:32AM +0100, Theo Buehler wrote: > > > On Thu, Nov 05, 2015 at 10:42:54AM +0100, Marc Espie wrote: > > > > - if (pledge("stdio rpath getpw tty id ps vminfo", NULL) == -1) > > > > + if (pledge("stdio rpath getpw tty proc id ps vminfo", NULL) == > > > > -1) > > > > err(1, "pledge"); > > > > > > I think both "proc" and "id" are too much: "id" was added to enable > > > renicing, but "proc" is good enough for that: > > > > > > Index: usr.bin/top/top.c > > > === > > > RCS file: /cvs/src/usr.bin/top/top.c,v > > > retrieving revision 1.87 > > > diff -u -p -r1.87 top.c > > > --- usr.bin/top/top.c 4 Nov 2015 21:28:27 - 1.87 > > > +++ usr.bin/top/top.c 5 Nov 2015 09:54:04 - > > > @@ -328,7 +328,7 @@ main(int argc, char *argv[]) > > > preset_argc = 0; > > > } while (i != 0); > > > > > > - if (pledge("stdio rpath getpw tty id ps vminfo", NULL) == -1) > > > + if (pledge("stdio rpath getpw tty proc ps vminfo", NULL) == -1) > > > err(1, "pledge"); > > > > > > /* set constants for username/uid display correctly */ > > > > WHAT ? I don't see setpriority in the list of syscalls that proc enables. > > > > That's right. Nevertheless /src/sys/kern/kern_pledge.c, line 234: > > 229 [SYS_setsid] = PLEDGE_PROC, > 230 > 231 [SYS_setrlimit] = PLEDGE_PROC | PLEDGE_ID, > 232 [SYS_getpriority] = PLEDGE_PROC | PLEDGE_ID, > 233 > 234 [SYS_setpriority] = PLEDGE_PROC | PLEDGE_ID, > 235 > 236 [SYS_setuid] = PLEDGE_ID, > > This was added to enable csh's nice builtin without adding "id" to > csh's promises. It's not documented so it doesn't exist for me. :P (hint hint)
cvs.1: document annotate command
Hi there, it seems the documentation for cvs(1) is missing a few commands: annotate, edit, editors, login, logout, pserver, rannotate, rlog, server, version, watch, watchers, unedit The patch below adds a description for annotate. Cheers, Frederic Index: gnu/usr.bin/cvs/man/cvs.1 === RCS file: /cvs/src/gnu/usr.bin/cvs/man/cvs.1,v retrieving revision 1.12 diff -u -p -r1.12 cvs.1 --- gnu/usr.bin/cvs/man/cvs.1 3 Jun 2013 17:02:36 - 1.12 +++ gnu/usr.bin/cvs/man/cvs.1 5 Nov 2015 14:07:04 - @@ -308,6 +333,10 @@ Execute control functions on the source repository. (Changes repository directly; uses working directory without changing it.) .TP +.B annotate +For each line of a file, show its last revision, the author's name, +and the date of the change. +.TP .B checkout Make a working directory of source files for editing. (Creates or changes working directory.) @@ -437,7 +466,7 @@ same date (unless you explicitly overrid the \fBupdate\fP command). .B \-D is available with the -.BR checkout ", " diff ", " history ", " export ", " +.BR annotate ", " checkout ", " diff ", " history ", " export ", " .BR rdiff ", " rtag ", and " .B update commands. @@ -467,7 +496,7 @@ files retrieved even when there is no ma most recent version is used in this situation.) .B \-f is available with these commands: -.BR checkout ", " export ", " +.BR annotate ", " checkout ", " export ", " .BR rdiff ", " rtag ", and " update . .TP \fB\-k\fP \fIkflag\fP @@ -493,7 +522,7 @@ at some other site. .B \-l Local; run only in current working directory, rather than recurring through subdirectories. Available with the following commands: -.BR checkout ", " commit ", " diff ", " +.BR annotate ", " checkout ", " commit ", " diff ", " .BR export ", " remove ", " rdiff ", " rtag ", " .BR status ", " tag ", and " update . .I Warning: @@ -584,7 +613,7 @@ command option is often useful, to suppr file does not contain the specified tag. .B \-r is available with the -.BR checkout ", " commit ", " diff ", " +.BR annotate ", " checkout ", " commit ", " diff ", " .BR history ", " export ", " .BR rdiff ", " rtag ", and " update commands. @@ -756,6 +785,27 @@ facilities, similar to .BR rcs ( 1 ). This command works recursively, so extreme care should be used. +.TP +\fBannotate\fP [\fB-flR\fP] [\fB-r\fP \fItag\fP | \fB-D\fP \fIdate\fP] [\fIfiles...\fP] +.I Requires: +repository. +.br +.I Changes: +nothing. +.br +.I Synonyms: +.BR ann ", " blame +.br +Print information about the last modification of each line in +.IR files . +The information includes the revision number, the author's name, and +the date of the revision. +By default (or if the \fB-R\fP option is used), +.B annotate +will print information about files in sub-directories; the \fB-l\fP +option can be used to disable this recursion. +The standard options \fB-f\fP, \fB-r\fP and \fB-D\fP can be used to +annotate specific revisions. .TP \fBcheckout\fP [\fBoptions\fP] \fImodules\fP.\|.\|. .I Requires:
Re: Possible em(4) fix
Hi Mark, If you need a box for testing purpose on this issue. I can provide you bug reports when I will get a spare box which trigger the watchdog timeout. In my case it's only with trunk device on failover mode so far. Regards, Alexis VACHETTE* * On 05/10/2015 22:45, Mark Kettenis wrote: Several people seem to complain on misc@ that they're seeing watchdog timeouts on em(4). But none of them bother to submit a proper bug report to bugs@. Anyway, here is a diff that might fix the issue. Please test, even if you're not experiencing any problems. Thanks, Mark Index: if_em.c === RCS file: /home/cvs/src/sys/dev/pci/if_em.c,v retrieving revision 1.306 diff -u -p -r1.306 if_em.c --- if_em.c 30 Sep 2015 11:25:08 - 1.306 +++ if_em.c 5 Oct 2015 20:35:13 - @@ -1210,12 +1210,6 @@ em_encap(struct em_softc *sc, struct mbu } } - sc->next_avail_tx_desc = i; - if (sc->pcix_82544) - atomic_sub_int(&sc->num_tx_desc_avail, txd_used); - else - atomic_sub_int(&sc->num_tx_desc_avail, map->dm_nsegs); - #if NVLAN > 0 /* Find out if we are in VLAN mode */ if (m_head->m_flags & M_VLANTAG) { @@ -1249,6 +1243,14 @@ em_encap(struct em_softc *sc, struct mbu tx_buffer = &sc->tx_buffer_area[first]; tx_buffer->next_eop = last; + membar_producer(); + + sc->next_avail_tx_desc = i; + if (sc->pcix_82544) + atomic_sub_int(&sc->num_tx_desc_avail, txd_used); + else + atomic_sub_int(&sc->num_tx_desc_avail, map->dm_nsegs); + /* * Advance the Transmit Descriptor Tail (Tdt), * this tells the E1000 that this frame is @@ -2377,6 +2379,8 @@ em_transmit_checksum_setup(struct em_sof tx_buffer->m_head = NULL; tx_buffer->next_eop = -1; + + membar_producer(); if (++curr_txd == sc->num_tx_desc) curr_txd = 0;
unify xmalloc (was Re: [patch] cvs: retire xfree())
On Thu, Nov 05, 2015 at 09:50:48AM +, Nicholas Marriott wrote: > I don't know why cvs and rcs xmalloc.c has ended up so different. It's not just about cvs and rcs: /usr/src/usr.bin/cvs/xmalloc.c /usr/src/usr.bin/diff/xmalloc.c /usr/src/usr.bin/file/xmalloc.c /usr/src/usr.bin/rcs/xmalloc.c /usr/src/usr.bin/ssh/xmalloc.c /usr/src/usr.bin/tmux/xmalloc.c (probably not same origin) All of them share code parts that almost look identical. Some of them skip tests, do additional tests, test for other return values, or have typos in their error messages (or call err instead of errx, duplicating their messages). This diff would unify them, taking into account that still different style guides apply (tmux) and some use fatal() or errx() with even different return values (diff). Ugh... Index: usr.bin/cvs/xmalloc.c === RCS file: /cvs/src/usr.bin/cvs/xmalloc.c,v retrieving revision 1.12 diff -u -p -u -p -r1.12 xmalloc.c --- usr.bin/cvs/xmalloc.c 5 Nov 2015 09:48:21 - 1.12 +++ usr.bin/cvs/xmalloc.c 5 Nov 2015 14:42:09 - @@ -13,6 +13,7 @@ * called by a name other than "ssh" or "Secure Shell". */ +#include #include #include #include @@ -30,7 +31,7 @@ xmalloc(size_t size) fatal("xmalloc: zero size"); ptr = malloc(size); if (ptr == NULL) - fatal("xmalloc: out of memory (allocating %lu bytes)", (u_long) size); + fatal("xmalloc: out of memory (allocating %zu bytes)", size); return ptr; } @@ -41,12 +42,10 @@ xcalloc(size_t nmemb, size_t size) if (size == 0 || nmemb == 0) fatal("xcalloc: zero size"); - if (SIZE_MAX / nmemb < size) - fatal("xcalloc: nmemb * size > SIZE_MAX"); ptr = calloc(nmemb, size); if (ptr == NULL) - fatal("xcalloc: out of memory (allocating %lu bytes)", - (u_long)(size * nmemb)); + fatal("xcalloc: out of memory (allocating %zu * %zu bytes)", + nmemb, size); return ptr; } @@ -54,28 +53,23 @@ void * xreallocarray(void *ptr, size_t nmemb, size_t size) { void *new_ptr; - size_t new_size = nmemb * size; - if (new_size == 0) - fatal("xrealloc: zero size"); - if (SIZE_MAX / nmemb < size) - fatal("xrealloc: nmemb * size > SIZE_MAX"); - new_ptr = realloc(ptr, new_size); + if (nmemb == 0 || size == 0) + fatal("xreallocarray: zero size"); + new_ptr = reallocarray(ptr, nmemb, size); if (new_ptr == NULL) - fatal("xrealloc: out of memory (new_size %lu bytes)", - (u_long) new_size); + fatal("xreallocarray: out of memory " + "(allocating %zu * %zu bytes)", nmemb, size); return new_ptr; } char * xstrdup(const char *str) { - size_t len; char *cp; - len = strlen(str) + 1; - cp = xmalloc(len); - strlcpy(cp, str, len); + if ((cp = strdup(str)) == NULL) + fatal("xstrdup: could not allocate memory"); return cp; } @@ -96,17 +90,20 @@ xasprintf(char **ret, const char *fmt, . } int -xsnprintf(char *str, size_t size, const char *fmt, ...) +xsnprintf(char *str, size_t len, const char *fmt, ...) { va_list ap; int i; + if (len > INT_MAX) + fatal("xsnprintf: len > INT_MAX"); + va_start(ap, fmt); - i = vsnprintf(str, size, fmt, ap); + i = vsnprintf(str, len, fmt, ap); va_end(ap); - if (i == -1 || i >= (int)size) - fatal("xsnprintf: overflow"); + if (i < 0 || i >= (int)len) + fatal("xsnprintf: could not allocate memory"); return (i); } Index: usr.bin/diff/xmalloc.c === RCS file: /cvs/src/usr.bin/diff/xmalloc.c,v retrieving revision 1.8 diff -u -p -u -p -r1.8 xmalloc.c --- usr.bin/diff/xmalloc.c 25 Sep 2015 16:16:26 - 1.8 +++ usr.bin/diff/xmalloc.c 5 Nov 2015 14:42:09 - @@ -27,9 +27,11 @@ xmalloc(size_t size) { void *ptr; + if (size == 0) + errx(2, "xmalloc: zero size"); ptr = malloc(size); if (ptr == NULL) - err(2, "xmalloc %zu", size); + errx(2, "xmalloc: out of memory (allocating %zu bytes)", size); return ptr; } @@ -40,7 +42,7 @@ xcalloc(size_t nmemb, size_t size) ptr = calloc(nmemb, size); if (ptr == NULL) - err(2, "xcalloc: out of memory (allocating %zu*%zu bytes)", + errx(2, "xcalloc: out of memory (allocating %zu * %zu bytes)", nmemb, size); return ptr; } @@ -52,7 +54,8 @@ xreallocarray(void *ptr, size_t nmemb, s new_ptr = reallocarray(ptr, nmemb, size); if (new_ptr == NULL) - err(2, "
Re: cvs.1: document annotate command
On Thu, Nov 05, 2015 at 03:11:38PM +0100, Frederic Nowak wrote: > Hi there, > > it seems the documentation for cvs(1) is missing a few commands: > annotate, edit, editors, login, logout, pserver, rannotate, rlog, > server, version, watch, watchers, unedit > The patch below adds a description for annotate. > > Cheers, > Frederic > > Index: gnu/usr.bin/cvs/man/cvs.1 > === please mail doc fixes for gnu cvs to that project. you probably want to check any issues are not present in the latest version before you do so. jmc > RCS file: /cvs/src/gnu/usr.bin/cvs/man/cvs.1,v > retrieving revision 1.12 > diff -u -p -r1.12 cvs.1 > --- gnu/usr.bin/cvs/man/cvs.1 3 Jun 2013 17:02:36 - 1.12 > +++ gnu/usr.bin/cvs/man/cvs.1 5 Nov 2015 14:07:04 - > @@ -308,6 +333,10 @@ Execute > control functions on the source repository. (Changes > repository directly; uses working directory without changing it.) > .TP > +.B annotate > +For each line of a file, show its last revision, the author's name, > +and the date of the change. > +.TP > .B checkout > Make a working directory of source files for editing. (Creates or > changes > working directory.) > @@ -437,7 +466,7 @@ same date (unless you explicitly overrid > the \fBupdate\fP command). > .B \-D > is available with the > -.BR checkout ", " diff ", " history ", " export ", " > +.BR annotate ", " checkout ", " diff ", " history ", " export ", " > .BR rdiff ", " rtag ", and " > .B update > commands. > @@ -467,7 +496,7 @@ files retrieved even when there is no ma > most recent version is used in this situation.) > .B \-f > is available with these commands: > -.BR checkout ", " export ", " > +.BR annotate ", " checkout ", " export ", " > .BR rdiff ", " rtag ", and " update . > .TP > \fB\-k\fP \fIkflag\fP > @@ -493,7 +522,7 @@ at some other site. > .B \-l > Local; run only in current working directory, rather than recurring > through > subdirectories. Available with the following commands: > -.BR checkout ", " commit ", " diff ", " > +.BR annotate ", " checkout ", " commit ", " diff ", " > .BR export ", " remove ", " rdiff ", " rtag ", " > .BR status ", " tag ", and " update . > .I Warning: > @@ -584,7 +613,7 @@ command option is often useful, to suppr > file does not contain the specified tag. > .B \-r > is available with the > -.BR checkout ", " commit ", " diff ", " > +.BR annotate ", " checkout ", " commit ", " diff ", " > .BR history ", " export ", " > .BR rdiff ", " rtag ", and " update > commands. > @@ -756,6 +785,27 @@ facilities, similar to > .BR rcs ( 1 ). > This command works recursively, so extreme care should be > used. > +.TP > +\fBannotate\fP [\fB-flR\fP] [\fB-r\fP \fItag\fP | \fB-D\fP \fIdate\fP] > [\fIfiles...\fP] > +.I Requires: > +repository. > +.br > +.I Changes: > +nothing. > +.br > +.I Synonyms: > +.BR ann ", " blame > +.br > +Print information about the last modification of each line in > +.IR files . > +The information includes the revision number, the author's name, and > +the date of the revision. > +By default (or if the \fB-R\fP option is used), > +.B annotate > +will print information about files in sub-directories; the \fB-l\fP > +option can be used to disable this recursion. > +The standard options \fB-f\fP, \fB-r\fP and \fB-D\fP can be used to > +annotate specific revisions. > .TP > \fBcheckout\fP [\fBoptions\fP] \fImodules\fP.\|.\|. > .I Requires: >
Re: cvs.1: document annotate command
> On 05 November 2015 at 16:08 Jason McIntyre wrote: > > > On Thu, Nov 05, 2015 at 03:11:38PM +0100, Frederic Nowak wrote: > > Hi there, > > > > it seems the documentation for cvs(1) is missing a few commands: > > annotate, edit, editors, login, logout, pserver, rannotate, rlog, > > server, version, watch, watchers, unedit > > The patch below adds a description for annotate. > > > > Cheers, > > Frederic > > > > Index: gnu/usr.bin/cvs/man/cvs.1 > > === > > please mail doc fixes for gnu cvs to that project. you probably want > to > check any issues are not present in the latest version before you do > so. > > jmc > But it seems that cvs.1 is maintained independently of the gnu version. gnu autogenerates cvs.1 from cvs.texinfo, which contains the missing commands, but is in a completely different style. Frederic > > RCS file: /cvs/src/gnu/usr.bin/cvs/man/cvs.1,v > > retrieving revision 1.12 > > diff -u -p -r1.12 cvs.1 > > --- gnu/usr.bin/cvs/man/cvs.1 3 Jun 2013 17:02:36 - 1.12 > > +++ gnu/usr.bin/cvs/man/cvs.1 5 Nov 2015 14:07:04 - > > @@ -308,6 +333,10 @@ Execute > > control functions on the source repository. (Changes > > repository directly; uses working directory without changing it.) > > .TP > > +.B annotate > > +For each line of a file, show its last revision, the author's name, > > +and the date of the change. > > +.TP > > .B checkout > > Make a working directory of source files for editing. (Creates or > > changes > > working directory.) > > @@ -437,7 +466,7 @@ same date (unless you explicitly overrid > > the \fBupdate\fP command). > > .B \-D > > is available with the > > -.BR checkout ", " diff ", " history ", " export ", " > > +.BR annotate ", " checkout ", " diff ", " history ", " export ", " > > .BR rdiff ", " rtag ", and " > > .B update > > commands. > > @@ -467,7 +496,7 @@ files retrieved even when there is no ma > > most recent version is used in this situation.) > > .B \-f > > is available with these commands: > > -.BR checkout ", " export ", " > > +.BR annotate ", " checkout ", " export ", " > > .BR rdiff ", " rtag ", and " update . > > .TP > > \fB\-k\fP \fIkflag\fP > > @@ -493,7 +522,7 @@ at some other site. > > .B \-l > > Local; run only in current working directory, rather than recurring > > through > > subdirectories. Available with the following commands: > > -.BR checkout ", " commit ", " diff ", " > > +.BR annotate ", " checkout ", " commit ", " diff ", " > > .BR export ", " remove ", " rdiff ", " rtag ", " > > .BR status ", " tag ", and " update . > > .I Warning: > > @@ -584,7 +613,7 @@ command option is often useful, to suppr > > file does not contain the specified tag. > > .B \-r > > is available with the > > -.BR checkout ", " commit ", " diff ", " > > +.BR annotate ", " checkout ", " commit ", " diff ", " > > .BR history ", " export ", " > > .BR rdiff ", " rtag ", and " update > > commands. > > @@ -756,6 +785,27 @@ facilities, similar to > > .BR rcs ( 1 ). > > This command works recursively, so extreme care should be > > used. > > +.TP > > +\fBannotate\fP [\fB-flR\fP] [\fB-r\fP \fItag\fP | \fB-D\fP > > \fIdate\fP] > > [\fIfiles...\fP] > > +.I Requires: > > +repository. > > +.br > > +.I Changes: > > +nothing. > > +.br > > +.I Synonyms: > > +.BR ann ", " blame > > +.br > > +Print information about the last modification of each line in > > +.IR files . > > +The information includes the revision number, the author's name, > > and > > +the date of the revision. > > +By default (or if the \fB-R\fP option is used), > > +.B annotate > > +will print information about files in sub-directories; the \fB-l\fP > > +option can be used to disable this recursion. > > +The standard options \fB-f\fP, \fB-r\fP and \fB-D\fP can be used to > > +annotate specific revisions. > > .TP > > \fBcheckout\fP [\fBoptions\fP] \fImodules\fP.\|.\|. > > .I Requires: > > >
Re: unify xmalloc (was Re: [patch] cvs: retire xfree())
I like this a lot. There are some trivial differences in the various xmalloc.h as well, and I think you could make the style consistent within the files (eg "return i" in xasprintf and xsnprintf). On Thu, Nov 05, 2015 at 03:50:29PM +0100, Tobias Stoeckmann wrote: > On Thu, Nov 05, 2015 at 09:50:48AM +, Nicholas Marriott wrote: > > I don't know why cvs and rcs xmalloc.c has ended up so different. > > It's not just about cvs and rcs: > > /usr/src/usr.bin/cvs/xmalloc.c > /usr/src/usr.bin/diff/xmalloc.c > /usr/src/usr.bin/file/xmalloc.c > /usr/src/usr.bin/rcs/xmalloc.c > /usr/src/usr.bin/ssh/xmalloc.c > /usr/src/usr.bin/tmux/xmalloc.c (probably not same origin) > > All of them share code parts that almost look identical. Some of them > skip tests, do additional tests, test for other return values, or have > typos in their error messages (or call err instead of errx, duplicating > their messages). > > This diff would unify them, taking into account that still different > style guides apply (tmux) and some use fatal() or errx() with even > different return values (diff). Ugh... > > > Index: usr.bin/cvs/xmalloc.c > === > RCS file: /cvs/src/usr.bin/cvs/xmalloc.c,v > retrieving revision 1.12 > diff -u -p -u -p -r1.12 xmalloc.c > --- usr.bin/cvs/xmalloc.c 5 Nov 2015 09:48:21 - 1.12 > +++ usr.bin/cvs/xmalloc.c 5 Nov 2015 14:42:09 - > @@ -13,6 +13,7 @@ > * called by a name other than "ssh" or "Secure Shell". > */ > > +#include > #include > #include > #include > @@ -30,7 +31,7 @@ xmalloc(size_t size) > fatal("xmalloc: zero size"); > ptr = malloc(size); > if (ptr == NULL) > - fatal("xmalloc: out of memory (allocating %lu bytes)", (u_long) > size); > + fatal("xmalloc: out of memory (allocating %zu bytes)", size); > return ptr; > } > > @@ -41,12 +42,10 @@ xcalloc(size_t nmemb, size_t size) > > if (size == 0 || nmemb == 0) > fatal("xcalloc: zero size"); > - if (SIZE_MAX / nmemb < size) > - fatal("xcalloc: nmemb * size > SIZE_MAX"); > ptr = calloc(nmemb, size); > if (ptr == NULL) > - fatal("xcalloc: out of memory (allocating %lu bytes)", > - (u_long)(size * nmemb)); > + fatal("xcalloc: out of memory (allocating %zu * %zu bytes)", > + nmemb, size); > return ptr; > } > > @@ -54,28 +53,23 @@ void * > xreallocarray(void *ptr, size_t nmemb, size_t size) > { > void *new_ptr; > - size_t new_size = nmemb * size; > > - if (new_size == 0) > - fatal("xrealloc: zero size"); > - if (SIZE_MAX / nmemb < size) > - fatal("xrealloc: nmemb * size > SIZE_MAX"); > - new_ptr = realloc(ptr, new_size); > + if (nmemb == 0 || size == 0) > + fatal("xreallocarray: zero size"); > + new_ptr = reallocarray(ptr, nmemb, size); > if (new_ptr == NULL) > - fatal("xrealloc: out of memory (new_size %lu bytes)", > - (u_long) new_size); > + fatal("xreallocarray: out of memory " > + "(allocating %zu * %zu bytes)", nmemb, size); > return new_ptr; > } > > char * > xstrdup(const char *str) > { > - size_t len; > char *cp; > > - len = strlen(str) + 1; > - cp = xmalloc(len); > - strlcpy(cp, str, len); > + if ((cp = strdup(str)) == NULL) > + fatal("xstrdup: could not allocate memory"); > return cp; > } > > @@ -96,17 +90,20 @@ xasprintf(char **ret, const char *fmt, . > } > > int > -xsnprintf(char *str, size_t size, const char *fmt, ...) > +xsnprintf(char *str, size_t len, const char *fmt, ...) > { > va_list ap; > int i; > > + if (len > INT_MAX) > + fatal("xsnprintf: len > INT_MAX"); > + > va_start(ap, fmt); > - i = vsnprintf(str, size, fmt, ap); > + i = vsnprintf(str, len, fmt, ap); > va_end(ap); > > - if (i == -1 || i >= (int)size) > - fatal("xsnprintf: overflow"); > + if (i < 0 || i >= (int)len) > + fatal("xsnprintf: could not allocate memory"); > > return (i); > } > Index: usr.bin/diff/xmalloc.c > === > RCS file: /cvs/src/usr.bin/diff/xmalloc.c,v > retrieving revision 1.8 > diff -u -p -u -p -r1.8 xmalloc.c > --- usr.bin/diff/xmalloc.c25 Sep 2015 16:16:26 - 1.8 > +++ usr.bin/diff/xmalloc.c5 Nov 2015 14:42:09 - > @@ -27,9 +27,11 @@ xmalloc(size_t size) > { > void *ptr; > > + if (size == 0) > + errx(2, "xmalloc: zero size"); > ptr = malloc(size); > if (ptr == NULL) > - err(2, "xmalloc %zu", size); > + errx(2, "xmalloc: out of memory (allocating %zu bytes)", size); > return ptr; > } > > @@ -40,7 +42,7 @@ xcalloc(size_t nmemb, size_t size) > > pt
Re: ftp.1: "dir |more" example not working as intended
Hi Frederic, Frederic Nowak wrote on Tue, Nov 03, 2015 at 04:59:35PM +0100: > I think the "dir |more" example in ftp.1 is not working as intended. > > ls (and by extension its synonym dir) expects to be called like this: > > ls [remote-directory [local-file]] > > Therefore, "dir |more" would print the contents of a remote directory > called "|more", which usually doesn't exist. I think the example is > supposed to be "dir . |more" which pipes the contents of the current > directory to more. > > The first patch below changes "dir |more" to "dir . |more". The second > patch changes it to "ls . |more", in case ls should be preferred over > its synonym dir. Second patch committed. Thanks! Ingo > Index: usr.bin/ftp/ftp.1 > === > RCS file: /cvs/src/usr.bin/ftp/ftp.1,v > retrieving revision 1.100 > diff -u -p -r1.100 ftp.1 > --- usr.bin/ftp/ftp.1 25 Sep 2015 20:32:39 - 1.100 > +++ usr.bin/ftp/ftp.1 3 Nov 2015 15:31:04 - > @@ -1481,7 +1481,7 @@ must be quoted; e.g., > .Qq ls -lt . > A particularly > useful example of this mechanism is: > -.Qq dir |more . > +.Qq ls \&. |more . > .It > Failing the above checks, if > .Dq globbing >
Re: unify xmalloc (was Re: [patch] cvs: retire xfree())
On Thu, Nov 05, 2015 at 03:57:26PM +, Nicholas Marriott wrote: > I like this a lot. > > There are some trivial differences in the various xmalloc.h as well, and > I think you could make the style consistent within the files (eg "return > i" in xasprintf and xsnprintf). Oh yes, forgot to check the header files. Updated diff below, including the return (i) vs. return i change. Index: usr.bin/cvs/xmalloc.c === RCS file: /cvs/src/usr.bin/cvs/xmalloc.c,v retrieving revision 1.12 diff -u -p -u -p -r1.12 xmalloc.c --- usr.bin/cvs/xmalloc.c 5 Nov 2015 09:48:21 - 1.12 +++ usr.bin/cvs/xmalloc.c 5 Nov 2015 16:32:21 - @@ -13,6 +13,7 @@ * called by a name other than "ssh" or "Secure Shell". */ +#include #include #include #include @@ -30,7 +31,7 @@ xmalloc(size_t size) fatal("xmalloc: zero size"); ptr = malloc(size); if (ptr == NULL) - fatal("xmalloc: out of memory (allocating %lu bytes)", (u_long) size); + fatal("xmalloc: out of memory (allocating %zu bytes)", size); return ptr; } @@ -41,12 +42,10 @@ xcalloc(size_t nmemb, size_t size) if (size == 0 || nmemb == 0) fatal("xcalloc: zero size"); - if (SIZE_MAX / nmemb < size) - fatal("xcalloc: nmemb * size > SIZE_MAX"); ptr = calloc(nmemb, size); if (ptr == NULL) - fatal("xcalloc: out of memory (allocating %lu bytes)", - (u_long)(size * nmemb)); + fatal("xcalloc: out of memory (allocating %zu * %zu bytes)", + nmemb, size); return ptr; } @@ -54,28 +53,23 @@ void * xreallocarray(void *ptr, size_t nmemb, size_t size) { void *new_ptr; - size_t new_size = nmemb * size; - if (new_size == 0) - fatal("xrealloc: zero size"); - if (SIZE_MAX / nmemb < size) - fatal("xrealloc: nmemb * size > SIZE_MAX"); - new_ptr = realloc(ptr, new_size); + if (nmemb == 0 || size == 0) + fatal("xreallocarray: zero size"); + new_ptr = reallocarray(ptr, nmemb, size); if (new_ptr == NULL) - fatal("xrealloc: out of memory (new_size %lu bytes)", - (u_long) new_size); + fatal("xreallocarray: out of memory " + "(allocating %zu * %zu bytes)", nmemb, size); return new_ptr; } char * xstrdup(const char *str) { - size_t len; char *cp; - len = strlen(str) + 1; - cp = xmalloc(len); - strlcpy(cp, str, len); + if ((cp = strdup(str)) == NULL) + fatal("xstrdup: could not allocate memory"); return cp; } @@ -92,21 +86,24 @@ xasprintf(char **ret, const char *fmt, . if (i < 0 || *ret == NULL) fatal("xasprintf: could not allocate memory"); - return (i); + return i; } int -xsnprintf(char *str, size_t size, const char *fmt, ...) +xsnprintf(char *str, size_t len, const char *fmt, ...) { va_list ap; int i; + if (len > INT_MAX) + fatal("xsnprintf: len > INT_MAX"); + va_start(ap, fmt); - i = vsnprintf(str, size, fmt, ap); + i = vsnprintf(str, len, fmt, ap); va_end(ap); - if (i == -1 || i >= (int)size) - fatal("xsnprintf: overflow"); + if (i < 0 || i >= (int)len) + fatal("xsnprintf: could not allocate memory"); - return (i); + return i; } Index: usr.bin/diff/xmalloc.c === RCS file: /cvs/src/usr.bin/diff/xmalloc.c,v retrieving revision 1.8 diff -u -p -u -p -r1.8 xmalloc.c --- usr.bin/diff/xmalloc.c 25 Sep 2015 16:16:26 - 1.8 +++ usr.bin/diff/xmalloc.c 5 Nov 2015 16:32:21 - @@ -27,9 +27,11 @@ xmalloc(size_t size) { void *ptr; + if (size == 0) + errx(2, "xmalloc: zero size"); ptr = malloc(size); if (ptr == NULL) - err(2, "xmalloc %zu", size); + errx(2, "xmalloc: out of memory (allocating %zu bytes)", size); return ptr; } @@ -40,7 +42,7 @@ xcalloc(size_t nmemb, size_t size) ptr = calloc(nmemb, size); if (ptr == NULL) - err(2, "xcalloc: out of memory (allocating %zu*%zu bytes)", + errx(2, "xcalloc: out of memory (allocating %zu * %zu bytes)", nmemb, size); return ptr; } @@ -52,7 +54,8 @@ xreallocarray(void *ptr, size_t nmemb, s new_ptr = reallocarray(ptr, nmemb, size); if (new_ptr == NULL) - err(2, "xrealloc %zu*%zu", nmemb, size); + errx(2, "xreallocarray: out of memory " + "(allocating %zu * %zu bytes)", nmemb, size); return new_ptr; } @@ -62,7 +65,7 @@ xstrdup(const char *str) char *cp;
Re: patch: fix top
Marc Espie wrote: > On Thu, Nov 05, 2015 at 11:52:32AM +0100, Theo Buehler wrote: > > On Thu, Nov 05, 2015 at 11:33:56AM +0100, Marc Espie wrote: > > > On Thu, Nov 05, 2015 at 10:54:32AM +0100, Theo Buehler wrote: > > > > On Thu, Nov 05, 2015 at 10:42:54AM +0100, Marc Espie wrote: > > > > > - if (pledge("stdio rpath getpw tty id ps vminfo", NULL) == -1) > > > > > + if (pledge("stdio rpath getpw tty proc id ps vminfo", NULL) == > > > > > -1) > > > > > err(1, "pledge"); > > > > > > > > I think both "proc" and "id" are too much: "id" was added to enable > > > > renicing, but "proc" is good enough for that: > > > > > > > > Index: usr.bin/top/top.c > > > > === > > > > RCS file: /cvs/src/usr.bin/top/top.c,v > > > > retrieving revision 1.87 > > > > diff -u -p -r1.87 top.c > > > > --- usr.bin/top/top.c 4 Nov 2015 21:28:27 - 1.87 > > > > +++ usr.bin/top/top.c 5 Nov 2015 09:54:04 - > > > > @@ -328,7 +328,7 @@ main(int argc, char *argv[]) > > > > preset_argc = 0; > > > > } while (i != 0); > > > > > > > > - if (pledge("stdio rpath getpw tty id ps vminfo", NULL) == -1) > > > > + if (pledge("stdio rpath getpw tty proc ps vminfo", NULL) == -1) > > > > err(1, "pledge"); > > > > > > > > /* set constants for username/uid display correctly */ > > > > > > WHAT ? I don't see setpriority in the list of syscalls that proc enables. > > > > > > > That's right. Nevertheless /src/sys/kern/kern_pledge.c, line 234: > > > > 229 [SYS_setsid] = PLEDGE_PROC, > > 230 > > 231 [SYS_setrlimit] = PLEDGE_PROC | PLEDGE_ID, > > 232 [SYS_getpriority] = PLEDGE_PROC | PLEDGE_ID, > > 233 > > 234 [SYS_setpriority] = PLEDGE_PROC | PLEDGE_ID, > > 235 > > 236 [SYS_setuid] = PLEDGE_ID, > > > > This was added to enable csh's nice builtin without adding "id" to > > csh's promises. > > It's not documented so it doesn't exist for me. :P > > (hint hint) Seconded.
Re: unbound 1.5.6 update
I have one OK for unbound/nsd, no other feedback. I'd like to commit these updates soon so if anyone has any objections please speak up.
Re: cvs.1: document annotate command
On Thu, Nov 05, 2015 at 04:59:21PM +0100, Frederic Nowak wrote: > > On 05 November 2015 at 16:08 Jason McIntyre wrote: > > > > > > On Thu, Nov 05, 2015 at 03:11:38PM +0100, Frederic Nowak wrote: > > > Hi there, > > > > > > it seems the documentation for cvs(1) is missing a few commands: > > > annotate, edit, editors, login, logout, pserver, rannotate, rlog, > > > server, version, watch, watchers, unedit > > > The patch below adds a description for annotate. > > > > > > Cheers, > > > Frederic > > > > > > Index: gnu/usr.bin/cvs/man/cvs.1 > > > === > > > > please mail doc fixes for gnu cvs to that project. you probably want > > to > > check any issues are not present in the latest version before you do > > so. > > > > jmc > > > > But it seems that cvs.1 is maintained independently of the gnu > version. gnu autogenerates cvs.1 from cvs.texinfo, which contains the > missing commands, but is in a completely different style. > > Frederic > however it's generated, we don;t have local changes in this file (as far as i'm aware). if gnu cvs have some doc bugs, you can ping them. if not, then our doc is out of date. but i doubt anyone will work on updating this page independently. jmc
chgrp(1) & chown(8): mark -h and -R as mutually exclusive
Hi there, the command line arguments -h and -R for chgrp and chown are mutually exclusive. The patch below changes the markup and the usage strings to make this clearer. Cheers, Frederic Index: bin/chmod/chgrp.1 === RCS file: /cvs/src/bin/chmod/chgrp.1,v retrieving revision 1.16 diff -u -p -r1.16 chgrp.1 --- bin/chmod/chgrp.1 21 Jan 2014 22:35:44 - 1.16 +++ bin/chmod/chgrp.1 5 Nov 2015 17:09:11 - @@ -40,9 +40,7 @@ .Nd change group .Sh SYNOPSIS .Nm chgrp -.Op Fl h -.Oo -.Fl R +.Oo Fl h | R .Op Fl H | L | P .Oc .Ar group Index: bin/chmod/chmod.c === RCS file: /cvs/src/bin/chmod/chmod.c,v retrieving revision 1.38 diff -u -p -r1.38 chmod.c --- bin/chmod/chmod.c 9 Oct 2015 01:37:06 - 1.38 +++ bin/chmod/chmod.c 5 Nov 2015 17:09:11 - @@ -350,11 +350,11 @@ usage(void) __progname, ischmod ? "mode" : "flags"); else fprintf(stderr, - "usage: %s [-h] [-R [-H | -L | -P]] %s file ...\n", + "usage: %s [-h | -R [-H | -L | -P]] %s file ...\n", __progname, ischown ? "owner[:group]" : "group"); if (ischown) fprintf(stderr, - " %s [-h] [-R [-H | -L | -P]] :group file ...\n", + " %s [-h | -R [-H | -L | -P]] :group file ...\n", __progname); exit(1); } Index: bin/chmod/chown.8 === RCS file: /cvs/src/bin/chmod/chown.8,v retrieving revision 1.19 diff -u -p -r1.19 chown.8 --- bin/chmod/chown.8 14 Sep 2015 20:06:58 - 1.19 +++ bin/chmod/chown.8 5 Nov 2015 17:09:11 - @@ -37,17 +37,13 @@ .Nd change file owner and group .Sh SYNOPSIS .Nm chown -.Op Fl h -.Oo -.Fl R +.Oo Fl h | R .Op Fl H | L | P .Oc .Ar owner Ns Op : Ns Ar group .Ar .Nm chown -.Op Fl h -.Oo -.Fl R +.Oo Fl h | R .Op Fl H | L | P .Oc .Pf : Ar group
Re: patch: fix top
On Thu, Nov 05, 2015 at 11:52:34AM -0500, Michael McConville wrote: > > It's not documented so it doesn't exist for me. :P > > > > (hint hint) > > Seconded. Here is an update for some missing syscalls for "stdio", "proc" and "id": Index: lib/libc/sys/pledge.2 === RCS file: /cvs/src/lib/libc/sys/pledge.2,v retrieving revision 1.12 diff -u -p -r1.12 pledge.2 --- lib/libc/sys/pledge.2 3 Nov 2015 16:31:54 - 1.12 +++ lib/libc/sys/pledge.2 5 Nov 2015 17:21:24 - @@ -155,11 +155,11 @@ previously allocated file descriptors: .Xr getresgid 2 , .Xr getresuid 2 , .Xr getrlimit 2 , +.Xr getrusage 2 , .Xr getsid 2 , .Xr getthrid 2 , .Xr gettimeofday 2 , .Xr getuid 2 , -.Xr getuid 2 , .Xr issetugid 2 , .Xr kevent 2 , .Xr kqueue 2 , @@ -174,8 +174,10 @@ previously allocated file descriptors: .Xr pipe 2 , .Xr pipe2 2 , .Xr poll 2 , +.Xr ppoll 2 , .Xr pread 2 , .Xr preadv 2 , +.Xr pselect 2 , .Xr pwrite 2 , .Xr pwritev 2 , .Xr read 2 , @@ -189,9 +191,13 @@ previously allocated file descriptors: .Xr setitimer 2 , .Xr shutdown 2 , .Xr sigaction 2 , +.Xr sigaltstack 2 , +.Xr sigpending 2 , .Xr sigprocmask 2 , .Xr sigreturn 2 , +.Xr sigsuspend 2 , .Xr socketpair 2 , +.Xr stat 2 , .Xr umask 2 , .Xr wait4 2 , .Xr write 2 , @@ -412,8 +418,13 @@ Allows the following process relationshi .Xr vfork 2 , .Xr kill 2 , .Xr setgroups 2 , +.Xr setpgid 2 , .Xr setresgid 2 , -.Xr setresuid 2 . +.Xr setresuid 2 , +.Xr setrlimit 2 , +.Xr setsid 2 , +.Xr getpriority 2 , +.Xr setpriority 2 . .It Va "exec" Allows a process to call .Xr execve 2 . @@ -457,9 +468,11 @@ process: .Pp .Xr setuid 2 , .Xr seteuid 2 , +.Xr setreuid 2 , .Xr setresuid 2 , .Xr setgid 2 , .Xr setegid 2 , +.Xr setregid 2 , .Xr setresgid 2 , .Xr setgroups 2 , .Xr setlogin 2 ,
Re: chgrp(1) & chown(8): mark -h and -R as mutually exclusive
I don't think it makes it clearer; it makes it more confusing. The usage messages of programs are not a sufficent grammer to exactly describe what conflicts with what. Taken too far, it would bewilder newcomers. > the command line arguments -h and -R for chgrp and chown are mutually > exclusive. The patch below changes the markup and the usage strings to > make this clearer. > > Cheers, > Frederic > > Index: bin/chmod/chgrp.1 > === > RCS file: /cvs/src/bin/chmod/chgrp.1,v > retrieving revision 1.16 > diff -u -p -r1.16 chgrp.1 > --- bin/chmod/chgrp.1 21 Jan 2014 22:35:44 - 1.16 > +++ bin/chmod/chgrp.1 5 Nov 2015 17:09:11 - > @@ -40,9 +40,7 @@ > .Nd change group > .Sh SYNOPSIS > .Nm chgrp > -.Op Fl h > -.Oo > -.Fl R > +.Oo Fl h | R > .Op Fl H | L | P > .Oc > .Ar group > Index: bin/chmod/chmod.c > === > RCS file: /cvs/src/bin/chmod/chmod.c,v > retrieving revision 1.38 > diff -u -p -r1.38 chmod.c > --- bin/chmod/chmod.c 9 Oct 2015 01:37:06 - 1.38 > +++ bin/chmod/chmod.c 5 Nov 2015 17:09:11 - > @@ -350,11 +350,11 @@ usage(void) > __progname, ischmod ? "mode" : "flags"); > else > fprintf(stderr, > - "usage: %s [-h] [-R [-H | -L | -P]] %s file ...\n", > + "usage: %s [-h | -R [-H | -L | -P]] %s file ...\n", > __progname, ischown ? "owner[:group]" : "group"); > if (ischown) > fprintf(stderr, > - " %s [-h] [-R [-H | -L | -P]] :group file ...\n", > + " %s [-h | -R [-H | -L | -P]] :group file ...\n", > __progname); > exit(1); > } > Index: bin/chmod/chown.8 > === > RCS file: /cvs/src/bin/chmod/chown.8,v > retrieving revision 1.19 > diff -u -p -r1.19 chown.8 > --- bin/chmod/chown.8 14 Sep 2015 20:06:58 - 1.19 > +++ bin/chmod/chown.8 5 Nov 2015 17:09:11 - > @@ -37,17 +37,13 @@ > .Nd change file owner and group > .Sh SYNOPSIS > .Nm chown > -.Op Fl h > -.Oo > -.Fl R > +.Oo Fl h | R > .Op Fl H | L | P > .Oc > .Ar owner Ns Op : Ns Ar group > .Ar > .Nm chown > -.Op Fl h > -.Oo > -.Fl R > +.Oo Fl h | R > .Op Fl H | L | P > .Oc > .Pf : Ar group >
Re: chgrp(1) & chown(8): mark -h and -R as mutually exclusive
Hi Frederic, Theo de Raadt wrote on Thu, Nov 05, 2015 at 10:53:55AM -0700: > Frederic Nowak wrote: >> the command line arguments -h and -R for chgrp and chown are mutually >> exclusive. The patch below changes the markup and the usage strings to >> make this clearer. Thank you for working on OpenBSD manual pages! > I don't think it makes it clearer; it makes it more confusing. > > The usage messages of programs are not a sufficent grammer to exactly > describe what conflicts with what. Taken too far, it would bewilder > newcomers. For a more comprehensive explanation of why this particular patch is rejected, look at this style guide entry: http://mdocml.bsd.lv/mdoc/style/synopsis.html Other parts of the extended mdoc(7) documentation may sometimes come in handy for your work as well: http://mdocml.bsd.lv/mdoc/ Yours, Ingo > > Index: bin/chmod/chgrp.1 > > === > > RCS file: /cvs/src/bin/chmod/chgrp.1,v > > retrieving revision 1.16 > > diff -u -p -r1.16 chgrp.1 > > --- bin/chmod/chgrp.1 21 Jan 2014 22:35:44 - 1.16 > > +++ bin/chmod/chgrp.1 5 Nov 2015 17:09:11 - > > @@ -40,9 +40,7 @@ > > .Nd change group > > .Sh SYNOPSIS > > .Nm chgrp > > -.Op Fl h > > -.Oo > > -.Fl R > > +.Oo Fl h | R > > .Op Fl H | L | P > > .Oc > > .Ar group > > Index: bin/chmod/chmod.c > > === > > RCS file: /cvs/src/bin/chmod/chmod.c,v > > retrieving revision 1.38 > > diff -u -p -r1.38 chmod.c > > --- bin/chmod/chmod.c 9 Oct 2015 01:37:06 - 1.38 > > +++ bin/chmod/chmod.c 5 Nov 2015 17:09:11 - > > @@ -350,11 +350,11 @@ usage(void) > > __progname, ischmod ? "mode" : "flags"); > > else > > fprintf(stderr, > > - "usage: %s [-h] [-R [-H | -L | -P]] %s file ...\n", > > + "usage: %s [-h | -R [-H | -L | -P]] %s file ...\n", > > __progname, ischown ? "owner[:group]" : "group"); > > if (ischown) > > fprintf(stderr, > > - " %s [-h] [-R [-H | -L | -P]] :group file ...\n", > > + " %s [-h | -R [-H | -L | -P]] :group file ...\n", > > __progname); > > exit(1); > > } > > Index: bin/chmod/chown.8 > > === > > RCS file: /cvs/src/bin/chmod/chown.8,v > > retrieving revision 1.19 > > diff -u -p -r1.19 chown.8 > > --- bin/chmod/chown.8 14 Sep 2015 20:06:58 - 1.19 > > +++ bin/chmod/chown.8 5 Nov 2015 17:09:11 - > > @@ -37,17 +37,13 @@ > > .Nd change file owner and group > > .Sh SYNOPSIS > > .Nm chown > > -.Op Fl h > > -.Oo > > -.Fl R > > +.Oo Fl h | R > > .Op Fl H | L | P > > .Oc > > .Ar owner Ns Op : Ns Ar group > > .Ar > > .Nm chown > > -.Op Fl h > > -.Oo > > -.Fl R > > +.Oo Fl h | R > > .Op Fl H | L | P > > .Oc > > .Pf : Ar group
Re: [patch] tcpdump print-null AF_LINK segfault
Kevin Reay writes: > Fixes a segfault (in tcpdump.c:default_print) when a printing a raw > packet of family AF_LINK with an unknown ether_type with > MALLOC_OPTIONS=S. The original version would print 4-bytes of d0 and > occasionally segfault. > > With this change, default_print() receives a caplen that is reduced by > NULL_HDRLEN (4-bytes) which offsets the value that the p pointer has > been incremented by earlier. This behaviour matches the other > default_print call later in the function. Committed, thanks. > Index: print-null.c > === > RCS file: /cvs/src/usr.sbin/tcpdump/print-null.c,v > retrieving revision 1.21 > diff -u -p -r1.21 print-null.c > --- print-null.c 16 Jan 2015 06:40:21 - 1.21 > +++ print-null.c 5 Nov 2015 02:05:00 - > @@ -179,7 +179,7 @@ null_if_print(u_char *user, const struct > > etherproto_string(htons(extracted_ethertype))); > } > if (!xflag && !qflag) > - default_print(p, caplen); > + default_print(p, caplen - NULL_HDRLEN); > } > } else if (ether_encap_print(ether_type, p, length, > caplen) == 0) { > @@ -188,7 +188,7 @@ null_if_print(u_char *user, const struct > ether_print((u_char *)ep, length + > sizeof(*ep)); > if (!xflag && !qflag) > - default_print(p, caplen); > + default_print(p, caplen - NULL_HDRLEN); > } > break; > #endif /* __OpenBSD__ */ -- jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE
Re: patch: fix top
Michael McConville wrote: > > It's not documented so it doesn't exist for me. :P > > > > (hint hint) > > Seconded. I thought thought that this was referring to the undocumented top option. Disregard. :)
Re: cvs.1: document annotate command
On Thu, 05 Nov 2015 17:12:28 +, Jason McIntyre wrote: > however it's generated, we don;t have local changes in this file (as far > as i'm aware). if gnu cvs have some doc bugs, you can ping them. if not, > then our doc is out of date. but i doubt anyone will work on updating > this page independently. We are never going to update GNU cvs from upstream and we do actually have quite a few local changes to cvs.1 in the tree. - todd
Re: cvs.1: document annotate command
On Thu, Nov 05, 2015 at 11:26:19AM -0700, Todd C. Miller wrote: > On Thu, 05 Nov 2015 17:12:28 +, Jason McIntyre wrote: > > > however it's generated, we don;t have local changes in this file (as far > > as i'm aware). if gnu cvs have some doc bugs, you can ping them. if not, > > then our doc is out of date. but i doubt anyone will work on updating > > this page independently. > > We are never going to update GNU cvs from upstream and we do actually > have quite a few local changes to cvs.1 in the tree. > > - todd i had guessed the former, but am shocked by the latter. with the exception of a couple tweaks to make the man macros play nicely, no one has updated this file for 7 years. anyway, i stand corrected. apologies to the original poster. but for the record, i won;t be touching this page. so the diff is up for any other developer to take/comment on. jmc
Re: ld.so crash second attempt
On 03/11/15 at 01:46P, Philip Guenther wrote: > On Sun, 25 Oct 2015, Peter Hajdu wrote: > > I try to give it one more attempt with a bit more description about the > > bug. > > > > After calling dlclose in _dl_notify_unload_shlib_ group reference counts > > are decreased by following the object's grpref-list. Unfortunately the > > references are removed from the list during the graph traversal. > > > > dlclose will run all destructors of the unused objects and tries to > > unload all objects reachable from the closed object's child and > > grpref-list. Since the grpref-list references were removed, the unused > > destructed object stays in memory as garbage. Next time when this > > object is loaded it is found in the memory and crashes during load. > > > > This patch unloads all unused objects instead of following the closed > > object's child and grpref list. > > Thank you for working on this. After a long rumination, I'd like to > propose a different diff, seen below. > > Your diff changes dlclose() to switch from calling _dl_unload_shlib() to a > new function _dl_unload_unused(). They both unload refcnt==0 objects: > _dl_unload_shlib() finds them by walking the dependency tree from the > selected object, while _dl_unload_unused() just scans the entire list. > > So why is the former not sufficient? As you describe, the problem occurs > when a grpref is removed which is the last reference to an object. grprefs > are used guarantee that entire load groups are unloaded all at once and > not piecemeal. If later dlopen() adds a dependency to a child in this > load group, the entire group will be kept even if that child is the last > real link. When that dependency is added, the later object takes a grpref > to the load_object, which is root of the load group. > > As you note _dl_run_all_dtors() releases that grpref, but we still know > where it had pointed: to the load_object of some object being released! > So we can retain the behavior of _dl_unload_shlib(), but we need to add a > check for whether our load_object is now unreferenced. If so, it > previously had a grpref which has been released, so we need to take down > the entire load group. > > Thus the diff below. It works with your test setup (thanks for writing > that!), passes regress/libexec/ld.so/, and chrome hasn't choked on it. > Can someone who's familiar with the sdl problem case test it there? > Hi Philip, I've tested the patch on amd64 with a simple sdl2 test and with my original tests on both amd64 and i386. Everything seems to work just fine. Thank you very much for your effort. Peter > > Does that make sense? > > > Again, thank you for pushing on this. If what I show here works, it's > because your description triggered an "ahhh, wait a moment..." thought. > > > Philip > > > Index: library.c > === > RCS file: /data/src/openbsd/src/libexec/ld.so/library.c,v > retrieving revision 1.71 > diff -u -p -r1.71 library.c > --- library.c 16 Jan 2015 16:18:07 - 1.71 > +++ library.c 3 Nov 2015 09:09:15 - > @@ -59,9 +59,27 @@ void > _dl_unload_shlib(elf_object_t *object) > { > struct dep_node *n; > + elf_object_t *load_object = object->load_object; > + > + /* > + * If our load object has become unreferenced then we lost the > + * last group reference to it, so the entire group should be taken > + * down. The current object is somewhere below load_object in > + * the child_list tree, so it'll get cleaned up by the recursion. > + * That means we can just switch here to the load object. > + */ > + if (load_object != object && OBJECT_REF_CNT(load_object) == 0 && > + (load_object->status & STAT_UNLOADED) == 0) { > + DL_DEB(("unload_shlib switched from %s to %s\n", > + object->load_name, load_object->load_name)); > + object = load_object; > + goto unload; > + } > + > DL_DEB(("unload_shlib called on %s\n", object->load_name)); > if (OBJECT_REF_CNT(object) == 0 && > (object->status & STAT_UNLOADED) == 0) { > +unload: > object->status |= STAT_UNLOADED; > TAILQ_FOREACH(n, &object->child_list, next_sib) > _dl_unload_shlib(n->data); > Index: library_mquery.c > === > RCS file: /data/src/openbsd/src/libexec/ld.so/library_mquery.c,v > retrieving revision 1.49 > diff -u -p -r1.49 library_mquery.c > --- library_mquery.c 22 Jan 2015 05:48:17 - 1.49 > +++ library_mquery.c 3 Nov 2015 09:10:39 - > @@ -64,10 +64,27 @@ void > _dl_unload_shlib(elf_object_t *object) > { > struct dep_node *n; > + elf_object_t *load_object = object->load_object; > + > + /* > + * If our load object has become unreferenced then we lost the > + * last group reference to it, so
remove NLS directory
Hi, After removing National Language Support (NLS) from base, I think the directory /usr/share/nls should go. Having a non-existing default path in catopen(3) does not make sense, so I also removed that. ok? bluhm Index: etc/mtree/4.4BSD.dist === RCS file: /data/mirror/openbsd/cvs/src/etc/mtree/4.4BSD.dist,v retrieving revision 1.274 diff -u -p -r1.274 4.4BSD.dist --- etc/mtree/4.4BSD.dist 10 Oct 2015 09:45:15 - 1.274 +++ etc/mtree/4.4BSD.dist 1 Nov 2015 19:03:51 - @@ -613,8 +613,6 @@ usr .. mk .. -nls -.. # ./usr/share/snmp snmp Index: lib/libc/nls/catopen.c === RCS file: /data/mirror/openbsd/cvs/src/lib/libc/nls/catopen.c,v retrieving revision 1.18 diff -u -p -r1.18 catopen.c --- lib/libc/nls/catopen.c 23 Oct 2015 18:49:07 - 1.18 +++ lib/libc/nls/catopen.c 1 Nov 2015 19:11:52 - @@ -43,7 +43,6 @@ #define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) -#define NLS_DEFAULT_PATH "/usr/share/nls/%L/%N.cat:/usr/share/nls/%l.%c/%N.cat:/usr/share/nls/%l/%N.cat" #define NLS_DEFAULT_LANG "C" static nl_catd load_msgcat(const char *); @@ -67,7 +66,7 @@ catopen(const char *name, int oflag) return load_msgcat(name); if (issetugid() != 0 || (nlspath = getenv("NLSPATH")) == NULL) - nlspath = NLS_DEFAULT_PATH; + return (nl_catd) -1; lang = NULL; if (oflag & NL_CAT_LOCALE) { Index: share/man/man7/hier.7 === RCS file: /data/mirror/openbsd/cvs/src/share/man/man7/hier.7,v retrieving revision 1.144 diff -u -p -r1.144 hier.7 --- share/man/man7/hier.7 24 Aug 2015 11:16:41 - 1.144 +++ share/man/man7/hier.7 1 Nov 2015 19:04:39 - @@ -421,8 +421,6 @@ Additional i386 console fonts. .It mk/ Templates for .Xr make 1 . -.It nls/ -National Language Support (NLS) catalogs. .It snmp/ Data files for .Xr snmpd 8 .
Re: nd6_nud_hint and rt_ifp
On Thu, Nov 05, 2015 at 11:53:34AM +0100, Martin Pieuchot wrote: > Change nd6_nud_hint() to no longer use rt_ifp directly. While here > remove unused argument and convert the route check to rtisvalid(9). > > ok? OK bluhm@ > > Index: netinet/tcp_input.c > === > RCS file: /cvs/src/sys/netinet/tcp_input.c,v > retrieving revision 1.307 > diff -u -p -r1.307 tcp_input.c > --- netinet/tcp_input.c 28 Oct 2015 12:14:25 - 1.307 > +++ netinet/tcp_input.c 5 Nov 2015 10:47:29 - > @@ -144,10 +144,9 @@ struct timeval tcp_ackdrop_ppslim_last; > #ifdef INET6 > #define ND6_HINT(tp) \ > do { \ > - if (tp && tp->t_inpcb && (tp->t_inpcb->inp_flags & INP_IPV6) && \ > - tp->t_inpcb->inp_route6.ro_rt) { \ > - nd6_nud_hint(tp->t_inpcb->inp_route6.ro_rt, \ > - tp->t_inpcb->inp_rtableid); \ > + if (tp && tp->t_inpcb && (tp->t_inpcb->inp_flags & INP_IPV6) && \ > + rtisvalid(tp->t_inpcb->inp_route6.ro_rt)) { \ > + nd6_nud_hint(tp->t_inpcb->inp_route6.ro_rt);\ > } \ > } while (0) > #else > Index: netinet6/nd6.c > === > RCS file: /cvs/src/sys/netinet6/nd6.c,v > retrieving revision 1.171 > diff -u -p -r1.171 nd6.c > --- netinet6/nd6.c2 Nov 2015 12:51:16 - 1.171 > +++ netinet6/nd6.c5 Nov 2015 10:49:44 - > @@ -847,25 +847,26 @@ nd6_free(struct rtentry *rt, int gc) > * XXX cost-effective methods? > */ > void > -nd6_nud_hint(struct rtentry *rt, u_int rtableid) > +nd6_nud_hint(struct rtentry *rt) > { > struct llinfo_nd6 *ln; > + struct ifnet *ifp; > > - if (rt == NULL) { > + ifp = if_get(rt->rt_ifidx); > + if (ifp == NULL) > return; > - } > > if ((rt->rt_flags & RTF_GATEWAY) != 0 || > (rt->rt_flags & RTF_LLINFO) == 0 || > rt->rt_llinfo == NULL || rt->rt_gateway == NULL || > rt->rt_gateway->sa_family != AF_LINK) { > /* This is not a host route. */ > - return; > + goto out; > } > > ln = (struct llinfo_nd6 *)rt->rt_llinfo; > if (ln->ln_state < ND6_LLINFO_REACHABLE) > - return; > + goto out; > > /* >* if we get upper-layer reachability confirmation many times, > @@ -873,13 +874,13 @@ nd6_nud_hint(struct rtentry *rt, u_int r >*/ > ln->ln_byhint++; > if (ln->ln_byhint > nd6_maxnudhint) > - return; > + goto out; > > ln->ln_state = ND6_LLINFO_REACHABLE; > - if (!ND6_LLINFO_PERMANENT(ln)) { > - nd6_llinfo_settimer(ln, > - (long)ND_IFINFO(rt->rt_ifp)->reachable * hz); > - } > + if (!ND6_LLINFO_PERMANENT(ln)) > + nd6_llinfo_settimer(ln, (long)ND_IFINFO(ifp)->reachable * hz); > +out: > + if_put(ifp); > } > > void > Index: netinet6/nd6.h > === > RCS file: /cvs/src/sys/netinet6/nd6.h,v > retrieving revision 1.54 > diff -u -p -r1.54 nd6.h > --- netinet6/nd6.h2 Nov 2015 12:51:16 - 1.54 > +++ netinet6/nd6.h5 Nov 2015 10:42:51 - > @@ -258,7 +258,7 @@ void nd6_setmtu(struct ifnet *); > void nd6_llinfo_settimer(struct llinfo_nd6 *, long); > void nd6_timer(void *); > void nd6_purge(struct ifnet *); > -void nd6_nud_hint(struct rtentry *, u_int); > +void nd6_nud_hint(struct rtentry *); > int nd6_resolve(struct ifnet *, struct rtentry *, > struct mbuf *, struct sockaddr *, u_char *); > void nd6_rtrequest(struct ifnet *, int, struct rtentry *);
Re: remove NLS directory
On Thu, Nov 05, 2015 at 04:29:12PM +0100, Alexander Bluhm wrote: > Hi, > > After removing National Language Support (NLS) from base, I think > the directory /usr/share/nls should go. Having a non-existing > default path in catopen(3) does not make sense, so I also removed > that. It sounds like not providing a default path violates POSIX. """ If NLSPATH does not exist in the environment, or if a message catalog cannot be found in any of the components specified by NLSPATH, then an implementation-defined default path shall be used. http://pubs.opengroup.org/onlinepubs/9699919799/functions/catopen.html Do we care? Perhaps this detail is not important?
libc asr _res.nsaddr_list overflow
Hi, I had sendmail crashes because of invalid pointers in _res.dnsrch. I have 4 nameservers in /etc/resolv.conf, the last one is IPv6. /usr/include/resolv.h: #define MAXNS 3 /* max # name servers we'll track */ struct __res_state { ... struct sockaddr_in nsaddr_list[MAXNS]; /* address of name server */ unsigned short id; /* current message id */ char*dnsrch[MAXDNSRCH+1]; /* components of domain to search */ After calling res_init(3), _res.dnsrch contained part of the IPv6 nameserver address as pointer. The reason is a missing overflow check when filling _res.nsaddr_list. The sendmail crashes started when I updated and recomiled my libc today. I have no idea, why this bug did not appear before. ok? bluhm Index: lib/libc/asr/res_init.c === RCS file: /data/mirror/openbsd/cvs/src/lib/libc/asr/res_init.c,v retrieving revision 1.6 diff -u -p -r1.6 res_init.c --- lib/libc/asr/res_init.c 5 Oct 2015 02:57:16 - 1.6 +++ lib/libc/asr/res_init.c 5 Nov 2015 21:30:08 - @@ -39,7 +39,7 @@ res_init(void) { _THREAD_PRIVATE_MUTEX(init); struct asr_ctx *ac; - int i; + int i, j; ac = _asr_use_resolver(NULL); @@ -58,9 +58,13 @@ res_init(void) strlcpy(_res.lookups, ac->ac_db, sizeof(_res.lookups)); _res.nscount = ac->ac_nscount; - for (i = 0; i < ac->ac_nscount; i++) { - memcpy(&_res.nsaddr_list[i], ac->ac_ns[i], + for (i = 0, j = 0; i < ac->ac_nscount && j < MAXNS; i++) { + if (ac->ac_ns[i]->sa_family != AF_INET || + ac->ac_ns[i]->sa_len > sizeof(_res.nsaddr_list[j])) + continue; + memcpy(&_res.nsaddr_list[j], ac->ac_ns[i], ac->ac_ns[i]->sa_len); + j++; } _res.options |= RES_INIT; }
Re: remove NLS directory
On Thu, Nov 05, 2015 at 10:49:30PM +0100, Stefan Sperling wrote: > It sounds like not providing a default path violates POSIX. > Do we care? Perhaps this detail is not important? I think this spec was not written with implementations without NLS in mind. So I don't care. The kernel has pledge(2) quirks for /usr/share/nls. I want to remove them and feel better if our libc does not know the path. bluhm
Re: remove NLS directory
Hi Stefan, Stefan Sperling wrote on Thu, Nov 05, 2015 at 10:49:30PM +0100: > On Thu, Nov 05, 2015 at 04:29:12PM +0100, Alexander Bluhm wrote: >> After removing National Language Support (NLS) from base, I think >> the directory /usr/share/nls should go. Having a non-existing >> default path in catopen(3) does not make sense, so I also removed >> that. > It sounds like not providing a default path violates POSIX. > > """ > If NLSPATH does not exist in the environment, or if a message catalog > cannot be found in any of the components specified by NLSPATH, then an > implementation-defined default path shall be used. > > http://pubs.opengroup.org/onlinepubs/9699919799/functions/catopen.html > > Do we care? Perhaps this detail is not important? FWIW, i don't see anything that would disallow the implementation-defined default path from being empty. Besides, an empty default path has the same effect as a default path consisting of empty directories, except that the former is more efficient. So even if somebody insists that an empty default path is a POSIX violation, it doesn't seem to be an *observable* violation. No user is supposed to add files to /usr/share/; users are only supposed to add files to /usr/local/. So bluhm@'s diff implies no functional change and makes sense to me. Yours, Ingo
Re: remove NLS directory
On Thu, Nov 05, 2015 at 11:12:50PM +0100, Alexander Bluhm wrote: > On Thu, Nov 05, 2015 at 10:49:30PM +0100, Stefan Sperling wrote: > > It sounds like not providing a default path violates POSIX. > > Do we care? Perhaps this detail is not important? > > I think this spec was not written with implementations without NLS > in mind. So I don't care. > > The kernel has pledge(2) quirks for /usr/share/nls. I want to > remove them and feel better if our libc does not know the path. Makes sense to me.
Re: libc asr _res.nsaddr_list overflow
On Thu, 05 Nov 2015 23:08:07 +0100, Alexander Bluhm wrote: > Hi, > > I had sendmail crashes because of invalid pointers in _res.dnsrch. > I have 4 nameservers in /etc/resolv.conf, the last one is IPv6. > > /usr/include/resolv.h: > #define MAXNS 3 /* max # name servers we'll track */ > struct __res_state { > ... > struct sockaddr_in > nsaddr_list[MAXNS]; /* address of name server */ > unsigned short id; /* current message id */ > char*dnsrch[MAXDNSRCH+1]; /* components of domain to search */ > > After calling res_init(3), _res.dnsrch contained part of the IPv6 > nameserver address as pointer. The reason is a missing overflow > check when filling _res.nsaddr_list. > > The sendmail crashes started when I updated and recomiled my libc > today. I have no idea, why this bug did not appear before. For anyone wondering, this only affects programs (like sendmail) that use the bind resolver internals directly. OK millert@ - todd
less time
time_t is not a long. Index: funcs.h === RCS file: /cvs/src/usr.bin/less/funcs.h,v retrieving revision 1.9 diff -u -p -r1.9 funcs.h --- funcs.h 5 Nov 2015 22:08:44 - 1.9 +++ funcs.h 5 Nov 2015 22:44:47 - @@ -227,7 +227,6 @@ extern void init_option(void); extern struct loption *findopt(int); extern struct loption *findopt_name(char **, char **, int *); extern int iread(int, unsigned char *, unsigned int); -extern long get_time(void); extern char *errno_message(char *); extern int percentage(off_t, off_t); extern off_t percent_pos(off_t, int, long); Index: linenum.c === RCS file: /cvs/src/usr.bin/less/linenum.c,v retrieving revision 1.8 diff -u -p -r1.8 linenum.c --- linenum.c 5 Nov 2015 22:08:44 - 1.8 +++ linenum.c 5 Nov 2015 22:44:47 - @@ -210,14 +210,14 @@ longloopmessage(void) } static int loopcount; -static long startime; +static time_t startime; static void longish(void) { if (loopcount >= 0 && ++loopcount > 100) { loopcount = 0; - if (get_time() >= startime + LONGTIME) { + if (time(NULL) >= startime + LONGTIME) { longloopmessage(); loopcount = -1; } @@ -287,7 +287,7 @@ find_linenum(off_t pos) * The decision is based on which way involves * traversing fewer bytes in the file. */ - startime = get_time(); + startime = time(NULL); if (p == &anchor || pos - p->prev->pos < p->pos - pos) { /* * Go forward. Index: os.c === RCS file: /cvs/src/usr.bin/less/os.c,v retrieving revision 1.12 diff -u -p -r1.12 os.c --- os.c5 Nov 2015 22:08:44 - 1.12 +++ os.c5 Nov 2015 22:44:47 - @@ -56,18 +56,6 @@ start: } /* - * Return the current time. - */ -long -get_time(void) -{ - time_t t; - - (void) time(&t); - return (t); -} - -/* * errno_message: Return an error message based on the value of "errno". */ char *
less ppp in getty
Sorry, uh, not tested... Index: main.c === RCS file: /cvs/src/libexec/getty/main.c,v retrieving revision 1.38 diff -u -p -r1.38 main.c --- main.c 16 Oct 2015 22:25:50 - 1.38 +++ main.c 5 Nov 2015 22:57:52 - @@ -158,7 +158,7 @@ main(int argc, char *argv[]) char *tname; int repcnt = 0, failopenlogged = 0; struct rlimit limit; - int rval, off = 0; + int off = 0; signal(SIGINT, SIG_IGN); /* @@ -278,14 +278,7 @@ main(int argc, char *argv[]) signal(SIGALRM, dingdong); alarm(TO); } - if ((rval = getname()) == 2) { - oflush(); - alarm(0); - signal(SIGALRM, SIG_DFL); - execle(PP, "ppplogin", ttyn, (char *) 0, env); - syslog(LOG_ERR, "%s: %m", PP); - exit(1); - } else if (rval) { + if (getname()) { int i; oflush(); @@ -339,7 +332,6 @@ main(int argc, char *argv[]) static int getname(void) { - int ppp_state = 0, ppp_connection = 0; unsigned char cs; int c, r; char *np; @@ -374,33 +366,6 @@ getname(void) if ((c = cs&0177) == 0) return (0); - /* -* PPP detection state machine.. -* Look for sequences: -* PPP_FRAME, PPP_STATION, PPP_ESCAPE, PPP_CONTROL_ESCAPED or -* PPP_FRAME, PPP_STATION, PPP_CONTROL (deviant from RFC) -* See RFC1662. -* Derived from code from Michael Hancock -* and Erik 'PPP' Olson -*/ - if (PP && cs == PPP_FRAME) { - ppp_state = 1; - } else if (ppp_state == 1 && cs == PPP_STATION) { - ppp_state = 2; - } else if (ppp_state == 2 && cs == PPP_ESCAPE) { - ppp_state = 3; - } else if ((ppp_state == 2 && cs == PPP_CONTROL) || - (ppp_state == 3 && cs == PPP_CONTROL_ESCAPED)) { - ppp_state = 4; - } else if (ppp_state == 4 && cs == PPP_LCP_HI) { - ppp_state = 5; - } else if (ppp_state == 5 && cs == PPP_LCP_LOW) { - ppp_connection = 1; - break; - } else { - ppp_state = 0; - } - if (c == EOT) exit(1); if (c == '\r' || c == '\n' || np >= name + sizeof name -1) { @@ -446,7 +411,7 @@ getname(void) *np = 0; if (c == '\r') crmod = 1; - return (1 + ppp_connection); + return (1); } static void
execless wump
here's a nickel kid, get a terminal with scrollback... Index: wump.c === RCS file: /cvs/src/games/wump/wump.c,v retrieving revision 1.26 diff -u -p -r1.26 wump.c --- wump.c 29 Aug 2013 20:22:22 - 1.26 +++ wump.c 5 Nov 2015 23:10:55 - @@ -858,10 +858,8 @@ int_compare(const void *a, const void *b void instructions(void) { - const char *pager; - pid_t pid; - int status; - int fd; + char buf[1024]; + FILE *fp; /* * read the instructions file, if needed, and show the user how to @@ -870,34 +868,15 @@ instructions(void) if (!getans("Instructions? (y-n) ")) return; - if ((fd = open(_PATH_WUMPINFO, O_RDONLY)) == -1) { + if ((fp = fopen(_PATH_WUMPINFO, "r")) == NULL) { (void)printf( "Sorry, but the instruction file seems to have disappeared in a\n\ puff of greasy black smoke! (poof)\n"); return; } - - if (!isatty(1)) - pager = "/bin/cat"; - else { - if (!(pager = getenv("PAGER")) || (*pager == 0)) - pager = _PATH_PAGER; - } - switch (pid = fork()) { - case 0: /* child */ - if (dup2(fd, 0) == -1) - err(1, "dup2"); - (void)execl(_PATH_BSHELL, "sh", "-c", pager, (char *)NULL); - err(1, "exec sh -c %s", pager); - /* NOT REACHED */ - case -1: - err(1, "fork"); - /* NOT REACHED */ - default: - (void)waitpid(pid, &status, 0); - close(fd); - break; - } + while (fgets(buf, sizeof(buf), fp)) + fputs(buf, stdout); + fclose(fp); } void
Re: libc asr _res.nsaddr_list overflow
Looks like I have fogotten to update the name server counter correctly. ok? bluhm Index: lib/libc/asr/res_init.c === RCS file: /data/mirror/openbsd/cvs/src/lib/libc/asr/res_init.c,v retrieving revision 1.7 diff -u -p -U4 -r1.7 res_init.c --- lib/libc/asr/res_init.c 5 Nov 2015 22:44:37 - 1.7 +++ lib/libc/asr/res_init.c 5 Nov 2015 23:01:55 - @@ -56,17 +56,17 @@ res_init(void) _res.options = ac->ac_options; if (_res.lookups[0] == '\0') strlcpy(_res.lookups, ac->ac_db, sizeof(_res.lookups)); - _res.nscount = ac->ac_nscount; for (i = 0, j = 0; i < ac->ac_nscount && j < MAXNS; i++) { if (ac->ac_ns[i]->sa_family != AF_INET || ac->ac_ns[i]->sa_len > sizeof(_res.nsaddr_list[j])) continue; memcpy(&_res.nsaddr_list[j], ac->ac_ns[i], ac->ac_ns[i]->sa_len); j++; } + _res.nscount = j; _res.options |= RES_INIT; } _THREAD_PRIVATE_MUTEX_UNLOCK(init);
Re: less time
ok On Thu, Nov 05, 2015 at 05:45:15PM -0500, Ted Unangst wrote: > time_t is not a long. > > > Index: funcs.h > === > RCS file: /cvs/src/usr.bin/less/funcs.h,v > retrieving revision 1.9 > diff -u -p -r1.9 funcs.h > --- funcs.h 5 Nov 2015 22:08:44 - 1.9 > +++ funcs.h 5 Nov 2015 22:44:47 - > @@ -227,7 +227,6 @@ externvoid init_option(void); > extern struct loption *findopt(int); > extern struct loption *findopt_name(char **, char **, int *); > extern int iread(int, unsigned char *, unsigned int); > -extern long get_time(void); > extern char *errno_message(char *); > extern int percentage(off_t, off_t); > extern off_t percent_pos(off_t, int, long); > Index: linenum.c > === > RCS file: /cvs/src/usr.bin/less/linenum.c,v > retrieving revision 1.8 > diff -u -p -r1.8 linenum.c > --- linenum.c 5 Nov 2015 22:08:44 - 1.8 > +++ linenum.c 5 Nov 2015 22:44:47 - > @@ -210,14 +210,14 @@ longloopmessage(void) > } > > static int loopcount; > -static long startime; > +static time_t startime; > > static void > longish(void) > { > if (loopcount >= 0 && ++loopcount > 100) { > loopcount = 0; > - if (get_time() >= startime + LONGTIME) { > + if (time(NULL) >= startime + LONGTIME) { > longloopmessage(); > loopcount = -1; > } > @@ -287,7 +287,7 @@ find_linenum(off_t pos) >* The decision is based on which way involves >* traversing fewer bytes in the file. >*/ > - startime = get_time(); > + startime = time(NULL); > if (p == &anchor || pos - p->prev->pos < p->pos - pos) { > /* >* Go forward. > Index: os.c > === > RCS file: /cvs/src/usr.bin/less/os.c,v > retrieving revision 1.12 > diff -u -p -r1.12 os.c > --- os.c 5 Nov 2015 22:08:44 - 1.12 > +++ os.c 5 Nov 2015 22:44:47 - > @@ -56,18 +56,6 @@ start: > } > > /* > - * Return the current time. > - */ > -long > -get_time(void) > -{ > - time_t t; > - > - (void) time(&t); > - return (t); > -} > - > -/* > * errno_message: Return an error message based on the value of "errno". > */ > char * >
Re: unify xmalloc (was Re: [patch] cvs: retire xfree())
Looks good, ok nicm On Thu, Nov 05, 2015 at 05:35:22PM +0100, Tobias Stoeckmann wrote: > On Thu, Nov 05, 2015 at 03:57:26PM +, Nicholas Marriott wrote: > > I like this a lot. > > > > There are some trivial differences in the various xmalloc.h as well, and > > I think you could make the style consistent within the files (eg "return > > i" in xasprintf and xsnprintf). > > Oh yes, forgot to check the header files. Updated diff below, including > the return (i) vs. return i change. > > Index: usr.bin/cvs/xmalloc.c > === > RCS file: /cvs/src/usr.bin/cvs/xmalloc.c,v > retrieving revision 1.12 > diff -u -p -u -p -r1.12 xmalloc.c > --- usr.bin/cvs/xmalloc.c 5 Nov 2015 09:48:21 - 1.12 > +++ usr.bin/cvs/xmalloc.c 5 Nov 2015 16:32:21 - > @@ -13,6 +13,7 @@ > * called by a name other than "ssh" or "Secure Shell". > */ > > +#include > #include > #include > #include > @@ -30,7 +31,7 @@ xmalloc(size_t size) > fatal("xmalloc: zero size"); > ptr = malloc(size); > if (ptr == NULL) > - fatal("xmalloc: out of memory (allocating %lu bytes)", (u_long) > size); > + fatal("xmalloc: out of memory (allocating %zu bytes)", size); > return ptr; > } > > @@ -41,12 +42,10 @@ xcalloc(size_t nmemb, size_t size) > > if (size == 0 || nmemb == 0) > fatal("xcalloc: zero size"); > - if (SIZE_MAX / nmemb < size) > - fatal("xcalloc: nmemb * size > SIZE_MAX"); > ptr = calloc(nmemb, size); > if (ptr == NULL) > - fatal("xcalloc: out of memory (allocating %lu bytes)", > - (u_long)(size * nmemb)); > + fatal("xcalloc: out of memory (allocating %zu * %zu bytes)", > + nmemb, size); > return ptr; > } > > @@ -54,28 +53,23 @@ void * > xreallocarray(void *ptr, size_t nmemb, size_t size) > { > void *new_ptr; > - size_t new_size = nmemb * size; > > - if (new_size == 0) > - fatal("xrealloc: zero size"); > - if (SIZE_MAX / nmemb < size) > - fatal("xrealloc: nmemb * size > SIZE_MAX"); > - new_ptr = realloc(ptr, new_size); > + if (nmemb == 0 || size == 0) > + fatal("xreallocarray: zero size"); > + new_ptr = reallocarray(ptr, nmemb, size); > if (new_ptr == NULL) > - fatal("xrealloc: out of memory (new_size %lu bytes)", > - (u_long) new_size); > + fatal("xreallocarray: out of memory " > + "(allocating %zu * %zu bytes)", nmemb, size); > return new_ptr; > } > > char * > xstrdup(const char *str) > { > - size_t len; > char *cp; > > - len = strlen(str) + 1; > - cp = xmalloc(len); > - strlcpy(cp, str, len); > + if ((cp = strdup(str)) == NULL) > + fatal("xstrdup: could not allocate memory"); > return cp; > } > > @@ -92,21 +86,24 @@ xasprintf(char **ret, const char *fmt, . > if (i < 0 || *ret == NULL) > fatal("xasprintf: could not allocate memory"); > > - return (i); > + return i; > } > > int > -xsnprintf(char *str, size_t size, const char *fmt, ...) > +xsnprintf(char *str, size_t len, const char *fmt, ...) > { > va_list ap; > int i; > > + if (len > INT_MAX) > + fatal("xsnprintf: len > INT_MAX"); > + > va_start(ap, fmt); > - i = vsnprintf(str, size, fmt, ap); > + i = vsnprintf(str, len, fmt, ap); > va_end(ap); > > - if (i == -1 || i >= (int)size) > - fatal("xsnprintf: overflow"); > + if (i < 0 || i >= (int)len) > + fatal("xsnprintf: could not allocate memory"); > > - return (i); > + return i; > } > Index: usr.bin/diff/xmalloc.c > === > RCS file: /cvs/src/usr.bin/diff/xmalloc.c,v > retrieving revision 1.8 > diff -u -p -u -p -r1.8 xmalloc.c > --- usr.bin/diff/xmalloc.c25 Sep 2015 16:16:26 - 1.8 > +++ usr.bin/diff/xmalloc.c5 Nov 2015 16:32:21 - > @@ -27,9 +27,11 @@ xmalloc(size_t size) > { > void *ptr; > > + if (size == 0) > + errx(2, "xmalloc: zero size"); > ptr = malloc(size); > if (ptr == NULL) > - err(2, "xmalloc %zu", size); > + errx(2, "xmalloc: out of memory (allocating %zu bytes)", size); > return ptr; > } > > @@ -40,7 +42,7 @@ xcalloc(size_t nmemb, size_t size) > > ptr = calloc(nmemb, size); > if (ptr == NULL) > - err(2, "xcalloc: out of memory (allocating %zu*%zu bytes)", > + errx(2, "xcalloc: out of memory (allocating %zu * %zu bytes)", > nmemb, size); > return ptr; > } > @@ -52,7 +54,8 @@ xreallocarray(void *ptr, size_t nmemb, s > > new_ptr = reallocarray(ptr, nmemb, size); > if (new_ptr == NULL) > - err(2, "xrealloc %zu*%zu", nmem
delete execl from phantasia
Just deleting the option to play again seems easier than figuring out why a loop won't work like any normal program. Just push the up arrow and hit enter if you want to play again. Index: io.c === RCS file: /cvs/src/games/phantasia/io.c,v retrieving revision 1.6 diff -u -p -r1.6 io.c --- io.c12 Jul 2014 03:41:04 - 1.6 +++ io.c5 Nov 2015 23:23:55 - @@ -217,7 +217,7 @@ inputoption() / / RETURN VALUE: none / -/ MODULES CALLED: fork(), exit(), wait(), death(), alarm(), execl(), wmove(), +/ MODULES CALLED: fork(), exit(), wait(), death(), alarm(), wmove(), / signal(), getenv(), wclear(), crmode(), clearok(), waddstr(), / cleanup(), wrefresh(), leavegame(), getanswer() / Index: misc.c === RCS file: /cvs/src/games/phantasia/misc.c,v retrieving revision 1.16 diff -u -p -r1.16 misc.c --- misc.c 12 Jul 2014 03:41:04 - 1.16 +++ misc.c 5 Nov 2015 23:24:20 - @@ -827,7 +827,7 @@ leavegame() / RETURN VALUE: none / / MODULES CALLED: freerecord(), enterscore(), more(), exit(), fread(), -/ fseek(), execl(), fopen(), floor(), wmove(), drandom(), wclear(), strcmp(), +/ fseek(), fopen(), floor(), wmove(), drandom(), wclear(), strcmp(), / fwrite(), fflush(), printw(), strlcpy(), fclose(), waddstr(), cleanup(), / fprintf(), wrefresh(), getanswer(), descrtype() / @@ -928,18 +928,7 @@ death(how) clear(); move(10, 0); addstr(deathmesg[(int) ROLL(0.0, (double) sizeof(deathmesg) / sizeof(char *))]); - addstr("Care to give it another try ? "); - ch = getanswer("NY", FALSE); - - if (ch == 'Y') { - cleanup(FALSE); - execl(_PATH_GAMEPROG, "phantasia", "-s", - (Wizard ? "-S" : (char *)NULL), (char *)NULL); - exit(0); - /* NOTREACHED */ - } cleanup(TRUE); - /* NOTREACHED */ } /**/ /
less: use __progname
Not sure if such changes which diverge from upstream are wanted, but here it is. Index: less.h === RCS file: /cvs/src/usr.bin/less/less.h,v retrieving revision 1.11 diff -u -p -r1.11 less.h --- less.h 5 Nov 2015 22:18:27 - 1.11 +++ less.h 5 Nov 2015 23:14:31 - @@ -32,7 +32,6 @@ #include #include #include -#include #include /* Index: main.c === RCS file: /cvs/src/usr.bin/less/main.c,v retrieving revision 1.18 diff -u -p -r1.18 main.c --- main.c 5 Nov 2015 22:18:27 - 1.18 +++ main.c 5 Nov 2015 23:14:31 - @@ -15,7 +15,6 @@ * Entry point, initialization, miscellaneous routines. */ -#include #include #include #include "less.h" @@ -31,7 +30,7 @@ off_t start_attnpos = -1; off_t end_attnpos = -1; intwscroll; -static char*progname; +extern char*__progname; intquitting; intsecure; @@ -68,7 +67,6 @@ main(int argc, char *argv[]) IFILE ifile; char *s; - progname = basename(argv[0]); argv++; argc--; @@ -77,8 +75,8 @@ main(int argc, char *argv[]) * act like LESS_IS_MORE is set. We have to set this as early * as possible for POSIX. */ - if ((strcmp(progname, "more") == 0) || - (strcmp(progname, "page") == 0)) { + if ((strcmp(__progname, "more") == 0) || + (strcmp(__progname, "page") == 0)) { less_is_more = 1; } else { s = lgetenv("LESS_IS_MORE");
err(3) trivia
Apparently the programmer didn't know that you could pass it NULL. However, including the function name seems more informative. ok? Index: usr.sbin/netgroup_mkdb/util.c === RCS file: /cvs/src/usr.sbin/netgroup_mkdb/util.c,v retrieving revision 1.6 diff -u -p -r1.6 util.c --- usr.sbin/netgroup_mkdb/util.c 4 Mar 2012 04:05:15 - 1.6 +++ usr.sbin/netgroup_mkdb/util.c 6 Nov 2015 02:01:24 - @@ -43,7 +43,7 @@ emalloc(size_t s) { void *ptr = malloc(s); if (ptr == NULL) - err(1, "%s", ""); + err(1, "emalloc"); return ptr; } @@ -56,7 +56,7 @@ erealloc(void *p, size_t s) { void *ptr = realloc(p, s); if (ptr == NULL) - err(1, "%s", ""); + err(1, "emalloc"); return ptr; }
Re: err(3) trivia
Hi Michael, Michael McConville wrote on Thu, Nov 05, 2015 at 09:09:51PM -0500: > Apparently the programmer didn't know that you could pass it NULL. > However, including the function name seems more informative. For malloc failure, including a function name is not necessary because the message netgroup_mkdb: Cannot allocate memory is already completely clear, and it doesn't matter whether it was malloc or realloc or calloc that failed. Citing a private function name like "emalloc" is potentially confusing because the user might wonder whether the fact that a non-standard function failed might somehow be relevant to the problem, which it is not. So just err(1, NULL) seem to be best here, and after malloc failure in general. Yours, Ingo > Index: usr.sbin/netgroup_mkdb/util.c > === > RCS file: /cvs/src/usr.sbin/netgroup_mkdb/util.c,v > retrieving revision 1.6 > diff -u -p -r1.6 util.c > --- usr.sbin/netgroup_mkdb/util.c 4 Mar 2012 04:05:15 - 1.6 > +++ usr.sbin/netgroup_mkdb/util.c 6 Nov 2015 02:01:24 - > @@ -43,7 +43,7 @@ emalloc(size_t s) > { > void *ptr = malloc(s); > if (ptr == NULL) > - err(1, "%s", ""); > + err(1, "emalloc"); > return ptr; > } > > @@ -56,7 +56,7 @@ erealloc(void *p, size_t s) > { > void *ptr = realloc(p, s); > if (ptr == NULL) > - err(1, "%s", ""); > + err(1, "emalloc"); > return ptr; > }
Re: ld.so crash second attempt
On Thu, Nov 5, 2015 at 1:00 PM, Peter Hajdu wrote: ... > I've tested the patch on amd64 with a simple sdl2 test and with my > original tests on both amd64 and i386. Everything seems to work just > fine. Thank you very much for your effort. And it's now committed. Thanks again for the nudge! Philip Guenther
eou(4) - another operating systems course assignment
the last assignment i set for the operating systems course i was helping with was to write a driver for a virtual network interface that implemented the client side of a protocol i made up. the protocol was largely inspired by vxlan, but requires some negotiation for a client to get a working link with the concentrator (server). the spec is up at http://www.uq.id.au/dlg/comp3301/assignment3.pdf. i wrote a dodgy server for the students to run their code against, which is up at https://source.eait.uq.edu.au/viewvc/comp3301-pracs/2015/. my implementation of the driver (so i could test the server) is below. Index: conf/GENERIC === RCS file: /cvs/src/sys/conf/GENERIC,v retrieving revision 1.220 diff -u -p -r1.220 GENERIC --- conf/GENERIC10 Aug 2015 20:35:36 - 1.220 +++ conf/GENERIC29 Oct 2015 23:14:30 - @@ -105,6 +105,7 @@ pseudo-device tun # network tunneling o pseudo-device vether # Virtual ethernet pseudo-device vxlan # Virtual extensible LAN pseudo-device vlan# IEEE 802.1Q VLAN +pseudo-device eou pseudo-device bio 1 # ioctl multiplexing device Index: conf/files === RCS file: /cvs/src/sys/conf/files,v retrieving revision 1.603 diff -u -p -r1.603 files --- conf/files 28 Sep 2015 08:32:04 - 1.603 +++ conf/files 29 Oct 2015 23:14:30 - @@ -541,6 +541,7 @@ pseudo-device trunk: ifnet, ether, ifmed pseudo-device mpe: ifnet, ether pseudo-device mpw: ifnet, ether pseudo-device vether: ifnet, ether +pseudo-device eou: ifnet, ether pseudo-device pppx: ifnet pseudo-device vxlan: ifnet, ether, ifmedia @@ -786,6 +787,7 @@ file net/trunklacp.ctrunk file net/if_mpe.c mpe needs-count file net/if_mpw.c mpw & bridgeneeds-count file net/if_vether.c vether needs-count +file net/if_eou.c eou needs-count file net/if_pppx.c pppxneeds-count file net/if_vxlan.cvxlan needs-count file net80211/ieee80211.c wlan Index: net/if_eou.c === RCS file: net/if_eou.c diff -N net/if_eou.c --- /dev/null 1 Jan 1970 00:00:00 - +++ net/if_eou.c29 Oct 2015 23:14:32 - @@ -0,0 +1,781 @@ +/* $OpenBSD$ */ + +/* + * Copyright (c) 2009 Theo de Raadt + * Copyright (c) 2015 David Gwynne + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include + +#include "bpfilter.h" +#if NBPFILTER > 0 +#include +#endif + +/* + * protocol + */ +struct eou_header { + uint32_teou_network; + uint16_teou_type; +} __packed; + +#define EOU_T_DATA 0x +#define EOU_T_PING 0x8000 +#define EOU_T_PONG 0x8001 + +struct eou_pingpong { + struct eou_header hdr; + uint16_t_pad; + uint64_tutime; + uint8_t random[32]; + uint8_t mac[8]; +} __packed; + +#define EOU_PORT 3301 + +/* + * driver + */ +struct eou_softc; +TAILQ_HEAD(eou_softcs, eou_softc); + +struct eou_socket { + TAILQ_ENTRY(eou_socket) eso_entry; + struct eou_softcseso_softcs; + + struct socket *eso_so; + struct sockaddr_storage eso_src; + struct sockaddr_storage eso_dst; +}; + +struct eou_softc { + struct arpcomsc_ac; + struct ifmedia sc_media; + + uint32_t sc_vnetid; /* network byte order */ + + struct eou_socket *sc_eso; + TAILQ_ENTRY(eou_softc) sc_entry; + + struct task sc_send; + struct timeout sc_tick; + struct task sc_ping; + struct timeout sc_dead; +}; + +TAILQ_HEAD(eou_sockets, eou_socket) eou_sockets; +union { + uin
Re: eou(4) - another operating systems course assignment
> On 6 Nov 2015, at 15:42, David Gwynne wrote: > > the last assignment i set for the operating systems course i was > helping with was to write a driver for a virtual network interface > that implemented the client side of a protocol i made up. > > the protocol was largely inspired by vxlan, but requires some > negotiation for a client to get a working link with the concentrator > (server). > > the spec is up at http://www.uq.id.au/dlg/comp3301/assignment3.pdf. > > i wrote a dodgy server for the students to run their code against, > which is up at https://source.eait.uq.edu.au/viewvc/comp3301-pracs/2015/. oops, the server is up at https://source.eait.uq.edu.au/viewvc/comp3301-eou-server/. dlg > > my implementation of the driver (so i could test the server) is > below. > > Index: conf/GENERIC > === > RCS file: /cvs/src/sys/conf/GENERIC,v > retrieving revision 1.220 > diff -u -p -r1.220 GENERIC > --- conf/GENERIC 10 Aug 2015 20:35:36 - 1.220 > +++ conf/GENERIC 29 Oct 2015 23:14:30 - > @@ -105,6 +105,7 @@ pseudo-device tun # network tunneling o > pseudo-device vether # Virtual ethernet > pseudo-device vxlan # Virtual extensible LAN > pseudo-device vlan# IEEE 802.1Q VLAN > +pseudo-deviceeou > > pseudo-device bio 1 # ioctl multiplexing device > > Index: conf/files > === > RCS file: /cvs/src/sys/conf/files,v > retrieving revision 1.603 > diff -u -p -r1.603 files > --- conf/files28 Sep 2015 08:32:04 - 1.603 > +++ conf/files29 Oct 2015 23:14:30 - > @@ -541,6 +541,7 @@ pseudo-device trunk: ifnet, ether, ifmed > pseudo-device mpe: ifnet, ether > pseudo-device mpw: ifnet, ether > pseudo-device vether: ifnet, ether > +pseudo-device eou: ifnet, ether > pseudo-device pppx: ifnet > pseudo-device vxlan: ifnet, ether, ifmedia > > @@ -786,6 +787,7 @@ file net/trunklacp.c trunk > file net/if_mpe.c mpe needs-count > file net/if_mpw.c mpw & bridgeneeds-count > file net/if_vether.c vether needs-count > +file net/if_eou.ceou needs-count > file net/if_pppx.cpppxneeds-count > file net/if_vxlan.c vxlan needs-count > file net80211/ieee80211.c wlan > Index: net/if_eou.c > === > RCS file: net/if_eou.c > diff -N net/if_eou.c > --- /dev/null 1 Jan 1970 00:00:00 - > +++ net/if_eou.c 29 Oct 2015 23:14:32 - > @@ -0,0 +1,781 @@ > +/* $OpenBSD$ */ > + > +/* > + * Copyright (c) 2009 Theo de Raadt > + * Copyright (c) 2015 David Gwynne > + * > + * Permission to use, copy, modify, and distribute this software for any > + * purpose with or without fee is hereby granted, provided that the above > + * copyright notice and this permission notice appear in all copies. > + * > + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES > + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF > + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR > + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES > + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN > + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF > + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include > + > +#include > +#include > + > +#include > + > +#include "bpfilter.h" > +#if NBPFILTER > 0 > +#include > +#endif > + > +/* > + * protocol > + */ > +struct eou_header { > + uint32_teou_network; > + uint16_teou_type; > +} __packed; > + > +#define EOU_T_DATA 0x > +#define EOU_T_PING 0x8000 > +#define EOU_T_PONG 0x8001 > + > +struct eou_pingpong { > + struct eou_header hdr; > + uint16_t_pad; > + uint64_tutime; > + uint8_t random[32]; > + uint8_t mac[8]; > +} __packed; > + > +#define EOU_PORT 3301 > + > +/* > + * driver > + */ > +struct eou_softc; > +TAILQ_HEAD(eou_softcs, eou_softc); > + > +struct eou_socket { > + TAILQ_ENTRY(eou_socket) eso_entry; > + struct eou_softcseso_softcs; > + > + struct socket *eso_so; > + struct sockaddr_storage eso_src; > + struct sockaddr_storage eso_dst; > +}; > + > +struct eou_softc { > + struct arpcomsc_ac; > + struct ifmedia sc_media; > + > + uint32_t
fix CRYPTO_chacha_20() on BE32 platforms
Running regress/lib/libcrypto/aead fails on big-endian platforms without the following diff, for the ``Test vector from RFC7539 2.8.2'' test, due to 64-bit counters being truncated to size_t. Index: chacha/chacha.c === RCS file: /OpenBSD/src/lib/libssl/src/crypto/chacha/chacha.c,v retrieving revision 1.6 diff -u -p -r1.6 chacha.c --- chacha/chacha.c 8 Jul 2014 14:30:23 - 1.6 +++ chacha/chacha.c 6 Nov 2015 05:37:19 - @@ -57,7 +57,7 @@ ChaCha(ChaCha_ctx *ctx, unsigned char *o void CRYPTO_chacha_20(unsigned char *out, const unsigned char *in, size_t len, -const unsigned char key[32], const unsigned char iv[8], size_t counter) +const unsigned char key[32], const unsigned char iv[8], uint64_t counter) { struct chacha_ctx ctx; Index: chacha/chacha.h === RCS file: /OpenBSD/src/lib/libssl/src/crypto/chacha/chacha.h,v retrieving revision 1.6 diff -u -p -r1.6 chacha.h --- chacha/chacha.h 25 Jul 2014 14:04:51 - 1.6 +++ chacha/chacha.h 6 Nov 2015 05:37:19 - @@ -44,7 +44,7 @@ void ChaCha(ChaCha_ctx *ctx, unsigned ch size_t len); void CRYPTO_chacha_20(unsigned char *out, const unsigned char *in, size_t len, -const unsigned char key[32], const unsigned char iv[8], size_t counter); +const unsigned char key[32], const unsigned char iv[8], uint64_t counter); #ifdef __cplusplus }
Re: patch: fix top
On Thu, Nov 05, 2015 at 06:23:52PM +0100, Theo Buehler wrote: > On Thu, Nov 05, 2015 at 11:52:34AM -0500, Michael McConville wrote: > > > It's not documented so it doesn't exist for me. :P > > > > > > (hint hint) > > > > Seconded. > > Here is an update for some missing syscalls for > "stdio", "proc" and "id": > > Index: lib/libc/sys/pledge.2 > === > RCS file: /cvs/src/lib/libc/sys/pledge.2,v > retrieving revision 1.12 > diff -u -p -r1.12 pledge.2 > --- lib/libc/sys/pledge.2 3 Nov 2015 16:31:54 - 1.12 > +++ lib/libc/sys/pledge.2 5 Nov 2015 17:21:24 - > @@ -155,11 +155,11 @@ previously allocated file descriptors: > .Xr getresgid 2 , > .Xr getresuid 2 , > .Xr getrlimit 2 , > +.Xr getrusage 2 , > .Xr getsid 2 , > .Xr getthrid 2 , > .Xr gettimeofday 2 , > .Xr getuid 2 , > -.Xr getuid 2 , > .Xr issetugid 2 , > .Xr kevent 2 , > .Xr kqueue 2 , > @@ -174,8 +174,10 @@ previously allocated file descriptors: > .Xr pipe 2 , > .Xr pipe2 2 , > .Xr poll 2 , > +.Xr ppoll 2 , > .Xr pread 2 , > .Xr preadv 2 , > +.Xr pselect 2 , > .Xr pwrite 2 , > .Xr pwritev 2 , > .Xr read 2 , > @@ -189,9 +191,13 @@ previously allocated file descriptors: > .Xr setitimer 2 , > .Xr shutdown 2 , > .Xr sigaction 2 , > +.Xr sigaltstack 2 , > +.Xr sigpending 2 , > .Xr sigprocmask 2 , > .Xr sigreturn 2 , > +.Xr sigsuspend 2 , > .Xr socketpair 2 , > +.Xr stat 2 , > .Xr umask 2 , > .Xr wait4 2 , > .Xr write 2 , > @@ -412,8 +418,13 @@ Allows the following process relationshi > .Xr vfork 2 , > .Xr kill 2 , > .Xr setgroups 2 , > +.Xr setpgid 2 , > .Xr setresgid 2 , > -.Xr setresuid 2 . > +.Xr setresuid 2 , > +.Xr setrlimit 2 , > +.Xr setsid 2 , > +.Xr getpriority 2 , > +.Xr setpriority 2 . > .It Va "exec" > Allows a process to call > .Xr execve 2 . > @@ -457,9 +468,11 @@ process: > .Pp > .Xr setuid 2 , > .Xr seteuid 2 , > +.Xr setreuid 2 , > .Xr setresuid 2 , > .Xr setgid 2 , > .Xr setegid 2 , > +.Xr setregid 2 , > .Xr setresgid 2 , > .Xr setgroups 2 , > .Xr setlogin 2 , Looks like an improvement to me, thanks
Re: chgrp(1) & chown(8): mark -h and -R as mutually exclusive
> On 05 November 2015 at 18:53 Theo de Raadt > wrote: > > > I don't think it makes it clearer; it makes it more confusing. > > The usage messages of programs are not a sufficent grammer to exactly > describe what conflicts with what. Taken too far, it would bewilder > newcomers. > Understood. It's definitely more complex. I thought the synopsis should show conflicts, but I get it now. Thanks! > > the command line arguments -h and -R for chgrp and chown are > > mutually > > exclusive. The patch below changes the markup and the usage strings > > to > > make this clearer. > > > > Cheers, > > Frederic > > > > Index: bin/chmod/chgrp.1 > > === > > RCS file: /cvs/src/bin/chmod/chgrp.1,v > > retrieving revision 1.16 > > diff -u -p -r1.16 chgrp.1 > > --- bin/chmod/chgrp.1 21 Jan 2014 22:35:44 - 1.16 > > +++ bin/chmod/chgrp.1 5 Nov 2015 17:09:11 - > > @@ -40,9 +40,7 @@ > > .Nd change group > > .Sh SYNOPSIS > > .Nm chgrp > > -.Op Fl h > > -.Oo > > -.Fl R > > +.Oo Fl h | R > > .Op Fl H | L | P > > .Oc > > .Ar group > > Index: bin/chmod/chmod.c > > === > > RCS file: /cvs/src/bin/chmod/chmod.c,v > > retrieving revision 1.38 > > diff -u -p -r1.38 chmod.c > > --- bin/chmod/chmod.c 9 Oct 2015 01:37:06 - 1.38 > > +++ bin/chmod/chmod.c 5 Nov 2015 17:09:11 - > > @@ -350,11 +350,11 @@ usage(void) > > __progname, ischmod ? "mode" : "flags"); > > else > > fprintf(stderr, > > - "usage: %s [-h] [-R [-H | -L | -P]] %s file ...\n", > > + "usage: %s [-h | -R [-H | -L | -P]] %s file ...\n", > > __progname, ischown ? "owner[:group]" : "group"); > > if (ischown) > > fprintf(stderr, > > - " %s [-h] [-R [-H | -L | -P]] :group file ...\n", > > + " %s [-h | -R [-H | -L | -P]] :group file ...\n", > > __progname); > > exit(1); > > } > > Index: bin/chmod/chown.8 > > === > > RCS file: /cvs/src/bin/chmod/chown.8,v > > retrieving revision 1.19 > > diff -u -p -r1.19 chown.8 > > --- bin/chmod/chown.8 14 Sep 2015 20:06:58 - 1.19 > > +++ bin/chmod/chown.8 5 Nov 2015 17:09:11 - > > @@ -37,17 +37,13 @@ > > .Nd change file owner and group > > .Sh SYNOPSIS > > .Nm chown > > -.Op Fl h > > -.Oo > > -.Fl R > > +.Oo Fl h | R > > .Op Fl H | L | P > > .Oc > > .Ar owner Ns Op : Ns Ar group > > .Ar > > .Nm chown > > -.Op Fl h > > -.Oo > > -.Fl R > > +.Oo Fl h | R > > .Op Fl H | L | P > > .Oc > > .Pf : Ar group > > >