[patch] remove some includes from encrypt(1) tool
Hi tech@, Small clean-up for encrypt(1) tool. * remove includes that aren't needed (as built on amd64) * move __progname into usage() because it's only used there * function usage() is at top of file so it doesn't need forward declaration - Michael Index: encrypt.c === RCS file: /cvs/src/usr.bin/encrypt/encrypt.c,v retrieving revision 1.42 diff -u -p -u -r1.42 encrypt.c --- encrypt.c 10 Oct 2015 18:14:20 - 1.42 +++ encrypt.c 12 Nov 2015 08:05:55 - @@ -25,32 +25,25 @@ * SUCH DAMAGE. */ -#include -#include #include -#include #include #include #include #include #include #include -#include /* * Very simple little program, for encrypting passwords from the command * line. Useful for scripts and such. */ -extern char *__progname; - -void usage(void); - #define DO_BLF 0 void usage(void) { + extern char *__progname; (void)fprintf(stderr, "usage: %s [-b rounds] [-c class] [-p | string]\n",
Re: More less(1)
ok nicm On Wed, Nov 11, 2015 at 11:45:07PM -0500, Michael McConville wrote: > That helper function I just tweaked has a total of one usage. Maybe just > inline it? > > > Index: opttbl.c > === > RCS file: /cvs/src/usr.bin/less/opttbl.c,v > retrieving revision 1.16 > diff -u -p -r1.16 opttbl.c > --- opttbl.c 12 Nov 2015 03:13:37 - 1.16 > +++ opttbl.c 12 Nov 2015 04:43:11 - > @@ -466,18 +466,6 @@ findopt(int c) > } > > /* > - * > - */ > -static int > -is_optchar(unsigned char c) > -{ > - if (isupper(c) || islower(c) || c == '-') > - return (1); > - else > - return (0); > -} > - > -/* > * Find an option in the option table, given its option name. > * p_optname is the (possibly partial) name to look for, and > * is updated to point after the matched name. > @@ -512,7 +500,10 @@ findopt_name(char **p_optname, char **p_ >*/ > for (uppercase = 0; uppercase <= 1; uppercase++) { > len = sprefix(optname, oname->oname, uppercase); > - if (len <= 0 || is_optchar(optname[len])) { > + if (len <= 0 || > + isupper((unsigned char)optname[len]) || > + islower((unsigned char)optname[len]) || > + optname[len] == '-') { > /* >* We didn't use all of the option name. >*/ >
Re: less(1) ctype fixes
On Wed, Nov 11, 2015 at 07:27:35PM -0500, Michael McConville wrote: > is_optchar() could also take an int in order to be more compatible with > the ctype functions. Perhaps for consistency it would be better to pass an int in and cast to unsigned char when handing off to ctype. I've gotten used to seeing these casts :) But ok for me either way. > isupper() || islower() is equivalent to isalpha() in the C locale, but > not necessarily in others (see the isalpha(3) manpage). > > We could use stdbool to make is_optchar() a one-liner, but I'll resist > the temptation. > > ok? > > Index: opttbl.c > === > RCS file: /cvs/src/usr.bin/less/opttbl.c,v > retrieving revision 1.15 > diff -u -p -r1.15 opttbl.c > --- opttbl.c 6 Nov 2015 15:50:33 - 1.15 > +++ opttbl.c 12 Nov 2015 00:22:20 - > @@ -458,7 +458,8 @@ findopt(int c) > for (o = option; o->oletter != '\0'; o++) { > if (o->oletter == c) > return (o); > - if ((o->otype & TRIPLE) && (toupper(o->oletter) == c)) > + if ((o->otype & TRIPLE) && > + (toupper((unsigned char)o->oletter) == c)) > return (o); > } > return (NULL); > @@ -468,15 +469,12 @@ findopt(int c) > * > */ > static int > -is_optchar(char c) > +is_optchar(unsigned char c) > { > - if (isupper(c)) > + if (isupper(c) || islower(c) || c == '-') > return (1); > - if (islower(c)) > - return (1); > - if (c == '-') > - return (1); > - return (0); > + else > + return (0); > } > > /* >
Re: More less(1)
On Wed, Nov 11, 2015 at 11:45:07PM -0500, Michael McConville wrote: > That helper function I just tweaked has a total of one usage. Maybe just > inline it? > I agree. > > Index: opttbl.c > === > RCS file: /cvs/src/usr.bin/less/opttbl.c,v > retrieving revision 1.16 > diff -u -p -r1.16 opttbl.c > --- opttbl.c 12 Nov 2015 03:13:37 - 1.16 > +++ opttbl.c 12 Nov 2015 04:43:11 - > @@ -466,18 +466,6 @@ findopt(int c) > } > > /* > - * > - */ > -static int > -is_optchar(unsigned char c) > -{ > - if (isupper(c) || islower(c) || c == '-') > - return (1); > - else > - return (0); > -} > - > -/* > * Find an option in the option table, given its option name. > * p_optname is the (possibly partial) name to look for, and > * is updated to point after the matched name. > @@ -512,7 +500,10 @@ findopt_name(char **p_optname, char **p_ >*/ > for (uppercase = 0; uppercase <= 1; uppercase++) { > len = sprefix(optname, oname->oname, uppercase); > - if (len <= 0 || is_optchar(optname[len])) { > + if (len <= 0 || > + isupper((unsigned char)optname[len]) || > + islower((unsigned char)optname[len]) || > + optname[len] == '-') { > /* >* We didn't use all of the option name. >*/ >
if_isconnected()
This is basically a rewrite of in6_ifpprefix() in a more generic fashion. The idea is to get rid of rt_ifp. I'm also introducing if_isconnected() because I want to use it in ARP. ok? Index: netinet6/in6.c === RCS file: /cvs/src/sys/netinet6/in6.c,v retrieving revision 1.178 diff -u -p -r1.178 in6.c --- netinet6/in6.c 2 Nov 2015 15:05:23 - 1.178 +++ netinet6/in6.c 12 Nov 2015 10:33:30 - @@ -61,7 +61,6 @@ * @(#)in.c8.2 (Berkeley) 11/15/93 */ -#include "bridge.h" #include "carp.h" #include @@ -84,9 +83,6 @@ #include #include -#if NBRIDGE > 0 -#include -#endif #include #include @@ -1448,44 +1444,6 @@ in6ifa_ifpwithaddr(struct ifnet *ifp, st } return (ifatoia6(ifa)); -} - -/* - * Check whether an interface has a prefix by looking up the cloning route. - */ -int -in6_ifpprefix(const struct ifnet *ifp, const struct in6_addr *addr) -{ - struct sockaddr_in6 dst; - struct rtentry *rt; - u_int tableid = ifp->if_rdomain; - - bzero(&dst, sizeof(dst)); - dst.sin6_len = sizeof(struct sockaddr_in6); - dst.sin6_family = AF_INET6; - dst.sin6_addr = *addr; - rt = rtalloc(sin6tosa(&dst), 0, tableid); - - if (rt == NULL) - return (0); - if ((rt->rt_flags & (RTF_CLONING | RTF_CLONED)) == 0 || - (rt->rt_ifp != ifp && -#if NBRIDGE > 0 - !SAME_BRIDGE(rt->rt_ifp->if_bridgeport, ifp->if_bridgeport) && -#endif -#if NCARP > 0 - (ifp->if_type != IFT_CARP || rt->rt_ifp != ifp->if_carpdev) && - (rt->rt_ifp->if_type != IFT_CARP || rt->rt_ifp->if_carpdev != ifp)&& - (ifp->if_type != IFT_CARP || rt->rt_ifp->if_type != IFT_CARP || - rt->rt_ifp->if_carpdev != ifp->if_carpdev) && -#endif - 1)) { - rtfree(rt); - return (0); - } - - rtfree(rt); - return (1); } /* Index: netinet6/in6_var.h === RCS file: /cvs/src/sys/netinet6/in6_var.h,v retrieving revision 1.57 diff -u -p -r1.57 in6_var.h --- netinet6/in6_var.h 5 Oct 2015 01:22:34 - 1.57 +++ netinet6/in6_var.h 12 Nov 2015 10:14:21 - @@ -506,7 +506,6 @@ void*in6_domifattach(struct ifnet *); void in6_domifdetach(struct ifnet *, void *); struct in6_ifaddr *in6ifa_ifpforlinklocal(struct ifnet *, int); struct in6_ifaddr *in6ifa_ifpwithaddr(struct ifnet *, struct in6_addr *); -intin6_ifpprefix(const struct ifnet *, const struct in6_addr *); intin6_addr2scopeid(unsigned int, struct in6_addr *); intin6_matchlen(struct in6_addr *, struct in6_addr *); intin6_are_prefix_equal(struct in6_addr *, struct in6_addr *, int); Index: netinet6/nd6_nbr.c === RCS file: /cvs/src/sys/netinet6/nd6_nbr.c,v retrieving revision 1.99 diff -u -p -r1.99 nd6_nbr.c --- netinet6/nd6_nbr.c 2 Nov 2015 15:05:23 - 1.99 +++ netinet6/nd6_nbr.c 12 Nov 2015 10:36:56 - @@ -81,6 +81,8 @@ void nd6_dad_ns_output(struct dadq *, st void nd6_dad_ns_input(struct ifaddr *); void nd6_dad_duplicated(struct dadq *); +int nd6_isneighbor(const struct ifnet *, const struct in6_addr *); + static int dad_maxtry = 15;/* max # of *tries* to transmit DAD packet */ /* @@ -149,7 +151,7 @@ nd6_ns_input(struct mbuf *m, int off, in /* * Make sure the source address is from a neighbor's address. */ - if (!in6_ifpprefix(ifp, &saddr6)) { + if (!nd6_isneighbor(ifp, &saddr6)) { nd6log((LOG_INFO, "nd6_ns_input: " "NS packet from non-neighbor\n")); goto bad; @@ -684,7 +686,7 @@ nd6_na_input(struct mbuf *m, int off, in /* * Make sure the source address is from a neighbor's address. */ - if (!in6_ifpprefix(ifp, &saddr6)) { + if (!nd6_isneighbor(ifp, &saddr6)) { nd6log((LOG_INFO, "nd6_na_input: " "ND packet from non-neighbor\n")); goto bad; @@ -1405,4 +1407,28 @@ nd6_dad_ns_input(struct ifaddr *ifa) if (dp) dp->dad_ns_icount++; } +} + +/* + * Check whether ``addr'' is a neighbor address connected to ``ifp''. + */ +int +nd6_isneighbor(const struct ifnet *ifp, const struct in6_addr *addr) +{ + struct rtentry *rt; + struct sockaddr_in6 sin6; + unsigned int tableid = ifp->if_rdomain; + int rv = 0; + + memset(&sin6, 0, sizeof(sin6)); + sin6.sin6_len = sizeof(struct sockaddr_in6); + sin6.sin6_family = AF_INET6; + sin6.sin6_addr = *addr; + rt = rtalloc(sin6tosa(&sin6), 0, tableid); + + if (rtisvalid(rt) && ISSET(rt->rt_flags, RTF_CLONING|RTF_CLONED)) + rv = if_
Re: move cron socket to /var/run/cron.sock (pledge)
Theo de Raadt writes: >> Grmbl. I've hard a hard time trying to understand *why* this would be >> needed. The answer is pledge(2), who makes chmod(2) fail with EPERM >> instead of killing the process. >> >> I find this confusing. IMO pledge(2) should let the kernel do the >> appropriate security checks for chown(2). > > Cannot. pledge handles *chown() at a realistic level. > > Otherwise, we'd need pledge checks in every function reachable > by VOP_SETATTR. I'm not sure I understand the reasons, but I'll trust you on that one. Still I find this change in behavior confusing, and I hope it won't bite us in the end. I'd prefer cron not to change its gid for a weird reason, or maybe change it only around the socket chmod call, with a comment explaining why this is necessary. Otherwise, millert's diff looks good, works fine and is a very desirable improvement IMO. ok jca@ but please consider the paragraph above. -- jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE
Re: PC Engines APU2 coming soon - how is OpenBSD's support so far?
Got two APU2b4 boards yesterday, and they fail to boot 5.8 or -current, i386 or amd64, from USB early in the process (see below). So far, I could not figure out if there are differences to your setup from your dmesgs. Eventually, did you revceive an earlier hardware revision APU2a4, with an earlier version of coreboot? Also, I tried to lower serial line speed from the initial 115k of coreboot, for the (unlikely) case that the kernel should change it. Finally, 'boot -c' dos not get as far as to UKC in order to try with ACPI disabled etc. What is your serial console output at boot time? Any ideas or suggestions what I should try next? Thanks, Rolf console output from power-up: Mainboard PCEngines apu2 Enable. APIC: 00 missing read_resources APIC: 01 missing read_resources APIC: 02 missing read_resources APIC: 03 missing read_resources SeaBIOS (version rel-1.8.0-181-g0af5958) BUILD: gcc: (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4 binutils: (GNU Binutils for Ubu4 SeaBIOS (version rel-1.8.0-181-g0af5958) BUILD: gcc: (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4 binutils: (GNU Binutils for Ubu4 Found coreboot cbmem console @ dffdf000 Found mainboard PC Engines PCEngines apu2 Relocating init from 0x000eeb10 to 0xdff66fd0 (size 28576) Found CBFS header at 0xfc50 multiboot: eax=0, ebx=0 boot order: 1: /pci@i0cf8/usb@10/usb-*@1 2: /pci@i0cf8/usb@10/usb-*@2 SeaBIOS (version rel-1.8.0-181-g0af5958) XHCI init on dev 00:10.0: regs @ 0xfeb22000, 4 ports, 32 slots, 32 byte contexts XHCIextcap 0x1 @ feb22500 XHCIprotocol USB 3.00, 2 ports (offset 1), def 0 XHCIprotocol USB 2.00, 2 ports (offset 3), def 10 XHCIextcap 0xa @ feb22540 Found 2 serial ports Searching bootorder for: /pci@i0cf8/*@14,7 EHCI init on dev 00:13.0 (regs=0xfeb25420) Searching bootorder for: /rom@img/memtest Searching bootorder for: /rom@img/setup XHCI port #3: 0x00200e03, powered, enabled, pls 0, speed 3 [High] Initialized USB HUB (0 ports used) WARNING - Timeout at xhci_event_wait:694! xhci_send_pipe: xfer failed (cc -1) Searching bootorder for: /pci@i0cf8/usb@10/storage@3/*@0/*@0,0 Searching bootorder for: /pci@i0cf8/usb@10/usb-*@3 USB MSC vendor='JetFlash' product='Transcend 1GB' rev='8.07' type=0 removable=1 USB MSC blksize=512 sectors=1972224 All threads complete. Scan for option roms PCengines Press F10 key now for boot menu: Searching bootorder for: HALT drive 0x000f5850: PCHS=0/0/0 translation=lba LCHS=978/32/63 s=1972224 Space available for UMB: c1000-ef000, f-f5850 Returned 258048 bytes of ZoneHigh e820 map has 7 items: 0: - 0009f800 = 1 RAM 1: 0009f800 - 000a = 2 RESERVED 2: 000f - 0010 = 2 RESERVED 3: 0010 - dffad000 = 1 RAM 4: dffad000 - e000 = 2 RESERVED 5: f800 - fc00 = 2 RESERVED 6: 0001 - 00011f00 = 1 RAM enter handle_19: NULL Booting from Hard Disk... Booting from :7c00 Using drive 0, partition 3. Loading. probing: pc0 com0 com1 mem[638K 3582M 496M a20=on] disk: hd0+ >> OpenBSD/amd64 BOOT 3.28 boot> cannot open hd0a:/etc/random.seed: No such file or directory booting hd0a:/5.8/amd64/bsd.rd: 3251512+1391248+2401280+0+520192 [72+360480+23]8 entry point at 0x1000160 [7205c766, 3404, 24448b12, a680a304] (output stops here)
Re: PC Engines APU2 coming soon - how is OpenBSD's support so far?
set tty com0 On 2015/11/12 14:32, Rolf Sommerhalder wrote: > Got two APU2b4 boards yesterday, and they fail to boot 5.8 or > -current, i386 or amd64, from USB early in the process (see below). > > So far, I could not figure out if there are differences to your setup > from your dmesgs. Eventually, did you revceive an earlier hardware > revision APU2a4, with an earlier version of coreboot? > > Also, I tried to lower serial line speed from the initial 115k of > coreboot, for the (unlikely) case that the kernel should change it. > > Finally, 'boot -c' dos not get as far as to UKC in order to try with > ACPI disabled etc. > > What is your serial console output at boot time? Any ideas or > suggestions what I should try next? > > Thanks, > Rolf > > > console output from power-up: > > Mainboard PCEngines apu2 Enable. > APIC: 00 missing read_resources > APIC: 01 missing read_resources > APIC: 02 missing read_resources > APIC: 03 missing read_resources > SeaBIOS (version rel-1.8.0-181-g0af5958) > BUILD: gcc: (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4 binutils: (GNU Binutils for > Ubu4 > SeaBIOS (version rel-1.8.0-181-g0af5958) > BUILD: gcc: (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4 binutils: (GNU Binutils for > Ubu4 > Found coreboot cbmem console @ dffdf000 > Found mainboard PC Engines PCEngines apu2 > Relocating init from 0x000eeb10 to 0xdff66fd0 (size 28576) > Found CBFS header at 0xfc50 > multiboot: eax=0, ebx=0 > boot order: > 1: /pci@i0cf8/usb@10/usb-*@1 > 2: /pci@i0cf8/usb@10/usb-*@2 > SeaBIOS (version rel-1.8.0-181-g0af5958) > XHCI init on dev 00:10.0: regs @ 0xfeb22000, 4 ports, 32 slots, 32 byte > contexts > XHCIextcap 0x1 @ feb22500 > XHCIprotocol USB 3.00, 2 ports (offset 1), def 0 > XHCIprotocol USB 2.00, 2 ports (offset 3), def 10 > XHCIextcap 0xa @ feb22540 > Found 2 serial ports > Searching bootorder for: /pci@i0cf8/*@14,7 > EHCI init on dev 00:13.0 (regs=0xfeb25420) > Searching bootorder for: /rom@img/memtest > Searching bootorder for: /rom@img/setup > XHCI port #3: 0x00200e03, powered, enabled, pls 0, speed 3 [High] > Initialized USB HUB (0 ports used) > WARNING - Timeout at xhci_event_wait:694! > xhci_send_pipe: xfer failed (cc -1) > Searching bootorder for: /pci@i0cf8/usb@10/storage@3/*@0/*@0,0 > Searching bootorder for: /pci@i0cf8/usb@10/usb-*@3 > USB MSC vendor='JetFlash' product='Transcend 1GB' rev='8.07' type=0 > removable=1 > USB MSC blksize=512 sectors=1972224 > All threads complete. > Scan for option roms > PCengines Press F10 key now for boot menu: > Searching bootorder for: HALT > drive 0x000f5850: PCHS=0/0/0 translation=lba LCHS=978/32/63 s=1972224 > Space available for UMB: c1000-ef000, f-f5850 > Returned 258048 bytes of ZoneHigh > e820 map has 7 items: > 0: - 0009f800 = 1 RAM > 1: 0009f800 - 000a = 2 RESERVED > 2: 000f - 0010 = 2 RESERVED > 3: 0010 - dffad000 = 1 RAM > 4: dffad000 - e000 = 2 RESERVED > 5: f800 - fc00 = 2 RESERVED > 6: 0001 - 00011f00 = 1 RAM > enter handle_19: > NULL > Booting from Hard Disk... > Booting from :7c00 > Using drive 0, partition 3. > Loading. > probing: pc0 com0 com1 mem[638K 3582M 496M a20=on] > disk: hd0+ > >> OpenBSD/amd64 BOOT 3.28 > boot> > cannot open hd0a:/etc/random.seed: No such file or directory > booting hd0a:/5.8/amd64/bsd.rd: 3251512+1391248+2401280+0+520192 > [72+360480+23]8 > entry point at 0x1000160 [7205c766, 3404, 24448b12, a680a304] > (output stops here) >
Re: PC Engines APU2 coming soon - how is OpenBSD's support so far?
you got stuck at the same place I did. For i386/amd64 you have to tell boot you want serial output either at the boot prompt or via boot.conf. stty com0 115200 set tty com0 See archive: http://marc.info/?l=openbsd-misc&m=144531335118929&w=2 And this should be on misc@ anyway. Take care. Daniel On 11/12/15 8:32 AM, Rolf Sommerhalder wrote: > Got two APU2b4 boards yesterday, and they fail to boot 5.8 or > -current, i386 or amd64, from USB early in the process (see below). > > So far, I could not figure out if there are differences to your setup > from your dmesgs. Eventually, did you revceive an earlier hardware > revision APU2a4, with an earlier version of coreboot? > > Also, I tried to lower serial line speed from the initial 115k of > coreboot, for the (unlikely) case that the kernel should change it. > > Finally, 'boot -c' dos not get as far as to UKC in order to try with > ACPI disabled etc. > > What is your serial console output at boot time? Any ideas or > suggestions what I should try next? > > Thanks, > Rolf > > > console output from power-up: > > Mainboard PCEngines apu2 Enable. > APIC: 00 missing read_resources > APIC: 01 missing read_resources > APIC: 02 missing read_resources > APIC: 03 missing read_resources > SeaBIOS (version rel-1.8.0-181-g0af5958) > BUILD: gcc: (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4 binutils: (GNU Binutils for > Ubu4 > SeaBIOS (version rel-1.8.0-181-g0af5958) > BUILD: gcc: (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4 binutils: (GNU Binutils for > Ubu4 > Found coreboot cbmem console @ dffdf000 > Found mainboard PC Engines PCEngines apu2 > Relocating init from 0x000eeb10 to 0xdff66fd0 (size 28576) > Found CBFS header at 0xfc50 > multiboot: eax=0, ebx=0 > boot order: > 1: /pci@i0cf8/usb@10/usb-*@1 > 2: /pci@i0cf8/usb@10/usb-*@2 > SeaBIOS (version rel-1.8.0-181-g0af5958) > XHCI init on dev 00:10.0: regs @ 0xfeb22000, 4 ports, 32 slots, 32 byte > contexts > XHCIextcap 0x1 @ feb22500 > XHCIprotocol USB 3.00, 2 ports (offset 1), def 0 > XHCIprotocol USB 2.00, 2 ports (offset 3), def 10 > XHCIextcap 0xa @ feb22540 > Found 2 serial ports > Searching bootorder for: /pci@i0cf8/*@14,7 > EHCI init on dev 00:13.0 (regs=0xfeb25420) > Searching bootorder for: /rom@img/memtest > Searching bootorder for: /rom@img/setup > XHCI port #3: 0x00200e03, powered, enabled, pls 0, speed 3 [High] > Initialized USB HUB (0 ports used) > WARNING - Timeout at xhci_event_wait:694! > xhci_send_pipe: xfer failed (cc -1) > Searching bootorder for: /pci@i0cf8/usb@10/storage@3/*@0/*@0,0 > Searching bootorder for: /pci@i0cf8/usb@10/usb-*@3 > USB MSC vendor='JetFlash' product='Transcend 1GB' rev='8.07' type=0 > removable=1 > USB MSC blksize=512 sectors=1972224 > All threads complete. > Scan for option roms > PCengines Press F10 key now for boot menu: > Searching bootorder for: HALT > drive 0x000f5850: PCHS=0/0/0 translation=lba LCHS=978/32/63 s=1972224 > Space available for UMB: c1000-ef000, f-f5850 > Returned 258048 bytes of ZoneHigh > e820 map has 7 items: > 0: - 0009f800 = 1 RAM > 1: 0009f800 - 000a = 2 RESERVED > 2: 000f - 0010 = 2 RESERVED > 3: 0010 - dffad000 = 1 RAM > 4: dffad000 - e000 = 2 RESERVED > 5: f800 - fc00 = 2 RESERVED > 6: 0001 - 00011f00 = 1 RAM > enter handle_19: > NULL > Booting from Hard Disk... > Booting from :7c00 > Using drive 0, partition 3. > Loading. > probing: pc0 com0 com1 mem[638K 3582M 496M a20=on] > disk: hd0+ >>> OpenBSD/amd64 BOOT 3.28 > boot> > cannot open hd0a:/etc/random.seed: No such file or directory > booting hd0a:/5.8/amd64/bsd.rd: 3251512+1391248+2401280+0+520192 > [72+360480+23]8 > entry point at 0x1000160 [7205c766, 3404, 24448b12, a680a304] > (output stops here) >
Re: PC Engines APU2 coming soon - how is OpenBSD's support so far?
Many thanks Stuart! > set tty com0 Bingo, and then reduce serial line speed from 115k to 9600 :-)
xfree leftover on diff(1)
Hi, diff(1) stopped using xfree, a few weeks ago, to use free directly, but xmalloc.h still kept a leftover: Index: xmalloc.h === RCS file: /cvs/src/usr.bin/diff/xmalloc.h,v retrieving revision 1.3 diff -u -p -u -r1.3 xmalloc.h --- xmalloc.h 29 Apr 2015 04:00:25 - 1.3 +++ xmalloc.h 12 Nov 2015 14:51:16 - @@ -22,7 +22,6 @@ void *xmalloc(size_t); void *xcalloc(size_t, size_t); void *xreallocarray(void *, size_t, size_t); -void xfree(void *); char *xstrdup(const char *); int xasprintf(char **, const char *, ...) __attribute__((__format__ (printf, 2, 3))) Best regards, Ricardo Mestre
Re: [patch] PkgCreate.pm make it more clear why a shared library is invalid
On Wed, Nov 11, 2015 at 05:13:45PM +0100, Adam Wolk wrote: > Hi tech@, > > I have been working recently on packaging a shared library for the > first time and hit a stumbling block yesterday. > > $ make package > `/usr/ports/pobj/libwebsockets-1.5/fake-amd64/.fake_done' is up to date. > ===> Building package for libwebsockets-1.5 > Create /usr/ports/packages/amd64/all/libwebsockets-1.5.tgz > reading plist| > Error: Invalid shared library @lib lib/libwebsockets.so.5 I'm pretty sure the naming scheme is out of place in the error message. But yeah, the message is not perfect.
Re: [patch] PkgCreate.pm make it more clear why a shared library is invalid
On Thu, 12 Nov 2015 16:15:35 +0100 Marc Espie wrote: > On Wed, Nov 11, 2015 at 05:13:45PM +0100, Adam Wolk wrote: > > Hi tech@, > > > > I have been working recently on packaging a shared library for the > > first time and hit a stumbling block yesterday. > > > > $ make package > > `/usr/ports/pobj/libwebsockets-1.5/fake-amd64/.fake_done' is up to > > date. ===> Building package for libwebsockets-1.5 > > Create /usr/ports/packages/amd64/all/libwebsockets-1.5.tgz > > reading plist| > > Error: Invalid shared library @lib lib/libwebsockets.so.5 > > I'm pretty sure the naming scheme is out of place in the error > message. But yeah, the message is not perfect. Maybe then just adding a name would help here? It is a bit difficult to handle since the code checks both that the file matches the naming scheme & that it's located in at least one sub-folder. Leaving it up to you. I know what to do next time I spot that. Thought it would be easier for someone else to understand the error when hit. Regards, Adam Index: OpenBSD/PkgCreate.pm === RCS file: /cvs/src/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm,v retrieving revision 1.118 diff -u -p -r1.118 PkgCreate.pm --- OpenBSD/PkgCreate.pm6 Nov 2015 08:53:12 - 1.118 +++ OpenBSD/PkgCreate.pm11 Nov 2015 16:07:33 - @@ -674,7 +674,7 @@ sub check_version $state->error("Incorrectly versioned shared library: #1", $unsubst); } } else { - $state->error("Invalid shared library #1", $unsubst); + $state->error("Invalid shared library name #1", $unsubst); } $state->{has_libraries} = 1; }
Re: export directive in make
Okay, I've had a bit of time to look (again) at gmake. This patch won't make it in its current form. It does only implement a very partial subset of what gmake does, namely the export VAR=VALUE syntax. I'll have to check gmake's code more closely, because the other export forms DO expand the full line, not just the variable value. I'm pretty sure it's more dangerous to recognize export partly and not support the other forms. There's also the fact that it's not a usual bsd-make construct (introduced as a known dot form).There's usually some risk of false positives, stuff where lines may start with export but not be export directives...
cron: use absolute paths in pathnames.h
This also gets rid of set_cron_cwd(), cron now chdirs to '/' via daemon(3). We can assume that the cron/at dirs were created at install time and we can't actually create them with the correct mode or group due to pledge anyway. I've moved the setegid(crontab) bit to open_socket() where it is actually needed. Now that common.c is gone I've moved strtot() into at.c and atrun.c (it was not actually common). - todd Index: usr.sbin/cron/Makefile === RCS file: /cvs/src/usr.sbin/cron/Makefile,v retrieving revision 1.5 diff -u -p -u -r1.5 Makefile --- usr.sbin/cron/Makefile 31 Oct 2015 12:19:41 - 1.5 +++ usr.sbin/cron/Makefile 12 Nov 2015 16:17:47 - @@ -2,7 +2,7 @@ PROG= cron SRCS= cron.c database.c user.c entry.c job.c do_command.c \ - misc.c env.c popen.c atrun.c common.c + misc.c env.c popen.c atrun.c CFLAGS+=-I${.CURDIR} MAN= cron.8 Index: usr.sbin/cron/atrun.c === RCS file: /cvs/src/usr.sbin/cron/atrun.c,v retrieving revision 1.38 diff -u -p -u -r1.38 atrun.c --- usr.sbin/cron/atrun.c 9 Nov 2015 16:37:07 - 1.38 +++ usr.sbin/cron/atrun.c 12 Nov 2015 16:17:47 - @@ -50,6 +50,21 @@ static void run_job(atjob *, char *); +static int +strtot(const char *nptr, char **endptr, time_t *tp) +{ + long long ll; + + errno = 0; + ll = strtoll(nptr, endptr, 10); + if (*endptr == nptr) + return (-1); + if (ll < 0 || (errno == ERANGE && ll == LLONG_MAX) || (time_t)ll != ll) + return (-1); + *tp = (time_t)ll; + return (0); +} + /* * Scan the at jobs dir and build up a list of jobs found. */ @@ -65,12 +80,12 @@ scan_atjobs(at_db **db, struct timespec struct dirent *file; struct stat sb; - if ((dfd = open(AT_SPOOL, O_RDONLY|O_DIRECTORY)) == -1) { - log_it("CRON", "OPEN FAILED", AT_SPOOL); + if ((dfd = open(_PATH_AT_SPOOL, O_RDONLY|O_DIRECTORY)) == -1) { + log_it("CRON", "OPEN FAILED", _PATH_AT_SPOOL); return (0); } if (fstat(dfd, &sb) != 0) { - log_it("CRON", "FSTAT FAILED", AT_SPOOL); + log_it("CRON", "FSTAT FAILED", _PATH_AT_SPOOL); close(dfd); return (0); } @@ -80,7 +95,7 @@ scan_atjobs(at_db **db, struct timespec } if ((atdir = fdopendir(dfd)) == NULL) { - log_it("CRON", "OPENDIR FAILED", AT_SPOOL); + log_it("CRON", "OPENDIR FAILED", _PATH_AT_SPOOL); close(dfd); return (0); } @@ -148,7 +163,7 @@ scan_atjobs(at_db **db, struct timespec void atrun(at_db *db, double batch_maxload, time_t now) { - char atfile[MAX_FNAME]; + char atfile[PATH_MAX]; struct stat sb; double la; atjob *job, *tjob, *batch = NULL; @@ -161,7 +176,7 @@ atrun(at_db *db, double batch_maxload, t if (job->run_time > now) continue; - snprintf(atfile, sizeof(atfile), "%s/%lld.%c", AT_SPOOL, + snprintf(atfile, sizeof(atfile), "%s/%lld.%c", _PATH_AT_SPOOL, (long long)job->run_time, job->queue); if (lstat(atfile, &sb) != 0 || !S_ISREG(sb.st_mode)) { @@ -194,7 +209,7 @@ atrun(at_db *db, double batch_maxload, t && (batch_maxload == 0.0 || ((getloadavg(&la, 1) == 1) && la <= batch_maxload)) ) { - snprintf(atfile, sizeof(atfile), "%s/%lld.%c", AT_SPOOL, + snprintf(atfile, sizeof(atfile), "%s/%lld.%c", _PATH_AT_SPOOL, (long long)batch->run_time, batch->queue); run_job(batch, atfile); TAILQ_REMOVE(&db->jobs, batch, entries); @@ -420,8 +435,6 @@ run_job(atjob *job, char *atfile) login_close(lc); } - chdir("/"); /* at job will chdir to correct place */ - /* If this is a low priority job, nice ourself. */ if (job->queue > 'b') (void)setpriority(PRIO_PROCESS, 0, job->queue - 'b'); @@ -480,8 +493,8 @@ run_job(atjob *job, char *atfile) fprintf(mail, "To: %s\n", mailto); fprintf(mail, "Subject: Output from \"at\" job\n"); fprintf(mail, "Auto-Submitted: auto-generated\n"); - fprintf(mail, "\nYour \"at\" job on %s\n\"%s/%s/%s\"\n", - hostname, CRONDIR, AT_SPOOL, atfile); + fprintf(mail, "\nYour \"at\" job on %s\n\"%s/%s\"\n", + hostname, _PATH_AT_SPOOL, atfile); fprintf(mail, "\nproduced the following output:\n\n"); /* Pipe the job's output to sendmail. */ Index: usr.sbin/cron/client.c ==
Re: unify xmalloc (was Re: [patch] cvs: retire xfree())
Michael W. Bombardieri wrote: > > > ok for removing xfree from aucat? > > > > yes, ok ratchov; if later this causes me merges i'll find another > > solution. Feel free to do the same in usr.bin/sndiod, as it's > > almost the same. > > Same thing for sndiod... ok mmcc@ > Index: abuf.c > === > RCS file: /cvs/src/usr.bin/sndiod/abuf.c,v > retrieving revision 1.3 > diff -u -p -u -r1.3 abuf.c > --- abuf.c16 Feb 2015 06:11:33 - 1.3 > +++ abuf.c12 Nov 2015 07:07:57 - > @@ -62,7 +62,7 @@ abuf_done(struct abuf *buf) > } > } > #endif > - xfree(buf->data); > + free(buf->data); > buf->data = (void *)0xdeadbeef; > } > > Index: dev.c > === > RCS file: /cvs/src/usr.bin/sndiod/dev.c,v > retrieving revision 1.18 > diff -u -p -u -r1.18 dev.c > --- dev.c 5 Sep 2015 11:19:20 - 1.18 > +++ dev.c 12 Nov 2015 07:07:57 - > @@ -15,6 +15,7 @@ > * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. > */ > #include > +#include > #include > > #include "abuf.h" > @@ -838,10 +839,8 @@ dev_cycle(struct dev *d) >*/ > s->pstate = SLOT_INIT; > abuf_done(&s->mix.buf); > - if (s->mix.decbuf) > - xfree(s->mix.decbuf); > - if (s->mix.resampbuf) > - xfree(s->mix.resampbuf); > + free(s->mix.decbuf); > + free(s->mix.resampbuf); > s->ops->eof(s->arg); > *ps = s->next; > dev_mix_adjvol(d); > @@ -1143,14 +1142,12 @@ dev_close(struct dev *d) > d->slot_list = NULL; > dev_sio_close(d); > if (d->mode & MODE_PLAY) { > - if (d->encbuf != NULL) > - xfree(d->encbuf); > - xfree(d->pbuf); > + free(d->encbuf); > + free(d->pbuf); > } > if (d->mode & MODE_REC) { > - if (d->decbuf != NULL) > - xfree(d->decbuf); > - xfree(d->rbuf); > + free(d->decbuf); > + free(d->rbuf); > } > } > > @@ -1256,7 +1253,7 @@ dev_del(struct dev *d) > } > midi_del(d->midi); > *p = d->next; > - xfree(d); > + free(d); > } > > unsigned int > @@ -1829,16 +1826,12 @@ slot_detach(struct slot *s) > } > *ps = s->next; > if (s->mode & MODE_RECMASK) { > - if (s->sub.encbuf) > - xfree(s->sub.encbuf); > - if (s->sub.resampbuf) > - xfree(s->sub.resampbuf); > + free(s->sub.encbuf); > + free(s->sub.resampbuf); > } > if (s->mode & MODE_PLAY) { > - if (s->mix.decbuf) > - xfree(s->mix.decbuf); > - if (s->mix.resampbuf) > - xfree(s->mix.resampbuf); > + free(s->mix.decbuf); > + free(s->mix.resampbuf); > dev_mix_adjvol(s->dev); > } > } > Index: file.c > === > RCS file: /cvs/src/usr.bin/sndiod/file.c,v > retrieving revision 1.15 > diff -u -p -u -r1.15 file.c > --- file.c27 Aug 2015 07:38:38 - 1.15 > +++ file.c12 Nov 2015 07:07:57 - > @@ -328,7 +328,7 @@ file_poll(void) > while ((f = *pf) != NULL) { > if (f->state == FILE_ZOMB) { > *pf = f->next; > - xfree(f); > + free(f); > } else > pf = &f->next; > } > Index: listen.c > === > RCS file: /cvs/src/usr.bin/sndiod/listen.c,v > retrieving revision 1.2 > diff -u -p -u -r1.2 listen.c > --- listen.c 13 Mar 2013 08:28:33 - 1.2 > +++ listen.c 12 Nov 2015 07:07:57 - > @@ -70,13 +70,12 @@ listen_close(struct listen *f) > } > *pf = f->next; > > - if (f->path != NULL) { > + if (f->path != NULL) > unlink(f->path); > - xfree(f->path); > - } > + free(f->path); > file_del(f->file); > close(f->fd); > - xfree(f); > + free(f); > } > > void > Index: midi.c > === > RCS file: /cvs/src/usr.bin/sndiod/midi.c,v > retrieving revision 1.10 > diff -u -p -u -r1.10 midi.c > --- midi.c28 Sep 2013 18:49:32 - 1.10 > +++ midi.c12 Nov 2015 07:07:57 - > @@ -461,7 +461,7 @@ port_del(struct port *c) > #endif > } > *p = c->next; > - xfree(c); > + free(c); > } > > int > Index: opt.c > === > RCS file: /cvs/src/usr.bin/sndiod/opt.c,v > retrievi
Remove non HMAC versions of MD5 and SHA1 from the OCF
They're not exposed via PF_KEY so I assume they were used directly via /dev/crypto. There's no code that uses them and by now no new code should. OK? Index: sys/crypto/cryptodev.h === RCS file: /cvs/src/sys/crypto/cryptodev.h,v retrieving revision 1.64 diff -u -p -r1.64 cryptodev.h --- sys/crypto/cryptodev.h 12 Nov 2015 16:57:00 - 1.64 +++ sys/crypto/cryptodev.h 12 Nov 2015 17:06:42 - @@ -93,25 +93,23 @@ #define CRYPTO_RIJNDAEL128_CBC 11 /* 128 bit blocksize */ #define CRYPTO_AES_CBC 11 /* 128 bit blocksize -- the same as above */ #define CRYPTO_ARC412 -#define CRYPTO_MD5 13 -#define CRYPTO_SHA114 -#define CRYPTO_DEFLATE_COMP15 /* Deflate compression algorithm */ -#define CRYPTO_NULL16 -#define CRYPTO_LZS_COMP17 /* LZS compression algorithm */ -#define CRYPTO_SHA2_256_HMAC 18 -#define CRYPTO_SHA2_384_HMAC 19 -#define CRYPTO_SHA2_512_HMAC 20 -#define CRYPTO_AES_CTR 21 -#define CRYPTO_AES_XTS 22 -#define CRYPTO_AES_GCM_16 23 -#define CRYPTO_AES_128_GMAC24 -#define CRYPTO_AES_192_GMAC25 -#define CRYPTO_AES_256_GMAC26 -#define CRYPTO_AES_GMAC27 -#define CRYPTO_CHACHA20_POLY1305 28 -#define CRYPTO_CHACHA20_POLY1305_MAC 29 -#define CRYPTO_ESN 30 /* Support for Extended Sequence Numbers */ -#define CRYPTO_ALGORITHM_MAX 30 /* Keep updated */ +#define CRYPTO_DEFLATE_COMP13 /* Deflate compression algorithm */ +#define CRYPTO_NULL14 +#define CRYPTO_LZS_COMP15 /* LZS compression algorithm */ +#define CRYPTO_SHA2_256_HMAC 16 +#define CRYPTO_SHA2_384_HMAC 17 +#define CRYPTO_SHA2_512_HMAC 18 +#define CRYPTO_AES_CTR 19 +#define CRYPTO_AES_XTS 20 +#define CRYPTO_AES_GCM_16 21 +#define CRYPTO_AES_128_GMAC22 +#define CRYPTO_AES_192_GMAC23 +#define CRYPTO_AES_256_GMAC24 +#define CRYPTO_AES_GMAC25 +#define CRYPTO_CHACHA20_POLY1305 26 +#define CRYPTO_CHACHA20_POLY1305_MAC 27 +#define CRYPTO_ESN 28 /* Support for Extended Sequence Numbers */ +#define CRYPTO_ALGORITHM_MAX 28 /* Keep updated */ /* Algorithm flags */ #defineCRYPTO_ALG_FLAG_SUPPORTED 0x01 /* Algorithm is supported */ Index: sys/crypto/cryptosoft.c === RCS file: /cvs/src/sys/crypto/cryptosoft.c,v retrieving revision 1.77 diff -u -p -r1.77 cryptosoft.c --- sys/crypto/cryptosoft.c 12 Nov 2015 16:57:00 - 1.77 +++ sys/crypto/cryptosoft.c 12 Nov 2015 17:06:43 - @@ -463,11 +463,6 @@ swcr_authcompute(struct cryptop *crp, st axf->Update(&ctx, aalg, axf->hashsize); axf->Final(aalg, &ctx); break; - - case CRYPTO_MD5: - case CRYPTO_SHA1: - axf->Final(aalg, &ctx); - break; } /* Inject the authentication data */ @@ -900,24 +895,6 @@ swcr_newsession(u_int32_t *sid, struct c (*swd)->sw_axf = axf; break; - case CRYPTO_MD5: - axf = &auth_hash_md5; - goto auth3common; - - case CRYPTO_SHA1: - axf = &auth_hash_sha1; - auth3common: - (*swd)->sw_ictx = malloc(axf->ctxsize, M_CRYPTO_DATA, - M_NOWAIT); - if ((*swd)->sw_ictx == NULL) { - swcr_freesession(i); - return ENOBUFS; - } - - axf->Init((*swd)->sw_ictx); - (*swd)->sw_axf = axf; - break; - case CRYPTO_AES_128_GMAC: axf = &auth_hash_gmac_aes_128; goto auth4common; @@ -1028,8 +1005,6 @@ swcr_freesession(u_int64_t tid) case CRYPTO_AES_192_GMAC: case CRYPTO_AES_256_GMAC: case CRYPTO_CHACHA20_POLY1305_MAC: - case CRYPTO_MD5: - case CRYPTO_SHA1: axf = swd->sw_axf; if (swd->sw_ictx) { @@ -1118,8 +1093,6 @@ swcr_process(struct cryptop *crp) case CRYPTO_SHA2_256_HMAC: case CRYPTO_SHA2_384_HMAC: case CRYPTO_SHA2_512_HMAC: - case CRYPTO_MD5: - case CRYPTO_SHA1: if ((crp->crp_etype = swcr_authcompute(crp, crd, sw, crp->crp_buf, type)) != 0) goto done; @@ -1179,8 +1152,6 @@ swcr_init(void) algs[CRYPTO_MD5_HMAC] = CRYPTO_ALG_FLAG_SUPPORTED; algs[CRYPTO_SHA1_HMAC] = CRYPTO_ALG_FLAG_SUPPORTED; algs[CRYPTO_RIPEMD160_HMAC] = CRYPTO_ALG_FLAG_SUPPORTED; - algs
[patch] was: Re: login(3) routines data integrity patch
Wondering if anyone had a chance to take a look at these - Subject line tagged accordingly :D Cheers, - Chris On 10/30/15 11:44, Chris Turner wrote: Hello - I was testing some login data collection scripts (on a VM) and discovered that in certain cases, it was possible for a login record to not be fully commited to disk prior to system shutdown, resulting in the last(1) entry for the login not being visible. (was doing e.g. ssh root@testbox to generate wtmp login records and then powering off the vm to see if my code processed unclean shutdown records correctly). I could see in some scenarios, aside from generating incorrect data, this incorrect record could be used to facillitate hiding presence of a successful compromise. The attached patch calls fsync(2) on related FD's in the login(3) routines, which corrected the problem on my test machine, and imho might be a good idea in general. The patch was generated on 5.8 current, but based on a rudimentary check of head it looks like it should apply cleanly and is 3 lines of diff if not :) It might be useful also to have last(1) warn of truncated/ incomplete records as were the case in my (I think now lost) corrupt wtmp file.. I did not attempt to implement this. Please let me know if there are any questions or concerns and thanks for a great system. Thanks, - Chris
Replace xfree with free on csh(1)
Hi, On csh(1), since Free() just calls free() and xfree() is a #define to Free() then free() can be called directly instead of xfree() and the #define can be removed, is this approach correct? Index: alloc.c === RCS file: /cvs/src/bin/csh/alloc.c,v retrieving revision 1.16 diff -u -p -u -r1.16 alloc.c --- alloc.c 8 Feb 2015 06:01:25 - 1.16 +++ alloc.c 12 Nov 2015 14:19:24 - @@ -74,9 +74,3 @@ Calloc(size_t s, size_t n) return (ptr); } - -void -Free(void *p) -{ - free(p); -} Index: csh.c === RCS file: /cvs/src/bin/csh/csh.c,v retrieving revision 1.36 diff -u -p -u -r1.36 csh.c --- csh.c 11 Nov 2015 02:52:46 - 1.36 +++ csh.c 12 Nov 2015 14:19:31 - @@ -609,7 +609,7 @@ srccat(Char *cp, Char *dp) Char *ep = Strspl(cp, dp); char *ptr = short2str(ep); -xfree(ep); +free(ep); return srcfile(ptr, mflag ? 0 : 1, 0); } @@ -716,10 +716,10 @@ srcunit(int unit, bool onlyown, bool hfl int i; /* We made it to the new state... free up its storage */ - /* This code could get run twice but xfree doesn't care */ + /* This code could get run twice but free doesn't care */ for (i = 0; i < fblocks; i++) - xfree(fbuf[i]); - xfree(fbuf); + free(fbuf[i]); + free(fbuf); /* Reset input arena */ memcpy(&B, &saveB, sizeof(B)); @@ -1014,7 +1014,7 @@ process(bool catch) (void) fflush(cshout); } if (seterr) { - xfree(seterr); + free(seterr); seterr = NULL; } @@ -1094,7 +1094,7 @@ dosource(Char **v, struct command *t) (void) Strlcpy(buf, *v, sizeof buf/sizeof(Char)); f = globone(buf, G_ERROR); (void) strlcpy(sbuf, short2str(f), sizeof sbuf); -xfree(f); +free(f); if (!srcfile(sbuf, 0, hflg) && !hflg) stderror(ERR_SYSTEM, sbuf, strerror(errno)); } Index: csh.h === RCS file: /cvs/src/bin/csh/csh.h,v retrieving revision 1.27 diff -u -p -u -r1.27 csh.h --- csh.h 28 Oct 2015 22:18:53 - 1.27 +++ csh.h 12 Nov 2015 14:19:32 - @@ -72,7 +72,6 @@ typedef void *ioctl_t;/* Third arg of #define xmalloc(i) Malloc(i) #define xreallocarray(p, i, j) Reallocarray(p, i, j) #define xcalloc(n, s) Calloc(n, s) -#define xfree(p) Free(p) #include FILE *cshin, *cshout, *csherr; Index: dir.c === RCS file: /cvs/src/bin/csh/dir.c,v retrieving revision 1.20 diff -u -p -u -r1.20 dir.c --- dir.c 8 Feb 2015 06:09:50 - 1.20 +++ dir.c 12 Nov 2015 14:19:34 - @@ -299,7 +299,7 @@ dnormalize(Char *cp) cwd[dotdot = Strlen(cwd)] = '/'; cwd[dotdot + 1] = '\0'; dp = Strspl(cwd, cp); - xfree(cwd); + free(cwd); return dp; } else { @@ -386,7 +386,7 @@ dgoto(Char *cp) p--;/* don't add a / after root */ for (q = cp; (*p++ = *q++) != '\0';) continue; - xfree(cp); + free(cp); cp = dp; dp += cwdlen; } @@ -414,11 +414,11 @@ dfollow(Char *cp) */ dp = dnormalize(cp); if (chdir(short2str(dp)) >= 0) { - xfree(cp); + free(cp); return dgoto(dp); } else { - xfree(dp); + free(dp); if (chdir(short2str(cp)) >= 0) return dgoto(cp); serrno = errno; @@ -438,7 +438,7 @@ dfollow(Char *cp) continue; if (chdir(short2str(buf)) >= 0) { printd = 1; - xfree(cp); + free(cp); cp = Strsave(buf); return dgoto(cp); } @@ -446,13 +446,13 @@ dfollow(Char *cp) } dp = value(cp); if ((dp[0] == '/' || dp[0] == '.') && chdir(short2str(dp)) >= 0) { - xfree(cp); + free(cp); cp = Strsave(dp); printd = 1; return dgoto(cp); } (void) strlcpy(ebuf, short2str(cp), sizeof ebuf); -xfree(cp); +free(cp); stderror(ERR_SYSTEM, ebuf, strerror(serrno)); return (NULL); } @@ -593,8 +593,8 @@ dfree(struct directory *dp) dp->di_next = dp->di_prev = 0; } else { - xfree((char *) dp->di_name); - xfree(dp); + free((char *) dp->di_name); + free(dp); } } @@ -630,7 +630,7 @@ dcanon(Char *cp, Char *p) (void) Strlcpy(tmpdir, p1, sizeof tmpdir/sizeof(Char)); (void) Strlcat(tmpdir, STRslash, sizeof tmpdir/sizeof(Char)); (void) Strlcat(tmpdir, cp, sizeof tmpdir/sizeof(Char)); - xfree(cp); + free(cp); cp = p = Strsave(tmpdir); } @@ -735,7 +735,7 @@ dcanon(Char *cp, Char *p) */
Re: Replace xfree with free on csh(1)
Ricardo Mestre wrote: > Hi, > > On csh(1), since Free() just calls free() and xfree() is a #define to > Free() then free() can be called directly instead of xfree() and the > #define can be removed, is this approach correct? Seems like this patch is mangled, unless it's something on my machine. This change looks good to me, though. > Index: alloc.c > === > RCS file: /cvs/src/bin/csh/alloc.c,v > retrieving revision 1.16 > diff -u -p -u -r1.16 alloc.c > --- alloc.c 8 Feb 2015 06:01:25 - 1.16 > +++ alloc.c 12 Nov 2015 14:19:24 - > @@ -74,9 +74,3 @@ Calloc(size_t s, size_t n) > return (ptr); > } > - > -void > -Free(void *p) > -{ > - free(p); > -} > Index: csh.c > === > RCS file: /cvs/src/bin/csh/csh.c,v > retrieving revision 1.36 > diff -u -p -u -r1.36 csh.c > --- csh.c 11 Nov 2015 02:52:46 - 1.36 > +++ csh.c 12 Nov 2015 14:19:31 - > @@ -609,7 +609,7 @@ srccat(Char *cp, Char *dp) > Char *ep = Strspl(cp, dp); > char *ptr = short2str(ep); > -xfree(ep); > +free(ep); > return srcfile(ptr, mflag ? 0 : 1, 0); > } > @@ -716,10 +716,10 @@ srcunit(int unit, bool onlyown, bool hfl > int i; > /* We made it to the new state... free up its storage */ > - /* This code could get run twice but xfree doesn't care */ > + /* This code could get run twice but free doesn't care */ > for (i = 0; i < fblocks; i++) > - xfree(fbuf[i]); > - xfree(fbuf); > + free(fbuf[i]); > + free(fbuf); > /* Reset input arena */ > memcpy(&B, &saveB, sizeof(B)); > @@ -1014,7 +1014,7 @@ process(bool catch) > (void) fflush(cshout); > } > if (seterr) { > - xfree(seterr); > + free(seterr); > seterr = NULL; > } > @@ -1094,7 +1094,7 @@ dosource(Char **v, struct command *t) > (void) Strlcpy(buf, *v, sizeof buf/sizeof(Char)); > f = globone(buf, G_ERROR); > (void) strlcpy(sbuf, short2str(f), sizeof sbuf); > -xfree(f); > +free(f); > if (!srcfile(sbuf, 0, hflg) && !hflg) > stderror(ERR_SYSTEM, sbuf, strerror(errno)); > } > Index: csh.h > === > RCS file: /cvs/src/bin/csh/csh.h,v > retrieving revision 1.27 > diff -u -p -u -r1.27 csh.h > --- csh.h 28 Oct 2015 22:18:53 - 1.27 > +++ csh.h 12 Nov 2015 14:19:32 - > @@ -72,7 +72,6 @@ typedef void *ioctl_t; /* Third arg of > #define xmalloc(i) Malloc(i) > #define xreallocarray(p, i, j) Reallocarray(p, i, j) > #define xcalloc(n, s)Calloc(n, s) > -#define xfree(p) Free(p) > #include > FILE *cshin, *cshout, *csherr; > Index: dir.c > === > RCS file: /cvs/src/bin/csh/dir.c,v > retrieving revision 1.20 > diff -u -p -u -r1.20 dir.c > --- dir.c 8 Feb 2015 06:09:50 - 1.20 > +++ dir.c 12 Nov 2015 14:19:34 - > @@ -299,7 +299,7 @@ dnormalize(Char *cp) > cwd[dotdot = Strlen(cwd)] = '/'; > cwd[dotdot + 1] = '\0'; > dp = Strspl(cwd, cp); > - xfree(cwd); > + free(cwd); > return dp; > } > else { > @@ -386,7 +386,7 @@ dgoto(Char *cp) > p--;/* don't add a / after root */ > for (q = cp; (*p++ = *q++) != '\0';) > continue; > - xfree(cp); > + free(cp); > cp = dp; > dp += cwdlen; > } > @@ -414,11 +414,11 @@ dfollow(Char *cp) > */ > dp = dnormalize(cp); > if (chdir(short2str(dp)) >= 0) { > - xfree(cp); > + free(cp); > return dgoto(dp); > } > else { > - xfree(dp); > + free(dp); > if (chdir(short2str(cp)) >= 0) > return dgoto(cp); > serrno = errno; > @@ -438,7 +438,7 @@ dfollow(Char *cp) > continue; > if (chdir(short2str(buf)) >= 0) { > printd = 1; > - xfree(cp); > + free(cp); > cp = Strsave(buf); > return dgoto(cp); > } > @@ -446,13 +446,13 @@ dfollow(Char *cp) > } > dp = value(cp); > if ((dp[0] == '/' || dp[0] == '.') && chdir(short2str(dp)) >= 0) { > - xfree(cp); > + free(cp); > cp = Strsave(dp); > printd = 1; > return dgoto(cp); > } > (void) strlcpy(ebuf, short2str(cp), sizeof ebuf); > -xfree(cp); > +free(cp); > stderror(ERR_SYSTEM, ebuf, strerror(serrno)); > return (NULL); > } > @@ -593,8 +593,8 @@ dfree(struct directory *dp) > dp->di_next = dp->di_prev = 0; > } > else { > - xfree((char *) dp->di_name); > - xfree(dp); > + free((char *) dp->di_name); > + free(dp); > } > } > @@ -630,7 +630,7 @@ dcanon(Char *cp, Char *p) > (void) Strlcpy(tmpdir, p1, sizeof tmpdir/sizeof(Char));
Re: cron: use absolute paths in pathnames.h
On Thu, 12 Nov 2015 09:24:41 -0700, "Todd C. Miller" wrote: > This also gets rid of set_cron_cwd(), cron now chdirs to '/' via > daemon(3). We can assume that the cron/at dirs were created at > install time and we can't actually create them with the correct > mode or group due to pledge anyway. > > I've moved the setegid(crontab) bit to open_socket() where it is > actually needed. Now that common.c is gone I've moved strtot() > into at.c and atrun.c (it was not actually common). The previous diff was missing the crontab/Makefile chunk. I've also made pathnames.h easier to read. - todd Index: usr.sbin/cron/Makefile === RCS file: /cvs/src/usr.sbin/cron/Makefile,v retrieving revision 1.5 diff -u -p -u -r1.5 Makefile --- usr.sbin/cron/Makefile 31 Oct 2015 12:19:41 - 1.5 +++ usr.sbin/cron/Makefile 12 Nov 2015 18:28:35 - @@ -2,7 +2,7 @@ PROG= cron SRCS= cron.c database.c user.c entry.c job.c do_command.c \ - misc.c env.c popen.c atrun.c common.c + misc.c env.c popen.c atrun.c CFLAGS+=-I${.CURDIR} MAN= cron.8 Index: usr.sbin/cron/atrun.c === RCS file: /cvs/src/usr.sbin/cron/atrun.c,v retrieving revision 1.38 diff -u -p -u -r1.38 atrun.c --- usr.sbin/cron/atrun.c 9 Nov 2015 16:37:07 - 1.38 +++ usr.sbin/cron/atrun.c 12 Nov 2015 18:28:35 - @@ -50,6 +50,21 @@ static void run_job(atjob *, char *); +static int +strtot(const char *nptr, char **endptr, time_t *tp) +{ + long long ll; + + errno = 0; + ll = strtoll(nptr, endptr, 10); + if (*endptr == nptr) + return (-1); + if (ll < 0 || (errno == ERANGE && ll == LLONG_MAX) || (time_t)ll != ll) + return (-1); + *tp = (time_t)ll; + return (0); +} + /* * Scan the at jobs dir and build up a list of jobs found. */ @@ -65,12 +80,12 @@ scan_atjobs(at_db **db, struct timespec struct dirent *file; struct stat sb; - if ((dfd = open(AT_SPOOL, O_RDONLY|O_DIRECTORY)) == -1) { - log_it("CRON", "OPEN FAILED", AT_SPOOL); + if ((dfd = open(_PATH_AT_SPOOL, O_RDONLY|O_DIRECTORY)) == -1) { + log_it("CRON", "OPEN FAILED", _PATH_AT_SPOOL); return (0); } if (fstat(dfd, &sb) != 0) { - log_it("CRON", "FSTAT FAILED", AT_SPOOL); + log_it("CRON", "FSTAT FAILED", _PATH_AT_SPOOL); close(dfd); return (0); } @@ -80,7 +95,7 @@ scan_atjobs(at_db **db, struct timespec } if ((atdir = fdopendir(dfd)) == NULL) { - log_it("CRON", "OPENDIR FAILED", AT_SPOOL); + log_it("CRON", "OPENDIR FAILED", _PATH_AT_SPOOL); close(dfd); return (0); } @@ -148,7 +163,7 @@ scan_atjobs(at_db **db, struct timespec void atrun(at_db *db, double batch_maxload, time_t now) { - char atfile[MAX_FNAME]; + char atfile[PATH_MAX]; struct stat sb; double la; atjob *job, *tjob, *batch = NULL; @@ -161,7 +176,7 @@ atrun(at_db *db, double batch_maxload, t if (job->run_time > now) continue; - snprintf(atfile, sizeof(atfile), "%s/%lld.%c", AT_SPOOL, + snprintf(atfile, sizeof(atfile), "%s/%lld.%c", _PATH_AT_SPOOL, (long long)job->run_time, job->queue); if (lstat(atfile, &sb) != 0 || !S_ISREG(sb.st_mode)) { @@ -194,7 +209,7 @@ atrun(at_db *db, double batch_maxload, t && (batch_maxload == 0.0 || ((getloadavg(&la, 1) == 1) && la <= batch_maxload)) ) { - snprintf(atfile, sizeof(atfile), "%s/%lld.%c", AT_SPOOL, + snprintf(atfile, sizeof(atfile), "%s/%lld.%c", _PATH_AT_SPOOL, (long long)batch->run_time, batch->queue); run_job(batch, atfile); TAILQ_REMOVE(&db->jobs, batch, entries); @@ -420,8 +435,6 @@ run_job(atjob *job, char *atfile) login_close(lc); } - chdir("/"); /* at job will chdir to correct place */ - /* If this is a low priority job, nice ourself. */ if (job->queue > 'b') (void)setpriority(PRIO_PROCESS, 0, job->queue - 'b'); @@ -480,8 +493,8 @@ run_job(atjob *job, char *atfile) fprintf(mail, "To: %s\n", mailto); fprintf(mail, "Subject: Output from \"at\" job\n"); fprintf(mail, "Auto-Submitted: auto-generated\n"); - fprintf(mail, "\nYour \"at\" job on %s\n\"%s/%s/%s\"\n", - hostname, CRONDIR, AT_SPOOL, atfile); + fprintf(mail, "\nYour \"at\" job on %s\n\"%s/%s\"\n", + hostname, _PATH_AT_SPOOL, atfile); fprintf(mail, "
initial 802.11n implementation
This diff adds an initial implementation of 802.11n. It is functional but mostly adds foundations to build future work on top of. It completes the little bits of 11n code added by damien@ years ago. It supports all non-optional 11n features for STA (client) operation. It adds 11n support only for the iwm(4) driver. Support for more drivers will be added later. - Add a new '11n' mode with all the ifmedia goo that goes with it. This is straightforward because the ifmedia word was extended to 64 bits back in September during the l2k15 hackathon in preparation for 11n. - Add a concept of MCS (modulation coding scheme) alongside the "rates" used in 11a/b/g. My initial plan was to extend the ieee80211_rateset structure until I noticed this struct is copied out verbatim into frames during 11a/b/g operation. So changing its size is not an option and I'm adding MCS as a new concept which exists only in 11n mode. The mandatory MCS 0-7 are supported, providing a maximum theoretical data rate of 65Mbit/s. - Add more 11n related state to various data structures, most notably ieee80211_node and ieee80211com. - Add support for block ack agreements and receiving A-MPDUs and A-MSDUs. This mostly builds on code which damien@ added years ago. I'm very happy he left a complete implementation for me to find. Sending A-MPDUs is left for later (the sender has to initiate block ack, and since we don't our 11n peers won't care, so no problem). The 11n standard adds a lot of new features, most of which are optional. The optional 11n features which this diff does not add support for include: - MIMO (MCS 8 and above) - Short guard interval aka SGI (improves throughput) - 40 MHz wide channels I've been testing against OpenWRT and Fritzbox APs based on the ath10k chipset. Testing against all sorts of APs is much appreciated. Apart from 11n operation I've been testing 11a/b/g operation as well. Everything seems to work. The diff has survived a full 'make release' + install cycle on amd64. Most development and testing was done on i386. To test this diff, apply it to /usr/src/sys, compile a new kernel and reboot into it. Then install the new if_media.h header and recompile ifconfig: doas install -m 444 -o root -g bin /usr/src/sys/net/if_media.h /usr/include/net/ cd /usr/src/sbin/ifconfig make obj make depend make doas make install `ifconfig iwm0 media' should show an additional line advertising 11n support: media autoselect mode 11n While associated to an 11n AP, `ifconfig iwm0' should indicate the MCS being used for transmissions, e.g.: media: IEEE802.11 autoselect (HT-MCS7 mode 11n) This work is being supported by genua gmbh which allows me to spend the necessary time to keep working on 11n and do my best at building this feature together with the OpenBSD community. Index: dev/pci/if_iwm.c === RCS file: /cvs/src/sys/dev/pci/if_iwm.c,v retrieving revision 1.63 diff -u -p -r1.63 if_iwm.c --- dev/pci/if_iwm.c4 Nov 2015 12:11:59 - 1.63 +++ dev/pci/if_iwm.c12 Nov 2015 15:33:07 - @@ -175,19 +175,22 @@ const uint8_t iwm_nvm_channels[] = { const struct iwm_rate { uint8_t rate; uint8_t plcp; + uint8_t ht_plcp; } iwm_rates[] = { - { 2, IWM_RATE_1M_PLCP }, - { 4, IWM_RATE_2M_PLCP }, - { 11, IWM_RATE_5M_PLCP }, - { 22, IWM_RATE_11M_PLCP }, - { 12, IWM_RATE_6M_PLCP }, - { 18, IWM_RATE_9M_PLCP }, - { 24, IWM_RATE_12M_PLCP }, - { 36, IWM_RATE_18M_PLCP }, - { 48, IWM_RATE_24M_PLCP }, - { 72, IWM_RATE_36M_PLCP }, - { 96, IWM_RATE_48M_PLCP }, - { 108, IWM_RATE_54M_PLCP }, + /* Legacy *//* HT */ + { 2, IWM_RATE_1M_PLCP, IWM_RATE_HT_SISO_MCS_INV_PLCP }, + { 4, IWM_RATE_2M_PLCP, IWM_RATE_HT_SISO_MCS_INV_PLCP }, + { 11, IWM_RATE_5M_PLCP, IWM_RATE_HT_SISO_MCS_INV_PLCP }, + { 22, IWM_RATE_11M_PLCP, IWM_RATE_HT_SISO_MCS_INV_PLCP }, + { 12, IWM_RATE_6M_PLCP, IWM_RATE_HT_SISO_MCS_0_PLCP }, + { 18, IWM_RATE_9M_PLCP, IWM_RATE_HT_SISO_MCS_INV_PLCP }, + { 24, IWM_RATE_12M_PLCP, IWM_RATE_HT_SISO_MCS_1_PLCP }, + { 36, IWM_RATE_18M_PLCP, IWM_RATE_HT_SISO_MCS_2_PLCP }, + { 48, IWM_RATE_24M_PLCP, IWM_RATE_HT_SISO_MCS_3_PLCP }, + { 72, IWM_RATE_36M_PLCP, IWM_RATE_HT_SISO_MCS_4_PLCP }, + { 96, IWM_RATE_48M_PLCP, IWM_RATE_HT_SISO_MCS_5_PLCP }, + { 108, IWM_RATE_54M_PLCP, IWM_RATE_HT_SISO_MCS_6_PLCP }, + { 128, IWM_RATE_INVM_PLCP, IWM_RATE_HT_SISO_MCS_7_PLCP }, }; #define IWM_RIDX_CCK 0 #define IWM_RIDX_OFDM 4 @@ -195,6 +198,18 @@ const struct iwm_rate { #define IWM_RIDX_IS_CCK(_i_) ((_i_) < IWM_RIDX_OFDM) #define IWM_RIDX_IS_OFDM(_i_) ((_i_) >= IWM_RIDX_OFDM) +/* Con
Re: [patch] was: Re: login(3) routines data integrity patch
Chris Turner wrote: > > Wondering if anyone had a chance to take a look at these - > Subject line tagged accordingly :D > > I could see in some scenarios, aside from generating incorrect > > data, this incorrect record could be used to facillitate hiding > > presence of a successful compromise. > > > > The attached patch calls fsync(2) on related FD's in the login(3) > > routines, which corrected the problem on my test machine, > > and imho might be a good idea in general. AFAIK it should not be necessary to call fsync() before close(). Closing a file should flush all its data. The patch either does nothing, or masks a much more serious somewhere else. (The latter is a distinct possibility, but we can't go adding fsync to hundreds of file operations throughout the tree.)
Re: Replace xfree with free on csh(1)
Hello Michael! Sorry, mea culpa. I hope it's not mangled now: Index: alloc.c === RCS file: /cvs/src/bin/csh/alloc.c,v retrieving revision 1.16 diff -u -p -u -r1.16 alloc.c --- alloc.c8 Feb 2015 06:01:25 -1.16 +++ alloc.c12 Nov 2015 20:07:44 - @@ -74,9 +74,3 @@ Calloc(size_t s, size_t n) return (ptr); } - -void -Free(void *p) -{ -free(p); -} Index: csh.c === RCS file: /cvs/src/bin/csh/csh.c,v retrieving revision 1.36 diff -u -p -u -r1.36 csh.c --- csh.c11 Nov 2015 02:52:46 -1.36 +++ csh.c12 Nov 2015 20:07:52 - @@ -609,7 +609,7 @@ srccat(Char *cp, Char *dp) Char *ep = Strspl(cp, dp); char *ptr = short2str(ep); -xfree(ep); +free(ep); return srcfile(ptr, mflag ? 0 : 1, 0); } @@ -716,10 +716,10 @@ srcunit(int unit, bool onlyown, bool hfl int i; /* We made it to the new state... free up its storage */ -/* This code could get run twice but xfree doesn't care */ +/* This code could get run twice but free doesn't care */ for (i = 0; i < fblocks; i++) -xfree(fbuf[i]); -xfree(fbuf); +free(fbuf[i]); +free(fbuf); /* Reset input arena */ memcpy(&B, &saveB, sizeof(B)); @@ -1014,7 +1014,7 @@ process(bool catch) (void) fflush(cshout); } if (seterr) { -xfree(seterr); +free(seterr); seterr = NULL; } @@ -1094,7 +1094,7 @@ dosource(Char **v, struct command *t) (void) Strlcpy(buf, *v, sizeof buf/sizeof(Char)); f = globone(buf, G_ERROR); (void) strlcpy(sbuf, short2str(f), sizeof sbuf); -xfree(f); +free(f); if (!srcfile(sbuf, 0, hflg) && !hflg) stderror(ERR_SYSTEM, sbuf, strerror(errno)); } Index: csh.h === RCS file: /cvs/src/bin/csh/csh.h,v retrieving revision 1.27 diff -u -p -u -r1.27 csh.h --- csh.h28 Oct 2015 22:18:53 -1.27 +++ csh.h12 Nov 2015 20:07:54 - @@ -72,7 +72,6 @@ typedef void *ioctl_t;/* Third arg of #define xmalloc(i)Malloc(i) #define xreallocarray(p, i, j)Reallocarray(p, i, j) #define xcalloc(n, s)Calloc(n, s) -#define xfree(p)Free(p) #include FILE *cshin, *cshout, *csherr; Index: dir.c === RCS file: /cvs/src/bin/csh/dir.c,v retrieving revision 1.20 diff -u -p -u -r1.20 dir.c --- dir.c8 Feb 2015 06:09:50 -1.20 +++ dir.c12 Nov 2015 20:07:56 - @@ -299,7 +299,7 @@ dnormalize(Char *cp) cwd[dotdot = Strlen(cwd)] = '/'; cwd[dotdot + 1] = '\0'; dp = Strspl(cwd, cp); -xfree(cwd); +free(cwd); return dp; } else { @@ -386,7 +386,7 @@ dgoto(Char *cp) p--;/* don't add a / after root */ for (q = cp; (*p++ = *q++) != '\0';) continue; -xfree(cp); +free(cp); cp = dp; dp += cwdlen; } @@ -414,11 +414,11 @@ dfollow(Char *cp) */ dp = dnormalize(cp); if (chdir(short2str(dp)) >= 0) { -xfree(cp); +free(cp); return dgoto(dp); } else { -xfree(dp); +free(dp); if (chdir(short2str(cp)) >= 0) return dgoto(cp); serrno = errno; @@ -438,7 +438,7 @@ dfollow(Char *cp) continue; if (chdir(short2str(buf)) >= 0) { printd = 1; -xfree(cp); +free(cp); cp = Strsave(buf); return dgoto(cp); } @@ -446,13 +446,13 @@ dfollow(Char *cp) } dp = value(cp); if ((dp[0] == '/' || dp[0] == '.') && chdir(short2str(dp)) >= 0) { -xfree(cp); +free(cp); cp = Strsave(dp); printd = 1; return dgoto(cp); } (void) strlcpy(ebuf, short2str(cp), sizeof ebuf); -xfree(cp); +free(cp); stderror(ERR_SYSTEM, ebuf, strerror(serrno)); return (NULL); } @@ -593,8 +593,8 @@ dfree(struct directory *dp) dp->di_next = dp->di_prev = 0; } else { -xfree((char *) dp->di_name); -xfree(dp); +free((char *) dp->di_name); +free(dp); } } @@ -630,7 +630,7 @@ dcanon(Char *cp, Char *p) (void) Strlcpy(tmpdir, p1, sizeof tmpdir/sizeof(Char)); (void) Strlcat(tmpdir, STRslash, sizeof tmpdir/sizeof(Char)); (void) Strlcat(tmpdir, cp, sizeof tmpdir/sizeof(Char)); -xfree(cp); +free(cp); cp = p = Strsave(tmpdir); } @@ -735,7 +735,7 @@ dcanon(Char *cp, Char *p) */ p = newcp; } -xfree(cp); +free(cp); cp = newcp; continue;/* canonicalize the link */ } @@ -824,7 +824,7 @@ dcanon(Char *cp, Char *p) */ p = newcp; } -xfree(cp); +free(cp); cp = newcp; continue;/* canonicalize the link */ } @@ -879,7 +879,7 @@ dcanon(Char *cp, Char *p)
open(2) with hardcoded values
Hi! After a quick grep on the tree I found a few places where open(2) is still used with hardcoded numeric values. I sent this to Theo for reviewing, but he might not had the time for it so here it goes: Index: jobs.c === RCS file: /cvs/src/bin/ksh/jobs.c,v retrieving revision 1.51 diff -u -p -u -r1.51 jobs.c --- jobs.c 12 Nov 2015 04:04:31 - 1.51 +++ jobs.c 12 Nov 2015 20:33:35 - @@ -520,7 +520,7 @@ exchild(struct op *t, int flags, volatil setsig(&sigtraps[SIGQUIT], SIG_IGN, SS_RESTORE_IGN|SS_FORCE); if (!(flags & (XPIPEI | XCOPROC))) { - int fd = open("/dev/null", 0); + int fd = open("/dev/null", O_RDONLY); if (fd != 0) { (void) ksh_dup2(fd, 0, true); close(fd); Index: badsect.c === RCS file: /cvs/src/sbin/badsect/badsect.c,v retrieving revision 1.26 diff -u -p -u -r1.26 badsect.c --- badsect.c 20 Jan 2015 18:22:20 - 1.26 +++ badsect.c 12 Nov 2015 20:34:07 - @@ -119,7 +119,7 @@ main(int argc, char *argv[]) err(5, "Cannot find dev 0%o corresponding to %s", stbuf.st_rdev, argv[1]); - if ((fsi = open(name, 0)) < 0) + if ((fsi = open(name, O_RDONLY)) < 0) err(6, "%s", name); fs = &sblock; Index: main.c === RCS file: /cvs/src/usr.sbin/mrouted/main.c,v retrieving revision 1.27 diff -u -p -u -r1.27 main.c --- main.c 26 Oct 2015 10:08:15 - 1.27 +++ main.c 12 Nov 2015 20:40:50 - @@ -132,14 +132,14 @@ usage:fprintf(stderr, (void)close(0); (void)close(1); (void)close(2); - (void)open("/", 0); + (void)open("/", O_RDONLY); (void)dup2(0, 1); (void)dup2(0, 2); #ifdef SYSV (void)setpgrp(); #else #ifdef TIOCNOTTY - t = open("/dev/tty", 2); + t = open("/dev/tty", O_RDWR); if (t >= 0) { (void)ioctl(t, TIOCNOTTY, (char *)0); (void)close(t); Index: quot.c === RCS file: /cvs/src/usr.sbin/quot/quot.c,v retrieving revision 1.27 diff -u -p -u -r1.27 quot.c --- quot.c 20 Aug 2015 22:39:29 - 1.27 +++ quot.c 12 Nov 2015 20:34:48 - @@ -561,7 +561,7 @@ quot(char *name, char *mp) * XXX this is completely broken. Of course you can't read a * directory, well, not anymore. How to fix this, though... */ - if ((fd = open(name, 0)) < 0) { + if ((fd = open(name, O_RDONLY)) < 0) { warn("%s", name); return; } Index: ypserv.c === RCS file: /cvs/src/usr.sbin/ypserv/ypserv/ypserv.c,v retrieving revision 1.42 diff -u -p -u -r1.42 ypserv.c --- ypserv.c26 Oct 2015 10:12:46 - 1.42 +++ ypserv.c12 Nov 2015 20:35:19 - @@ -451,10 +451,10 @@ main(int argc, char *argv[]) if (pid) exit(0); closefrom(0); - i = open("/dev/console", 2); + i = open("/dev/console", O_RDWR); (void) dup2(i, 1); (void) dup2(i, 2); - i = open("/dev/tty", 2); + i = open("/dev/tty", O_RDWR); if (i >= 0) { (void) ioctl(i, TIOCNOTTY, NULL); (void) close(i); Best regards, Ricardo Mestre
newsyslog -r
The -r option of newsyslog(8) removes the requirement that newsyslog runs as root. Would it also make sense to not try to send the SIGHUP to syslogd in that case? Jan Index: newsyslog.8 === RCS file: /cvs/src/usr.bin/newsyslog/newsyslog.8,v retrieving revision 1.52 diff -u -p -u -p -r1.52 newsyslog.8 --- newsyslog.8 16 Sep 2014 16:27:23 - 1.52 +++ newsyslog.8 12 Nov 2015 21:20:52 - @@ -123,7 +123,7 @@ Removes the restriction that must be running as root. Note that in this mode .Nm -will not be able to send a +will not try to send a .Dv SIGHUP signal to .Xr syslogd 8 . Index: newsyslog.c === RCS file: /cvs/src/usr.bin/newsyslog/newsyslog.c,v retrieving revision 1.95 diff -u -p -u -p -r1.95 newsyslog.c --- newsyslog.c 20 Aug 2015 22:32:41 - 1.95 +++ newsyslog.c 12 Nov 2015 21:20:52 - @@ -406,7 +406,7 @@ send_signal(char *pidfile, int signal) warnx("%s pid file: %s", err, pidfile); else if (noaction) (void)printf("kill -%s %ld\n", sys_signame[signal], (long)pid); - else if (kill(pid, signal)) + else if (needroot && kill(pid, signal)) warnx("warning - could not send SIG%s to PID from pid file %s", sys_signame[signal], pidfile); }
Re: open(2) with hardcoded values
> Ricardo Mestre wrote: > > Hi! > > > > After a quick grep on the tree I found a few places where open(2) is > > still used with hardcoded numeric values. > > > > I sent this to Theo for reviewing, but he might not had the time for it > > so here it goes: > > When you send patches, can you base them in a single common directory? There's > no way to apply this without running patch 5 times in 5 different directories. Also, don't cut and paste -- converting tabs to spaces requires us to edit every file by hand anyways.
Re: cron: use absolute paths in pathnames.h
"Todd C. Miller" writes: > On Thu, 12 Nov 2015 09:24:41 -0700, "Todd C. Miller" wrote: > >> This also gets rid of set_cron_cwd(), cron now chdirs to '/' via >> daemon(3). We can assume that the cron/at dirs were created at >> install time and we can't actually create them with the correct >> mode or group due to pledge anyway. >> >> I've moved the setegid(crontab) bit to open_socket() where it is >> actually needed. Now that common.c is gone I've moved strtot() >> into at.c and atrun.c (it was not actually common). > > The previous diff was missing the crontab/Makefile chunk. > I've also made pathnames.h easier to read. ok jca@ Thanks, -- jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE
Re: chmod(1) -f flag is still used?
Your process here is really strange. You see something, then you write a diff before answering your own question, then you send a mail asking a question with the diff already present as an investment. In OpenBSD, we have a 20 year old repository that explains why a change was made. Before the 20 years, there are older repositories to view. There are also many other resources which might document why -f existed in the past. Without review of those, it is wrong to simply delete it. Use 'cvs annnoate' and look at the history for that line in the file. revision 1.26 date: 2010/01/12 19:30:53; author: jasper; state: Exp; lines: +2 -2; sync comment with reality, -f won't be documented. as discussed with jmc@, otto@ and millert@ ok otto@ millert@ So at least 4 people discussed it. You didn't discover that? Look at -r1.1 of chmod.c case 'f': /* XXX: undocumented. */ fflag = 1; That still does not explain it. But did you get there? There are older repositories and documents to review. But at least now there are two questions and you can dig further rather than spending the time writing a diff. Yet you did it first. How bizzare. Your diff is pointless, without first know the answers to the questions, isn't it? It think it is nice that people are trying to help; but if you are modifying binaries often used in scripts, the standard of work has to be very high. > Digging around the tree (Yes, i want try to contribute if possible), > i found this small piece of code: > > > >case 'f':/* no longer documented. */ > > fflag = 1; > > break; > > And the usage of this flag in two conditional statement in a logic > OR: > > >if (ischmod) { > > if (!fchmodat(AT_FDCWD, p->fts_accpath, oct ? omode : > > getmode(set, p->fts_statp->st_mode), atflags) > > || fflag) > > continue; > >} else if (!ischflags) { > > if (!fchownat(AT_FDCWD, p->fts_accpath, uid, gid, > > atflags) || fflag) > > continue; > > I checked the man pages related to chmod(1), chgrp(1), chflags(1) and > chown(8) and as the comment stated, nowhere the option is mentioned. > There is a motivation why the unused -f option is still there? As the > option is not documented anymore, this mean that fflag will be false > in every documented use case. > Anyway, attached a diff usable if the option can be removed. > > Regards > > --UT4aJajqd8PRde7T > Content-Type: text/plain; charset=us-ascii > Content-Disposition: attachment; filename="f_option.diff" > > Index: chmod.c > === > RCS file: /cvs/src/bin/chmod/chmod.c,v > retrieving revision 1.38 > diff -u -p -r1.38 chmod.c > --- chmod.c 9 Oct 2015 01:37:06 - 1.38 > +++ chmod.c 12 Nov 2015 20:51:28 - > @@ -62,7 +62,7 @@ main(int argc, char *argv[]) > unsigned long val; > int oct; > mode_t omode; > - int Hflag, Lflag, Rflag, ch, fflag, fts_options, hflag, rval, atflags; > + int Hflag, Lflag, Rflag, ch, fts_options, hflag, rval, atflags; > uid_t uid; > gid_t gid; > u_int32_t fclear, fset; > @@ -79,8 +79,8 @@ main(int argc, char *argv[]) > > uid = (uid_t)-1; > gid = (gid_t)-1; > - Hflag = Lflag = Rflag = fflag = hflag = 0; > - while ((ch = getopt(argc, argv, "HLPRXfghorstuwx")) != -1) > + Hflag = Lflag = Rflag = hflag = 0; > + while ((ch = getopt(argc, argv, "HLPRXghorstuwx")) != -1) > switch (ch) { > case 'H': > Hflag = 1; > @@ -96,9 +96,6 @@ main(int argc, char *argv[]) > case 'R': > Rflag = 1; > break; > - case 'f': /* no longer documented. */ > - fflag = 1; > - break; > case 'h': > hflag = 1; > break; > @@ -261,12 +258,11 @@ done: > > if (ischmod) { > if (!fchmodat(AT_FDCWD, p->fts_accpath, oct ? omode : > - getmode(set, p->fts_statp->st_mode), atflags) > - || fflag) > + getmode(set, p->fts_statp->st_mode), atflags)) > continue; > } else if (!ischflags) { > if (!fchownat(AT_FDCWD, p->fts_accpath, uid, gid, > - atflags) || fflag) > + atflags)) > continue; > } else { > if (!chflagsat(AT_FDCWD, p->fts_accpath, oct ? fset : > > --UT4aJajqd8PRde7T-- >
Re: open(2) with hardcoded values
Ricardo Mestre wrote: > Hi! > > After a quick grep on the tree I found a few places where open(2) is > still used with hardcoded numeric values. > > I sent this to Theo for reviewing, but he might not had the time for it > so here it goes: When you send patches, can you base them in a single common directory? There's no way to apply this without running patch 5 times in 5 different directories. Thanks. > > Index: jobs.c > === > RCS file: /cvs/src/bin/ksh/jobs.c,v > retrieving revision 1.51 > diff -u -p -u -r1.51 jobs.c > --- jobs.c 12 Nov 2015 04:04:31 - 1.51 > +++ jobs.c 12 Nov 2015 20:33:35 - > @@ -520,7 +520,7 @@ exchild(struct op *t, int flags, volatil > setsig(&sigtraps[SIGQUIT], SIG_IGN, > SS_RESTORE_IGN|SS_FORCE); > if (!(flags & (XPIPEI | XCOPROC))) { > - int fd = open("/dev/null", 0); > + int fd = open("/dev/null", O_RDONLY); > if (fd != 0) { > (void) ksh_dup2(fd, 0, true); > close(fd); > Index: badsect.c > === > RCS file: /cvs/src/sbin/badsect/badsect.c,v > retrieving revision 1.26 > diff -u -p -u -r1.26 badsect.c > --- badsect.c 20 Jan 2015 18:22:20 - 1.26 > +++ badsect.c 12 Nov 2015 20:34:07 - > @@ -119,7 +119,7 @@ main(int argc, char *argv[]) > err(5, "Cannot find dev 0%o corresponding to %s", > stbuf.st_rdev, argv[1]); > > - if ((fsi = open(name, 0)) < 0) > + if ((fsi = open(name, O_RDONLY)) < 0) > err(6, "%s", name); > > fs = &sblock; > Index: main.c > === > RCS file: /cvs/src/usr.sbin/mrouted/main.c,v > retrieving revision 1.27 > diff -u -p -u -r1.27 main.c > --- main.c 26 Oct 2015 10:08:15 - 1.27 > +++ main.c 12 Nov 2015 20:40:50 - > @@ -132,14 +132,14 @@ usage:fprintf(stderr, > (void)close(0); > (void)close(1); > (void)close(2); > - (void)open("/", 0); > + (void)open("/", O_RDONLY); > (void)dup2(0, 1); > (void)dup2(0, 2); > #ifdef SYSV > (void)setpgrp(); > #else > #ifdef TIOCNOTTY > - t = open("/dev/tty", 2); > + t = open("/dev/tty", O_RDWR); > if (t >= 0) { > (void)ioctl(t, TIOCNOTTY, (char *)0); > (void)close(t); > Index: quot.c > === > RCS file: /cvs/src/usr.sbin/quot/quot.c,v > retrieving revision 1.27 > diff -u -p -u -r1.27 quot.c > --- quot.c 20 Aug 2015 22:39:29 - 1.27 > +++ quot.c 12 Nov 2015 20:34:48 - > @@ -561,7 +561,7 @@ quot(char *name, char *mp) > * XXX this is completely broken. Of course you can't read a > * directory, well, not anymore. How to fix this, though... > */ > - if ((fd = open(name, 0)) < 0) { > + if ((fd = open(name, O_RDONLY)) < 0) { > warn("%s", name); > return; > } > Index: ypserv.c > === > RCS file: /cvs/src/usr.sbin/ypserv/ypserv/ypserv.c,v > retrieving revision 1.42 > diff -u -p -u -r1.42 ypserv.c > --- ypserv.c26 Oct 2015 10:12:46 - 1.42 > +++ ypserv.c12 Nov 2015 20:35:19 - > @@ -451,10 +451,10 @@ main(int argc, char *argv[]) > if (pid) > exit(0); > closefrom(0); > - i = open("/dev/console", 2); > + i = open("/dev/console", O_RDWR); > (void) dup2(i, 1); > (void) dup2(i, 2); > - i = open("/dev/tty", 2); > + i = open("/dev/tty", O_RDWR); > if (i >= 0) { > (void) ioctl(i, TIOCNOTTY, NULL); > (void) close(i); > > Best regards, > Ricardo Mestre >
Re: tcpbench pledge
David Hill(dh...@mindcry.org) on 2015.11.10 11:44:39 -0500: > Hello - > > pledge starts after getopt because of setrtable. > > rpath needed incase -k (kvm_openfile) > proc needed for drop_gid (setresgid) > > I believe I've hit every code path. More eyes are welcome. Hi, two changes -T at this time does not work with pledge. setsockopt(...IP_TOS) is not allowed. so i disable it except for the last pledge in the client case. with -s, we need "inet" in the event loop because there we will do accept(). move the pledge("stdin") into the client case only. ok? diff --git usr.bin/tcpbench/tcpbench.c usr.bin/tcpbench/tcpbench.c index 6bd2027..e753fbf 100644 --- usr.bin/tcpbench/tcpbench.c +++ usr.bin/tcpbench/tcpbench.c @@ -986,8 +986,6 @@ quit(int sig, short event, void *arg) int main(int argc, char **argv) { - extern int optind; - extern char *optarg; struct timeval tv; unsigned int secs, rtable; @@ -1108,6 +1106,16 @@ main(int argc, char **argv) } } + /* +* XXX pledge +* -T toskeyword cannot be used with pledge() at this time because +* the IP_TOS setsockopt(2) is not allowed even with promise "inet" +* other pledge() calls below need revisiting as well. +*/ + if (ptb->Tflag == -1 && + pledge("stdio rpath dns inet id proc", NULL) == -1) + err(1, "pledge"); + argv += optind; argc -= optind; if ((argc != (ptb->sflag ? 0 : 1)) || @@ -1125,6 +1133,10 @@ main(int argc, char **argv) } else drop_gid(); + if (ptb->Tflag == -1 && + pledge("stdio id dns inet", NULL) == -1) + err(1, "pledge"); + if (!ptb->sflag) host = argv[0]; /* @@ -1169,6 +1181,10 @@ main(int argc, char **argv) errx(1, "getaddrinfo: %s", gai_strerror(herr)); } + if (ptb->Tflag == -1 && + pledge("stdio id inet", NULL) == -1) + err(1, "pledge"); + if (getrlimit(RLIMIT_NOFILE, &rl) == -1) err(1, "getrlimit"); if (rl.rlim_cur < MAX_FD) @@ -1177,7 +1193,11 @@ main(int argc, char **argv) err(1, "setrlimit"); if (getrlimit(RLIMIT_NOFILE, &rl) == -1) err(1, "getrlimit"); - + + if (ptb->Tflag == -1 && + pledge("stdio inet", NULL) == -1) + err(1, "pledge"); + /* Init world */ TAILQ_INIT(&sc_queue); if ((ptb->dummybuf = malloc(ptb->dummybuf_len)) == NULL) @@ -1215,8 +1235,11 @@ main(int argc, char **argv) evtimer_add(&ev_progtimer, &tv); } client_init(aitop, nconn, udp_sc, aib); + + if (pledge("stdio", NULL) == -1) + err(1, "pledge"); } - + /* libevent main loop*/ event_dispatch();
Re: chmod(1) -f flag is still used?
On 2015-11-12, Theo de Raadt wrote: > There are older repositories and documents to review. Specifically, the Berkeley repository culminating in 4.4BSD can be conveniently accessed here: https://svnweb.freebsd.org/csrg/ (That's converted. The original was in SCCS.) Just in case somebody really needs to dig into old history. -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: Replace xfree with free on csh(1)
It seems I was still with mangling problems, does it look good now? Index: alloc.c === RCS file: /cvs/src/bin/csh/alloc.c,v retrieving revision 1.16 diff -u -p -u -r1.16 alloc.c --- alloc.c 8 Feb 2015 06:01:25 - 1.16 +++ alloc.c 12 Nov 2015 20:07:44 - @@ -74,9 +74,3 @@ Calloc(size_t s, size_t n) return (ptr); } - -void -Free(void *p) -{ - free(p); -} Index: csh.c === RCS file: /cvs/src/bin/csh/csh.c,v retrieving revision 1.36 diff -u -p -u -r1.36 csh.c --- csh.c 11 Nov 2015 02:52:46 - 1.36 +++ csh.c 12 Nov 2015 20:07:52 - @@ -609,7 +609,7 @@ srccat(Char *cp, Char *dp) Char *ep = Strspl(cp, dp); char *ptr = short2str(ep); -xfree(ep); +free(ep); return srcfile(ptr, mflag ? 0 : 1, 0); } @@ -716,10 +716,10 @@ srcunit(int unit, bool onlyown, bool hfl int i; /* We made it to the new state... free up its storage */ - /* This code could get run twice but xfree doesn't care */ + /* This code could get run twice but free doesn't care */ for (i = 0; i < fblocks; i++) - xfree(fbuf[i]); - xfree(fbuf); + free(fbuf[i]); + free(fbuf); /* Reset input arena */ memcpy(&B, &saveB, sizeof(B)); @@ -1014,7 +1014,7 @@ process(bool catch) (void) fflush(cshout); } if (seterr) { - xfree(seterr); + free(seterr); seterr = NULL; } @@ -1094,7 +1094,7 @@ dosource(Char **v, struct command *t) (void) Strlcpy(buf, *v, sizeof buf/sizeof(Char)); f = globone(buf, G_ERROR); (void) strlcpy(sbuf, short2str(f), sizeof sbuf); -xfree(f); +free(f); if (!srcfile(sbuf, 0, hflg) && !hflg) stderror(ERR_SYSTEM, sbuf, strerror(errno)); } Index: csh.h === RCS file: /cvs/src/bin/csh/csh.h,v retrieving revision 1.27 diff -u -p -u -r1.27 csh.h --- csh.h 28 Oct 2015 22:18:53 - 1.27 +++ csh.h 12 Nov 2015 20:07:54 - @@ -72,7 +72,6 @@ typedef void *ioctl_t;/* Third arg of #define xmalloc(i) Malloc(i) #define xreallocarray(p, i, j) Reallocarray(p, i, j) #define xcalloc(n, s) Calloc(n, s) -#define xfree(p) Free(p) #include FILE *cshin, *cshout, *csherr; Index: dir.c === RCS file: /cvs/src/bin/csh/dir.c,v retrieving revision 1.20 diff -u -p -u -r1.20 dir.c --- dir.c 8 Feb 2015 06:09:50 - 1.20 +++ dir.c 12 Nov 2015 20:07:56 - @@ -299,7 +299,7 @@ dnormalize(Char *cp) cwd[dotdot = Strlen(cwd)] = '/'; cwd[dotdot + 1] = '\0'; dp = Strspl(cwd, cp); - xfree(cwd); + free(cwd); return dp; } else { @@ -386,7 +386,7 @@ dgoto(Char *cp) p--;/* don't add a / after root */ for (q = cp; (*p++ = *q++) != '\0';) continue; - xfree(cp); + free(cp); cp = dp; dp += cwdlen; } @@ -414,11 +414,11 @@ dfollow(Char *cp) */ dp = dnormalize(cp); if (chdir(short2str(dp)) >= 0) { - xfree(cp); + free(cp); return dgoto(dp); } else { - xfree(dp); + free(dp); if (chdir(short2str(cp)) >= 0) return dgoto(cp); serrno = errno; @@ -438,7 +438,7 @@ dfollow(Char *cp) continue; if (chdir(short2str(buf)) >= 0) { printd = 1; - xfree(cp); + free(cp); cp = Strsave(buf); return dgoto(cp); } @@ -446,13 +446,13 @@ dfollow(Char *cp) } dp = value(cp); if ((dp[0] == '/' || dp[0] == '.') && chdir(short2str(dp)) >= 0) { - xfree(cp); + free(cp); cp = Strsave(dp); printd = 1; return dgoto(cp); } (void) strlcpy(ebuf, short2str(cp), sizeof ebuf); -xfree(cp); +free(cp); stderror(ERR_SYSTEM, ebuf, strerror(serrno)); return (NULL); } @@ -593,8 +593,8 @@ dfree(struct directory *dp) dp->di_next = dp->di_prev = 0; } else { - xfree((char *) dp->di_name); - xfree(dp); + free((char *) dp->di_name); + free(dp); } } @@ -630,7 +630,7 @@ dcanon(Char *cp, Char *p) (void) Strlcpy(tmpdir, p1, sizeof tmpdir/sizeof(Char)); (void) Strlcat(tmpdir, STRslash, sizeof tmpdir/sizeof(Char)); (void) Strlcat(tmpdir, cp, sizeof tmpdir/sizeof(Char)); - xfree(cp); + free(cp); cp = p = Strsave(tmpdir); } @@ -735,7 +735,7 @@ dcanon(Char *cp, Char *p) */ p = newcp; } - xfree(cp); + free(cp); cp = newcp;
chmod(1) -f flag is still used?
Hi tech. Digging around the tree (Yes, i want try to contribute if possible), i found this small piece of code: >case 'f': /* no longer documented. */ > fflag = 1; > break; And the usage of this flag in two conditional statement in a logic OR: >if (ischmod) { > if (!fchmodat(AT_FDCWD, p->fts_accpath, oct ? omode : > getmode(set, p->fts_statp->st_mode), atflags) > || fflag) > continue; >} else if (!ischflags) { > if (!fchownat(AT_FDCWD, p->fts_accpath, uid, gid, > atflags) || fflag) > continue; I checked the man pages related to chmod(1), chgrp(1), chflags(1) and chown(8) and as the comment stated, nowhere the option is mentioned. There is a motivation why the unused -f option is still there? As the option is not documented anymore, this mean that fflag will be false in every documented use case. Anyway, attached a diff usable if the option can be removed. Regards Index: chmod.c === RCS file: /cvs/src/bin/chmod/chmod.c,v retrieving revision 1.38 diff -u -p -r1.38 chmod.c --- chmod.c 9 Oct 2015 01:37:06 - 1.38 +++ chmod.c 12 Nov 2015 20:51:28 - @@ -62,7 +62,7 @@ main(int argc, char *argv[]) unsigned long val; int oct; mode_t omode; - int Hflag, Lflag, Rflag, ch, fflag, fts_options, hflag, rval, atflags; + int Hflag, Lflag, Rflag, ch, fts_options, hflag, rval, atflags; uid_t uid; gid_t gid; u_int32_t fclear, fset; @@ -79,8 +79,8 @@ main(int argc, char *argv[]) uid = (uid_t)-1; gid = (gid_t)-1; - Hflag = Lflag = Rflag = fflag = hflag = 0; - while ((ch = getopt(argc, argv, "HLPRXfghorstuwx")) != -1) + Hflag = Lflag = Rflag = hflag = 0; + while ((ch = getopt(argc, argv, "HLPRXghorstuwx")) != -1) switch (ch) { case 'H': Hflag = 1; @@ -96,9 +96,6 @@ main(int argc, char *argv[]) case 'R': Rflag = 1; break; - case 'f': /* no longer documented. */ - fflag = 1; - break; case 'h': hflag = 1; break; @@ -261,12 +258,11 @@ done: if (ischmod) { if (!fchmodat(AT_FDCWD, p->fts_accpath, oct ? omode : - getmode(set, p->fts_statp->st_mode), atflags) - || fflag) + getmode(set, p->fts_statp->st_mode), atflags)) continue; } else if (!ischflags) { if (!fchownat(AT_FDCWD, p->fts_accpath, uid, gid, - atflags) || fflag) + atflags)) continue; } else { if (!chflagsat(AT_FDCWD, p->fts_accpath, oct ? fset :
Re: Replace xfree with free on csh(1)
Ricardo Mestre wrote: > It seems I was still with mangling problems, does it look good now? You're still wrapping a couple lines in the second-to-last hunk, but I fixed them manually. ok mmcc@ > Index: alloc.c > === > RCS file: /cvs/src/bin/csh/alloc.c,v > retrieving revision 1.16 > diff -u -p -u -r1.16 alloc.c > --- alloc.c 8 Feb 2015 06:01:25 - 1.16 > +++ alloc.c 12 Nov 2015 20:07:44 - > @@ -74,9 +74,3 @@ Calloc(size_t s, size_t n) > > return (ptr); > } > - > -void > -Free(void *p) > -{ > - free(p); > -} > Index: csh.c > === > RCS file: /cvs/src/bin/csh/csh.c,v > retrieving revision 1.36 > diff -u -p -u -r1.36 csh.c > --- csh.c 11 Nov 2015 02:52:46 - 1.36 > +++ csh.c 12 Nov 2015 20:07:52 - > @@ -609,7 +609,7 @@ srccat(Char *cp, Char *dp) > Char *ep = Strspl(cp, dp); > char *ptr = short2str(ep); > > -xfree(ep); > +free(ep); > return srcfile(ptr, mflag ? 0 : 1, 0); > } > > @@ -716,10 +716,10 @@ srcunit(int unit, bool onlyown, bool hfl > int i; > > /* We made it to the new state... free up its storage */ > - /* This code could get run twice but xfree doesn't care */ > + /* This code could get run twice but free doesn't care */ > for (i = 0; i < fblocks; i++) > - xfree(fbuf[i]); > - xfree(fbuf); > + free(fbuf[i]); > + free(fbuf); > > /* Reset input arena */ > memcpy(&B, &saveB, sizeof(B)); > @@ -1014,7 +1014,7 @@ process(bool catch) > (void) fflush(cshout); > } > if (seterr) { > - xfree(seterr); > + free(seterr); > seterr = NULL; > } > > @@ -1094,7 +1094,7 @@ dosource(Char **v, struct command *t) > (void) Strlcpy(buf, *v, sizeof buf/sizeof(Char)); > f = globone(buf, G_ERROR); > (void) strlcpy(sbuf, short2str(f), sizeof sbuf); > -xfree(f); > +free(f); > if (!srcfile(sbuf, 0, hflg) && !hflg) > stderror(ERR_SYSTEM, sbuf, strerror(errno)); > } > Index: csh.h > === > RCS file: /cvs/src/bin/csh/csh.h,v > retrieving revision 1.27 > diff -u -p -u -r1.27 csh.h > --- csh.h 28 Oct 2015 22:18:53 - 1.27 > +++ csh.h 12 Nov 2015 20:07:54 - > @@ -72,7 +72,6 @@ typedef void *ioctl_t; /* Third arg of > #define xmalloc(i) Malloc(i) > #define xreallocarray(p, i, j) Reallocarray(p, i, j) > #define xcalloc(n, s)Calloc(n, s) > -#define xfree(p) Free(p) > > #include > FILE *cshin, *cshout, *csherr; > Index: dir.c > === > RCS file: /cvs/src/bin/csh/dir.c,v > retrieving revision 1.20 > diff -u -p -u -r1.20 dir.c > --- dir.c 8 Feb 2015 06:09:50 - 1.20 > +++ dir.c 12 Nov 2015 20:07:56 - > @@ -299,7 +299,7 @@ dnormalize(Char *cp) > cwd[dotdot = Strlen(cwd)] = '/'; > cwd[dotdot + 1] = '\0'; > dp = Strspl(cwd, cp); > - xfree(cwd); > + free(cwd); > return dp; > } > else { > @@ -386,7 +386,7 @@ dgoto(Char *cp) > p--;/* don't add a / after root */ > for (q = cp; (*p++ = *q++) != '\0';) > continue; > - xfree(cp); > + free(cp); > cp = dp; > dp += cwdlen; > } > @@ -414,11 +414,11 @@ dfollow(Char *cp) > */ > dp = dnormalize(cp); > if (chdir(short2str(dp)) >= 0) { > - xfree(cp); > + free(cp); > return dgoto(dp); > } > else { > - xfree(dp); > + free(dp); > if (chdir(short2str(cp)) >= 0) > return dgoto(cp); > serrno = errno; > @@ -438,7 +438,7 @@ dfollow(Char *cp) > continue; > if (chdir(short2str(buf)) >= 0) { > printd = 1; > - xfree(cp); > + free(cp); > cp = Strsave(buf); > return dgoto(cp); > } > @@ -446,13 +446,13 @@ dfollow(Char *cp) > } > dp = value(cp); > if ((dp[0] == '/' || dp[0] == '.') && chdir(short2str(dp)) >= 0) { > - xfree(cp); > + free(cp); > cp = Strsave(dp); > printd = 1; > return dgoto(cp); > } > (void) strlcpy(ebuf, short2str(cp), sizeof ebuf); > -xfree(cp); > +free(cp); > stderror(ERR_SYSTEM, ebuf, strerror(serrno)); > return (NULL); > } > @@ -593,8 +593,8 @@ dfree(struct directory *dp) > dp->di_next = dp->di_prev = 0; > } > else { > - xfree((char *) dp->di_name); > - xfree(dp); > + free((char *) dp->di_name); > + free(dp); > } > } > > @@ -630,7 +630,7 @@ dcanon(Char *cp, Char *p) > (void) Strlcpy(tmpdir, p1, sizeof tmpdir/sizeof(Char)); > (void) Strlcat(tmpdir, STRslash, sizeof tmpdir/sizeof(Char)); > (void) Strlcat(tmpdir, cp, sizeof tmpdi
cron: remove log_it() and use syslog() directly
Now that we only log via syslog it makes sense to do so directly. We also no longer need to do anything on SIGHUP, which is now explicitly ignored (was implicitly before). I've preserved the format of the log entries which is basically: (username) WHAT (details) Logs due to normal operation (e.g. crontab operations or running commands) are logged at LOG_INFO like before. Actual errors are logged at LOG_ERR, less important things are logged at LOG_WARNING OR LOG_NOTICE. - todd Index: usr.sbin/cron/atrun.c === RCS file: /cvs/src/usr.sbin/cron/atrun.c,v retrieving revision 1.39 diff -u -p -u -r1.39 atrun.c --- usr.sbin/cron/atrun.c 12 Nov 2015 21:12:05 - 1.39 +++ usr.sbin/cron/atrun.c 12 Nov 2015 22:37:47 - @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -81,11 +82,11 @@ scan_atjobs(at_db **db, struct timespec struct stat sb; if ((dfd = open(_PATH_AT_SPOOL, O_RDONLY|O_DIRECTORY)) == -1) { - log_it("CRON", "OPEN FAILED", _PATH_AT_SPOOL); + syslog(LOG_ERR, "(CRON) OPEN FAILED (%s)", _PATH_AT_SPOOL); return (0); } if (fstat(dfd, &sb) != 0) { - log_it("CRON", "FSTAT FAILED", _PATH_AT_SPOOL); + syslog(LOG_ERR, "(CRON) FSTAT FAILED (%s)", _PATH_AT_SPOOL); close(dfd); return (0); } @@ -95,7 +96,7 @@ scan_atjobs(at_db **db, struct timespec } if ((atdir = fdopendir(dfd)) == NULL) { - log_it("CRON", "OPENDIR FAILED", _PATH_AT_SPOOL); + syslog(LOG_ERR, "(CRON) OPENDIR FAILED (%s)", _PATH_AT_SPOOL); close(dfd); return (0); } @@ -237,7 +238,7 @@ run_job(atjob *job, char *atfile) /* Open the file and unlink it so we don't try running it again. */ if ((fd = open(atfile, O_RDONLY|O_NONBLOCK|O_NOFOLLOW, 0)) < 0) { - log_it("CRON", "CAN'T OPEN", atfile); + syslog(LOG_ERR, "(CRON) CAN'T OPEN (%s)", atfile); return; } unlink(atfile); @@ -253,7 +254,7 @@ run_job(atjob *job, char *atfile) break; case -1: /* error */ - log_it("CRON", "error", "can't fork"); + syslog(LOG_ERR, "(CRON) CAN'T FORK (%m)"); /* FALLTHROUGH */ default: /* parent */ @@ -272,39 +273,43 @@ run_job(atjob *job, char *atfile) */ pw = getpwuid(job->uid); if (pw == NULL) { - log_it("CRON", "ORPHANED JOB", atfile); + syslog(LOG_WARNING, "(CRON) ORPHANED JOB (%s)", atfile); _exit(EXIT_FAILURE); } if (pw->pw_expire && time(NULL) >= pw->pw_expire) { - log_it(pw->pw_name, "ACCOUNT EXPIRED, JOB ABORTED", - atfile); + syslog(LOG_NOTICE, "(%s) ACCOUNT EXPIRED, JOB ABORTED (%s)", + pw->pw_name, atfile); _exit(EXIT_FAILURE); } /* Sanity checks */ if (fstat(fd, &sb) < 0) { - log_it(pw->pw_name, "FSTAT FAILED", atfile); + syslog(LOG_ERR, "(%s) FSTAT FAILED (%s)", pw->pw_name, atfile); _exit(EXIT_FAILURE); } if (!S_ISREG(sb.st_mode)) { - log_it(pw->pw_name, "NOT REGULAR", atfile); + syslog(LOG_WARNING, "(%s) NOT REGULAR (%s)", pw->pw_name, + atfile); _exit(EXIT_FAILURE); } if ((sb.st_mode & ALLPERMS) != (S_IRUSR | S_IWUSR | S_IXUSR)) { - log_it(pw->pw_name, "BAD FILE MODE", atfile); + syslog(LOG_WARNING, "(%s) BAD FILE MODE (%s)", pw->pw_name, + atfile); _exit(EXIT_FAILURE); } if (sb.st_uid != 0 && sb.st_uid != job->uid) { - log_it(pw->pw_name, "WRONG FILE OWNER", atfile); + syslog(LOG_WARNING, "(%s) WRONG FILE OWNER (%s)", pw->pw_name, + atfile); _exit(EXIT_FAILURE); } if (sb.st_nlink > 1) { - log_it(pw->pw_name, "BAD LINK COUNT", atfile); + syslog(LOG_WARNING, "(%s) BAD LINK COUNT (%s)", pw->pw_name, + atfile); _exit(EXIT_FAILURE); } if ((fp = fdopen(dup(fd), "r")) == NULL) { - log_it("CRON", "error", "dup(2) failed"); + syslog(LOG_ERR, "(CRON) DUP FAILED (%m)"); _exit(EXIT_FAILURE); } @@ -358,11 +363,13 @@ run_job(atjob *job, char *atfile) if (!safe_p(pw->pw_name, mailto)) _exit(EXIT_FAILURE); if ((uid_t)nuid != job->uid) { - log_it(pw->pw_name, "UID MISMATCH", atfile); + syslog(LOG_WARNING, "(%s) UID MISMATCH (%s)", pw->pw_name, + atfile);
Re: sunfire v120 gem interfaces
On Tue, Nov 10, 2015 at 08:27:36PM +1000, David Gwynne wrote: > any joy? i mean, failure? Well I got something different. I've noticed the failures only seem to happen when my roommates arrive home. I can use my stuff remotely all day from work without a hitch, roommates come home and usually within an hr there is an internet complaint. Since I started using the little scripts to detect connection failure and down/up the iface in question, things had been pretty good simply in the fact that nobody could really notice before it fixed itself. Today the machine dropped to ddb>! of course i couldn't remember a damn thing to type :( i got trace, terribly sorry it wasn't more... ddb> trace extent_free(400012600c0, 0, 0, 0, 1fef078, 800012fa) at extent_free +0x174 iommu_dvmamap_unload(40001266300, 0, 4000129f080, 0, 0, 2) at iommu_dvmamap_unl oad+0x74 gem_rint(400014ac000, 40016ff, 7fff, e0017c48, 4000, 80 00) at gem_rint+0x160 gem_intr(400014ac000, c00ca000, 2000, 0, 0, 8000) at gem_intr+0x154 intr_handler(e0017ec8, 4000117ae00, 4bca3020, 0, 800, 2) at intr_handler+0xc sparc_interrupt(0, 400014b, 80206910, 400171b7c60, 40009ec0810, 0) at sparc _interrupt+0x298 gem_ioctl(400014ac048, 400014ac000, 400171b7c60, 400171b7c60, 0, 40009b73c10) a t gem_ioctl+0x19c ifioctl(0, 80206910, 400171b7c60, 40009b73c10, 1012d74, 0) at ifioctl+0x38c sys_ioctl(0, 400171b7db8, 400171b7df8, 0, 0, 14b) at sys_ioctl+0x190 syscall(400171b7ed0, 436, bec8920888, bec892088c, 0, 0) at syscall+0x3c4 softtrap(3, 80206910, fffe3018, 0, 0, 1ff7fff6df8) at softtrap+0x19c ddb> > > > On 9 Nov 2015, at 10:40 AM, Ryan Freeman wrote: > > > > On Mon, Nov 09, 2015 at 10:07:31AM +1000, David Gwynne wrote: > >> can you get the ifconfig output when its locked up? and a copy of what > >> systat mb is showing? > >> > >> cheers, > >> dlg > > > > Thanks David, > > > > I have setup a script to try and capture this immediately when it happens. > > > > FWIW here is the output as it is now, working: > > > > 16:35 ryan@void:~$ ifconfig > > lo0: flags=8049 mtu 32768 > >priority: 0 > >groups: lo > >inet6 fe80::1%lo0 prefixlen 64 scopeid 0x4 > >inet6 ::1 prefixlen 128 > >inet 127.0.0.1 netmask 0xff00 > > gem0: flags=8867 > > mtu 1500 > >lladdr 00:03:ba:2b:47:70 > >priority: 0 > >groups: egress > >media: Ethernet autoselect (100baseTX full-duplex) > >status: active > >inet 96.54.13.103 netmask 0xfc00 broadcast 96.54.15.255 > > gem1: > > flags=8b63 > > mtu 1500 > >lladdr 00:03:ba:2b:47:71 > >priority: 0 > >media: Ethernet autoselect (100baseTX full-duplex) > >status: active > >inet 10.16.1.30 netmask 0xffe0 broadcast 10.16.1.31 > >inet6 fe80::203:baff:fe2b:4771%gem1 prefixlen 64 scopeid 0x2 > >inet6 2001:470:b:6cf::1 prefixlen 64 > > enc0: flags=0<> > >priority: 0 > >groups: enc > >status: active > > vlan100: flags=8843 mtu 1500 > >lladdr 00:03:ba:2b:47:71 > >description: servers > >priority: 0 > >vlan: 100 parent interface: gem1 > >groups: vlan > >status: active > >inet 10.21.1.30 netmask 0xffe0 broadcast 10.21.1.31 > >inet6 fe80::203:baff:fe2b:4771%vlan100 prefixlen 64 scopeid 0x5 > >inet6 2001:470:eac8:666::1 prefixlen 64 > > vlan101: flags=8843 mtu 1500 > >lladdr 00:03:ba:2b:47:71 > >description: workstations > >priority: 0 > >vlan: 101 parent interface: gem1 > >groups: vlan > >status: active > >inet 10.21.8.254 netmask 0xff80 broadcast 10.21.8.255 > >inet6 fe80::203:baff:fe2b:4771%vlan101 prefixlen 64 scopeid 0x6 > >inet6 2001:470:eac8:a::1 prefixlen 64 > > vlan102: flags=8843 mtu 1500 > >lladdr 00:03:ba:2b:47:71 > >description: wireless > >priority: 0 > >vlan: 102 parent interface: gem1 > >groups: vlan > >status: active > >inet 10.21.9.254 netmask 0xff80 broadcast 10.21.9.255 > >inet6 fe80::203:baff:fe2b:4771%vlan102 prefixlen 64 scopeid 0x7 > >inet6 2001:470:eac8:b::1 prefixlen 64 > > vlan2: flags=8843 mtu 1500 > >lladdr 00:03:ba:2b:47:71 > >description: transit > >priority: 0 > >vlan: 2 parent interface: gem1 > >groups: vlan > >status: active > >inet 172.21.1.2 netmask 0xfffc broadcast 172.21.1.3 > > tun0: flags=51 mtu 1500 > >priority: 0 > >groups: tun > >status: down > >inet 10.21.2.1 --> 10.21.2.2 netmask 0xfffc > > gif0: flags=8051 mtu 1280 > >priority: 0 > >groups: gif egress > >tunnel: inet 96.54.13.103 -> 216.218.226.238 > >inet6 fe80::203:baff:fe2b:4770%gif0 -> prefixlen 64 scopeid 0xa > >inet6 2001:470:a:6cf::2 -> 2001:470:a:6cf::1 prefixlen 12
mpsafe ifqueues
this introduces mpsafety to ifqueue operations. this follows on from some mopping up of (now) inappropriate use of ifqueues and the IF_ and IFQ_ operations on them. in most cases those ifqueues have been replaced with mbuf_lists or mbuf_queues. the reason we want mpsafe ifqueues is so we can run the network stack without the big lock, but still run drivers on another cpu (which may or may not need the big lock). we do this by adding a mutex in struct ifqueue to protect the queue data structures. that ends up sending us down a rabbit hole. ifqueues are like bufqs (or bufqs are like ifqueues) in that they abstract a set of operations (enqueue, dequeue) on top of different queueing disciplines (priq or hfsc). they also support switching disciplines at runtime. so the ifq operations are now functions which wrap discipline code. priq has been factored out and hfsc has been massaged slightly. the ifq code manages the locking, the accounting (ifq_len), and freeing the mbufs (to avoid locking in the mbuf layer while holding an ifq lock). a discipline just has to accept or reject a queue op. however, a lot of drivers use IFQ_POLL, which gives them a reference to an mbuf which is still on the ifqueue. now that we're expecting multiple cpus to operate on a queue, it is possible that one cpu could be between IFQ_POLL and IFQ_DEQUEUE calls while another cpu is purging the queue. ie, the first cpu will end up using after a free. i was going to provide an IFQ_REQUEUE api so drivers could cleanly dequeue an mbuf, attempt to transmit it, and requeue it if there's a temporary failure. that worked great from a mbuf and queue consistency point of view, but kenjiro cho pointed out that it can make statistics in some disciplines hard. eg, requeue on hfsc in my code caused the bandwidth estimates to go wrong on the next dequeue. the alternative i came up with was to break apart the dequeue operation into something like a database transaction. a driver that wants to try and queue an mbuf calls ifq_deq_begin to get a reference to the mbuf and hold the ifqueue mutex. if it figures out it can tx the mbuf, it calls ifq_deq_commit to properly take the mbuf and release the lock. if it cant take the mbuf it calles ifq_deq_rollback, which basically gives up the mutex. this diff implements all that, and does a naive conversion of most drivers using IFQ_POLL over to ifq_deq_begin/commit/rollback. the exceptions to that are bge, de, and vge. bge and vge have been modified to only use IFQ_DEQUEUE after checking for enough space on the tx ring. de has been changed to simplify its working by using m_defrag, but still uses a transaction. it is a big diff, but i have been beating on it a bit and im confident with it. all the risk in my mind is in the driver changes. i would appreciate testing by everyone though, but in particular de and vge users. cheers, dlg Index: share/man/man9/ifq_enq.9 === RCS file: share/man/man9/ifq_enq.9 diff -N share/man/man9/ifq_enq.9 --- /dev/null 1 Jan 1970 00:00:00 - +++ share/man/man9/ifq_enq.912 Nov 2015 05:50:12 - @@ -0,0 +1,140 @@ +.\" $OpenBSD$ +.\" +.\" 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. +.\" +.Dd $Mdocdate: November 12 2015 $ +.Dt IFQ_ENQ 9 +.Os +.Sh NAME +.Nm ifq_enq , +.Nm ifq_deq , +.Nm ifq_deq_begin , +.Nm ifq_deq_commit , +.Nm ifq_deq_rollback , +.Nm ifq_purge , +.Nm ifq_len , +.Nm ifq_empty +.Nd Interface send queue API +.Sh SYNOPSIS +.In net/if_var.h +.Ft int +.Fn ifq_enq "struct ifqueue *ifq" "struct mbuf *m" +.Ft struft mbuf * +.Fn ifq_deq "struct ifqueue *ifq" +.Ft struft mbuf * +.Fn ifq_deq_begin "struct ifqueue *ifq" +.Ft void +.Fn ifq_deq_commit "struct ifqueue *ifq" "struct mbuf *m" +.Ft void +.Fn ifq_deq_rollback "struct ifqueue *ifq" "struct mbuf *m" +.Ft unsigned int +.Fn ifq_purge "struct ifqueue *ifq" +.Ft unsigned int +.Fn ifq_len "struct ifqueue *ifq" +.Ft unsigned int +.Fn ifq_empty "struct ifqueue *ifq" +.Sh DESCRIPTION +The ifqueue API provides implementions of data structures and +operations for the network stack to queue mbufs for a network driver +to dequeue from its start routine for transmission. +.Bl -tag -width Ds +.It Fn ifq_enq "struct ifqueue *i
Re: sunfire v120 gem interfaces
> On 13 Nov 2015, at 12:16, Ryan Freeman wrote: > > On Tue, Nov 10, 2015 at 08:27:36PM +1000, David Gwynne wrote: >> any joy? i mean, failure? > > Well I got something different. I've noticed the failures only seem to happen > when my roommates arrive home. I can use my stuff remotely all day from work > without a hitch, roommates come home and usually within an hr there is an > internet complaint. > > Since I started using the little scripts to detect connection failure > and down/up the iface in question, things had been pretty good simply in the > fact that nobody could really notice before it fixed itself. > > Today the machine dropped to ddb>! of course i couldn't remember a damn > thing to type :( i got trace, terribly sorry it wasn't more... > > ddb> trace > extent_free(400012600c0, 0, 0, 0, 1fef078, 800012fa) at > extent_free > +0x174 > iommu_dvmamap_unload(40001266300, 0, 4000129f080, 0, 0, 2) at > iommu_dvmamap_unl > oad+0x74 > gem_rint(400014ac000, 40016ff, 7fff, e0017c48, 4000, > 80 > 00) at gem_rint+0x160 > gem_intr(400014ac000, c00ca000, 2000, 0, 0, 8000) at gem_intr+0x154 > intr_handler(e0017ec8, 4000117ae00, 4bca3020, 0, 800, 2) at intr_handler+0xc > sparc_interrupt(0, 400014b, 80206910, 400171b7c60, 40009ec0810, 0) at > sparc > _interrupt+0x298 > gem_ioctl(400014ac048, 400014ac000, 400171b7c60, 400171b7c60, 0, 40009b73c10) > a > t gem_ioctl+0x19c > ifioctl(0, 80206910, 400171b7c60, 40009b73c10, 1012d74, 0) at ifioctl+0x38c > sys_ioctl(0, 400171b7db8, 400171b7df8, 0, 0, 14b) at sys_ioctl+0x190 > syscall(400171b7ed0, 436, bec8920888, bec892088c, 0, 0) at syscall+0x3c4 > softtrap(3, 80206910, fffe3018, 0, 0, 1ff7fff6df8) at softtrap+0x19c > ddb> that is interesting. if you're still in ddb, can you go sh panic? if not, not biggy. my gut feeling is our ring accounting is wonky. mpi@ and jmatthew@ have tweaks to gem(4) for mpsafety which might fix this. ill poke them to see if they would share. dlg > > > >> >>> On 9 Nov 2015, at 10:40 AM, Ryan Freeman wrote: >>> >>> On Mon, Nov 09, 2015 at 10:07:31AM +1000, David Gwynne wrote: can you get the ifconfig output when its locked up? and a copy of what systat mb is showing? cheers, dlg >>> >>> Thanks David, >>> >>> I have setup a script to try and capture this immediately when it happens. >>> >>> FWIW here is the output as it is now, working: >>> >>> 16:35 ryan@void:~$ ifconfig >>> lo0: flags=8049 mtu 32768 >>> priority: 0 >>> groups: lo >>> inet6 fe80::1%lo0 prefixlen 64 scopeid 0x4 >>> inet6 ::1 prefixlen 128 >>> inet 127.0.0.1 netmask 0xff00 >>> gem0: flags=8867 >>> mtu 1500 >>> lladdr 00:03:ba:2b:47:70 >>> priority: 0 >>> groups: egress >>> media: Ethernet autoselect (100baseTX full-duplex) >>> status: active >>> inet 96.54.13.103 netmask 0xfc00 broadcast 96.54.15.255 >>> gem1: >>> flags=8b63 >>> mtu 1500 >>> lladdr 00:03:ba:2b:47:71 >>> priority: 0 >>> media: Ethernet autoselect (100baseTX full-duplex) >>> status: active >>> inet 10.16.1.30 netmask 0xffe0 broadcast 10.16.1.31 >>> inet6 fe80::203:baff:fe2b:4771%gem1 prefixlen 64 scopeid 0x2 >>> inet6 2001:470:b:6cf::1 prefixlen 64 >>> enc0: flags=0<> >>> priority: 0 >>> groups: enc >>> status: active >>> vlan100: flags=8843 mtu 1500 >>> lladdr 00:03:ba:2b:47:71 >>> description: servers >>> priority: 0 >>> vlan: 100 parent interface: gem1 >>> groups: vlan >>> status: active >>> inet 10.21.1.30 netmask 0xffe0 broadcast 10.21.1.31 >>> inet6 fe80::203:baff:fe2b:4771%vlan100 prefixlen 64 scopeid 0x5 >>> inet6 2001:470:eac8:666::1 prefixlen 64 >>> vlan101: flags=8843 mtu 1500 >>> lladdr 00:03:ba:2b:47:71 >>> description: workstations >>> priority: 0 >>> vlan: 101 parent interface: gem1 >>> groups: vlan >>> status: active >>> inet 10.21.8.254 netmask 0xff80 broadcast 10.21.8.255 >>> inet6 fe80::203:baff:fe2b:4771%vlan101 prefixlen 64 scopeid 0x6 >>> inet6 2001:470:eac8:a::1 prefixlen 64 >>> vlan102: flags=8843 mtu 1500 >>> lladdr 00:03:ba:2b:47:71 >>> description: wireless >>> priority: 0 >>> vlan: 102 parent interface: gem1 >>> groups: vlan >>> status: active >>> inet 10.21.9.254 netmask 0xff80 broadcast 10.21.9.255 >>> inet6 fe80::203:baff:fe2b:4771%vlan102 prefixlen 64 scopeid 0x7 >>> inet6 2001:470:eac8:b::1 prefixlen 64 >>> vlan2: flags=8843 mtu 1500 >>> lladdr 00:03:ba:2b:47:71 >>> description: transit >>> priority: 0 >>> vlan: 2 parent interface: gem1 >>> groups: vlan >>> status: active >>> inet 172.21.1.2 netmask 0xfffc broadcast 172.21.1.3 >>> tun0: flags=51 mtu 1500 >>> priority: 0 >>> groups: tun >>> status: dow
Re: sunfire v120 gem interfaces
On Fri, Nov 13, 2015 at 12:36:40PM +1000, David Gwynne wrote: > > > On 13 Nov 2015, at 12:16, Ryan Freeman wrote: > > > > On Tue, Nov 10, 2015 at 08:27:36PM +1000, David Gwynne wrote: > >> any joy? i mean, failure? > > > > Well I got something different. I've noticed the failures only seem to > > happen > > when my roommates arrive home. I can use my stuff remotely all day from > > work > > without a hitch, roommates come home and usually within an hr there is an > > internet complaint. > > > > Since I started using the little scripts to detect connection failure > > and down/up the iface in question, things had been pretty good simply in the > > fact that nobody could really notice before it fixed itself. > > > > Today the machine dropped to ddb>! of course i couldn't remember a damn > > thing to type :( i got trace, terribly sorry it wasn't more... > > > > ddb> trace > > extent_free(400012600c0, 0, 0, 0, 1fef078, 800012fa) at > > extent_free > > +0x174 > > iommu_dvmamap_unload(40001266300, 0, 4000129f080, 0, 0, 2) at > > iommu_dvmamap_unl > > oad+0x74 > > gem_rint(400014ac000, 40016ff, 7fff, e0017c48, 4000, > > 80 > > 00) at gem_rint+0x160 > > gem_intr(400014ac000, c00ca000, 2000, 0, 0, 8000) at gem_intr+0x154 > > intr_handler(e0017ec8, 4000117ae00, 4bca3020, 0, 800, 2) at intr_handler+0xc > > sparc_interrupt(0, 400014b, 80206910, 400171b7c60, 40009ec0810, 0) at > > sparc > > _interrupt+0x298 > > gem_ioctl(400014ac048, 400014ac000, 400171b7c60, 400171b7c60, 0, > > 40009b73c10) a > > t gem_ioctl+0x19c > > ifioctl(0, 80206910, 400171b7c60, 40009b73c10, 1012d74, 0) at ifioctl+0x38c > > sys_ioctl(0, 400171b7db8, 400171b7df8, 0, 0, 14b) at sys_ioctl+0x190 > > syscall(400171b7ed0, 436, bec8920888, bec892088c, 0, 0) at syscall+0x3c4 > > softtrap(3, 80206910, fffe3018, 0, 0, 1ff7fff6df8) at softtrap+0x19c > > ddb> > > that is interesting. if you're still in ddb, can you go sh panic? > > if not, not biggy. Sadly, I am not. as it is my router, I had to reboot to get back online to send the mail. If it triggers again I will make sure I include that. > my gut feeling is our ring accounting is wonky. mpi@ and jmatthew@ have > tweaks to gem(4) for mpsafety which might fix this. ill poke them to see if > they would share. I am willing to try anything! :) I will reiterate that I am just running 5.8 stable (with mtier binpatches for errata); if it requires me to bump up to -current, no biggie :) > > dlg > > > > > > > > >> > >>> On 9 Nov 2015, at 10:40 AM, Ryan Freeman wrote: > >>> > >>> On Mon, Nov 09, 2015 at 10:07:31AM +1000, David Gwynne wrote: > can you get the ifconfig output when its locked up? and a copy of what > systat mb is showing? > > cheers, > dlg > >>> > >>> Thanks David, > >>> > >>> I have setup a script to try and capture this immediately when it happens. > >>> > >>> FWIW here is the output as it is now, working: > >>> > >>> 16:35 ryan@void:~$ ifconfig > >>> lo0: flags=8049 mtu 32768 > >>> priority: 0 > >>> groups: lo > >>> inet6 fe80::1%lo0 prefixlen 64 scopeid 0x4 > >>> inet6 ::1 prefixlen 128 > >>> inet 127.0.0.1 netmask 0xff00 > >>> gem0: flags=8867 > >>> mtu 1500 > >>> lladdr 00:03:ba:2b:47:70 > >>> priority: 0 > >>> groups: egress > >>> media: Ethernet autoselect (100baseTX full-duplex) > >>> status: active > >>> inet 96.54.13.103 netmask 0xfc00 broadcast 96.54.15.255 > >>> gem1: > >>> flags=8b63 > >>> mtu 1500 > >>> lladdr 00:03:ba:2b:47:71 > >>> priority: 0 > >>> media: Ethernet autoselect (100baseTX full-duplex) > >>> status: active > >>> inet 10.16.1.30 netmask 0xffe0 broadcast 10.16.1.31 > >>> inet6 fe80::203:baff:fe2b:4771%gem1 prefixlen 64 scopeid 0x2 > >>> inet6 2001:470:b:6cf::1 prefixlen 64 > >>> enc0: flags=0<> > >>> priority: 0 > >>> groups: enc > >>> status: active > >>> vlan100: flags=8843 mtu 1500 > >>> lladdr 00:03:ba:2b:47:71 > >>> description: servers > >>> priority: 0 > >>> vlan: 100 parent interface: gem1 > >>> groups: vlan > >>> status: active > >>> inet 10.21.1.30 netmask 0xffe0 broadcast 10.21.1.31 > >>> inet6 fe80::203:baff:fe2b:4771%vlan100 prefixlen 64 scopeid 0x5 > >>> inet6 2001:470:eac8:666::1 prefixlen 64 > >>> vlan101: flags=8843 mtu 1500 > >>> lladdr 00:03:ba:2b:47:71 > >>> description: workstations > >>> priority: 0 > >>> vlan: 101 parent interface: gem1 > >>> groups: vlan > >>> status: active > >>> inet 10.21.8.254 netmask 0xff80 broadcast 10.21.8.255 > >>> inet6 fe80::203:baff:fe2b:4771%vlan101 prefixlen 64 scopeid 0x6 > >>> inet6 2001:470:eac8:a::1 prefixlen 64 > >>> vlan102: flags=8843 mtu 1500 > >>> lladdr 00:03:ba:2b:47:71 > >>> description: wireless > >>> priority: 0 > >>>