Re: grdc: show timezone when TZ is set

2022-09-17 Thread Paul Janzen
The recent change to grdc(6), to display additional information if TZ is
set, has a few issues.

1.  Time zone offset incorrectly reported in Newfoundland.

Some time zones have offsets of 30 or 45 minutes.  The displayed time
offset is currently truncated to the closest hour.  (Australia/Eucla
is a fun time zone too.)

2.  The new, additional information disappears if the window is sized too
small (wintoosmall).  There's basically room for it though...  except

3.  The TZ information is a string of unknown length, and so it doesn't
necessarily display correctly.

Yeah, I know with pledge() you can't do testing like
TZ=:/home/pjanzen/dev/usr/share/zoneinfo/testing/2022/America/Kentucky/Monticello
any more, even though that's a perfectly cromulent and functional TZ on my
system otherwise. So for the time being, probably any TZ that exists and
doesn't abort grdc is 38 bytes or shorter.  Which works.

But, if your timezone exists, it already has its name in short form
included in tm->tm_zone.  That's what I think should be
printed, even if "EDT" is way less cool than "America/Pangnirtung".  I
mean, if the point is just to be able to label clocks with nice places,
instead of the time zone it's showing, maybe it could be a different option.

Counterpoint:  some of the timezones have short names that are just the UTC
offset, which is really boring and duplicated given that we print out the
offset already.  Hey, maybe we could just print the offset...

4.  There's no indication if you type an invalid TZ--you get UTC and a
misleading label onscreen.

Timezone handling defaults to UTC if anything breaks along the chain, as
the tzset(3) man page makes clear.  That means if you misspell Antarctica
while setting your TZ=Antartica/McMurdo, you'll end up half a day off from
all your pals at McMurdo as your screen happily tells you that you're
seeing McMurdo +0 time.

There's no simple way to tell if your $TZ is valid or not (if you get back
UTC, maybe that's really what it should be!).  At least if we display
tm->tm_zone rather than $TZ, we're not misleading.



I was going to be upset that the man page for grdc(6) is way pickier on TZ
than tzset(3), but it's quite accurate given the pledge() call.  Speaking
of which, I don't expect any one else plays with timezone files, and surely
one doesn't want one's general utilities to be pwned by possible bugs in
the time-handling code exploited with custom files created outside
/usr/share/zoneinfo.  But it's still a touch irritating-should-be-fixable
that, because the pledge() has to be after initscr(), grdc has the
possibility of leaving the terminal in the wrong state when it aborts on
test TZ files.



Paul Janzen.


Index: grdc.c
===
RCS file: /cvs/src/games/grdc/grdc.c,v
retrieving revision 1.35
diff -u -p -r1.35 grdc.c
--- grdc.c  17 Sep 2022 10:32:05 -  1.35
+++ grdc.c  18 Sep 2022 05:30:04 -
@@ -41,6 +41,7 @@ volatile sig_atomic_t sigwinched = 0;
 
 int hascolor = 0;
 
+void print_tz(int, int, int);
 void getwinsize(int *, int *);
 void set(int, int);
 void standt(int);
@@ -184,11 +185,8 @@ main(int argc, char *argv[])
move(ybase, xbase + XLENGTH);
vline(ACS_VLINE, YDEPTH);
 
-   if (tz != NULL) {
-   move(ybase - 1, xbase);
-   printw("[ %s %+d ]", tz,
-   tm->tm_gmtoff / 60 / 60 );
-   }
+   if (tz)
+   print_tz(ybase - 1, xbase, wintoosmall);
 
attrset(COLOR_PAIR(2));
}
@@ -199,6 +197,8 @@ main(int argc, char *argv[])
move(0, 0);
printw("%02d:%02d:%02d", tm->tm_hour, tm->tm_min,
tm->tm_sec);
+   if (tz)
+   print_tz(1, 0, wintoosmall);
} else for (k = 0; k < 6; k++) {
if (scrol) {
for(i = 0; i < 5; i++)
@@ -282,6 +282,22 @@ set(int t, int n)
}
if (mask & m)
mask |= m;
+}
+
+void
+print_tz(int y, int x, int sml)
+{
+   int i, j;
+
+   move(y, x);
+   i = tm->tm_gmtoff / 60 / 60;
+   j = tm->tm_gmtoff / 60 - i * 60;
+   if (i < 0)
+   j = -j;
+   if (!sml)
+   printw("[ %s %+dh%02d ]", tm->tm_zone, i, j);
+   else
+   printw("[%+dh%02d]", i, j);
 }
 
 void



[patch] Fix vmd for user VMs

2022-09-17 Thread Matthew Martin
When vmd/vmctl switched to handling memory in bytes, seems a few places
for user VMs were missed. Additionally the first hunk removes the quota
hit if the VM will not be created.


diff --git config.c config.c
index 374d7de6629..425c901f36a 100644
--- config.c
+++ config.c
@@ -241,8 +241,10 @@ config_setvm(struct privsep *ps, struct vmd_vm *vm, 
uint32_t peerid, uid_t uid)
/* increase the user reference counter and check user limits */
if (vm->vm_user != NULL && user_get(vm->vm_user->usr_id.uid) != NULL) {
user_inc(vcp, vm->vm_user, 1);
-   if (user_checklimit(vm->vm_user, vcp) == -1)
+   if (user_checklimit(vm->vm_user, vcp) == -1) {
+   user_inc(vcp, vm->vm_user, 0);
return (EPERM);
+   }
}
 
/*
diff --git vmd.c vmd.c
index 2f3ac1a76f2..a7687d6ce93 100644
--- vmd.c
+++ vmd.c
@@ -1966,7 +1966,7 @@ user_inc(struct vm_create_params *vcp, struct vmd_user 
*usr, int inc)
usr->usr_maxifs += vcp->vcp_nnics * inc;
 
if (log_getverbose() > 1) {
-   (void)fmt_scaled(usr->usr_maxmem * 1024 * 1024, mem);
+   (void)fmt_scaled(usr->usr_maxmem, mem);
log_debug("%s: %c uid %d ref %d cpu %llu mem %s ifs %llu",
__func__, inc == 1 ? '+' : '-',
usr->usr_id.uid, usr->usr_refcnt,
diff --git vmd.h vmd.h
index 9010ad6eb9f..8be7db3d059 100644
--- vmd.h
+++ vmd.h
@@ -67,7 +67,7 @@
 
 /* default user instance limits */
 #define VM_DEFAULT_USER_MAXCPU 4
-#define VM_DEFAULT_USER_MAXMEM 2048
+#define VM_DEFAULT_USER_MAXMEM 2L * 1024 * 1024 * 1024 /* 2 GiB */
 #define VM_DEFAULT_USER_MAXIFS 8
 
 /* vmd -> vmctl error codes */



gpiobl(4): enable/disable screen backlight on apple silicon laptops

2022-09-17 Thread Tobias Heider
Hi,

below is a diff for a new driver to control the screen backlight on
Apple Silicon laptops via 'gpio-backlight'.  This allows disabling the
screen via wsconsctl or hotkeys once they are hooked up.
The task is needed because aplsmc(4) sleeps in aplsmc_set_pin() which
crashes when called via hotkey.

ok?

diff --git sys/arch/arm64/conf/GENERIC sys/arch/arm64/conf/GENERIC
index bc88d2c9a59..c4a80a84de6 100644
--- sys/arch/arm64/conf/GENERIC
+++ sys/arch/arm64/conf/GENERIC
@@ -138,6 +138,7 @@ amdgpu* at pci?
 drm*   at amdgpu?
 wsdisplay* at amdgpu?
 
+gpiobl*at fdt?
 gpiocharger*   at fdt?
 gpiokeys*  at fdt?
 gpioleds*  at fdt?
diff --git sys/dev/fdt/files.fdt sys/dev/fdt/files.fdt
index 6a721edfa3e..3bf3ca4f26e 100644
--- sys/dev/fdt/files.fdt
+++ sys/dev/fdt/files.fdt
@@ -601,6 +601,10 @@ device dapmic
 attach dapmic at i2c
 file   dev/fdt/dapmic.cdapmic
 
+device gpiobl
+attach gpiobl at fdt
+file   dev/fdt/gpiobl.cgpiobl
+
 device gpiocharger
 attach gpiocharger at fdt
 file   dev/fdt/gpiocharger.c   gpiocharger
diff --git sys/dev/fdt/gpiobl.c sys/dev/fdt/gpiobl.c
new file mode 100644
index 000..f9774df20f2
--- /dev/null
+++ sys/dev/fdt/gpiobl.c
@@ -0,0 +1,127 @@
+/* $OpenBSD$   */
+/*
+ * Copyright (c) 2022 Tobias Heider 
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+struct gpiobl_softc {
+   struct device   sc_dev;
+   int sc_on;
+   uint32_tsc_gpio[3];
+   struct task sc_task;
+};
+
+struct gpiobl_softc *sc_gpiobl;
+
+intgpiobl_match(struct device *, void *, void *);
+void   gpiobl_attach(struct device *, struct device *, void *);
+
+const struct cfattach gpiobl_ca = {
+   sizeof(struct gpiobl_softc), gpiobl_match, gpiobl_attach
+};
+
+struct cfdriver gpiobl_cd = {
+   NULL, "gpiobl", DV_DULL
+};
+
+void gpiobl_task(void *);
+int gpiobl_get_param(struct wsdisplay_param *);
+int gpiobl_set_param(struct wsdisplay_param *);
+
+int
+gpiobl_match(struct device *parent, void *match, void *aux)
+{
+   struct fdt_attach_args *faa = aux;
+
+   return OF_is_compatible(faa->fa_node, "gpio-backlight");
+}
+
+
+void
+gpiobl_attach(struct device *parent, struct device *self, void *aux)
+{
+   struct gpiobl_softc *sc = (struct gpiobl_softc *)self;
+   struct fdt_attach_args *faa = aux;
+   size_t len;
+
+   len = OF_getproplen(faa->fa_node, "gpios");
+   if (len <= 0)
+   return;
+   OF_getpropintarray(faa->fa_node, "gpios", sc->sc_gpio, len);
+   gpio_controller_config_pin(sc->sc_gpio, GPIO_CONFIG_OUTPUT);
+
+   sc->sc_on = OF_getpropbool(faa->fa_node, "default-on");
+   sc_gpiobl = sc;
+
+   task_set(&sc->sc_task, gpiobl_task, sc);
+   ws_get_param = gpiobl_get_param;
+   ws_set_param = gpiobl_set_param;
+   printf("\n");
+}
+
+void
+gpiobl_task(void *args)
+{
+   struct gpiobl_softc *sc = args;
+   gpio_controller_set_pin(&sc->sc_gpio[0], sc->sc_on);
+}
+
+int
+gpiobl_get_param(struct wsdisplay_param *dp)
+{
+   struct gpiobl_softc *sc = (struct gpiobl_softc *)sc_gpiobl;
+
+   switch (dp->param) {
+   case WSDISPLAYIO_PARAM_BRIGHTNESS:
+   dp->min = 0;
+   dp->max = 1;
+   dp->curval = sc->sc_on;
+   return 0;
+   default:
+   return -1;
+   }
+}
+
+int
+gpiobl_set_param(struct wsdisplay_param *dp)
+{
+   struct gpiobl_softc *sc = (struct gpiobl_softc *)sc_gpiobl;
+
+   switch (dp->param) {
+   case WSDISPLAYIO_PARAM_BRIGHTNESS:
+   if (dp->curval == sc->sc_on)
+   return 0;
+   sc->sc_on = !sc->sc_on;
+   task_add(systq, &sc->sc_task);
+   return 0;
+   default:
+   return -1;
+   }
+}



Change pru_abort() return type to the type of void and make pru_abort optional

2022-09-17 Thread Vitaliy Makkoveev
We have no interest on pru_abort() return value. Also we call it only
through soabort() which is dummy pru_abort() wrapper and has no return
value.

Also only the connection oriented sockets need to implement
(*pru_abort)() handler. Such sockets are tcp(4) and unix(4) sockets, so
we could remove existing code for all others. Also the route domain and
key management sockets have the wrong handlers because they don't
destroy passed socket, but only disconnect it.

We call soabort()/pru_abort() only to destroy the sockets linked to
the `so_q' and `so_q1' of listening socket. Such sockets are not yet
exported to the userland and have no associated file descriptor.

We have two cases when we destroy them. The first case is the soclose()
when we destroy the listening socket. The second one is the
syn_cache_get() when we destroy newly created socket in the error path
of incoming connection.

Also, I like to have the diagnostic block within pru_rcvd() and
pru_abort() wrappers. The requests handlers are optional, but they have
no "pru_ != NULL" check, so something like below could be reasonable

pru_abort(struct socket *so)
{
#ifdef DIAGNOSTIC
if (so->so_proto->pr_usrreqs->pru_abort == NULL)
panic("Inappropriate %s call for socket of proto %d type %d",
__func__, so->so_proto->pr_protocol,
so->so_proto->pr_type);
#endif

(*so->so_proto->pr_usrreqs->pru_abort)(so);
}


Index: sys/kern/uipc_usrreq.c
===
RCS file: /cvs/src/sys/kern/uipc_usrreq.c,v
retrieving revision 1.188
diff -u -p -r1.188 uipc_usrreq.c
--- sys/kern/uipc_usrreq.c  17 Sep 2022 12:40:52 -  1.188
+++ sys/kern/uipc_usrreq.c  17 Sep 2022 19:06:09 -
@@ -501,15 +501,13 @@ out:
return (error);
 }
 
-int
+void
 uipc_abort(struct socket *so)
 {
struct unpcb *unp = sotounpcb(so);
 
unp_detach(unp);
sofree(so, 0);
-
-   return (0);
 }
 
 int
Index: sys/net/pfkeyv2.c
===
RCS file: /cvs/src/sys/net/pfkeyv2.c,v
retrieving revision 1.252
diff -u -p -r1.252 pfkeyv2.c
--- sys/net/pfkeyv2.c   3 Sep 2022 22:43:38 -   1.252
+++ sys/net/pfkeyv2.c   17 Sep 2022 19:06:10 -
@@ -175,7 +175,6 @@ int pfkeyv2_disconnect(struct socket *);
 int pfkeyv2_shutdown(struct socket *);
 int pfkeyv2_send(struct socket *, struct mbuf *, struct mbuf *,
 struct mbuf *);
-int pfkeyv2_abort(struct socket *);
 int pfkeyv2_sockaddr(struct socket *, struct mbuf *);
 int pfkeyv2_peeraddr(struct socket *, struct mbuf *);
 int pfkeyv2_output(struct mbuf *, struct socket *);
@@ -209,7 +208,6 @@ const struct pr_usrreqs pfkeyv2_usrreqs 
.pru_disconnect = pfkeyv2_disconnect,
.pru_shutdown   = pfkeyv2_shutdown,
.pru_send   = pfkeyv2_send,
-   .pru_abort  = pfkeyv2_abort,
.pru_sockaddr   = pfkeyv2_sockaddr,
.pru_peeraddr   = pfkeyv2_peeraddr,
 };
@@ -380,13 +378,6 @@ out:
m_freem(m);
 
return (error);
-}
-
-int
-pfkeyv2_abort(struct socket *so)
-{
-   soisdisconnected(so);
-   return (0);
 }
 
 int
Index: sys/net/rtsock.c
===
RCS file: /cvs/src/sys/net/rtsock.c,v
retrieving revision 1.356
diff -u -p -r1.356 rtsock.c
--- sys/net/rtsock.c13 Sep 2022 09:05:47 -  1.356
+++ sys/net/rtsock.c17 Sep 2022 19:06:10 -
@@ -118,7 +118,6 @@ int route_shutdown(struct socket *);
 void   route_rcvd(struct socket *);
 introute_send(struct socket *, struct mbuf *, struct mbuf *,
struct mbuf *);
-introute_abort(struct socket *);
 introute_sockaddr(struct socket *, struct mbuf *);
 introute_peeraddr(struct socket *, struct mbuf *);
 void   route_input(struct mbuf *m0, struct socket *, sa_family_t);
@@ -345,13 +344,6 @@ out:
 }
 
 int
-route_abort(struct socket *so)
-{
-   soisdisconnected(so);
-   return (0);
-}
-
-int
 route_sockaddr(struct socket *so, struct mbuf *nam)
 {
return (EINVAL);
@@ -2406,7 +2398,6 @@ const struct pr_usrreqs route_usrreqs = 
.pru_shutdown   = route_shutdown,
.pru_rcvd   = route_rcvd,
.pru_send   = route_send,
-   .pru_abort  = route_abort,
.pru_sockaddr   = route_sockaddr,
.pru_peeraddr   = route_peeraddr,
 };
Index: sys/netinet/ip_divert.c
===
RCS file: /cvs/src/sys/netinet/ip_divert.c,v
retrieving revision 1.87
diff -u -p -r1.87 ip_divert.c
--- sys/netinet/ip_divert.c 5 Sep 2022 14:56:09 -   1.87
+++ sys/netinet/ip_divert.c 17 Sep 2022 19:06:10 -
@@ -70,7 +70,6 @@ const struct pr_usrreqs divert_usrreqs =
.pru_bind   = divert_bind,
.pru_shutdown   = divert_shutdown,
.pru_send   = divert_send,
-   .pru_abort  = divert_abort,
.pru_control= in_c

memory barrier in counters_zero

2022-09-17 Thread Alexander Bluhm
Hi,

Inspired by Taylor's talk at EuroBSDCon I think a memory barrier
in counters_zero() is missing.  Reading uses two consumer barriers,
so writing should also have two.

Following code would have no barrier between writing generation
number and writing counters.

counters_leave();
counters_zero();

counters_leave() writes to generation number at the end, so
counters_zero() needs a barrier at the start.

ok?

bluhm

Index: kern/subr_percpu.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/kern/subr_percpu.c,v
retrieving revision 1.9
diff -u -p -r1.9 subr_percpu.c
--- kern/subr_percpu.c  10 Mar 2021 10:21:47 -  1.9
+++ kern/subr_percpu.c  17 Sep 2022 14:17:34 -
@@ -213,6 +213,7 @@ counters_zero(struct cpumem *cm, unsigne
unsigned int i;
 
counters = cpumem_first(&cmi, cm);
+   membar_producer();
do {
for (i = 0; i < n; i++)
counters[i] = 0;



Re: iostat.8 wording

2022-09-17 Thread Jason McIntyre
On Thu, Sep 15, 2022 at 04:43:19PM +0100, Jason McIntyre wrote:
> On Thu, Sep 15, 2022 at 04:41:57PM +0200, Jan Stary wrote:
> > I believe this reads a little bit better.
> > 
> > Jan
> > 
> 
> i agree, but i'd leave those commas in.
> jmc
> 

i went ahead and committed your diff, with commas.
jmc



ldomctl: console: add -E escape_char

2022-09-17 Thread Klemens Nanni
In my case, accessing guest domain consoles always happens through SSH,
ILOM, or conserver, so there's usually one more level to escape.

Changing cu(1)'s escape character makes things easier to type and harder
to mess up (~. instead of ~~. kills SSH/whatever instead of the guest
console).

Using 'cu -l ttyV* -E@' is not an option as 'ldomctl console -E@ foo'
takes care of the name-to-tty mapping, which may change with ldom.conf
changes.

'ldomctl start|panic -c foo' also drop into the console but seem like
briefly used shortcuts (watch boot log, debug a specific thing) whereas
'ldomctl console foo' is usually used for long running console access.

Feedback? OK? (for after release)

diff --git a/usr.sbin/ldomctl/ldomctl.8 b/usr.sbin/ldomctl/ldomctl.8
index 6d4b6dee6b5..776a2270809 100644
--- a/usr.sbin/ldomctl/ldomctl.8
+++ b/usr.sbin/ldomctl/ldomctl.8
@@ -44,10 +44,16 @@ in bytes.
 can be specified with a human-readable scale, using the format described in
 .Xr scan_scaled 3 ,
 e.g. 512M.
-.It Cm console Ar domain
+.It Cm console Oo Fl E Ar escape_char Oc Ar domain
 Using
 .Xr cu 1
 connect to the console of the guest domain.
+.Bl -tag -width 3n
+.It Fl E Ar escape_char
+Specify an escape character as per
+.Xr cu 1
+.Fl E .
+.El
 .It Cm delete Ar configuration
 Delete the specified configuration from non-volatile storage.
 .It Cm download Ar directory
diff --git a/usr.sbin/ldomctl/ldomctl.c b/usr.sbin/ldomctl/ldomctl.c
index e48a560f7db..906ab414488 100644
--- a/usr.sbin/ldomctl/ldomctl.c
+++ b/usr.sbin/ldomctl/ldomctl.c
@@ -131,7 +131,8 @@ usage(void)
"\t%1$s init-system [-n] file\n"
"\t%1$s create-vdisk -s size file\n"
"\t%1$s panic|start [-c] domain\n"
-   "\t%1$s console|status|stop [domain]\n",
+   "\t%1$s status|stop [domain]\n"
+   "\t%1$s console [-E escape_char] domain\n",
getprogname());
 
exit(EXIT_FAILURE);
@@ -403,7 +404,7 @@ download(int argc, char **argv)
 }
 
 void
-console_exec(uint64_t gid)
+console_exec(uint64_t gid, const char *escape_char)
 {
struct guest *guest;
char console_str[8];
@@ -419,6 +420,7 @@ console_exec(uint64_t gid)
 
closefrom(STDERR_FILENO + 1);
execl(LDOMCTL_CU, LDOMCTL_CU, "-r", "-l", console_str,
+   "-E", (escape_char != NULL) ? escape_char : "~",
(char *)NULL);
err(1, "failed to open console");
}
@@ -468,7 +470,7 @@ guest_start(int argc, char **argv)
err(1, "read");
 
if (console)
-   console_exec(gid);
+   console_exec(gid, NULL);
 }
 
 void
@@ -543,7 +545,7 @@ guest_panic(int argc, char **argv)
err(1, "read");
 
if (console)
-   console_exec(gid);
+   console_exec(gid, NULL);
 }
 
 void
@@ -680,15 +682,29 @@ void
 guest_console(int argc, char **argv)
 {
uint64_t gid;
+   int ch;
+   const char *Earg = NULL;
 
-   if (argc != 2)
+   while ((ch = getopt(argc, argv, "E:")) != -1) {
+   switch (ch) {
+   case 'E':
+   Earg = optarg;
+   break;
+   default:
+   usage();
+   }
+   }
+   argc -= optind;
+   argv += optind;
+
+   if (argc != 1)
usage();
 
hv_config();
 
-   gid = find_guest(argv[1]);
+   gid = find_guest(argv[0]);
 
-   console_exec(gid);
+   console_exec(gid, Earg);
 }
 
 void



Re: grdc: show timezone when TZ is set

2022-09-17 Thread Klemens Nanni
On Sat, Sep 17, 2022 at 12:13:16PM +0200, Florian Obser wrote:
> Good catch, I have adapted the text from date(1) for this, I think it
> flows nicer and dropped the example.
> 
> Update diff with a local variable for getenv(3) and pulled the call up,
> it's not going to change during runtime.
> 
> OK?

OK kn



Re: grdc: show timezone when TZ is set

2022-09-17 Thread Florian Obser
On 2022-09-17 08:42 UTC, Klemens Nanni  wrote:
> On Sat, Sep 17, 2022 at 09:40:27AM +0200, Florian Obser wrote:
>> On 2021-10-24 03:06 +02, James Russell Stickney  wrote:
>> > I recently found myself wanting to moniter local time from a number of 
>> > locations around the world.
>> > Setting the TZ environment variable on grdc did a wonderfull job at this.
>> > At which point, I wanted to know which clock was showing what time.
>> > This lead to the following patch.
>> >
>> > If curious as to how this looked, it was sort of like the image below.
>> > https://nl1.outband.net/image/grdc_desktop_example.png
>> >
>> 
>> I recently found a use for this as well and remembered this diff. One
>> long line re-wrapped.
>> 
>> OK?
>
> Reads fine, but I don't use this "game".
>
>> 
>> (Or commit it with OK florian)
>> 
>> diff --git grdc.6 grdc.6
>> index 16c1fb5cd3d..69febddc9a2 100644
>> --- grdc.6
>> +++ grdc.6
>> @@ -30,6 +30,13 @@ skips seconds.
>>  Pressing the
>>  .Sq q
>>  key exits the program.
>> +.Sh ENVIRONMENT
>> +.Bl -tag -width "daemon_timeout"
>> +.It Ev TZ
>> +Time shown will be from zone as found under /usr/share/zonefile.
>
> This should be
> .Pa /usr/share/zonefile .

Good catch, I have adapted the text from date(1) for this, I think it
flows nicer and dropped the example.

Update diff with a local variable for getenv(3) and pulled the call up,
it's not going to change during runtime.

OK?

diff --git grdc.6 grdc.6
index 16c1fb5cd3d..a7258488e5a 100644
--- grdc.6
+++ grdc.6
@@ -30,6 +30,15 @@ skips seconds.
 Pressing the
 .Sq q
 key exits the program.
+.Sh ENVIRONMENT
+.Bl -tag -width Ds
+.It Ev TZ
+The time zone to use for displaying the time.
+It is specified as a pathname relative to
+.Pa /usr/share/zoneinfo .
+If this variable is not set, the time zone is determined based on
+.Pa /etc/localtime .
+.El
 .Sh AUTHORS
 .An -nosplit
 .An Amos Shapir ,
diff --git grdc.c grdc.c
index 287fb14e95f..94f80a865c0 100644
--- grdc.c
+++ grdc.c
@@ -78,6 +78,9 @@ main(int argc, char *argv[])
int xbase;
int ybase;
int wintoosmall;
+   char *tz;
+
+   tz = getenv("TZ");
 
scrol = wintoosmall = 0;
while ((i = getopt(argc, argv, "sh")) != -1) {
@@ -139,6 +142,16 @@ main(int argc, char *argv[])
alarm(n);
}
do {
+   mask = 0;
+   tm = localtime(&now.tv_sec);
+   set(tm->tm_sec % 10, 0);
+   set(tm->tm_sec / 10, 4);
+   set(tm->tm_min % 10, 10);
+   set(tm->tm_min / 10, 14);
+   set(tm->tm_hour % 10, 20);
+   set(tm->tm_hour / 10, 24);
+   set(10, 7);
+   set(10, 17);
if (sigwinched) {
sigwinched = 0;
wintoosmall = 0;
@@ -171,21 +184,17 @@ main(int argc, char *argv[])
move(ybase, xbase + XLENGTH);
vline(ACS_VLINE, YDEPTH);
 
+   if (tz != NULL) {
+   move(ybase - 1, xbase);
+   printw("[ %s %+d ]", tz,
+   tm->tm_gmtoff / 60 / 60 );
+   }
+
attrset(COLOR_PAIR(2));
}
for (k = 0; k < 6; k++)
old[k] = 0;
}
-   mask = 0;
-   tm = localtime(&now.tv_sec);
-   set(tm->tm_sec % 10, 0);
-   set(tm->tm_sec / 10, 4);
-   set(tm->tm_min % 10, 10);
-   set(tm->tm_min / 10, 14);
-   set(tm->tm_hour % 10, 20);
-   set(tm->tm_hour / 10, 24);
-   set(10, 7);
-   set(10, 17);
if (wintoosmall) {
move(0, 0);
printw("%02d:%02d:%02d", tm->tm_hour, tm->tm_min,





-- 
I'm not entirely sure you are real.



ssl.3: link to SSL_read_early_data(3)

2022-09-17 Thread Klemens Nanni
This page now exists.

OK?

Index: ssl.3
===
RCS file: /cvs/src/lib/libssl/man/ssl.3,v
retrieving revision 1.21
diff -u -p -r1.21 ssl.3
--- ssl.3   13 Jul 2022 22:05:53 -  1.21
+++ ssl.3   17 Sep 2022 09:10:19 -
@@ -319,7 +319,7 @@ To transmit data:
 .Xr SSL_connect 3 ,
 .Xr SSL_do_handshake 3 ,
 .Xr SSL_read 3 ,
-.\" XXX enable after the 6.8 release: Xr SSL_read_early_data 3 ,
+.Xr SSL_read_early_data 3 ,
 .Xr SSL_renegotiate 3 ,
 .Xr SSL_shutdown 3 ,
 .Xr SSL_write 3



Re: grdc: show timezone when TZ is set

2022-09-17 Thread Klemens Nanni
On Sat, Sep 17, 2022 at 09:40:27AM +0200, Florian Obser wrote:
> On 2021-10-24 03:06 +02, James Russell Stickney  wrote:
> > I recently found myself wanting to moniter local time from a number of 
> > locations around the world.
> > Setting the TZ environment variable on grdc did a wonderfull job at this.
> > At which point, I wanted to know which clock was showing what time.
> > This lead to the following patch.
> >
> > If curious as to how this looked, it was sort of like the image below.
> > https://nl1.outband.net/image/grdc_desktop_example.png
> >
> 
> I recently found a use for this as well and remembered this diff. One
> long line re-wrapped.
> 
> OK?

Reads fine, but I don't use this "game".

> 
> (Or commit it with OK florian)
> 
> diff --git grdc.6 grdc.6
> index 16c1fb5cd3d..69febddc9a2 100644
> --- grdc.6
> +++ grdc.6
> @@ -30,6 +30,13 @@ skips seconds.
>  Pressing the
>  .Sq q
>  key exits the program.
> +.Sh ENVIRONMENT
> +.Bl -tag -width "daemon_timeout"
> +.It Ev TZ
> +Time shown will be from zone as found under /usr/share/zonefile.

This should be
.Pa /usr/share/zonefile .

> +For Example:
> +TZ=Asia/Tokyo grdc
> +.El
>  .Sh AUTHORS
>  .An -nosplit
>  .An Amos Shapir ,
> diff --git grdc.c grdc.c
> index 287fb14e95f..f8521a5029d 100644
> --- grdc.c
> +++ grdc.c
> @@ -139,6 +139,16 @@ main(int argc, char *argv[])
>   alarm(n);
>   }
>   do {
> + mask = 0;
> + tm = localtime(&now.tv_sec);
> + set(tm->tm_sec % 10, 0);
> + set(tm->tm_sec / 10, 4);
> + set(tm->tm_min % 10, 10);
> + set(tm->tm_min / 10, 14);
> + set(tm->tm_hour % 10, 20);
> + set(tm->tm_hour / 10, 24);
> + set(10, 7);
> + set(10, 17);
>   if (sigwinched) {
>   sigwinched = 0;
>   wintoosmall = 0;
> @@ -171,21 +181,17 @@ main(int argc, char *argv[])
>   move(ybase, xbase + XLENGTH);
>   vline(ACS_VLINE, YDEPTH);
>  
> + if (getenv("TZ") ) {

You could assign the return value here...

> + move(ybase - 1, xbase);
> + printw("[ %s %+d ]", getenv("TZ"),

... and reuse it here.

> + tm->tm_gmtoff / 60 / 60 );
> + }
> +
>   attrset(COLOR_PAIR(2));
>   }
>   for (k = 0; k < 6; k++)
>   old[k] = 0;
>   }
> - mask = 0;
> - tm = localtime(&now.tv_sec);
> - set(tm->tm_sec % 10, 0);
> - set(tm->tm_sec / 10, 4);
> - set(tm->tm_min % 10, 10);
> - set(tm->tm_min / 10, 14);
> - set(tm->tm_hour % 10, 20);
> - set(tm->tm_hour / 10, 24);
> - set(10, 7);
> - set(10, 17);
>   if (wintoosmall) {
>   move(0, 0);
>   printw("%02d:%02d:%02d", tm->tm_hour, tm->tm_min,
> 
> 
> -- 
> I'm not entirely sure you are real.
> 



Re: grdc: show timezone when TZ is set

2022-09-17 Thread Florian Obser
On 2021-10-24 03:06 +02, James Russell Stickney  wrote:
> I recently found myself wanting to moniter local time from a number of 
> locations around the world.
> Setting the TZ environment variable on grdc did a wonderfull job at this.
> At which point, I wanted to know which clock was showing what time.
> This lead to the following patch.
>
> If curious as to how this looked, it was sort of like the image below.
> https://nl1.outband.net/image/grdc_desktop_example.png
>

I recently found a use for this as well and remembered this diff. One
long line re-wrapped.

OK?

(Or commit it with OK florian)

diff --git grdc.6 grdc.6
index 16c1fb5cd3d..69febddc9a2 100644
--- grdc.6
+++ grdc.6
@@ -30,6 +30,13 @@ skips seconds.
 Pressing the
 .Sq q
 key exits the program.
+.Sh ENVIRONMENT
+.Bl -tag -width "daemon_timeout"
+.It Ev TZ
+Time shown will be from zone as found under /usr/share/zonefile.
+For Example:
+TZ=Asia/Tokyo grdc
+.El
 .Sh AUTHORS
 .An -nosplit
 .An Amos Shapir ,
diff --git grdc.c grdc.c
index 287fb14e95f..f8521a5029d 100644
--- grdc.c
+++ grdc.c
@@ -139,6 +139,16 @@ main(int argc, char *argv[])
alarm(n);
}
do {
+   mask = 0;
+   tm = localtime(&now.tv_sec);
+   set(tm->tm_sec % 10, 0);
+   set(tm->tm_sec / 10, 4);
+   set(tm->tm_min % 10, 10);
+   set(tm->tm_min / 10, 14);
+   set(tm->tm_hour % 10, 20);
+   set(tm->tm_hour / 10, 24);
+   set(10, 7);
+   set(10, 17);
if (sigwinched) {
sigwinched = 0;
wintoosmall = 0;
@@ -171,21 +181,17 @@ main(int argc, char *argv[])
move(ybase, xbase + XLENGTH);
vline(ACS_VLINE, YDEPTH);
 
+   if (getenv("TZ") ) {
+   move(ybase - 1, xbase);
+   printw("[ %s %+d ]", getenv("TZ"),
+   tm->tm_gmtoff / 60 / 60 );
+   }
+
attrset(COLOR_PAIR(2));
}
for (k = 0; k < 6; k++)
old[k] = 0;
}
-   mask = 0;
-   tm = localtime(&now.tv_sec);
-   set(tm->tm_sec % 10, 0);
-   set(tm->tm_sec / 10, 4);
-   set(tm->tm_min % 10, 10);
-   set(tm->tm_min / 10, 14);
-   set(tm->tm_hour % 10, 20);
-   set(tm->tm_hour / 10, 24);
-   set(10, 7);
-   set(10, 17);
if (wintoosmall) {
move(0, 0);
printw("%02d:%02d:%02d", tm->tm_hour, tm->tm_min,


-- 
I'm not entirely sure you are real.