Re: Add -R alias to -r for scp(1)

2020-02-09 Thread Jan Stary
On Jan 02 11:30:35, es...@nerim.net wrote:
> Once in three times, I type scp -R and go "oh fuck" when it doesn't work.

Same here with 'ssh -p' vs 'scp -P'.



Re: [PATCH] Fixing an uninitialized variable that can lead to #GP.

2020-02-09 Thread Jonathan Gray
On Sun, Feb 09, 2020 at 06:17:47PM -0800, Anthony Steinhauser wrote:
> In the current implementation of the TAA mitigation if the cpuid_level
> is 6 and it's an Intel CPU, the sefflags_edx variable is used without
> being initialized. If the SEFF0EDX_ARCH_CAP bit is accidentally flipped
> in it, the rdmsr on the unimplemented MSR_ARCH_CAPABILITIES index leads
> to a #GP fault.
> 
> This change initializes the sefflags_edx variable to 0 which is
> consistent with the MSR_ARCH_CAPABILITIES being unavailable.

Thanks for the report.  Committed a different fix:

Index: i386/i386/cpu.c
===
RCS file: /cvs/src/sys/arch/i386/i386/cpu.c,v
retrieving revision 1.98
diff -u -p -r1.98 cpu.c
--- i386/i386/cpu.c 20 Dec 2019 07:55:30 -  1.98
+++ i386/i386/cpu.c 10 Feb 2020 03:04:02 -
@@ -476,8 +476,10 @@ cpu_tsx_disable(struct cpu_info *ci)
uint32_t dummy, sefflags_edx;
 
/* this runs before identifycpu() populates ci_feature_sefflags_edx */
-   if (cpuid_level >= 0x07)
-   CPUID_LEAF(0x7, 0, dummy, dummy, dummy, sefflags_edx);
+   if (cpuid_level < 0x07)
+   return;
+   CPUID_LEAF(0x7, 0, dummy, dummy, dummy, sefflags_edx);
+
if (strcmp(cpu_vendor, "GenuineIntel") == 0 &&
(sefflags_edx & SEFF0EDX_ARCH_CAP)) {
msr = rdmsr(MSR_ARCH_CAPABILITIES);
Index: amd64/amd64/cpu.c
===
RCS file: /cvs/src/sys/arch/amd64/amd64/cpu.c,v
retrieving revision 1.143
diff -u -p -r1.143 cpu.c
--- amd64/amd64/cpu.c   20 Dec 2019 07:49:31 -  1.143
+++ amd64/amd64/cpu.c   10 Feb 2020 03:03:51 -
@@ -1167,8 +1167,10 @@ cpu_tsx_disable(struct cpu_info *ci)
uint32_t dummy, sefflags_edx;
 
/* this runs before identifycpu() populates ci_feature_sefflags_edx */
-   if (cpuid_level >= 0x07)
-   CPUID_LEAF(0x7, 0, dummy, dummy, dummy, sefflags_edx);
+   if (cpuid_level < 0x07)
+   return;
+   CPUID_LEAF(0x7, 0, dummy, dummy, dummy, sefflags_edx);
+
if (strcmp(cpu_vendor, "GenuineIntel") == 0 &&
(sefflags_edx & SEFF0EDX_ARCH_CAP)) {
msr = rdmsr(MSR_ARCH_CAPABILITIES);



Re: [PATCH] Fixing an uninitialized variable that can lead to #GP.

2020-02-09 Thread Mike Larkin
On Sun, Feb 09, 2020 at 06:17:47PM -0800, Anthony Steinhauser wrote:
> In the current implementation of the TAA mitigation if the cpuid_level
> is 6 and it's an Intel CPU, the sefflags_edx variable is used without
> being initialized. If the SEFF0EDX_ARCH_CAP bit is accidentally flipped
> in it, the rdmsr on the unimplemented MSR_ARCH_CAPABILITIES index leads
> to a #GP fault.
> 
> This change initializes the sefflags_edx variable to 0 which is
> consistent with the MSR_ARCH_CAPABILITIES being unavailable.
> ---
>  sys/arch/amd64/amd64/cpu.c | 2 +-
>  sys/arch/i386/i386/cpu.c   | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/sys/arch/amd64/amd64/cpu.c b/sys/arch/amd64/amd64/cpu.c
> index 48ab6b5e7f3..f9beff0d5e3 100644
> --- a/sys/arch/amd64/amd64/cpu.c
> +++ b/sys/arch/amd64/amd64/cpu.c
> @@ -1164,7 +1164,7 @@ void
>  cpu_tsx_disable(struct cpu_info *ci)
>  {
>   uint64_t msr;
> - uint32_t dummy, sefflags_edx;
> + uint32_t dummy, sefflags_edx = 0;
>  
>   /* this runs before identifycpu() populates ci_feature_sefflags_edx */
>   if (cpuid_level >= 0x07)
> diff --git a/sys/arch/i386/i386/cpu.c b/sys/arch/i386/i386/cpu.c
> index b31a431c594..76f1b65bede 100644
> --- a/sys/arch/i386/i386/cpu.c
> +++ b/sys/arch/i386/i386/cpu.c
> @@ -473,7 +473,7 @@ void
>  cpu_tsx_disable(struct cpu_info *ci)
>  {
>   uint64_t msr;
> - uint32_t dummy, sefflags_edx;
> + uint32_t dummy, sefflags_edx = 0;
>  
>   /* this runs before identifycpu() populates ci_feature_sefflags_edx */
>   if (cpuid_level >= 0x07)
> -- 
> 2.25.0.341.g760bfbb309-goog
> 

Probably safer to use rdmsr_safe for this sort of thing also.

-ml



[PATCH] Fixing an uninitialized variable that can lead to #GP.

2020-02-09 Thread Anthony Steinhauser
In the current implementation of the TAA mitigation if the cpuid_level
is 6 and it's an Intel CPU, the sefflags_edx variable is used without
being initialized. If the SEFF0EDX_ARCH_CAP bit is accidentally flipped
in it, the rdmsr on the unimplemented MSR_ARCH_CAPABILITIES index leads
to a #GP fault.

This change initializes the sefflags_edx variable to 0 which is
consistent with the MSR_ARCH_CAPABILITIES being unavailable.
---
 sys/arch/amd64/amd64/cpu.c | 2 +-
 sys/arch/i386/i386/cpu.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/arch/amd64/amd64/cpu.c b/sys/arch/amd64/amd64/cpu.c
index 48ab6b5e7f3..f9beff0d5e3 100644
--- a/sys/arch/amd64/amd64/cpu.c
+++ b/sys/arch/amd64/amd64/cpu.c
@@ -1164,7 +1164,7 @@ void
 cpu_tsx_disable(struct cpu_info *ci)
 {
uint64_t msr;
-   uint32_t dummy, sefflags_edx;
+   uint32_t dummy, sefflags_edx = 0;
 
/* this runs before identifycpu() populates ci_feature_sefflags_edx */
if (cpuid_level >= 0x07)
diff --git a/sys/arch/i386/i386/cpu.c b/sys/arch/i386/i386/cpu.c
index b31a431c594..76f1b65bede 100644
--- a/sys/arch/i386/i386/cpu.c
+++ b/sys/arch/i386/i386/cpu.c
@@ -473,7 +473,7 @@ void
 cpu_tsx_disable(struct cpu_info *ci)
 {
uint64_t msr;
-   uint32_t dummy, sefflags_edx;
+   uint32_t dummy, sefflags_edx = 0;
 
/* this runs before identifycpu() populates ci_feature_sefflags_edx */
if (cpuid_level >= 0x07)
-- 
2.25.0.341.g760bfbb309-goog



Re: Add mprotect_ept ioctl to vmm(4)

2020-02-09 Thread Adam Steen
On Fri, Feb 07, 2020 at 04:38:16PM -0800, Mike Larkin wrote:
> 
> On Fri, Feb 07, 2020 at 01:25:38PM -0800, Mike Larkin wrote:
> > On Fri, Feb 07, 2020 at 04:20:16AM +, Adam Steen wrote:
> > > Hi
> > >
> > > Please see the attached patch to add an 'IOCTL handler to sets the access
> > > protections of the ept'
> > >
> > > vmd(8) does not make use of this change, but solo5, which uses vmm(4) as
> > > a backend hypervisor. The code calling 'VMM_IOC_MPROTECT_EPT' is
> > > available here 
> > > https://github.com/Solo5/solo5/compare/master...adamsteen:wnox
> > >
> > > there are changes to vmd too, but this is just to ensure completeness,
> > > if mprotect ept is called in the future, we would want the vm to be
> > > stopped if we get a protection fault.
> > >
> > > I was unsure what todo if called with execute only permissions on a cpu 
> > > that
> > > does not support it. I went with add read permissions and logging the
> > > fact, instead of returning EINVAL.
> > >
> > > Cheers
> > > Adam
> > >
> >
> > I have been giving Adam feedback on this diff for a while. There are a few
> > minor comments below, but I think this is ok if someone wants to commit it 
> > after
> > the fixes below are incorporated.
> >
> > -ml
> >
> 
> See updated comment below.
> 
> -ml
>

Please see the updated patch below and further comments.




> > > + /* No W^X permissions */
> > > + if ((prot & PROT_MASK) != prot &&
> > > + (prot & (PROT_WRITE | PROT_EXEC)) == (PROT_WRITE | PROT_EXEC)) {
> > > + DPRINTF("%s: No W^X permissions\n", __func__);
> > > + return (EINVAL);
> > > + }
> >
> > I would probably reword this to "W+X permission requested".
> >

updated.



> > > + /* No execute only on EPT CPUs that don't have that capability */
> > > + if (vmm_softc->mode == VMM_MODE_EPT) {
> > > + msr = rdmsr(IA32_VMX_EPT_VPID_CAP);
> > > + if (prot == PROT_EXEC &&
> > > + (msr & IA32_EPT_VPID_CAP_XO_TRANSLATIONS)) {
> > > + printf("%s: Execute only permissions unsupported,"
> > > +" adding read permission\n", __func__);
> > > + /* XXX should this return (EINVAL) */
> > > +
> > > + prot |= PROT_READ;
> > > + }
> > > + }

the (msr & IA32_EPT_VPID_CAP_XO_TRANSLATIONS) check should be
(msr & IA32_EPT_VPID_CAP_XO_TRANSLATIONS) == 0, ie only add read
permissions if the cpu does NOT support execute only.

changed the printf to DPRINTF



> > > +/*
> > > + * vmx_mprotect_ept
> > > + *
> > > + * apply the ept protections to the requested pages, faulting the page if
> >
> > "faulting in"
> >
> > > + * required.
> > > + */
> > > +int
> > > +vmx_mprotect_ept(vm_map_t vm_map, paddr_t sgpa, paddr_t egpa, int prot)

updated.



> > > + /*
> > > +  * l3idx should always be < MAXDSIZ/1GB because we don't support more
> > > +  * than MAXDSIZ guest phys mem.
> > > +  */
> > > + if (l3idx >= MAXDSIZ / ((paddr_t)1024*1024*1024))
> >
> > Spaces around *s
> >
> > > + return NULL;
> > > +

updated.



? div
Index: sys/arch/amd64/amd64/vmm.c
===
RCS file: /cvs/src/sys/arch/amd64/amd64/vmm.c,v
retrieving revision 1.258
diff -u -p -u -p -r1.258 vmm.c
--- sys/arch/amd64/amd64/vmm.c  31 Jan 2020 01:51:27 -  1.258
+++ sys/arch/amd64/amd64/vmm.c  10 Feb 2020 00:45:20 -
@@ -124,6 +124,7 @@ int vm_get_info(struct vm_info_params *)
 int vm_resetcpu(struct vm_resetcpu_params *);
 int vm_intr_pending(struct vm_intr_params *);
 int vm_rwregs(struct vm_rwregs_params *, int);
+int vm_mprotect_ept(struct vm_mprotect_ept_params *);
 int vm_rwvmparams(struct vm_rwvmparams_params *, int);
 int vm_find(uint32_t, struct vm **);
 int vcpu_readregs_vmx(struct vcpu *, uint64_t, struct vcpu_reg_state *);
@@ -186,6 +187,8 @@ int svm_fault_page(struct vcpu *, paddr_
 int vmx_fault_page(struct vcpu *, paddr_t);
 int vmx_handle_np_fault(struct vcpu *);
 int svm_handle_np_fault(struct vcpu *);
+int vmx_mprotect_ept(vm_map_t, paddr_t, paddr_t, int);
+pt_entry_t *vmx_pmap_find_pte_ept(pmap_t, paddr_t);
 int vmm_alloc_vpid(uint16_t *);
 void vmm_free_vpid(uint16_t);
 const char *vcpu_state_decode(u_int);
@@ -493,6 +496,9 @@ vmmioctl(dev_t dev, u_long cmd, caddr_t 
case VMM_IOC_WRITEREGS:
ret = vm_rwregs((struct vm_rwregs_params *)data, 1);
break;
+   case VMM_IOC_MPROTECT_EPT:
+   ret = vm_mprotect_ept((struct vm_mprotect_ept_params *)data);
+   break;
case VMM_IOC_READVMPARAMS:
ret = vm_rwvmparams((struct vm_rwvmparams_params *)data, 0);
break;
@@ -531,6 +537,7 @@ pledge_ioctl_vmm(struct proc *p, long co
case VMM_IOC_INTR:
case VMM_IOC_READREGS:
case VMM_IOC_WRITEREGS:
+   case VMM_IOC_MPROTECT_EPT:
case VMM_IOC_READVMPARAMS:
case VMM_IOC_WRITEVMPARAMS:
return (0);
@@ -806,6 +813,287 @@ vm_rwregs(struct vm_rwregs_params 

Re: remove needless #ifdef

2020-02-09 Thread YASUOKA Masahiko
Hi,

On Sun, 09 Feb 2020 19:28:50 +0100
Jeremie Courreges-Anglas  wrote:
> On Sun, Feb 09 2020, Jan Stary  wrote:
>> Currently, sys/net/pipex_local.h asks #ifdef __OpenBSD__
>> and if so, defines "Static" to be nothing, to use it later.
>> That can go away, right?
> 
> I believe that's something the IIJ folks want to keep, cc'ing Yasuoka.

I once thought keeping "static" is better for maintaining the code,
but now I don't think it's necessary.  So it's ok to remove them.


>>  Jan
>>
>>
>> Index: sys/net/pipex_local.h
>> ===
>> RCS file: /cvs/src/sys/net/pipex_local.h,v
>> retrieving revision 1.30
>> diff -u -p -r1.30 pipex_local.h
>> --- sys/net/pipex_local.h31 Jan 2019 18:01:14 -  1.30
>> +++ sys/net/pipex_local.h9 Feb 2020 15:26:51 -
>> @@ -26,12 +26,6 @@
>>   * SUCH DAMAGE.
>>   */
>>  
>> -#ifdef __OpenBSD__
>> -#define Static
>> -#else
>> -#define Static static
>> -#endif
>> -
>>  #define PIPEX_PPTP  1
>>  #define PIPEX_L2TP  1
>>  #define PIPEX_PPPOE 1
>> @@ -372,59 +366,56 @@ extern struct pipex_hash_head  pipex_id_h
>>  #define PIPEX_TCP_OPTLEN 40
>>  #define PIPEX_L2TP_MINLEN   8
>>  
>> -/*
>> - * static function prototypes
>> - */
>> -Static void  pipex_iface_start (struct pipex_iface_context 
>> *);
>> -Static void  pipex_iface_stop (struct pipex_iface_context 
>> *);
>> -Static int   pipex_add_session (struct pipex_session_req *, 
>> struct pipex_iface_context *);
>> -Static int   pipex_close_session (struct 
>> pipex_session_close_req *);
>> -Static int   pipex_config_session (struct 
>> pipex_session_config_req *);
>> -Static int   pipex_get_stat (struct pipex_session_stat_req 
>> *);
>> -Static int   pipex_get_closed (struct 
>> pipex_session_list_req *);
>> -Static int   pipex_destroy_session (struct pipex_session *);
>> -Static struct pipex_session  *pipex_lookup_by_ip_address (struct in_addr);
>> -Static struct pipex_session  *pipex_lookup_by_session_id (int, int);
>> -Static void  pipex_ip_output (struct mbuf *, struct 
>> pipex_session *);
>> -Static void  pipex_ppp_output (struct mbuf *, struct 
>> pipex_session *, int);
>> -Static int   pipex_ppp_proto (struct mbuf *, struct 
>> pipex_session *, int, int *);
>> -Static void  pipex_ppp_input (struct mbuf *, struct 
>> pipex_session *, int);
>> -Static void  pipex_ip_input (struct mbuf *, struct 
>> pipex_session *);
>> +void  pipex_iface_start (struct pipex_iface_context *);
>> +void  pipex_iface_stop (struct pipex_iface_context *);
>> +int   pipex_add_session (struct pipex_session_req *, struct 
>> pipex_iface_context *);
>> +int   pipex_close_session (struct pipex_session_close_req 
>> *);
>> +int   pipex_config_session (struct pipex_session_config_req 
>> *);
>> +int   pipex_get_stat (struct pipex_session_stat_req *);
>> +int   pipex_get_closed (struct pipex_session_list_req *);
>> +int   pipex_destroy_session (struct pipex_session *);
>> +struct pipex_session  *pipex_lookup_by_ip_address (struct in_addr);
>> +struct pipex_session  *pipex_lookup_by_session_id (int, int);
>> +void  pipex_ip_output (struct mbuf *, struct pipex_session 
>> *);
>> +void  pipex_ppp_output (struct mbuf *, struct pipex_session 
>> *, int);
>> +int   pipex_ppp_proto (struct mbuf *, struct pipex_session 
>> *, int, int *);
>> +void  pipex_ppp_input (struct mbuf *, struct pipex_session 
>> *, int);
>> +void  pipex_ip_input (struct mbuf *, struct pipex_session 
>> *);
>>  #ifdef INET6
>> -Static void  pipex_ip6_input (struct mbuf *, struct 
>> pipex_session *);
>> +void  pipex_ip6_input (struct mbuf *, struct pipex_session 
>> *);
>>  #endif
>> -Static struct mbuf   *pipex_common_input(struct pipex_session *, 
>> struct mbuf *, int, int, int);
>> +struct mbuf   *pipex_common_input(struct pipex_session *, struct 
>> mbuf *, int, int, int);
>>  
>>  #ifdef PIPEX_PPPOE
>> -Static void  pipex_pppoe_output (struct mbuf *, struct 
>> pipex_session *);
>> +void  pipex_pppoe_output (struct mbuf *, struct 
>> pipex_session *);
>>  #endif
>>  
>>  #ifdef PIPEX_PPTP
>> -Static void  pipex_pptp_output (struct mbuf *, struct 
>> pipex_session *, int, int);
>> -Static struct pipex_session  *pipex_pptp_userland_lookup_session(struct 
>> mbuf *, struct sockaddr *);
>> +void  pipex_pptp_output (struct mbuf *, struct 
>> pipex_session *, int, int);
>> +struct pipex_session  *pipex_pptp_userland_lookup_session(struct mbuf *, 
>> struct 

Re: extern already declared

2020-02-09 Thread Todd C . Miller
On Sun, 09 Feb 2020 19:05:28 +0100, Jan Stary wrote:

> But the externs should be mentioned in the manpage, right?
> That's the only place they are mentioned before being talked about
> in the text; although I suspect that's why people keep declaring them
> in source code - it's what SYNOPSIS said.

I don't think so, you don't copy the contents of the SYNOPSIS to
your program.  The reason we have code that declares these itself
is that is what you needed to do in 4.3BSD (and probably System V
where the API originated).

 - todd



remove the 'support' for troff fonts in lp[rd]

2020-02-09 Thread Jan Stary
(Replying to an old thread)

On Jan 28 12:06:42, chrisbenn...@bennettconstruction.us wrote:
> #define   _PATH_VFONT "/usr/libdata/vfont/"
> #define   _PATH_VFONTB"/usr/libdata/vfont/B"
> #define   _PATH_VFONTI"/usr/libdata/vfont/I"
> #define   _PATH_VFONTR"/usr/libdata/vfont/R"
> #define   _PATH_VFONTS"/usr/libdata/vfont/S"


On Jan 28 11:18:58, todd.mil...@courtesan.com wrote:
> The troff support in lpd is of the old phototypesetter variety.  It
> has no real value in today's world.  The "ditroff" support is what
> we would consider modern troff.
> 
> I think we can safely remove the old font bits and the associated
> control file bits.

The diff below

* removes the nonexistent font support from lpr and lpd
* removes the -1234 options from the code and manpage
* removes the BUGS section mentioning that the nonexistent fonts
  must be located at the printserver, where they are not implemented

Jan


Index: usr.sbin/lpd/printer.c
===
RCS file: /cvs/src/usr.sbin/lpd/printer.c,v
retrieving revision 1.2
diff -u -p -r1.2 printer.c
--- usr.sbin/lpd/printer.c  3 Jul 2019 03:24:03 -   1.2
+++ usr.sbin/lpd/printer.c  9 Feb 2020 21:32:41 -
@@ -474,13 +474,6 @@ printjob(const char *cfname, int retry)
log_warnx("strtonum: %s", errstr);
break;
 
-   case '1':   /* troff fonts */
-   case '2':
-   case '3':
-   case '4':
-   /* XXX not implemented */
-   break;
-
default:
if (line[0] < 'a' || line[0] > 'z')
break;
Index: usr.sbin/lpr/common_source/pathnames.h
===
RCS file: /cvs/src/usr.sbin/lpr/common_source/pathnames.h,v
retrieving revision 1.6
diff -u -p -r1.6 pathnames.h
--- usr.sbin/lpr/common_source/pathnames.h  28 Oct 2015 13:25:55 -  
1.6
+++ usr.sbin/lpr/common_source/pathnames.h  9 Feb 2020 21:32:41 -
@@ -40,8 +40,3 @@
 #define_PATH_PR"/usr/bin/pr"
 #define_PATH_PRINTCAP  "/etc/printcap"
 #define_PATH_SOCKETNAME"/var/run/printer"
-#define_PATH_VFONT "/usr/libdata/vfont/"
-#define_PATH_VFONTB"/usr/libdata/vfont/B"
-#define_PATH_VFONTI"/usr/libdata/vfont/I"
-#define_PATH_VFONTR"/usr/libdata/vfont/R"
-#define_PATH_VFONTS"/usr/libdata/vfont/S"
Index: usr.sbin/lpr/lpd/lpd.8
===
RCS file: /cvs/src/usr.sbin/lpr/lpd/lpd.8,v
retrieving revision 1.30
diff -u -p -r1.30 lpd.8
--- usr.sbin/lpr/lpd/lpd.8  8 Feb 2020 01:09:58 -   1.30
+++ usr.sbin/lpr/lpd/lpd.8  9 Feb 2020 21:32:41 -
@@ -261,18 +261,6 @@ The file contains a raster image.
 .It r
 The file contains text data with
 FORTRAN carriage control characters.
-.It \&1
-Troff Font R.
-Name of the font file to use instead of the default.
-.It \&2
-Troff Font I.
-Name of the font file to use instead of the default.
-.It \&3
-Troff Font B.
-Name of the font file to use instead of the default.
-.It \&4
-Troff Font S.
-Name of the font file to use instead of the default.
 .It W
 Width.
 Changes the page width (in characters) used by
Index: usr.sbin/lpr/lpd/printjob.c
===
RCS file: /cvs/src/usr.sbin/lpr/lpd/printjob.c,v
retrieving revision 1.61
diff -u -p -r1.61 printjob.c
--- usr.sbin/lpr/lpd/printjob.c 3 Jul 2019 03:24:03 -   1.61
+++ usr.sbin/lpr/lpd/printjob.c 9 Feb 2020 21:32:41 -
@@ -316,16 +316,6 @@ again:
goto again;
 }
 
-#defineFONTLEN 50
-char   fonts[4][FONTLEN];  /* fonts for troff */
-
-char ifonts[4][40] = {
-   _PATH_VFONTR,
-   _PATH_VFONTI,
-   _PATH_VFONTB,
-   _PATH_VFONTS,
-};
-
 /*
  * The remaining part is the reading of the control file (cf)
  * and performing the various actions.
@@ -348,15 +338,6 @@ printit(char *file)
return(OK);
}
/*
-* Reset troff fonts.
-*/
-   for (i = 0; i < 4; i++)
-   strlcpy(fonts[i], ifonts[i], FONTLEN);
-   (void)snprintf([2], sizeof(width) - 2, "%ld", PW);
-   indent[2] = '0';
-   indent[3] = '\0';
-
-   /*
 *  read the control file for work to do
 *
 *  file format -- first character in the line is a command
@@ -381,10 +362,6 @@ printit(char *file)
 *  g -- "file name" plot(1G) file to print
 *  v -- "file name" plain raster file to print
 *  c -- "file name" cifplot file to print
-*  1 -- "R font file" for 

Re: syslogd closing all udp is a tiny bit aggressiv

2020-02-09 Thread Alexander Bluhm
On Thu, Feb 06, 2020 at 05:57:15PM -0500, sven falempin wrote:
> > Your DNS lookup fails at startup, sockets are closed.
> > Later at SIGHUP you DNS works again.  Now the sockets are needed.
> > So do not close them if DNS for udp fails.

I thought again about this problem.  The fix can be more specific.
- if user requested udp4 or udp6, close the other af socket.
- after SIGHUP, when DNS works, close the unneeded af socket.

ok?

Index: usr.sbin/syslogd/syslogd.c
===
RCS file: /data/mirror/openbsd/cvs/src/usr.sbin/syslogd/syslogd.c,v
retrieving revision 1.262
diff -u -p -r1.262 syslogd.c
--- usr.sbin/syslogd/syslogd.c  5 Jul 2019 13:23:27 -   1.262
+++ usr.sbin/syslogd/syslogd.c  9 Feb 2020 20:25:20 -
@@ -853,20 +853,6 @@ main(int argc, char *argv[])
event_add(ev_udp, NULL);
if (fd_udp6 != -1)
event_add(ev_udp6, NULL);
-   } else {
-   /*
-* If generic UDP file descriptors are used neither
-* for receiving nor for sending, close them.  Then
-* there is no useless *.514 in netstat.
-*/
-   if (fd_udp != -1 && !send_udp) {
-   close(fd_udp);
-   fd_udp = -1;
-   }
-   if (fd_udp6 != -1 && !send_udp6) {
-   close(fd_udp6);
-   fd_udp6 = -1;
-   }
}
for (i = 0; i < nbind; i++)
if (fd_bind[i] != -1)
@@ -2416,6 +2402,7 @@ init(void)
s = 0;
strlcpy(progblock, "*", sizeof(progblock));
strlcpy(hostblock, "*", sizeof(hostblock));
+   send_udp = send_udp6 = 0;
while (getline(, , cf) != -1) {
/*
 * check for end-of-section, comments, strip off trailing
@@ -2508,6 +2495,22 @@ init(void)
Initialized = 1;
dropped_warn(_dropped, "during initialization");

+   if (SecureMode) {
+   /*
+* If generic UDP file descriptors are used neither
+* for receiving nor for sending, close them.  Then
+* there is no useless *.514 in netstat.
+*/
+   if (fd_udp != -1 && !send_udp) {
+   close(fd_udp);
+   fd_udp = -1;
+   }
+   if (fd_udp6 != -1 && !send_udp6) {
+   close(fd_udp6);
+   fd_udp6 = -1;
+   }
+   }
+
if (Debug) {
SIMPLEQ_FOREACH(f, , f_next) {
for (i = 0; i <= LOG_NFACILITIES; i++)
@@ -2755,6 +2758,13 @@ cfline(char *line, char *progblock, char
sizeof(f->f_un.f_forw.f_addr)) != 0) {
log_warnx("bad hostname \"%s\"",
f->f_un.f_forw.f_loghost);
+   /* DNS lookup may work after SIGHUP, keep sockets */
+   if (strcmp(proto, "udp") == 0)
+   send_udp = send_udp6 = 1;
+   else if (strcmp(proto, "udp4") == 0)
+   send_udp = 1;
+   else if (strcmp(proto, "udp6") == 0)
+   send_udp6 = 1;
break;
}
f->f_file = -1;



Re: locate.updatedb TMPDIR

2020-02-09 Thread Joerg Jung
On Sun, Feb 09, 2020 at 04:33:13PM +0100, Ingo Schwarze wrote:
>
> this is absolutely not OK.
> 
> How did you test this?

I changed weekly directly on the remote machine to detect and narrow 
down the issue and generated the diff later on my local machine source
tree. 

>$ doas cat /var/log/weekly.part  
>   /etc/weekly[79]: no closing quote

Hah! Thanks for spotting this! Below the correct diff.
OK? 

FYI, this effectively reverts Revision 1.9 committed by mickey about 20
years ago.

> > Note, this might break existing setups, where one has set TMPDIR in
> > /etc/weekly.local to point elsewhere.  This might be handled with a
> > -current upgrade entry?

Please find below another possible diff for current.html
OK?


Index: etc/weekly
===
RCS file: /cvs/src/etc/weekly,v
retrieving revision 1.29
diff -u -p -r1.29 weekly
--- etc/weekly  30 Dec 2019 16:49:51 -  1.29
+++ etc/weekly  9 Feb 2020 19:51:31 -
@@ -48,7 +48,7 @@ if [ -f /var/db/locate.database ]; then
if TMP=`mktemp /var/db/locate.database.XX`; then
trap 'rm -f $TMP; exit 1' 0 1 15
UPDATEDB="/usr/libexec/locate.updatedb"
-   echo "${UPDATEDB} --fcodes=- --tmpdir=${TMPDIR:-/tmp}" | \
+   echo "${UPDATEDB} --fcodes=-" | \
nice -5 su -m nobody 1>$TMP
if [ $? -ne 0 ]; then
echo "Rebuilding locate database failed"





Index: faq/current.html
===
RCS file: /cvs/www/faq/current.html,v
retrieving revision 1.1025
diff -u -p -r1.1025 current.html
--- faq/current.html8 Feb 2020 10:19:11 -   1.1025
+++ faq/current.html9 Feb 2020 19:51:35 -
@@ -205,8 +205,17 @@ Old binaries should be deleted and scrip
 adapted.
 
 
-# rm -f /usr/sbin/{dig,host,nslookup}
+# rm -f /usr/sbin/{dig,host,nslookup}
 
+
+
+2020/02/09 - /etc/weekly locate.updatedb TMPDIR
+
+TMPDIR is no longer propagated for locate.updatedb 
+in https://man.openbsd.org/weekly.8;>weekly(8).
+Custom TMPDIR values for locate.updatedb set in 
+root crontab or /etc/weekly.local should be moved into
+/etc/locate.rc.
 
 
 

Re: locate.updatedb TMPDIR

2020-02-09 Thread Joerg Jung
On Sun, Feb 09, 2020 at 04:18:52PM +0100, Ingo Schwarze wrote:
> Hi Todd,
> 
> Todd C. Miller wrote on Sun, Feb 09, 2020 at 07:52:10AM -0700:
> 
> > I'm fine with this.
> 
> I don't really object, but i'm not sure it is needed either.
> 
> It's certainly obvious that command line arguments override defaults.
> That's what they always do.  It's their whole point, in general.
> 
> Also, command line arguments (at least almost) always override
> configuration file settings.  If they don't, i would usually call
> that a serious design error.  There may be exceptions, like
> configuration settings to enable or disable optional command
> line functionality, but that is very unusual.

Personally, I won't necessarily expect that, as I have seen way to many
tools doing all kinds of weird things with ordering, e.g. defaults,
overridden by local user config, overridden by current env, overridden
by global config, overridden by command line flags, etc.  In this
particular case I had to lookup the order in the code to narrow down the
actual issue.  Hence I thought it would be a good idea to document this.

However, I'm fine with assuming sane defaults on OpenBSD, so not needed
then. 

> > However, it doesn't look like we document /etc/locate.rc anywhere.
> > I'm not sure it deserves its own man page
> > but I think it should at least be documented in locate.updatedb
> > in some fashion.
> 
> It is mentioned there, but not really documented.
> 
> OK?

OK jung@

>   Ingo
> 
> 
> Index: locate.updatedb.8
> ===
> RCS file: /cvs/src/usr.bin/locate/locate/locate.updatedb.8,v
> retrieving revision 1.18
> diff -u -r1.18 locate.updatedb.8
> --- locate.updatedb.8 10 Dec 2009 00:45:43 -  1.18
> +++ locate.updatedb.8 9 Feb 2020 15:14:57 -
> @@ -51,10 +51,6 @@
>  .Pa /etc/weekly
>  script.
>  .Pp
> -The contents of the newly built database can be controlled by the
> -.Pa /etc/locate.rc
> -file as well as the command line arguments.
> -.Pp
>  The options are as follows:
>  .Bl -tag -width Ds
>  .It Fl -fcodes
> @@ -75,6 +71,14 @@
>  .It Fl -tmpdir
>  Sets the directory temporary files are stored in.
>  .El
> +.Pp
> +The default settings are controlled by the configuration file
> +.Pa /etc/locate.rc .
> +It is a
> +.Xr sh 1
> +script that can be used to set variables.
> +The names of the variables match the names of the command line
> +options, but in all caps.
>  .Sh FILES
>  .Bl -tag -width /var/db/locate.database -compact
>  .It Pa /etc/locate.rc
> 



Re: Audio control API, part 2: add new sndioctl(1) utility

2020-02-09 Thread Alexandre Ratchov
On Sun, Feb 09, 2020 at 07:20:15PM +0100, Landry Breuil wrote:
> On Sun, Feb 09, 2020 at 01:14:47PM +0100, Alexandre Ratchov wrote:
> > Here's a new sndioctl utility similar to mixerctl(1) but using the new
> > sndio API. Example:
> > 
> > $ sndioctl 
> > output.level=127
> > app/aucat0.level=127
> > app/firefox0.level=127
> > app/firefox1.level=12
> > app/midisyn0.level=127
> > app/mpv0.level=127
> > app/prog5.level=127
> > app/prog6.level=127
> > app/prog7.level=127
> > hw/input.level=62
> > hw/input.mute=0
> > hw/output.level=63
> > hw/output.mute=0
> 
> i suppose that replaces audio/aucatctl port ?

Yes. But aucatctl will continue to work, it's based on the MIDI
interface that will stay for now. The advantage of sndioctl is that it
exposes selected hardware controls, while aucatctl exposes sndiod
internal knobs only.

> audio/cmixer relies on the
> latter but i'll have no issue migrating to it if sndioctl gets added.
> 

The -m option might be useful to cmixer to get updates of the knobs
state without the need to restart sndioctl periodically.



Re: remove needless #ifdef

2020-02-09 Thread Jeremie Courreges-Anglas
On Sun, Feb 09 2020, Jan Stary  wrote:
> Currently, sys/net/pipex_local.h asks #ifdef __OpenBSD__
> and if so, defines "Static" to be nothing, to use it later.
> That can go away, right?

I believe that's something the IIJ folks want to keep, cc'ing Yasuoka.

>   Jan
>
>
> Index: sys/net/pipex_local.h
> ===
> RCS file: /cvs/src/sys/net/pipex_local.h,v
> retrieving revision 1.30
> diff -u -p -r1.30 pipex_local.h
> --- sys/net/pipex_local.h 31 Jan 2019 18:01:14 -  1.30
> +++ sys/net/pipex_local.h 9 Feb 2020 15:26:51 -
> @@ -26,12 +26,6 @@
>   * SUCH DAMAGE.
>   */
>  
> -#ifdef __OpenBSD__
> -#define Static
> -#else
> -#define Static static
> -#endif
> -
>  #define  PIPEX_PPTP  1
>  #define  PIPEX_L2TP  1
>  #define  PIPEX_PPPOE 1
> @@ -372,59 +366,56 @@ extern struct pipex_hash_head   pipex_id_h
>  #define PIPEX_TCP_OPTLEN 40
>  #define  PIPEX_L2TP_MINLEN   8
>  
> -/*
> - * static function prototypes
> - */
> -Static void  pipex_iface_start (struct pipex_iface_context 
> *);
> -Static void  pipex_iface_stop (struct pipex_iface_context *);
> -Static int   pipex_add_session (struct pipex_session_req *, 
> struct pipex_iface_context *);
> -Static int   pipex_close_session (struct 
> pipex_session_close_req *);
> -Static int   pipex_config_session (struct 
> pipex_session_config_req *);
> -Static int   pipex_get_stat (struct pipex_session_stat_req 
> *);
> -Static int   pipex_get_closed (struct pipex_session_list_req 
> *);
> -Static int   pipex_destroy_session (struct pipex_session *);
> -Static struct pipex_session  *pipex_lookup_by_ip_address (struct in_addr);
> -Static struct pipex_session  *pipex_lookup_by_session_id (int, int);
> -Static void  pipex_ip_output (struct mbuf *, struct 
> pipex_session *);
> -Static void  pipex_ppp_output (struct mbuf *, struct 
> pipex_session *, int);
> -Static int   pipex_ppp_proto (struct mbuf *, struct 
> pipex_session *, int, int *);
> -Static void  pipex_ppp_input (struct mbuf *, struct 
> pipex_session *, int);
> -Static void  pipex_ip_input (struct mbuf *, struct 
> pipex_session *);
> +void  pipex_iface_start (struct pipex_iface_context *);
> +void  pipex_iface_stop (struct pipex_iface_context *);
> +int   pipex_add_session (struct pipex_session_req *, struct 
> pipex_iface_context *);
> +int   pipex_close_session (struct pipex_session_close_req *);
> +int   pipex_config_session (struct pipex_session_config_req 
> *);
> +int   pipex_get_stat (struct pipex_session_stat_req *);
> +int   pipex_get_closed (struct pipex_session_list_req *);
> +int   pipex_destroy_session (struct pipex_session *);
> +struct pipex_session  *pipex_lookup_by_ip_address (struct in_addr);
> +struct pipex_session  *pipex_lookup_by_session_id (int, int);
> +void  pipex_ip_output (struct mbuf *, struct pipex_session 
> *);
> +void  pipex_ppp_output (struct mbuf *, struct pipex_session 
> *, int);
> +int   pipex_ppp_proto (struct mbuf *, struct pipex_session 
> *, int, int *);
> +void  pipex_ppp_input (struct mbuf *, struct pipex_session 
> *, int);
> +void  pipex_ip_input (struct mbuf *, struct pipex_session *);
>  #ifdef INET6
> -Static void  pipex_ip6_input (struct mbuf *, struct 
> pipex_session *);
> +void  pipex_ip6_input (struct mbuf *, struct pipex_session 
> *);
>  #endif
> -Static struct mbuf   *pipex_common_input(struct pipex_session *, 
> struct mbuf *, int, int, int);
> +struct mbuf   *pipex_common_input(struct pipex_session *, struct 
> mbuf *, int, int, int);
>  
>  #ifdef PIPEX_PPPOE
> -Static void  pipex_pppoe_output (struct mbuf *, struct 
> pipex_session *);
> +void  pipex_pppoe_output (struct mbuf *, struct 
> pipex_session *);
>  #endif
>  
>  #ifdef PIPEX_PPTP
> -Static void  pipex_pptp_output (struct mbuf *, struct 
> pipex_session *, int, int);
> -Static struct pipex_session  *pipex_pptp_userland_lookup_session(struct mbuf 
> *, struct sockaddr *);
> +void  pipex_pptp_output (struct mbuf *, struct pipex_session 
> *, int, int);
> +struct pipex_session  *pipex_pptp_userland_lookup_session(struct mbuf *, 
> struct sockaddr *);
>  #endif
>  
>  #ifdef PIPEX_L2TP
> -Static void  pipex_l2tp_output (struct mbuf *, struct 
> pipex_session *);
> +void  pipex_l2tp_output (struct mbuf *, struct pipex_session 
> *);
>  #endif
>  
>  #ifdef PIPEX_MPPE
> -Static void  pipex_mppe_init (struct pipex_mppe 

Re: Audio control API, part 2: add new sndioctl(1) utility

2020-02-09 Thread Landry Breuil
On Sun, Feb 09, 2020 at 01:14:47PM +0100, Alexandre Ratchov wrote:
> Here's a new sndioctl utility similar to mixerctl(1) but using the new
> sndio API. Example:
> 
> $ sndioctl 
> output.level=127
> app/aucat0.level=127
> app/firefox0.level=127
> app/firefox1.level=12
> app/midisyn0.level=127
> app/mpv0.level=127
> app/prog5.level=127
> app/prog6.level=127
> app/prog7.level=127
> hw/input.level=62
> hw/input.mute=0
> hw/output.level=63
> hw/output.mute=0

i suppose that replaces audio/aucatctl port ? audio/cmixer relies on the
latter but i'll have no issue migrating to it if sndioctl gets added.



Re: extern already declared

2020-02-09 Thread Jan Stary
On Feb 09 09:49:35, mill...@openbsd.org wrote:
> On Sun, 09 Feb 2020 17:46:51 +0100, Jan Stary wrote:
> 
> > Whenever unistd.h declares getopt(3), it also declares
> > the extern optind and optarg, so files including unistd.h
> > don't need to declare those themselves, right?
> 
> Correct.  Most of those date back from before optind and optarg
> were defined for you by unistd.h.

But the externs should be mentioned in the manpage, right?
That's the only place they are mentioned before being talked about
in the text; although I suspect that's why people keep declaring them
in source code - it's what SYNOPSIS said.

Jan



afile.h not wav.h

2020-02-09 Thread Jan Stary
The afile.h include has been so named for some time
but the corresponding #define has not been changed from WAV_H
- not that it matters much of course.

Jan


Index: afile.h
===
RCS file: /cvs/src/usr.bin/aucat/afile.h,v
retrieving revision 1.1
diff -u -p -r1.1 afile.h
--- afile.h 21 Jan 2015 08:43:55 -  1.1
+++ afile.h 9 Feb 2020 17:42:02 -
@@ -14,8 +14,8 @@
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
-#ifndef WAV_H
-#define WAV_H
+#ifndef AFILE_H
+#define AFILE_H
 
 #include 
 #include "dsp.h"
@@ -52,4 +52,4 @@ size_t afile_write(struct afile *, void 
 int afile_seek(struct afile *, off_t);
 void afile_close(struct afile *);
 
-#endif /* !defined(WAV_H) */
+#endif /* !defined(AFILE_H) */



Re: extern already declared

2020-02-09 Thread Todd C . Miller
On Sun, 09 Feb 2020 17:46:51 +0100, Jan Stary wrote:

> Whenever unistd.h declares getopt(3), it also declares
> the extern optind and optarg, so files including unistd.h
> don't need to declare those themselves, right?

Correct.  Most of those date back from before optind and optarg
were defined for you by unistd.h.

 - todd



extern already declared

2020-02-09 Thread Jan Stary
Whenever unistd.h declares getopt(3), it also declares
the extern optind and optarg, so files including unistd.h
don't need to declare those themselves, right?

Jan

Index: games/fortune/strfile/strfile.c
===
RCS file: /cvs/src/games/fortune/strfile/strfile.c,v
retrieving revision 1.29
diff -u -p -r1.29 strfile.c
--- games/fortune/strfile/strfile.c 4 Jun 2017 13:39:25 -   1.29
+++ games/fortune/strfile/strfile.c 9 Feb 2020 16:23:42 -
@@ -252,8 +252,6 @@ main(int ac, char *av[])
 void
 getargs(int argc, char *argv[])
 {
-   extern char *optarg;
-   extern int  optind;
int ch;
 
while ((ch = getopt(argc, argv, "c:hiorsx")) != -1) {
Index: games/hunt/hunt/hunt.c
===
RCS file: /cvs/src/games/hunt/hunt/hunt.c,v
retrieving revision 1.22
diff -u -p -r1.22 hunt.c
--- games/hunt/hunt/hunt.c  8 Apr 2017 22:50:41 -   1.22
+++ games/hunt/hunt/hunt.c  9 Feb 2020 16:23:42 -
@@ -85,8 +85,6 @@ int
 main(int ac, char **av)
 {
int c;
-   extern int  optind;
-   extern char *optarg;
longenter_status;
int option;
struct servent  *se;
Index: games/hunt/huntd/driver.c
===
RCS file: /cvs/src/games/hunt/huntd/driver.c,v
retrieving revision 1.29
diff -u -p -r1.29 driver.c
--- games/hunt/huntd/driver.c   21 Jan 2017 08:22:57 -  1.29
+++ games/hunt/huntd/driver.c   9 Feb 2020 16:23:42 -
@@ -80,8 +80,6 @@ main(int ac, char **av)
static fd_set   read_fds;
static FLAG first = TRUE;
static FLAG server = FALSE;
-   extern int  optind;
-   extern char *optarg;
extern char *__progname;
int c;
static struct timeval   linger = { 0, 0 };
Index: games/robots/main.c
===
RCS file: /cvs/src/games/robots/main.c,v
retrieving revision 1.28
diff -u -p -r1.28 main.c
--- games/robots/main.c 28 Jun 2019 13:32:52 -  1.28
+++ games/robots/main.c 9 Feb 2020 16:23:42 -
@@ -56,7 +56,6 @@ main(int ac, char *av[])
int score_err = 0; /* hold errno from score file open */
int ch;
int ret;
-   extern int  optind;
char*home;
 #ifdef FANCY
char*sp;
Index: regress/lib/libc/db/dbtest.c
===
RCS file: /cvs/src/regress/lib/libc/db/dbtest.c,v
retrieving revision 1.16
diff -u -p -r1.16 dbtest.c
--- regress/lib/libc/db/dbtest.c27 Jul 2017 15:08:37 -  1.16
+++ regress/lib/libc/db/dbtest.c9 Feb 2020 16:23:48 -
@@ -76,8 +76,6 @@ int XXlineno; /* Fast breakpoint for 
 int
 main(int argc, char *argv[])
 {
-   extern int optind;
-   extern char *optarg;
enum S command, state;
DB *dbp;
DBT data, key, keydata;
Index: regress/lib/libc/getaddrinfo/gaitest.c
===
RCS file: /cvs/src/regress/lib/libc/getaddrinfo/gaitest.c,v
retrieving revision 1.6
diff -u -p -r1.6 gaitest.c
--- regress/lib/libc/getaddrinfo/gaitest.c  9 Jun 2009 18:15:08 -   
1.6
+++ regress/lib/libc/getaddrinfo/gaitest.c  9 Feb 2020 16:23:48 -
@@ -119,8 +119,6 @@ main(argc, argv)
struct addrinfo *res;
int error, i;
char *p, *q;
-   extern int optind;
-   extern char *optarg;
int c;
char nbuf[10];
 
Index: regress/lib/libc/regex/main.c
===
RCS file: /cvs/src/regress/lib/libc/regex/main.c,v
retrieving revision 1.10
diff -u -p -r1.10 main.c
--- regress/lib/libc/regex/main.c   13 Jul 2016 06:17:11 -  1.10
+++ regress/lib/libc/regex/main.c   9 Feb 2020 16:23:48 -
@@ -41,8 +41,6 @@ main(int argc, char *argv[])
int c;
int errflg = 0;
register int i;
-   extern int optind;
-   extern char *optarg;
 
progname = argv[0];
 
Index: regress/lib/libutil/fmt_scaled/fmt_test.c
===
RCS file: /cvs/src/regress/lib/libutil/fmt_scaled/fmt_test.c,v
retrieving revision 1.15
diff -u -p -r1.15 fmt_test.c
--- regress/lib/libutil/fmt_scaled/fmt_test.c   16 Mar 2017 02:42:31 -  
1.15
+++ regress/lib/libutil/fmt_scaled/fmt_test.c   9 Feb 2020 16:23:49 -
@@ -36,8 +36,6 @@ __dead static void usage(int stat)
 int
 main(int argc, char **argv)
 {
-   extern char *optarg;
-   extern int optind;
int i, ch;
  
while ((ch = getopt(argc, argv, "hv")) != -1) {



Re: Push KERNEL_LOCK() down in pgsigio() and selwakeup()

2020-02-09 Thread Visa Hankala
On Tue, Feb 04, 2020 at 02:21:02PM +0100, Martin Pieuchot wrote:
>  void
>  selwakeup(struct selinfo *sip)
>  {
> + KERNEL_LOCK();
> + KNOTE(>si_note, NOTE_SUBMIT);
> + doselwakeup(sip);
> + KERNEL_UNLOCK();
> +}

There is a problem with audio code. Audio interrupt handlers generally
run without the kernel lock. Acquiring the kernel lock is not safe at
this level because the audio_lock mutex might be locked. In addition,
IPL_AUDIO is above IPL_MPFLOOR on some architectures.



remove needless #ifdef

2020-02-09 Thread Jan Stary
Currently, sys/net/pipex_local.h asks #ifdef __OpenBSD__
and if so, defines "Static" to be nothing, to use it later.
That can go away, right?

Jan


Index: sys/net/pipex_local.h
===
RCS file: /cvs/src/sys/net/pipex_local.h,v
retrieving revision 1.30
diff -u -p -r1.30 pipex_local.h
--- sys/net/pipex_local.h   31 Jan 2019 18:01:14 -  1.30
+++ sys/net/pipex_local.h   9 Feb 2020 15:26:51 -
@@ -26,12 +26,6 @@
  * SUCH DAMAGE.
  */
 
-#ifdef __OpenBSD__
-#define Static
-#else
-#define Static static
-#endif
-
 #definePIPEX_PPTP  1
 #definePIPEX_L2TP  1
 #definePIPEX_PPPOE 1
@@ -372,59 +366,56 @@ extern struct pipex_hash_head pipex_id_h
 #define PIPEX_TCP_OPTLEN 40
 #definePIPEX_L2TP_MINLEN   8
 
-/*
- * static function prototypes
- */
-Static void  pipex_iface_start (struct pipex_iface_context *);
-Static void  pipex_iface_stop (struct pipex_iface_context *);
-Static int   pipex_add_session (struct pipex_session_req *, 
struct pipex_iface_context *);
-Static int   pipex_close_session (struct 
pipex_session_close_req *);
-Static int   pipex_config_session (struct 
pipex_session_config_req *);
-Static int   pipex_get_stat (struct pipex_session_stat_req *);
-Static int   pipex_get_closed (struct pipex_session_list_req 
*);
-Static int   pipex_destroy_session (struct pipex_session *);
-Static struct pipex_session  *pipex_lookup_by_ip_address (struct in_addr);
-Static struct pipex_session  *pipex_lookup_by_session_id (int, int);
-Static void  pipex_ip_output (struct mbuf *, struct 
pipex_session *);
-Static void  pipex_ppp_output (struct mbuf *, struct 
pipex_session *, int);
-Static int   pipex_ppp_proto (struct mbuf *, struct 
pipex_session *, int, int *);
-Static void  pipex_ppp_input (struct mbuf *, struct 
pipex_session *, int);
-Static void  pipex_ip_input (struct mbuf *, struct 
pipex_session *);
+void  pipex_iface_start (struct pipex_iface_context *);
+void  pipex_iface_stop (struct pipex_iface_context *);
+int   pipex_add_session (struct pipex_session_req *, struct 
pipex_iface_context *);
+int   pipex_close_session (struct pipex_session_close_req *);
+int   pipex_config_session (struct pipex_session_config_req *);
+int   pipex_get_stat (struct pipex_session_stat_req *);
+int   pipex_get_closed (struct pipex_session_list_req *);
+int   pipex_destroy_session (struct pipex_session *);
+struct pipex_session  *pipex_lookup_by_ip_address (struct in_addr);
+struct pipex_session  *pipex_lookup_by_session_id (int, int);
+void  pipex_ip_output (struct mbuf *, struct pipex_session *);
+void  pipex_ppp_output (struct mbuf *, struct pipex_session *, 
int);
+int   pipex_ppp_proto (struct mbuf *, struct pipex_session *, 
int, int *);
+void  pipex_ppp_input (struct mbuf *, struct pipex_session *, 
int);
+void  pipex_ip_input (struct mbuf *, struct pipex_session *);
 #ifdef INET6
-Static void  pipex_ip6_input (struct mbuf *, struct 
pipex_session *);
+void  pipex_ip6_input (struct mbuf *, struct pipex_session *);
 #endif
-Static struct mbuf   *pipex_common_input(struct pipex_session *, 
struct mbuf *, int, int, int);
+struct mbuf   *pipex_common_input(struct pipex_session *, struct mbuf 
*, int, int, int);
 
 #ifdef PIPEX_PPPOE
-Static void  pipex_pppoe_output (struct mbuf *, struct 
pipex_session *);
+void  pipex_pppoe_output (struct mbuf *, struct pipex_session 
*);
 #endif
 
 #ifdef PIPEX_PPTP
-Static void  pipex_pptp_output (struct mbuf *, struct 
pipex_session *, int, int);
-Static struct pipex_session  *pipex_pptp_userland_lookup_session(struct mbuf 
*, struct sockaddr *);
+void  pipex_pptp_output (struct mbuf *, struct pipex_session 
*, int, int);
+struct pipex_session  *pipex_pptp_userland_lookup_session(struct mbuf *, 
struct sockaddr *);
 #endif
 
 #ifdef PIPEX_L2TP
-Static void  pipex_l2tp_output (struct mbuf *, struct 
pipex_session *);
+void  pipex_l2tp_output (struct mbuf *, struct pipex_session 
*);
 #endif
 
 #ifdef PIPEX_MPPE
-Static void  pipex_mppe_init (struct pipex_mppe *, int, int, 
u_char *, int);
-Static void  GetNewKeyFromSHA (u_char *, u_char *, int, u_char 
*);
-Static void  pipex_mppe_reduce_key (struct pipex_mppe *);
-Static void  mppe_key_change (struct pipex_mppe *);
-Static void  pipex_mppe_input (struct mbuf *, struct 

Re: locate.updatedb TMPDIR

2020-02-09 Thread Ingo Schwarze
Hi Joerg,

this is absolutely not OK.

How did you test this?

   $ doas cat /var/log/weekly.part  
  /etc/weekly[79]: no closing quote

With that fixed, i agree with the direction of the change.

Yours,
  Ingo

Joerg Jung wrote on Sun, Feb 09, 2020 at 12:33:42AM +0100:

> I have a machine with a large data storage attached, but it has only 2GB
> of /tmp (which I consider enough usually).  On this machine weekly
> locate.updatedb fails, due to /tmp being full.  To fix this I would like
> to point locate to a different TMPDIR.
>  
> But it seems one can not just set TMPDIR from /etc/locate.rc to point
> elsewhere, since command line args in /etc/weekly override
> /etc/locate.rc settings.
> 
> While it's possible to add a weekly.local to set TMPDIR I believe it
> should be better set in the actual configuration file instead of 
> ignoring locate.rc.
> 
> Thus the diff below proposes to remove command line argument to be able
> to use /etc/locate.rc instead.
> 
> Note, this might break existing setups, where one has set TMPDIR in
> /etc/weekly.local to point elsewhere.  This might be handled with a
> -current upgrade entry?
> 
> Comments? OK?
> 
> Thanks,
> Regards,
> Joerg
> 
> 
> Index: etc/weekly
> ===
> RCS file: /cvs/src/etc/weekly,v
> retrieving revision 1.29
> diff -u -p -r1.29 weekly
> --- etc/weekly30 Dec 2019 16:49:51 -  1.29
> +++ etc/weekly8 Feb 2020 23:13:02 -
> @@ -48,7 +48,7 @@ if [ -f /var/db/locate.database ]; then
>   if TMP=`mktemp /var/db/locate.database.XX`; then
>   trap 'rm -f $TMP; exit 1' 0 1 15
>   UPDATEDB="/usr/libexec/locate.updatedb"
> - echo "${UPDATEDB} --fcodes=- --tmpdir=${TMPDIR:-/tmp}" | \
> + echo "${UPDATEDB} --fcodes=- | \
>   nice -5 su -m nobody 1>$TMP
>   if [ $? -ne 0 ]; then
>   echo "Rebuilding locate database failed"



Re: locate.updatedb TMPDIR

2020-02-09 Thread Todd C . Miller
On Sun, 09 Feb 2020 16:18:52 +0100, Ingo Schwarze wrote:

> It is mentioned there, but not really documented.

OK millert@.

 - todd



Re: locate.updatedb TMPDIR

2020-02-09 Thread Ingo Schwarze
Hi Todd,

Todd C. Miller wrote on Sun, Feb 09, 2020 at 07:52:10AM -0700:

> I'm fine with this.

I don't really object, but i'm not sure it is needed either.

It's certainly obvious that command line arguments override defaults.
That's what they always do.  It's their whole point, in general.

Also, command line arguments (at least almost) always override
configuration file settings.  If they don't, i would usually call
that a serious design error.  There may be exceptions, like
configuration settings to enable or disable optional command
line functionality, but that is very unusual.

> However, it doesn't look like we document /etc/locate.rc anywhere.
> I'm not sure it deserves its own man page
> but I think it should at least be documented in locate.updatedb
> in some fashion.

It is mentioned there, but not really documented.

OK?
  Ingo


Index: locate.updatedb.8
===
RCS file: /cvs/src/usr.bin/locate/locate/locate.updatedb.8,v
retrieving revision 1.18
diff -u -r1.18 locate.updatedb.8
--- locate.updatedb.8   10 Dec 2009 00:45:43 -  1.18
+++ locate.updatedb.8   9 Feb 2020 15:14:57 -
@@ -51,10 +51,6 @@
 .Pa /etc/weekly
 script.
 .Pp
-The contents of the newly built database can be controlled by the
-.Pa /etc/locate.rc
-file as well as the command line arguments.
-.Pp
 The options are as follows:
 .Bl -tag -width Ds
 .It Fl -fcodes
@@ -75,6 +71,14 @@
 .It Fl -tmpdir
 Sets the directory temporary files are stored in.
 .El
+.Pp
+The default settings are controlled by the configuration file
+.Pa /etc/locate.rc .
+It is a
+.Xr sh 1
+script that can be used to set variables.
+The names of the variables match the names of the command line
+options, but in all caps.
 .Sh FILES
 .Bl -tag -width /var/db/locate.database -compact
 .It Pa /etc/locate.rc



Re: locate.updatedb TMPDIR

2020-02-09 Thread Todd C . Miller
On Sun, 09 Feb 2020 00:46:52 +0100, Joerg Jung wrote:

I'm fine with this.  However, it doesn't look like we document
/etc/locate.rc anywhere.  I'm not sure it deserves its own man page
but I think it should at least be documented in locate.updatedb
in some fashion.

 - todd

> Index: usr.bin/locate/locate/locate.updatedb.8
> ===
> RCS file: /cvs/src/usr.bin/locate/locate/locate.updatedb.8,v
> retrieving revision 1.18
> diff -u -p -r1.18 locate.updatedb.8
> --- usr.bin/locate/locate/locate.updatedb.8   10 Dec 2009 00:45:43 -
>   1.18
> +++ usr.bin/locate/locate/locate.updatedb.8   8 Feb 2020 23:44:41 -
> @@ -54,6 +54,7 @@ script.
>  The contents of the newly built database can be controlled by the
>  .Pa /etc/locate.rc
>  file as well as the command line arguments.
> +Command line arguments override rc file and defaults.
>  .Pp
>  The options are as follows:
>  .Bl -tag -width Ds
>



Re: mg: fix problems found by gcc 10

2020-02-09 Thread Sebastian Benoit
read ok

Florian Obser(flor...@openbsd.org) on 2020.02.09 10:46:34 +0100:
> Anyone? I'll commit this soon if I don't hear back, I don't think this
> is contentious.
> 
> On Fri, Feb 07, 2020 at 03:59:50PM +0100, Florian Obser wrote:
> > Moving from misc to tech.
> > 
> > This is effectively Ulrich's diff from github with a bit of whitespace 
> > shuffling.
> > 
> > OK?
> > 
> > diff --git def.h def.h
> > index d4f00e84e59..0db023973e0 100644
> > --- def.h
> > +++ def.h
> > @@ -337,7 +337,7 @@ void ttnowindow(void);
> >  voidttcolor(int);
> >  voidttresize(void);
> >  
> > -volatile sig_atomic_t winch_flag;
> > +extern volatile sig_atomic_t winch_flag;
> >  
> >  /* ttyio.c */
> >  voidttopen(void);
> > @@ -752,11 +752,7 @@ extern char cinfo[];
> >  extern char*keystrings[];
> >  extern char pat[NPAT];
> >  extern char prompt[];
> > -
> > -/*
> > - * Globals.
> > - */
> > -int tceeol;
> > -int tcinsl;
> > -int tcdell;
> > -int rptcount;  /* successive invocation count */
> > +extern int  tceeol;
> > +extern int  tcinsl;
> > +extern int  tcdell;
> > +extern int  rptcount;  /* successive invocation count */
> > diff --git kbd.c kbd.c
> > index 06d6c9fcf48..5f9b0a9efa6 100644
> > --- kbd.c
> > +++ kbd.c
> > @@ -26,13 +26,13 @@ char prompt[PROMPTL] = "", *promptp = prompt;
> >  
> >  static int mgwrap(PF, int, int);
> >  
> > -static int  use_metakey = TRUE;
> > -static int  pushed = FALSE;
> > -static int  pushedc;
> > +static int  use_metakey = TRUE;
> > +static int  pushed = FALSE;
> > +static int  pushedc;
> >  
> >  struct map_element *ele;
> > -
> > -struct key key;
> > +struct key  key;
> > +int rptcount;
> >  
> >  /*
> >   * Toggle the value of use_metakey
> > diff --git tty.c tty.c
> > index 0b64c4b5453..c378cb240dd 100644
> > --- tty.c
> > +++ tty.c
> > @@ -45,6 +45,11 @@ static const char*scroll_fwd;/* How to 
> > scroll forward. */
> >  
> >  static void winchhandler(int);
> >  
> > +volatile sig_atomic_t   winch_flag;
> > +int tceeol;
> > +int tcinsl;
> > +int tcdell;
> > +
> >  /* ARGSUSED */
> >  static void
> >  winchhandler(int sig)
> > 
> > 
> > On Tue, Feb 04, 2020 at 12:51:46AM +0100, Han Boetes wrote:
> > > The latest version of gcc is more picky about global variables resulting 
> > > in
> > > this bug report for my portable version of mg:
> > >   https://github.com/hboetes/mg/issues/12
> > > 
> > > To which Ulrich M?ller created a pull request which fixed the problem:
> > >   https://github.com/hboetes/mg/pull/13/files
> > > 
> > > Is this worth applying to the upstream branch?
> > 
> > -- 
> > I'm not entirely sure you are real.
> > 
> 
> -- 
> I'm not entirely sure you are real.
> 



Re: locate.updatedb TMPDIR

2020-02-09 Thread Todd C . Miller
On Sun, 09 Feb 2020 00:33:42 +0100, Joerg Jung wrote:

> I have a machine with a large data storage attached, but it has only 2GB
> of /tmp (which I consider enough usually).  On this machine weekly
> locate.updatedb fails, due to /tmp being full.  To fix this I would like
> to point locate to a different TMPDIR.
>  
> But it seems one can not just set TMPDIR from /etc/locate.rc to point
> elsewhere, since command line args in /etc/weekly override
> /etc/locate.rc settings.
>
> While it's possible to add a weekly.local to set TMPDIR I believe it
> should be better set in the actual configuration file instead of 
> ignoring locate.rc.
>
> Thus the diff below proposes to remove command line argument to be able
> to use /etc/locate.rc instead.

I think this is fine. The existing situation where /etc/weekly
overrides /etc/locate.rc violates the principle of least surprise.

 - todd



Re: mention /etc/examples/ in bgpf.conf(5)/bgpd(8)

2020-02-09 Thread Ingo Schwarze
Hi Jason,

Jason McIntyre wrote on Sun, Feb 09, 2020 at 07:49:10AM +:

> - bgpd.8 refers to /etc/bgpd.conf. that file doesn;t exist by default.

I do not consider that a problem, not even a minor one.  ENVIRONMENT
says which variables are inspected if they exist.  FILES says which
files are used if they exists.  If they don't, well, then they are
not used.  I don't see anything that needs to be explained in that
respect.

> - i'm not convinced bgpd.8 needs to refer to the example file.

Fair enough, deleted from my tree.  So we will usually point to the
examples from the file format manuals, but not from the program
manuals, unless there are special considerations for a specific
program.

> - only root can view the example file. i understand why, but in itself
>   it's not that helpful.

I don't see a reasonable way to improve that.  Besides, only root
can configure the daemon, so it's not a very serious obstacle in
practice.

> - we've seen from this thread that people are missing the existence of
>   /etc/examples/bgpd.conf. that's a shame because it looks like a nicely
>   written file.
> 
> the essential issue is we want people to find the examples. the least
> amount of work to achieve that is just for bgpd.conf.5 to mention it.
> adding extra stuff about what's in there is a lot of work and sets us up
> for things going out of date in the future. and although it might work
> well for bgpd - a big, complex, piece of software, it will probably make
> less sense for most other software. leaving us with a divided strategy.
> 
> it'd be good to have a clear idea of which pages we're planning to
> change, and how, so that it's clear for other authors.
> 
> for bgpd i propose:
> 
> - no change to bgpd.8. i don;t have a solution to the fact that we moved
>   its config file to examples/ so there isn;t an /etc/bgpd.conf file. i
>   suppose everyone understands what is happening.
> - for bgpd.conf.5, add an entry to FILES "example configuration file".
>   no more.

For now, that's what i did, even though i like deraadt@'s idea, but
we lack consensus, so i applied the minimum change that everybody
agreed with.

Whether to add additional information as part of a strategy to do
this in several cases where it makes sense (but of course not
everywhere), or merely in this individual case as an exception,
or not at all - that can be decided separately.

Theo has brought forward some very substantial arguments in favour,
but i didn't want to summarily dismiss Jason's reservations that
it increases the risk of information getting out of sync, either.

> - i'm not the right person to judge the existence of individual example
>   files. ratchov already indicated he doesn;t see the point of
>   examples/mixerctl.conf. i guess individual devs get to judge this.

That wouldn't result in a consistent user experience.  For example,
am i supposed to delete /etc/examples/man.conf because i don't like it?
I'll refrain from that because deraadt@, espie@, and others made it
clear that they value the concept in general.

> - i think an addition to afterboot.8 totally makes sense. it's what it's
>   there for.

I assume espie@ will commit that.

> - i don;t think an addition to help.1 makes sense. that is just trying
>   to tell people how to use unix, and no one reads it anyway.

Fair enough, i'll leave it alone.

Yours,
  Ingo



Re: mention /etc/examples/ in bgpf.conf(5)/bgpd(8)

2020-02-09 Thread Ingo Schwarze
Hi Marc,

Marc Espie wrote on Sun, Feb 09, 2020 at 02:27:23PM +0100:

> I still think it's a good idea to put it in afterboot(8).

No more objections, with or without jmc@'s tweaks.
It seems clear that enough people want it in that page.

Yours,
  Ingo


> Index: afterboot.8
> ===
> RCS file: /cvs/src/share/man/man8/afterboot.8,v
> retrieving revision 1.164
> diff -u -p -r1.164 afterboot.8
> --- afterboot.8   28 Sep 2018 18:21:31 -  1.164
> +++ afterboot.8   9 Feb 2020 13:26:29 -
> @@ -60,6 +60,10 @@ command, type:
>  Administrators will rapidly become more familiar with
>  .Ox
>  if they get used to using the high quality manual pages.
> +.Pp
> +Some base programs and subsystems also come with sample configuration 
> +files in
> +.Pa /etc/examples .
>  .Ss Errata
>  By the time that you have installed your system, it is possible that
>  bugs in the release have been found.



Re: mention /etc/examples/ in bgpf.conf(5)/bgpd(8)

2020-02-09 Thread Jason McIntyre
On Sun, Feb 09, 2020 at 02:27:23PM +0100, Marc Espie wrote:
> On Sun, Feb 09, 2020 at 12:41:43AM +0100, Sebastian Benoit wrote:
> > Ingo Schwarze(schwa...@usta.de) on 2020.02.09 00:33:06 +0100:
> > > Hi,
> > > 
> > > Jason McIntyre wrote on Sat, Feb 08, 2020 at 10:15:08PM +:
> > > 
> > > > - i'm ok with adding the path to these files to a FILES section
> > > 
> > > So, here is a specific patch for bgpf.conf(5) and bgpd(8) such
> > > that we can agree on a general direction for one case where
> > > the example file is particularly important.
> > > 
> > > Once the direction is agreed, applying it to the relatively
> > > small number of other cases is likely not difficult.
> > > 
> > > OK?
> > >   Ingo
> > 
> > I'm not against this as it only adds to the manpage, but an
> > alternative could be to just tell users (in afterboot(8)?) that there is
> > /etc/examples for them to look at and see whats there?
> > 
> > Otherwise ok.
> 
> I still think it's a good idea to put it in afterboot(8).
> That was the patch I sent to a few people that obviously triggered Ingo.
> 
> As for /etc/examples, I still think that directory has merits.
> It's WAY easier to copy an example file and uncomment/tweak the parts you
> need while skimming through the manpage than creating one from scratch.
> 
> Also, cut from an EXAMPLE in the manpage is distasteful.
> 
> Yeah, it's more info that has to be kept in synch. So what ? It's still
> useful, so it should stay.
> 
> Here's an updated version, taking Theo's remarks into account.
> 

hi. i'm fine with your text, but it would be better placed in the
section "Daemons" (yes i'm aware not all the files are for daemons)
or a new section in "FURTHER CHANGES".

jmc

> Index: afterboot.8
> ===
> RCS file: /cvs/src/share/man/man8/afterboot.8,v
> retrieving revision 1.164
> diff -u -p -r1.164 afterboot.8
> --- afterboot.8   28 Sep 2018 18:21:31 -  1.164
> +++ afterboot.8   9 Feb 2020 13:26:29 -
> @@ -60,6 +60,10 @@ command, type:
>  Administrators will rapidly become more familiar with
>  .Ox
>  if they get used to using the high quality manual pages.
> +.Pp
> +Some base programs and subsystems also come with sample configuration 
> +files in
> +.Pa /etc/examples .
>  .Ss Errata
>  By the time that you have installed your system, it is possible that
>  bugs in the release have been found.
> 



Re: mention /etc/examples/ in bgpf.conf(5)/bgpd(8)

2020-02-09 Thread Marc Espie
On Sun, Feb 09, 2020 at 12:41:43AM +0100, Sebastian Benoit wrote:
> Ingo Schwarze(schwa...@usta.de) on 2020.02.09 00:33:06 +0100:
> > Hi,
> > 
> > Jason McIntyre wrote on Sat, Feb 08, 2020 at 10:15:08PM +:
> > 
> > > - i'm ok with adding the path to these files to a FILES section
> > 
> > So, here is a specific patch for bgpf.conf(5) and bgpd(8) such
> > that we can agree on a general direction for one case where
> > the example file is particularly important.
> > 
> > Once the direction is agreed, applying it to the relatively
> > small number of other cases is likely not difficult.
> > 
> > OK?
> >   Ingo
> 
> I'm not against this as it only adds to the manpage, but an
> alternative could be to just tell users (in afterboot(8)?) that there is
> /etc/examples for them to look at and see whats there?
> 
> Otherwise ok.

I still think it's a good idea to put it in afterboot(8).
That was the patch I sent to a few people that obviously triggered Ingo.

As for /etc/examples, I still think that directory has merits.
It's WAY easier to copy an example file and uncomment/tweak the parts you
need while skimming through the manpage than creating one from scratch.

Also, cut from an EXAMPLE in the manpage is distasteful.

Yeah, it's more info that has to be kept in synch. So what ? It's still
useful, so it should stay.

Here's an updated version, taking Theo's remarks into account.

Index: afterboot.8
===
RCS file: /cvs/src/share/man/man8/afterboot.8,v
retrieving revision 1.164
diff -u -p -r1.164 afterboot.8
--- afterboot.8 28 Sep 2018 18:21:31 -  1.164
+++ afterboot.8 9 Feb 2020 13:26:29 -
@@ -60,6 +60,10 @@ command, type:
 Administrators will rapidly become more familiar with
 .Ox
 if they get used to using the high quality manual pages.
+.Pp
+Some base programs and subsystems also come with sample configuration 
+files in
+.Pa /etc/examples .
 .Ss Errata
 By the time that you have installed your system, it is possible that
 bugs in the release have been found.



Audio control API, part 4: switch ports to sndio API

2020-02-09 Thread Alexandre Ratchov
There are two ports only using the kernel-based API, this diff updates
them to use new libsndio-based API:
  - sysutils/tray-app
  - audio/gqmpeg

As a side effect, this fixes gqmpeg crashes, makes these programs use
the right device, and make them work on many uaudio(4) and envy(4)
devices with no hardware master level knob. Also when one program
changes the volume, slider of other programs are properly updated.

enjoy,

Index: audio/gqmpeg/Makefile
===
RCS file: /cvs/ports/audio/gqmpeg/Makefile,v
retrieving revision 1.64
diff -u -p -u -p -r1.64 Makefile
--- audio/gqmpeg/Makefile   12 Jul 2019 20:43:33 -  1.64
+++ audio/gqmpeg/Makefile   4 Feb 2020 22:28:34 -
@@ -3,7 +3,7 @@
 COMMENT=   front-end to various audio players
 
 DISTNAME=  gqmpeg-0.91.1
-REVISION=  14
+REVISION=  15
 CATEGORIES=audio
 
 HOMEPAGE=  http://gqmpeg.sourceforge.net/
Index: audio/gqmpeg/patches/patch-src_Makefile_in
===
RCS file: audio/gqmpeg/patches/patch-src_Makefile_in
diff -N audio/gqmpeg/patches/patch-src_Makefile_in
--- /dev/null   1 Jan 1970 00:00:00 -
+++ audio/gqmpeg/patches/patch-src_Makefile_in  4 Feb 2020 22:28:34 -
@@ -0,0 +1,14 @@
+$OpenBSD$
+
+Index: src/Makefile.in
+--- src/Makefile.in.orig
 src/Makefile.in
+@@ -342,7 +342,7 @@ gqmpeg_SOURCES = \
+   $(module_mpg123) $(module_xmp) $(module_ogg123) $(module_radio)
+ 
+ 
+-gqmpeg_LDADD = $(GTK_LIBS) $(LIBPNG)
++gqmpeg_LDADD = $(GTK_LIBS) $(LIBPNG) -lsndio
+ 
+ EXTRA_DIST = \
+   $(extra_SLIK)   \
Index: audio/gqmpeg/patches/patch-src_mixer_c
===
RCS file: /cvs/ports/audio/gqmpeg/patches/patch-src_mixer_c,v
retrieving revision 1.2
diff -u -p -u -p -r1.2 patch-src_mixer_c
--- audio/gqmpeg/patches/patch-src_mixer_c  14 Oct 2007 14:12:42 -  
1.2
+++ audio/gqmpeg/patches/patch-src_mixer_c  4 Feb 2020 22:28:34 -
@@ -1,39 +1,287 @@
 $OpenBSD: patch-src_mixer_c,v 1.2 2007/10/14 14:12:42 jasper Exp $
 src/mixer.c.orig   Tue Sep 10 16:16:26 2002
-+++ src/mixer.cSun Oct 14 15:47:27 2007
-@@ -285,7 +285,11 @@ void mixer_init(gint init_device_id)
- 
-   mixer_device = getenv("MIXERDEVICE");
-   if (mixer_device == NULL)
-+#ifdef __OpenBSD__
-+mixer_device = "/dev/mixer";
-+#else
- mixer_device = "/dev/mixer0";
-+#endif
+Index: src/mixer.c
+--- src/mixer.c.orig
 src/mixer.c
+@@ -39,10 +39,16 @@
+ #include 
+ #endif
  
-   if ((fd = open(mixer_device, O_RDWR)) == -1) {
- perror(mixer_device);
-@@ -362,7 +366,11 @@ static void mixer_set_vol(DeviceData *device, gint vol
- 
-   mixer_device = getenv("MIXERDEVICE");
-   if (mixer_device == NULL)
-+#ifdef __OpenBSD__
-+mixer_device = "/dev/mixer";
-+#else
- mixer_device = "/dev/mixer0";
-+#endif
+-#if defined(__NetBSD__) || defined(__OpenBSD__)
++#if defined(__NetBSD__)
+ #include 
+ #endif
  
-   if ((fd = open(mixer_device, O_RDWR)) == -1) {
- perror(mixer_device);
-@@ -406,7 +414,11 @@ static gint mixer_get_vol(DeviceData *device)
- 
-   mixer_device = getenv("MIXERDEVICE");
-   if (mixer_device == NULL)
-+#ifdef __OpenBSD__
-+mixer_device = "/dev/mixer";
-+#else
- mixer_device = "/dev/mixer0";
++#if defined(__OpenBSD__)
++#include 
++#include 
++#include "display.h"
 +#endif
++
+ #if defined(sun) && defined(__svr4__)
+ #include 
+ #endif
+@@ -267,11 +273,11 @@ static gint mixer_get_vol(DeviceData *device)
+ 
+ /*
+  *
+- * NetBSD and OpenBSD
++ * NetBSD
+  *
+  */
+ 
+-#elif defined(__NetBSD__) || defined(__OpenBSD__)
++#elif defined(__NetBSD__)
+ 
+ mixer_devinfo_t *infos;
+ mixer_ctrl_t *values;
+@@ -442,6 +448,241 @@ static gint mixer_get_vol(DeviceData *device)
+ 
+ /*
+  *
++ * OpenBSD
++ *
++ */
++
++#elif defined(__OpenBSD__)
++
++struct control {
++  struct control *next;
++  unsigned int addr;
++  unsigned int value;
++};
++
++static struct control *controls;
++static struct sioctl_hdl *hdl;
++static struct pollfd *pfds;
++static int initialized;
++
++/*
++ * new control registered
++ */
++static void ondesc(void *unused, struct sioctl_desc *d, int val)
++{
++  struct control *i, **pi;
++
++  if (d == NULL)
++  return;
++
++  /*
++   * delete existing control with the same address
++   */
++  for (pi =  (i = *pi) != NULL; pi = >next) {
++  if (d->addr == i->addr) {
++  *pi = i->next;
++  free(i);
++  break;
++  }
++  }
++
++  /*
++   * SIOCTL_NONE 

Audio control API, part 3: switch -lossaudio to sndio

2020-02-09 Thread Alexandre Ratchov
Certain ports use -lossaudio to get access to the volume knobs. This
diff updates -lossaudio to use the new sndio API. By default, it
exposes both sndiod output level and hardware master input/output
knobs (if present). The source selectors are not exposed any longer as
sndiod doesn't expose them.

As a side effect, this solves two problems:

- makes mixer programs (like the xfce4-mixer port) use the right
  device. Example if you use a usb head-set, the program will display
  knobs of the head-set instead of knobs of the build-in device.

- makes mixer programs work on systems that have no master level
  knobs, like many uaudio(4) or envy(4) devices

The library version stays the same as thigs works exactly as before,
so no need to rebuild ports relying no this hack^Wlibrary.

Index: lib/libossaudio/Makefile
===
RCS file: /cvs/src/lib/libossaudio/Makefile,v
retrieving revision 1.5
diff -u -p -u -p -r1.5 Makefile
--- lib/libossaudio/Makefile16 Jul 2014 20:02:17 -  1.5
+++ lib/libossaudio/Makefile8 Feb 2020 14:49:55 -
@@ -4,9 +4,11 @@
 LIB=   ossaudio
 MAN=   ossaudio.3
 
-SRCS=  ossaudio.c
+SRCS=  ossaudio.c aucat.c debug.c sioctl.c sioctl_aucat.c sioctl_sun.c
 
 CPPFLAGS+= -I${.CURDIR}
+
+.PATH: ${.CURDIR}/../libsndio
 
 includes:
@cd ${.CURDIR}; cmp -s soundcard.h ${DESTDIR}/usr/include/soundcard.h 
|| \
Index: lib/libossaudio/ossaudio.c
===
RCS file: /cvs/src/lib/libossaudio/ossaudio.c,v
retrieving revision 1.20
diff -u -p -u -p -r1.20 ossaudio.c
--- lib/libossaudio/ossaudio.c  28 Jun 2019 13:32:42 -  1.20
+++ lib/libossaudio/ossaudio.c  8 Feb 2020 14:49:55 -
@@ -36,26 +36,41 @@
 #include 
 #include 
 #include 
-#include 
-#include 
 #include 
-
+#include 
+#include 
+#include 
+#include 
 #include "soundcard.h"
-#undef ioctl
+
+#ifdef DEBUG
+#define DPRINTF(...) do { fprintf(stderr, __VA_ARGS__); } while (0)
+#else
+#define DPRINTF(...) do {} while (0)
+#endif
 
 #define GET_DEV(com) ((com) & 0xff)
 
-#define TO_OSSVOL(x)   (((x) * 100 + 127) / 255)
-#define FROM_OSSVOL(x) x) > 100 ? 100 : (x)) * 255 + 50) / 100)
+#define TO_OSSVOL(x)   (((x) * 100 + SIOCTL_VALMAX / 2) / SIOCTL_VALMAX)
+#define FROM_OSSVOL(x) x) > 100 ? 100 : (x)) * SIOCTL_VALMAX + 50) / 100)
 
-static struct audiodevinfo *getdevinfo(int);
+#define INTARG (*(int*)argp)
+
+struct control {
+   struct control *next;
+   int type;   /* one of SOUND_MIXER_xxx */
+   int chan;   /* 0 -> left, 1 -> right, -1 -> mono */
+   int addr;   /* sioctl control id */
+   int value;  /* current value */
+};
 
 static int mixer_ioctl(int, unsigned long, void *);
-static int opaque_to_enum(struct audiodevinfo *di, audio_mixer_name_t *label, 
int opq);
-static int enum_to_ord(struct audiodevinfo *di, int enm);
-static int enum_to_mask(struct audiodevinfo *di, int enm);
 
-#define INTARG (*(int*)argp)
+static int initialized;
+static struct control *controls;
+static struct sioctl_hdl *hdl;
+static char *dev_name = SIOCTL_DEVANY;
+static struct pollfd *pfds;
 
 int
 _oss_ioctl(int fd, unsigned long com, ...)
@@ -71,201 +86,162 @@ _oss_ioctl(int fd, unsigned long com, ..
else if (IOCGROUP(com) == 'M')
return mixer_ioctl(fd, com, argp);
else
-   return ioctl(fd, com, argp);
+   return (ioctl)(fd, com, argp);
 }
 
-/* If the mixer device should have more than MAX_MIXER_DEVS devices
- * some will not be available to Linux */
-#define MAX_MIXER_DEVS 64
-struct audiodevinfo {
-   int done;
-   dev_t dev;
-   ino_t ino;
-   int16_t devmap[SOUND_MIXER_NRDEVICES],
-   rdevmap[MAX_MIXER_DEVS];
-   char names[MAX_MIXER_DEVS][MAX_AUDIO_DEV_LEN];
-   int enum2opaque[MAX_MIXER_DEVS];
-u_long devmask, recmask, stereomask;
-   u_long caps, recsource;
-};
-
-static int
-opaque_to_enum(struct audiodevinfo *di, audio_mixer_name_t *label, int opq)
+/*
+ * new control
+ */
+static void
+mixer_ondesc(void *unused, struct sioctl_desc *d, int val)
 {
-   int i, o;
+   struct control *i, **pi;
+   int type;
 
-   for (i = 0; i < MAX_MIXER_DEVS; i++) {
-   o = di->enum2opaque[i];
-   if (o == opq)
-   break;
-   if (o == -1 && label != NULL &&
-   !strncmp(di->names[i], label->name, sizeof di->names[i])) {
-   di->enum2opaque[i] = opq;
+   if (d == NULL)
+   return;
+
+   /*
+* delete existing control with the same address
+*/
+   for (pi =  (i = *pi) != NULL; pi = >next) {
+   if (d->addr == i->addr) {
+   *pi = i->next;
+   free(i);
break;
}
}
-   if (i >= MAX_MIXER_DEVS)
-   i 

Audio control API, part 2: add new sndioctl(1) utility

2020-02-09 Thread Alexandre Ratchov
Here's a new sndioctl utility similar to mixerctl(1) but using the new
sndio API. Example:

$ sndioctl 
output.level=127
app/aucat0.level=127
app/firefox0.level=127
app/firefox1.level=12
app/midisyn0.level=127
app/mpv0.level=127
app/prog5.level=127
app/prog6.level=127
app/prog7.level=127
hw/input.level=62
hw/input.mute=0
hw/output.level=63
hw/output.mute=0

Configuration parameters that are not exposed by sndiod will be
handled by audioctl(1), including the /etc/mixerctl.conf file at
system startup.

Originally the program was designed to handle modern many-channel
devices by presenting many-channel knobs on a single line; this
feature isn't used yet as the corresponding kernel bits are missing.

Index: usr.bin/Makefile
===
RCS file: /cvs/src/usr.bin/Makefile,v
retrieving revision 1.161
diff -u -p -u -p -r1.161 Makefile
--- usr.bin/Makefile9 Aug 2019 06:18:25 -   1.161
+++ usr.bin/Makefile9 Feb 2020 11:05:02 -
@@ -22,7 +22,7 @@ SUBDIR= apply arch at aucat audioctl awk
pr printenv printf quota radioctl rcs rdist rdistd \
readlink renice rev rpcgen rpcinfo rs rsync rup rusers rwall \
sdiff script sed sendbug shar showmount signify skey \
-   skeyaudit skeyinfo skeyinit sndiod snmp \
+   skeyaudit skeyinfo skeyinit sndioctl sndiod snmp \
sort spell split ssh stat su systat \
tail talk tcpbench tee telnet tftp tic time \
tmux top touch tput tr true tset tsort tty usbhidaction usbhidctl \
Index: usr.bin/sndioctl/Makefile
===
RCS file: usr.bin/sndioctl/Makefile
diff -N usr.bin/sndioctl/Makefile
--- /dev/null   1 Jan 1970 00:00:00 -
+++ usr.bin/sndioctl/Makefile   9 Feb 2020 11:05:02 -
@@ -0,0 +1,5 @@
+#  $OpenBSD$
+
+PROG=  sndioctl
+LDADD+=-lsndio
+.include 
Index: usr.bin/sndioctl/sndioctl.1
===
RCS file: usr.bin/sndioctl/sndioctl.1
diff -N usr.bin/sndioctl/sndioctl.1
--- /dev/null   1 Jan 1970 00:00:00 -
+++ usr.bin/sndioctl/sndioctl.1 9 Feb 2020 11:05:02 -
@@ -0,0 +1,148 @@
+.\" $OpenBSD$
+.\"
+.\" Copyright (c) 2007 Alexandre Ratchov 
+.\"
+.\" 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: April 8 2011 $
+.Dt SNDIOCTL 1
+.Os
+.Sh NAME
+.Nm sndioctl
+.Nd control audio parameters
+.Sh SYNOPSIS
+.Nm
+.Bk -words
+.Op Fl iv
+.Op Fl f Ar device
+.Op Ar command ...
+.Ek
+.Nm
+.Bk -words
+.Fl d
+.Ek
+.Sh DESCRIPTION
+The
+.Nm
+utility can display or change parameters of
+.Xr sndio 7
+audio devices.
+The options are as follows:
+.Bl -tag -width Ds
+.It Fl d
+Dump the raw list of available parameters and exit.
+Useful as a debug tool.
+.It Fl f Ar device
+Use this
+.Xr sndio 7
+audio device.
+.It Fl m
+Monitor and display audio parameters changes.
+.It Fl i
+Display characteristics of requested parameters
+instead of their values.
+.It Fl v
+Enable verbose mode, a.k.a. multi-channel mode.
+By default parameters affecting different channels
+of the same stream are disguised as a single mono
+parameter to hide details that are not essential.
+.El
+.Pp
+If no commands are specified all valid parameters are displayed on
+.Em stdout .
+Unless
+.Fl d ,
+.Fl m ,
+or
+.Fl i
+are used, displayed parameters are valid commands.
+The set of available controls depends on the control device.
+.Pp
+Commands use the following two formats to display and set
+parameters respectively:
+.Pp
+.Dl group/stream[channel].function
+.Dl group/stream[channel].function=value
+.Pp
+On the left-hand side are specified the optional parameter group,
+the affected stream name, and the optional channel number.
+Examples of left-hand side terms:
+.Pp
+.Dl output.level
+.Dl hw/spkr[6].mute
+.Pp
+There are 4 parameter types: switches, numbers, selectors, and vectors.
+.Pp
+Numbers are specified in decimal and follow the same semantics
+as MIDI controllers.
+Values are in the 0..127 range and 64 is the neutral state (if applicable).
+Two-state controls (switches) take either 0 or 1 as value,
+typically corresponding to the
+.Em off
+and
+.Em on
+states respectively.
+.Pp
+If a decimal is prefixed by the plus 

Audio control API, part 1: libsndio, sndiod bits

2020-02-09 Thread Alexandre Ratchov
This diff adds an API to control knobs of audio interfaces. It aims to
address these points:

- allow the controls of modern audio hardware and sndiod software
  volume knobs in a uniform way. Hardware knobs are exposed by sndiod,
  which will be also important from security standpoint: by default
  programs using this API won't need to mess with /dev nodes.

- allow multiple programs to use the controls at the same time without
  the need to continuously scan the controls.

- the API is multi-channel and allows programs to "clump" controls and
  to represent many knobs as a single one. For instance the volume
  knob of a "modern" 10-channel azalia(4) could be represented as a
  single knob. This requires driver changes, not yet there.

- the API allows controls to be dynamically added or removed. This is
  useful to avoid restarting programs when devices are swapped,
  ex. when usb head-sets are used.

For now sndiod exposes only its own controls and the master output and
input volume knobs of the underlying hardware (if any). Other controls
don't seem necessary to expose to regular programs; we can keep things
simple and leave the other controls as configuration parameters set
only once, at system startup.

To ease discussions and review, the diff is split in 4 parts. This
diff is the first of 3 base diffs and 1 ports diff (see next
mails). To test the new code, apply all diffs, for instance:

cd /usr/src
patch -p0 <1.diff
patch -p0 <2.diff
patch -p0 <3.diff
cd /usr/src/include && doas make includes
cd /usr/src/lib/libsndio && make obj && make && doas make install
cd /usr/src/lib/libossaudio && make obj && make && doas make install
cd /usr/src/usr.bin/sndiod && make obj && make && doas make install
cd /usr/src/usr.bin/sndioctl && make obj && make && doas make install
doas rcctl restart sndiod
cd /usr/ports
patch -p0 <4.diff
cd /usr/ports/audio/gqmpeg && make && make install
cd /usr/ports/sysutils/tray-app && make && make install

I'm very interested in any regression. Feedback about the new features
is of course welcome as well.

Enjoy,

Index: include/sndio.h
===
RCS file: /cvs/src/include/sndio.h,v
retrieving revision 1.9
diff -u -p -u -p -r1.9 sndio.h
--- include/sndio.h 20 Dec 2015 11:29:29 -  1.9
+++ include/sndio.h 8 Feb 2020 14:49:37 -
@@ -24,12 +24,20 @@
  */
 #define SIO_DEVANY "default"
 #define MIO_PORTANY"default"
+#define SIOCTL_DEVANY  "default"
+
+/*
+ * limits
+ */
+#define SIOCTL_NAMEMAX 12  /* max name length */
+#define SIOCTL_VALMAX  127 /* max control value */
 
 /*
  * private ``handle'' structure
  */
 struct sio_hdl;
 struct mio_hdl;
+struct sioctl_hdl;
 
 /*
  * parameters of a full-duplex stream
@@ -85,12 +93,39 @@ struct sio_cap {
 #define SIO_XSTRINGS { "ignore", "sync", "error" }
 
 /*
+ * controlled component of the device
+ */
+struct sioctl_node {
+   char name[SIOCTL_NAMEMAX];  /* ex. "spkr" */
+   int unit;   /* optional number or -1 */
+};
+
+/*
+ * description of a control (index, value) pair
+ */
+struct sioctl_desc {
+   unsigned int addr;  /* control address */
+#define SIOCTL_NONE0   /* deleted */
+#define SIOCTL_NUM 2   /* integer in the 0..127 range */
+#define SIOCTL_SW  3   /* on/off switch (0 or 1) */
+#define SIOCTL_VEC 4   /* number, element of vector */
+#define SIOCTL_LIST5   /* switch, element of a list */
+   unsigned int type;  /* one of above */
+   char func[SIOCTL_NAMEMAX];  /* function name, ex. "level" */
+   char group[SIOCTL_NAMEMAX]; /* group this control belongs to */
+   struct sioctl_node node0;   /* affected node */
+   struct sioctl_node node1;   /* dito for SIOCTL_{VEC,LIST} */
+};
+
+/*
  * mode bitmap
  */
 #define SIO_PLAY   1
 #define SIO_REC2
 #define MIO_OUT4
 #define MIO_IN 8
+#define SIOCTL_READ0x100
+#define SIOCTL_WRITE   0x200
 
 /*
  * default bytes per sample for the given bits per sample
@@ -144,10 +179,24 @@ int mio_pollfd(struct mio_hdl *, struct 
 int mio_revents(struct mio_hdl *, struct pollfd *);
 int mio_eof(struct mio_hdl *);
 
+struct sioctl_hdl *sioctl_open(const char *, unsigned int, int);
+void sioctl_close(struct sioctl_hdl *);
+int sioctl_ondesc(struct sioctl_hdl *,
+void (*)(void *, struct sioctl_desc *, int), void *);
+int sioctl_onval(struct sioctl_hdl *,
+void (*)(void *, unsigned int, unsigned int), void *);
+int sioctl_setval(struct sioctl_hdl *, unsigned int, unsigned int);
+int sioctl_nfds(struct sioctl_hdl *);
+int sioctl_pollfd(struct sioctl_hdl *, struct pollfd *, int);
+int sioctl_revents(struct sioctl_hdl *, struct pollfd *);
+int sioctl_eof(struct sioctl_hdl *);
+
 int mio_rmidi_getfd(const char *, unsigned int, int);
 struct mio_hdl *mio_rmidi_fdopen(int, 

Re: mg: fix problems found by gcc 10

2020-02-09 Thread Florian Obser
Anyone? I'll commit this soon if I don't hear back, I don't think this
is contentious.

On Fri, Feb 07, 2020 at 03:59:50PM +0100, Florian Obser wrote:
> Moving from misc to tech.
> 
> This is effectively Ulrich's diff from github with a bit of whitespace 
> shuffling.
> 
> OK?
> 
> diff --git def.h def.h
> index d4f00e84e59..0db023973e0 100644
> --- def.h
> +++ def.h
> @@ -337,7 +337,7 @@ void   ttnowindow(void);
>  void  ttcolor(int);
>  void  ttresize(void);
>  
> -volatile sig_atomic_t winch_flag;
> +extern volatile sig_atomic_t winch_flag;
>  
>  /* ttyio.c */
>  void  ttopen(void);
> @@ -752,11 +752,7 @@ extern char   cinfo[];
>  extern char  *keystrings[];
>  extern char   pat[NPAT];
>  extern char   prompt[];
> -
> -/*
> - * Globals.
> - */
> -int   tceeol;
> -int   tcinsl;
> -int   tcdell;
> -int   rptcount;  /* successive invocation count */
> +extern inttceeol;
> +extern inttcinsl;
> +extern inttcdell;
> +extern intrptcount;  /* successive invocation count */
> diff --git kbd.c kbd.c
> index 06d6c9fcf48..5f9b0a9efa6 100644
> --- kbd.c
> +++ kbd.c
> @@ -26,13 +26,13 @@ char   prompt[PROMPTL] = "", *promptp = prompt;
>  
>  static int mgwrap(PF, int, int);
>  
> -static intuse_metakey = TRUE;
> -static intpushed = FALSE;
> -static intpushedc;
> +static intuse_metakey = TRUE;
> +static intpushed = FALSE;
> +static intpushedc;
>  
>  struct map_element   *ele;
> -
> -struct key key;
> +struct keykey;
> +int   rptcount;
>  
>  /*
>   * Toggle the value of use_metakey
> diff --git tty.c tty.c
> index 0b64c4b5453..c378cb240dd 100644
> --- tty.c
> +++ tty.c
> @@ -45,6 +45,11 @@ static const char  *scroll_fwd;/* How to scroll 
> forward. */
>  
>  static void   winchhandler(int);
>  
> +volatile sig_atomic_t winch_flag;
> +int   tceeol;
> +int   tcinsl;
> +int   tcdell;
> +
>  /* ARGSUSED */
>  static void
>  winchhandler(int sig)
> 
> 
> On Tue, Feb 04, 2020 at 12:51:46AM +0100, Han Boetes wrote:
> > The latest version of gcc is more picky about global variables resulting in
> > this bug report for my portable version of mg:
> >   https://github.com/hboetes/mg/issues/12
> > 
> > To which Ulrich Müller created a pull request which fixed the problem:
> >   https://github.com/hboetes/mg/pull/13/files
> > 
> > Is this worth applying to the upstream branch?
> 
> -- 
> I'm not entirely sure you are real.
> 

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