Re: AR8161 patch
On Mon, Mar 30, 2015 at 09:52:49PM +0300, Atanas Vladimirov wrote: > Hi, > This is based on work of o...@openbsd.se and I send it to tech@ by request > from Alexey Suslikov. > As a result my "Attansic Technology AR8161" works as it should. > For more information see: > https://www.marc.info/?t=14148214521&r=1&w=2 > https://www.marc.info/?l=openbsd-misc&w=2&r=1&s=Atheros+AR816X+Ethernet+Support+&q=b > Best wishes, > Atanas The whitespace errors make the diff mostly unreadable, fix those and remove the conflict marker. Don't duplicate pcie defines. Drop device_printf/device_print_prettyname. Don't #if 0 alc_init, patch it.
Re: Do you need/prefer the non-DUID option in the installer?
>Theo de Raadt, 15 Mar 2015 12:15: >> > Yes I do. when I install machines that I dump/restore clone, I do >> > not use DUID's. it's very nice to make a system without DUID's in >> > that case. >> >> I'm sorry, but I don't understand the usage case here which blocks >> DUIDS, so let's see a better explanation or demonstration. >> >> When you have DUIDs in /etc/fstab, you can still use the disk partitions >> using the raw disk names. The partitions are obvious. Figuring out which >> disk it is, is really easy, lots of options to provide the translation. >> >> And as far as I know, all the tools have been adapted to accept DUID. > >IIRC 'bioctl -d' cannot deal with DUID's. >not a showstopper, just sayin' Sounds like you might use this. Want to trial a diff that adds support? If it is wrong, don't worry, someone will hate your bad diff, and do it right. (That is pretty much the history of DUID support in the tools)
Re: sort output file permissions
On Mon, Mar 30, 2015 at 02:29:51PM -0600, Todd C. Miller wrote: > On Mon, 30 Mar 2015 20:05:38 +0200, Alexander Bluhm wrote: > > > If an outfile exists but is not an infile, permissions are preserved. > > If an outfile exists and is also an infile, it gets 666 & ~umask. > > Do we want this inconsistency? > > That's what the old sort did. It looks like GNU sort preserves the > permissions. I'm OK with it either way but we should either preserve > the original permissions or apply the umask, not both, > > > If an outfile is also used as infile but has no write prmissions, > > it gets overwritten anyway. Do we want this? Should we add an > > access(real_outfile, W_OK)? > > Sure. Also, there is a missing call to atexit() in sort(1) which > prevented the temp file from getting cleaned up on error. OK bluhm@ > > - todd > > Index: usr.bin/sort/sort.c > === > RCS file: /cvs/src/usr.bin/sort/sort.c,v > retrieving revision 1.48 > diff -u -r1.48 sort.c > --- usr.bin/sort/sort.c 20 Mar 2015 23:04:07 - 1.48 > +++ usr.bin/sort/sort.c 30 Mar 2015 20:28:49 - > @@ -889,7 +889,7 @@ > { false, false, false, false, false, false }; > > result = 0; > - outfile = sort_strdup("-"); > + outfile = "-"; > real_outfile = NULL; > > struct sort_mods *sm = &default_sort_mods_object; > @@ -898,6 +898,8 @@ > > set_signal_handler(); > > + atexit(clear_tmp_files); > + > set_hw_params(); > set_locale(); > set_tmpdir(); > @@ -951,8 +953,7 @@ > sort_opts_vals.mflag = true; > break; > case 'o': > - sort_free(outfile); > - outfile = sort_strdup(optarg); > + outfile = optarg; > break; > case 's': > sort_opts_vals.sflag = true; > @@ -1126,20 +1127,25 @@ > set_random_seed(); > > /* Case when the outfile equals one of the input files: */ > - if (strcmp(outfile, "-")) { > - int i; > + if (strcmp(outfile, "-") != 0) { > + struct stat sb; > + int fd, i; > > for (i = 0; i < argc; ++i) { > if (strcmp(argv[i], outfile) == 0) { > - real_outfile = sort_strdup(outfile); > - for (;;) { > - const size_t size = strlen(outfile) + > strlen(".tmp") + 1; > - outfile = sort_realloc(outfile, size); > - strlcat(outfile, ".tmp", size); > - if (access(outfile, F_OK) < 0) > - break; > - } > + if (stat(outfile, &sb) == -1) > + err(2, "%s", outfile); > + if (access(outfile, W_OK) == -1) > + err(2, "%s", outfile); > + real_outfile = outfile; > + sort_asprintf(&outfile, "%s.XX", > + real_outfile); > + if ((fd = mkstemp(outfile)) == -1 || > + fchmod(fd, sb.st_mode & ALLPERMS) == -1) > + err(2, "%s", outfile); > + close(fd); > tmp_file_atexit(outfile); > + break; > } > } > } > @@ -1194,13 +1200,10 @@ > } > > if (real_outfile) { > - unlink(real_outfile); > if (rename(outfile, real_outfile) < 0) > err(2, "%s", real_outfile); > - sort_free(real_outfile); > + sort_free(outfile); > } > - > - sort_free(outfile); > > return result; > }
Re: Do you need/prefer the non-DUID option in the installer?
On Mon, Mar 30, 2015 at 4:04 PM, frantisek holop wrote: > Theo de Raadt, 15 Mar 2015 12:15: >> > Yes I do. when I install machines that I dump/restore clone, I do >> > not use DUID's. it's very nice to make a system without DUID's in >> > that case. >> >> I'm sorry, but I don't understand the usage case here which blocks >> DUIDS, so let's see a better explanation or demonstration. >> >> When you have DUIDs in /etc/fstab, you can still use the disk partitions >> using the raw disk names. The partitions are obvious. Figuring out which >> disk it is, is really easy, lots of options to provide the translation. >> >> And as far as I know, all the tools have been adapted to accept DUID. > > IIRC 'bioctl -d' cannot deal with DUID's. > not a showstopper, just sayin' > > -f > -- > doubt is the beginning of wisdom > Completely hackish and subject to races, but fulfills my needs right now: https://github.com/acamari/getdev
Re: Do you need/prefer the non-DUID option in the installer?
Theo de Raadt, 15 Mar 2015 12:15: > > Yes I do. when I install machines that I dump/restore clone, I do > > not use DUID's. it's very nice to make a system without DUID's in > > that case. > > I'm sorry, but I don't understand the usage case here which blocks > DUIDS, so let's see a better explanation or demonstration. > > When you have DUIDs in /etc/fstab, you can still use the disk partitions > using the raw disk names. The partitions are obvious. Figuring out which > disk it is, is really easy, lots of options to provide the translation. > > And as far as I know, all the tools have been adapted to accept DUID. IIRC 'bioctl -d' cannot deal with DUID's. not a showstopper, just sayin' -f -- doubt is the beginning of wisdom
Re: sort output file permissions
On Mon, 30 Mar 2015 20:05:38 +0200, Alexander Bluhm wrote: > If an outfile exists but is not an infile, permissions are preserved. > If an outfile exists and is also an infile, it gets 666 & ~umask. > Do we want this inconsistency? That's what the old sort did. It looks like GNU sort preserves the permissions. I'm OK with it either way but we should either preserve the original permissions or apply the umask, not both, > If an outfile is also used as infile but has no write prmissions, > it gets overwritten anyway. Do we want this? Should we add an > access(real_outfile, W_OK)? Sure. Also, there is a missing call to atexit() in sort(1) which prevented the temp file from getting cleaned up on error. - todd Index: usr.bin/sort/sort.c === RCS file: /cvs/src/usr.bin/sort/sort.c,v retrieving revision 1.48 diff -u -r1.48 sort.c --- usr.bin/sort/sort.c 20 Mar 2015 23:04:07 - 1.48 +++ usr.bin/sort/sort.c 30 Mar 2015 20:28:49 - @@ -889,7 +889,7 @@ { false, false, false, false, false, false }; result = 0; - outfile = sort_strdup("-"); + outfile = "-"; real_outfile = NULL; struct sort_mods *sm = &default_sort_mods_object; @@ -898,6 +898,8 @@ set_signal_handler(); + atexit(clear_tmp_files); + set_hw_params(); set_locale(); set_tmpdir(); @@ -951,8 +953,7 @@ sort_opts_vals.mflag = true; break; case 'o': - sort_free(outfile); - outfile = sort_strdup(optarg); + outfile = optarg; break; case 's': sort_opts_vals.sflag = true; @@ -1126,20 +1127,25 @@ set_random_seed(); /* Case when the outfile equals one of the input files: */ - if (strcmp(outfile, "-")) { - int i; + if (strcmp(outfile, "-") != 0) { + struct stat sb; + int fd, i; for (i = 0; i < argc; ++i) { if (strcmp(argv[i], outfile) == 0) { - real_outfile = sort_strdup(outfile); - for (;;) { - const size_t size = strlen(outfile) + strlen(".tmp") + 1; - outfile = sort_realloc(outfile, size); - strlcat(outfile, ".tmp", size); - if (access(outfile, F_OK) < 0) - break; - } + if (stat(outfile, &sb) == -1) + err(2, "%s", outfile); + if (access(outfile, W_OK) == -1) + err(2, "%s", outfile); + real_outfile = outfile; + sort_asprintf(&outfile, "%s.XX", + real_outfile); + if ((fd = mkstemp(outfile)) == -1 || + fchmod(fd, sb.st_mode & ALLPERMS) == -1) + err(2, "%s", outfile); + close(fd); tmp_file_atexit(outfile); + break; } } } @@ -1194,13 +1200,10 @@ } if (real_outfile) { - unlink(real_outfile); if (rename(outfile, real_outfile) < 0) err(2, "%s", real_outfile); - sort_free(real_outfile); + sort_free(outfile); } - - sort_free(outfile); return result; }
AR8161 patch
Hi, This is based on work of o...@openbsd.se and I send it to tech@ by request from Alexey Suslikov. As a result my "Attansic Technology AR8161" works as it should. For more information see: https://www.marc.info/?t=14148214521&r=1&w=2 https://www.marc.info/?l=openbsd-misc&w=2&r=1&s=Atheros+AR816X+Ethernet+Support+&q=b Best wishes, Atanas Index: if_alc.c === RCS file: /home/vlado/cvsync/cvsroot/src/sys/dev/pci/if_alc.c,v retrieving revision 1.27 diff -u -p -r1.27 if_alc.c --- if_alc.c22 Jul 2014 13:12:11 - 1.27 +++ if_alc.c2 Nov 2014 15:11:59 - @@ -1,5 +1,10 @@ + +/* $OpenBSD: if_alc.c,v 1.26 2013/12/28 03:34:53 deraadt Exp $ */ +/*- patched by oht to fit with the AR816X_FAMILY*/ + /* $OpenBSD: if_alc.c,v 1.27 2014/07/22 13:12:11 mpi Exp $ */ /*- +>>> 1.27 * Copyright (c) 2009, Pyun YongHyeon * All rights reserved. * @@ -26,7 +31,7 @@ * SUCH DAMAGE. */ -/* Driver for Atheros AR8131/AR8132 PCIe Ethernet. */ +/* Driver for Atheros AR8131/AR8132 AR8161/AR8162 AR8171/AR8172 PCIe Ethernet. */ #include "bpfilter.h" #include "vlan.h" @@ -84,12 +89,17 @@ voidalc_watchdog(struct ifnet *); intalc_mediachange(struct ifnet *); void alc_mediastatus(struct ifnet *, struct ifmediareq *); -void alc_aspm(struct alc_softc *, int); +void alc_aspm(struct alc_softc *, int, int); +void alc_aspm_813x(struct alc_softc *, int); +void alc_aspm_816x(struct alc_softc *, int); void alc_disable_l0s_l1(struct alc_softc *); intalc_dma_alloc(struct alc_softc *); void alc_dma_free(struct alc_softc *); intalc_encap(struct alc_softc *, struct mbuf **); void alc_get_macaddr(struct alc_softc *); + void alc_get_macaddr_813x(struct alc_softc *); + void alc_get_macaddr_816x(struct alc_softc *); + void alc_get_macaddr_par(struct alc_softc *); void alc_init_cmb(struct alc_softc *); void alc_init_rr_ring(struct alc_softc *); intalc_init_rx_ring(struct alc_softc *); @@ -97,9 +107,26 @@ voidalc_init_smb(struct alc_softc *); void alc_init_tx_ring(struct alc_softc *); intalc_intr(void *); void alc_mac_config(struct alc_softc *); + uint32_t alc_mii_readreg_813x(struct alc_softc *, int, int); + uint32_t alc_mii_readreg_816x(struct alc_softc *, int, int); + uint32_t alc_mii_writereg_813x(struct alc_softc *, int, int, int); + uint32_t alc_mii_writereg_816x(struct alc_softc *, int, int, int); + void alc_dsp_fixup(struct alc_softc *, int); + intalc_miibus_readreg(struct device *, int, int); void alc_miibus_statchg(struct device *); +intalc_miibus_writeregr(struct device *, int, int, int); void alc_miibus_writereg(struct device *, int, int, int); + uint32_t alc_miidbg_readreg(struct alc_softc *, int); + uint32_t alc_miidbg_writereg(struct alc_softc *, int, int); + uint32_t alc_miiext_readreg(struct alc_softc *, int, int); + uint32_t alc_miiext_writereg(struct alc_softc *, int, int, int); + //int alc_mediachange_locked(struct alc_softc *); + void alc_phy_reset_813x(struct alc_softc *); + void alc_phy_reset_816x(struct alc_softc *); + void alc_setwol_813x(struct alc_softc *); + void alc_setwol_816x(struct alc_softc *); + intalc_newbuf(struct alc_softc *, struct alc_rxdesc *); void alc_phy_down(struct alc_softc *); void alc_phy_reset(struct alc_softc *); @@ -116,6 +143,18 @@ void alc_stop_mac(struct alc_softc *); void alc_stop_queue(struct alc_softc *); void alc_tick(void *); void alc_txeof(struct alc_softc *); +void alc_init_pcie(struct alc_softc *, int); +void alc_config_msi(struct alc_softc *); + +intalc_dma_alloc(struct alc_softc *); +void alc_dma_free(struct alc_softc *); +intalc_encap(struct alc_softc *, struct mbuf **); +void alc_osc_reset(struct alc_softc *); + + +intdevice_print_prettyname(struct alc_softc *); +intdevice_printf(struct alc_softc *, const char * , ...); + uint32_t alc_dma_burst[] = { 128, 256, 512, 1024, 2048, 4096, 0 }; @@ -125,11 +164,16 @@ const struct pci_matchid alc_devices[] = { PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_L1D }, { PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_L1D_1 }, { PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_L2C_1 }, - { PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_L2C_2 } + { PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_L2C_2 }, + { PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_AR8161 }, + { PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_AR8162 }, + { PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_AR8171 }, + { PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_AR8172 } + }; struct cfattach alc_ca = { - sizeof (struct alc_softc), alc_match, alc_attach, NULL, + sizeof (struct alc_softc), alc_match, alc_attach, alc_detach, alc_activate }; @@ -138,6 +182,32 @@ struct cfdriver alc_cd = { }; int alcdebug = 0; + +int + device_print_prettyname(struct alc_
Re: sort output file permissions
On Mon, Mar 30, 2015 at 10:20:33AM -0600, Todd C. Miller wrote: > I like this even better as it gets rid of the predictable temp file > name. I also removed some useless dynamic allocations. The temp > file handling in sort is still rather bad but at least this fixes > the -o flag. If an outfile exists but is not an infile, permissions are preserved. If an outfile exists and is also an infile, it gets 666 & ~umask. Do we want this inconsistency? If an outfile is also used as infile but has no write prmissions, it gets overwritten anyway. Do we want this? Should we add an access(real_outfile, W_OK)? > + if (asprintf(&outfile, "%s.XX", > outfile) == -1) This line is too long. bluhm
Re: ehci(4) Full-speed isochronous transfers support
On Sat, Mar 28, 2015 at 11:29:11AM +0100, Martin Pieuchot wrote: > With the increasing number of machines shipping with rate-matching > hubs instead of companion controllers to support USB Full and Low- > speed devices, a number of people asked me if it was possible to > add support for Full-speed isochronous transfers in order to use > USB1.1 uaudio(4) devices with ehci(4)-only systems. > > The diff below does that. It also contain some cleanups for the > High-speed isochronous code and plug some memory leaks for free. Excellent! > > Please let me know how it goes with 1.1 and 2.0 devices. seems to work for me with simple uaudio devices. Sound is not stable, but this might be the hardware and/or the uaudio driver. As soon as I get it back, I'll test with a device that I know very well, which would help understanding problems (if any). -- Alexandre
libtls manpage diff
- Correct title. - tls_accept_socket() also may return TLS_{READ,WRITE}_AGAIN. Index: tls_init.3 === RCS file: /cvs/src/lib/libtls/tls_init.3,v retrieving revision 1.18 diff -u -r1.18 tls_init.3 --- tls_init.3 22 Feb 2015 15:09:54 - 1.18 +++ tls_init.3 30 Mar 2015 16:36:47 - @@ -15,7 +15,7 @@ .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" .Dd $Mdocdate: February 22 2015 $ -.Dt TLS 3 +.Dt TLS_INIT 3 .Os .Sh NAME .Nm tls_init , @@ -391,9 +391,10 @@ Functions that return a pointer will return NULL on error. .Pp The -.Fn tls_read -and +.Fn tls_read , .Fn tls_write +and +.Fn tls_accept_socket functions and the .Fn tls_connect family of functions have two special return values.
tls_accept_socket() error message
httpd/server.c contains the following: ret = tls_accept_socket(srv->srv_tls_ctx, &clt->clt_tls_ctx, clt->clt_s); [...] } else if (ret != 0) { log_warnx("%s: TLS accept failed - %s", __func__, tls_error(srv->srv_tls_ctx)); return; Here the return value of tls_error(srv->srv_tls_ctx) may be incorrect if tls_accept_socket() sets the error message in clt->clt_tls_ctx. For instance, in my case, the above code snippet produces the following log entries: Mar 29 22:53:22 alpha httpd[6684]: server_accept_tls: TLS accept failed - (null) Perhaps the following diff would be a good way to fix this. Index: tls_server.c === RCS file: /cvs/src/lib/libtls/tls_server.c,v retrieving revision 1.5 diff -p -U5 -r1.5 tls_server.c --- tls_server.c7 Feb 2015 09:50:09 - 1.5 +++ tls_server.c30 Mar 2015 17:28:33 - @@ -133,10 +133,11 @@ tls_accept_socket(struct tls *ctx, struc if ((ret = SSL_accept(conn_ctx->ssl_conn)) != 1) { err = tls_ssl_error(conn_ctx, ret, "accept"); if (err == TLS_READ_AGAIN || err == TLS_WRITE_AGAIN) { return (err); } + tls_set_error(ctx, "%s", tls_error(conn_ctx)); goto err; } return (0);
Re: sort output file permissions
I like this even better as it gets rid of the predictable temp file name. I also removed some useless dynamic allocations. The temp file handling in sort is still rather bad but at least this fixes the -o flag. - todd Index: usr.bin/sort/sort.c === RCS file: /cvs/src/usr.bin/sort/sort.c,v retrieving revision 1.48 diff -u -r1.48 sort.c --- usr.bin/sort/sort.c 20 Mar 2015 23:04:07 - 1.48 +++ usr.bin/sort/sort.c 30 Mar 2015 16:13:50 - @@ -889,7 +889,7 @@ { false, false, false, false, false, false }; result = 0; - outfile = sort_strdup("-"); + outfile = "-"; real_outfile = NULL; struct sort_mods *sm = &default_sort_mods_object; @@ -951,8 +951,7 @@ sort_opts_vals.mflag = true; break; case 'o': - sort_free(outfile); - outfile = sort_strdup(optarg); + outfile = optarg; break; case 's': sort_opts_vals.sflag = true; @@ -1126,20 +1125,24 @@ set_random_seed(); /* Case when the outfile equals one of the input files: */ - if (strcmp(outfile, "-")) { - int i; + if (strcmp(outfile, "-") != 0) { + int fd, i; + mode_t um; for (i = 0; i < argc; ++i) { if (strcmp(argv[i], outfile) == 0) { - real_outfile = sort_strdup(outfile); - for (;;) { - const size_t size = strlen(outfile) + strlen(".tmp") + 1; - outfile = sort_realloc(outfile, size); - strlcat(outfile, ".tmp", size); - if (access(outfile, F_OK) < 0) - break; - } + real_outfile = outfile; + if (asprintf(&outfile, "%s.XX", outfile) == -1) + err(2, NULL); + + um = umask(S_IWGRP|S_IWOTH); + (void)umask(um); + if ((fd = mkstemp(outfile)) == -1 || + fchmod(fd, DEFFILEMODE & ~um) == -1) + err(2, "%s", outfile); + close(fd); tmp_file_atexit(outfile); + break; } } } @@ -1194,13 +1197,10 @@ } if (real_outfile) { - unlink(real_outfile); if (rename(outfile, real_outfile) < 0) err(2, "%s", real_outfile); - sort_free(real_outfile); + sort_free(outfile); } - - sort_free(outfile); return result; }
Re: Proposed small change for ping(8) -- updated diff
Hi, After discussing with Sven Falempin changed the message to "Packet timed out" to be more exact updated diff: Index: ping.8 === RCS file: /cvs/src/sbin/ping/ping.8,v retrieving revision 1.52 diff -u -r1.52 ping.8 --- ping.8 24 Mar 2014 11:11:49 - 1.52 +++ ping.8 30 Mar 2015 16:18:04 - @@ -199,7 +199,7 @@ Verbose output. ICMP packets other than .Dv ECHO_REPLY -that are received are listed. +that are received are listed. Also reports timed out packets as they progress. .It Fl w Ar maxwait Specifies the maximum number of seconds to wait for responses after the last request has been sent. Index: ping.c === RCS file: /cvs/src/sbin/ping/ping.c,v retrieving revision 1.118 diff -u -r1.118 ping.c --- ping.c 23 Mar 2015 09:36:25 - 1.118 +++ ping.c 30 Mar 2015 16:18:04 - @@ -576,6 +576,8 @@ nmissedmax = ntransmitted - nreceived - 1; if (!(options & F_FLOOD) && (options & F_AUD_MISS)) write(STDERR_FILENO, "\a", 1); + if (!(options & F_FLOOD) && (options & F_VERBOSE)) + write(STDOUT_FILENO, "Packet timed out\n",17); } errno = save_errno; }
Re: sort output file permissions
How about this instead? It is more or less equivalent to what the old sort did. - todd Index: file.c === RCS file: /cvs/src/usr.bin/sort/file.c,v retrieving revision 1.3 diff -u -r1.3 file.c --- file.c 20 Mar 2015 00:26:38 - 1.3 +++ file.c 30 Mar 2015 15:28:13 - @@ -512,16 +512,14 @@ FILE *file; if (strcmp(fn, "-") == 0) { - return (mode && mode[0] == 'r') ? stdin : stdout; - } else { - mode_t orig_file_mask = 0; - int is_tmp = file_is_tmp(fn); + return (mode[0] == 'r') ? stdin : stdout; + } else if (file_is_tmp(fn)) { + mode_t um; - if (is_tmp && (mode[0] == 'w')) - orig_file_mask = umask(S_IWGRP | S_IWOTH | - S_IRGRP | S_IROTH); + if (mode[0] == 'w') + um = umask(S_IWGRP|S_IWOTH|S_IRGRP|S_IROTH); - if (is_tmp && (compress_program != NULL)) { + if (compress_program != NULL) { char *cmd; int len; @@ -543,12 +541,20 @@ err(2, NULL); sort_free(cmd); + } else { + if ((file = fopen(fn, mode)) == NULL) + err(2, "%s", fn); + if (mode[0] == 'w') { + if (fchmod(fileno(file), DEFFILEMODE & ~um) == -1) + err(2, "%s", fn); + } + } - } else if ((file = fopen(fn, mode)) == NULL) + if (mode[0] == 'w') + umask(um); + } else { + if ((file = fopen(fn, mode)) == NULL) err(2, "%s", fn); - - if (is_tmp && (mode[0] == 'w')) - umask(orig_file_mask); } return file;
Re: sort output file permissions
On Mon, Mar 30, 2015 at 04:48:55PM +0200, Alexander Bluhm wrote: > On Mon, Mar 30, 2015 at 08:59:16AM +0200, Otto Moerbeek wrote: > > If you call umask(2), it's better to reset it to the old value after > > you're done. > > I reset the umask immediately after reading it. I only need the > current value to use it in chmod. Ah, right, didn't spot that. > > > But it's likely better to fchmod the file while we have it still open. > > I was thinking about that, too. But it does not fit into the sort > layers. The current sort code sets the permission for the temp > file to 0600. Later I change it to a more permissive value. > > As the name is used to unlink and rename the files anyway, I think > my solution adding a chmod does not make it worse. if it's hard to do otherwise, maybe this is ok. -Otto > > bluhm > > > > Index: usr.bin/sort/sort.c > > > === > > > RCS file: /data/mirror/openbsd/cvs/src/usr.bin/sort/sort.c,v > > > retrieving revision 1.48 > > > diff -u -p -r1.48 sort.c > > > --- usr.bin/sort/sort.c 20 Mar 2015 23:04:07 - 1.48 > > > +++ usr.bin/sort/sort.c 29 Mar 2015 18:16:19 - > > > @@ -1194,6 +1194,17 @@ main(int argc, char *argv[]) > > > } > > > > > > if (real_outfile) { > > > + struct stat sb; > > > + mode_t mask; > > > + > > > + if (stat(real_outfile, &sb) < 0) > > > + err(2, "%s", real_outfile); > > > + if (access(real_outfile, W_OK) < 0) > > > + err(2, "write %s", real_outfile); > > > + mask = umask(0); > > > + umask(mask); > > > + chmod(outfile, sb.st_mode & ~mask & (S_IRWXU|S_IRWXG|S_IRWXO)); > > > + > > > unlink(real_outfile); > > > if (rename(outfile, real_outfile) < 0) > > > err(2, "%s", real_outfile);
Re: sort output file permissions
On Mon, Mar 30, 2015 at 08:59:16AM +0200, Otto Moerbeek wrote: > If you call umask(2), it's better to reset it to the old value after > you're done. I reset the umask immediately after reading it. I only need the current value to use it in chmod. > But it's likely better to fchmod the file while we have it still open. I was thinking about that, too. But it does not fit into the sort layers. The current sort code sets the permission for the temp file to 0600. Later I change it to a more permissive value. As the name is used to unlink and rename the files anyway, I think my solution adding a chmod does not make it worse. bluhm > > Index: usr.bin/sort/sort.c > > === > > RCS file: /data/mirror/openbsd/cvs/src/usr.bin/sort/sort.c,v > > retrieving revision 1.48 > > diff -u -p -r1.48 sort.c > > --- usr.bin/sort/sort.c 20 Mar 2015 23:04:07 - 1.48 > > +++ usr.bin/sort/sort.c 29 Mar 2015 18:16:19 - > > @@ -1194,6 +1194,17 @@ main(int argc, char *argv[]) > > } > > > > if (real_outfile) { > > + struct stat sb; > > + mode_t mask; > > + > > + if (stat(real_outfile, &sb) < 0) > > + err(2, "%s", real_outfile); > > + if (access(real_outfile, W_OK) < 0) > > + err(2, "write %s", real_outfile); > > + mask = umask(0); > > + umask(mask); > > + chmod(outfile, sb.st_mode & ~mask & (S_IRWXU|S_IRWXG|S_IRWXO)); > > + > > unlink(real_outfile); > > if (rename(outfile, real_outfile) < 0) > > err(2, "%s", real_outfile);
Re: Remove useless lock around opendir/readdir
> On Mar 30, 2015, at 12:11 AM, Philip Guenther wrote: > > On Fri, Mar 27, 2015 at 2:50 AM, Carlos Martín Nieto wrote: >> A call to opendir thread-safe and the readdir calls only share the buffer >> within the same directory stream, >> which is local to this function. Therefore this lock does not buy us >> anything. > > Yep. > > Heads up on this, bcook, in case the Windows opendir/readdir emulation > isn't thread-safe (unlikely). > > > Philip Guenther > Thanks. We're currently inheriting that emulation from mingw-w64's runtime, which wraps _findfirst/_findnext. It is thread safe.
Re: the libressl wikipedia article is awful.
Thank you Joel. Platforms were updated by user Bspil. > 26. 3. 2015 v 14:05, Joel Sing : > > The current list of platforms supported by LibreSSL portable is available at: > > http://www.libressl.org/releases.html > >> I can also add list of removed operating systems in the text, if someone >> will see it valuable there. >> >> In general - I can go through the article and the check the accuracy. I’m >> not sure, if will be able to check all details. Which our documents can be >> used as my inputs? >> >> Thank you, >> Jiri >> >> -- >> Jiri Navratil, http://kouc.navratil.cz, +420 222 767 131 >> >>> 22. 3. 2015 v 2:51, Bob Beck : >>> >>> Someone who wikipedias should fix it. It runs on a lot more than >>> OpenBSD and FreeBSD. >
Re: Proposed small change for ping(8)
ping? or no interest in this? On 03/26/2015 02:34 PM, Gregory Edigarov wrote: Hello, This makes ping -v really verbose, telling about lost packets as they progress. Index: ping.8 === RCS file: /cvs/src/sbin/ping/ping.8,v retrieving revision 1.52 diff -u -p -u -r1.52 ping.8 --- ping.8 24 Mar 2014 11:11:49 - 1.52 +++ ping.8 26 Mar 2015 12:28:44 - @@ -199,7 +199,7 @@ Set the routing table to be used for out Verbose output. ICMP packets other than .Dv ECHO_REPLY -that are received are listed. +that are received are listed. Also reports lost packets as they go. .It Fl w Ar maxwait Specifies the maximum number of seconds to wait for responses after the last request has been sent. Index: ping.c === RCS file: /cvs/src/sbin/ping/ping.c,v retrieving revision 1.118 diff -u -p -u -r1.118 ping.c --- ping.c 23 Mar 2015 09:36:25 - 1.118 +++ ping.c 26 Mar 2015 12:28:44 - @@ -576,6 +576,8 @@ catcher(int signo) nmissedmax = ntransmitted - nreceived - 1; if (!(options & F_FLOOD) && (options & F_AUD_MISS)) write(STDERR_FILENO, "\a", 1); + if (!(options & F_FLOOD) && (options & F_VERBOSE)) + write(STDOUT_FILENO, "Lost packet\n",12); } errno = save_errno; }
Re: sort output file permissions
On Sun, Mar 29, 2015 at 09:50:48PM +0200, Alexander Bluhm wrote: > Hi, > > While doing make makesum in the ports framework, I realized that > the distinfo file always gets permissions 0600. It uses sort -o > in a way that the output file will overwrite the input file. In > this case, sort creates a temp file with 0600 and replaces the > output file at the end. > > I would like semantics where the permissions are preserved. So in > case of overwriting a file, use the minimum of umask and original > permissions. While there, prevent overwriting files without write > access. > > comment/ok? If you call umask(2), it's better to reset it to the old value after you're done. But it's likely better to fchmod the file while we have it still open. -Otto > > bluhm > > Index: usr.bin/sort/sort.c > === > RCS file: /data/mirror/openbsd/cvs/src/usr.bin/sort/sort.c,v > retrieving revision 1.48 > diff -u -p -r1.48 sort.c > --- usr.bin/sort/sort.c 20 Mar 2015 23:04:07 - 1.48 > +++ usr.bin/sort/sort.c 29 Mar 2015 18:16:19 - > @@ -1194,6 +1194,17 @@ main(int argc, char *argv[]) > } > > if (real_outfile) { > + struct stat sb; > + mode_t mask; > + > + if (stat(real_outfile, &sb) < 0) > + err(2, "%s", real_outfile); > + if (access(real_outfile, W_OK) < 0) > + err(2, "write %s", real_outfile); > + mask = umask(0); > + umask(mask); > + chmod(outfile, sb.st_mode & ~mask & (S_IRWXU|S_IRWXG|S_IRWXO)); > + > unlink(real_outfile); > if (rename(outfile, real_outfile) < 0) > err(2, "%s", real_outfile);