regress locale/check_isw

2015-07-06 Thread Sebastien Marie
Hi,

While working on regress test for locale, I saw check_isw regress test
have same message for isgraph/islower ('6').

Discriminate the both, and renumerate tests.

Comments ? OK ?

Please note the regress test is currently failing. I hope to fix it
soon.

-- 
Sebastien Marie


Index: check_isw.c
===
RCS file: /cvs/src/regress/lib/libc/locale/check_isw/check_isw.c,v
retrieving revision 1.1
diff -u -p -r1.1 check_isw.c
--- check_isw.c 11 Aug 2005 21:57:02 -  1.1
+++ check_isw.c 7 Jul 2015 06:34:47 -
@@ -58,14 +58,14 @@ test1()
check_bool(iscntrl(i), iswcntrl(i), '4');
check_bool(isdigit(i), iswdigit(i), '5');
check_bool(isgraph(i), iswgraph(i), '6');
-   check_bool(islower(i), iswlower(i), '6');
-   check_bool(isprint(i), iswprint(i), '7');
-   check_bool(ispunct(i), iswpunct(i), '8');
-   check_bool(isspace(i), iswspace(i), '9');
-   check_bool(isupper(i), iswupper(i), 'a');
-   check_bool(isxdigit(i), iswxdigit(i), 'b');
-   check_value(tolower(i), towlower(i), 'c');
-   check_value(toupper(i), towupper(i), 'd');
+   check_bool(islower(i), iswlower(i), '7');
+   check_bool(isprint(i), iswprint(i), '8');
+   check_bool(ispunct(i), iswpunct(i), '9');
+   check_bool(isspace(i), iswspace(i), 'a');
+   check_bool(isupper(i), iswupper(i), 'b');
+   check_bool(isxdigit(i), iswxdigit(i), 'c');
+   check_value(tolower(i), towlower(i), 'd');
+   check_value(toupper(i), towupper(i), 'e');
if (i % 8 == 7)
printf("\n");
}
@@ -108,21 +108,21 @@ test2()
check_bool(iscntrl(s[j]), iswcntrl(c), '4');
check_bool(isdigit(s[j]), iswdigit(c), '5');
check_bool(isgraph(s[j]), iswgraph(c), '6');
-   check_bool(islower(s[j]), iswlower(c), '6');
-   check_bool(isprint(s[j]), iswprint(c), '7');
-   check_bool(ispunct(s[j]), iswpunct(c), '8');
-   check_bool(isspace(s[j]), iswspace(c), '9');
-   check_bool(isupper(s[j]), iswupper(c), 'a');
-   check_bool(isxdigit(s[j]), iswxdigit(c), 'b');
+   check_bool(islower(s[j]), iswlower(c), '7');
+   check_bool(isprint(s[j]), iswprint(c), '8');
+   check_bool(ispunct(s[j]), iswpunct(c), '9');
+   check_bool(isspace(s[j]), iswspace(c), 'a');
+   check_bool(isupper(s[j]), iswupper(c), 'b');
+   check_bool(isxdigit(s[j]), iswxdigit(c), 'c');
d = towlower(c);
if (wctomb(buf, d) == 1) {  
-   check_value(tolower(s[j]), buf[0], 'c');
+   check_value(tolower(s[j]), buf[0], 'd');
} else {
bad++;
}
d = towupper(c);
if (wctomb(buf, d) == 1) {  
-   check_value(toupper(s[j]), buf[0], 'c');
+   check_value(toupper(s[j]), buf[0], 'e');
} else {
bad++;
}



Re: unwritable PKG_CACHE directory

2015-07-06 Thread Dale Lindskog
On Mon, 6 Jul 2015, Chris Bennett wrote:

> If you don't have root access, should you really be installing packages?

It is impossible to install packages when you are not root.  pkg_add won't 
let you.

This isn't about installing packages without root access.  This is about 
the -n and -s options, which I often run as a non-root user.  The -n and 
-s options don't actually install packages.



Re: unwritable PKG_CACHE directory

2015-07-06 Thread Chris Bennett
On Mon, Jul 06, 2015 at 07:15:06PM -0600, Dale Lindskog wrote:
> It is discouraged but possible to run pkg_add(1) with -n or -s as a user 
> other than root.  However, if pkg_add(1) does not have write permission to 
> $PKG_CACHE, then unclear error messages are produced.  For example:
> 
> $ ls -ld $PKG_CACHE
> drwxr-xr-x  2 root  wheel  3072 Jul  2 12:13 /var/pkg_cache
> $ pkg_add -vn gcal
> pkg_add should be run as root
> Update candidates: quirks-2.54 -> quirks-2.54
> quirks-2.54 signed on 2015-03-08T12:33:05Z
> Fatal error: Ustar 
> [ftp://ftp.openbsd.org/pub/OpenBSD/5.7/packages/amd64/gcal-3.6.3p0.tgz][?]: 
> Error while reading header
>  at /usr/libdata/perl5/OpenBSD/Ustar.pm line 89.
> 

Fatal error: Ustar, etc
means that the file transfer failed. It happens.
If it happens way too much, make a directory and download all the
packages with something like wget, which tries many times when
connections break. Set that folder as PKG_PATH and
another as PKG_CACHE. export PKG_PATH=/home/dude/packages
export PKG_CACHE=/home/dude/pkg_cache

I do this frequently with gigantic packages such as tex and jdk.

I suggest that you change to using an http server.
If you want to have a writable PKG_CACHE, why not do something simple
like /home/dude/pkg_cache?

If you don't have root access, should you really be installing packages?
Pass the request upwards. There may be valid reasons NOT to install
certain packages. They do not get the full security audit like the base
system.

If you have cut off remote root access for security reasons, get an IP
KVM hooked up for the few times you need root access

Chris Bennett



Re: unwritable PKG_CACHE directory

2015-07-06 Thread Dale Lindskog
On Mon, 6 Jul 2015, Dale Lindskog wrote:

> I confirmed also that Perl's '-w' returns true on a directory even when 
> write permission is completely removed from that directory.

I should have said:

I confirmed also that, *when the Perl program is run by root*, Perl's '-w' 
returns true on a directory even when write permission is completely 
removed from that directory.



Re: unwritable PKG_CACHE directory

2015-07-06 Thread Dale Lindskog
On Tue, 7 Jul 2015, li...@wrant.com wrote:

> > One solution is for pkg_add(1) to silently omit the attempt to copy 
> > the package to an unwritable $PKG_CACHE.
> 
> The end result with the change proposed would be to hide the problem you
> have with permissions for $PKG_CACHE. In the end you will not be
> caching anything.

You will cache every package you install.  You need to be root to install 
a package, and in my test root has write permission even when the write 
bit isn't set.  I confirmed also that Perl's '-w' returns true on a 
directory even when write permission is completely removed from that 
directory.

> Why would your proposed change be the best solution then, when it hides
> the problem, instead of fixing it completely?

It isn't hidden: in my diff, the man page indicates that, for the -n 
option, caching is conditional on the directory being writable by the 
invoker.



Re: unwritable PKG_CACHE directory

2015-07-06 Thread lists
You're right, this most probably needs a fix.

> However, if pkg_add(1) does not have write permission to 
> $PKG_CACHE, then unclear error messages are produced.

So, there is an error which makes you think.

You notice and consider something is not that right, then go to address
the issue.

In the best possible way you can, or plead for help or just fix it
yourself, depending on your perseverance.

> One solution is for pkg_add(1) to silently omit the attempt to copy
> the package to an unwritable $PKG_CACHE.

Probably other solutions exist, some may be better.

Logically you would be setting this variable in the first place to get
the packages cached.

The end result with the change proposed would be to hide the problem you
have with permissions for $PKG_CACHE. In the end you will not be
caching anything.

Why would your proposed change be the best solution then, when it hides
the problem, instead of fixing it completely?

Please see the principle instead of minutia.



unwritable PKG_CACHE directory

2015-07-06 Thread Dale Lindskog
It is discouraged but possible to run pkg_add(1) with -n or -s as a user 
other than root.  However, if pkg_add(1) does not have write permission to 
$PKG_CACHE, then unclear error messages are produced.  For example:

$ ls -ld $PKG_CACHE
drwxr-xr-x  2 root  wheel  3072 Jul  2 12:13 /var/pkg_cache
$ pkg_add -vn gcal
pkg_add should be run as root
Update candidates: quirks-2.54 -> quirks-2.54
quirks-2.54 signed on 2015-03-08T12:33:05Z
Fatal error: Ustar 
[ftp://ftp.openbsd.org/pub/OpenBSD/5.7/packages/amd64/gcal-3.6.3p0.tgz][?]: 
Error while reading header
 at /usr/libdata/perl5/OpenBSD/Ustar.pm line 89.

One solution is for pkg_add(1) to silently omit the attempt to copy the 
package to an unwritable $PKG_CACHE.  Below is a diff that achieves this, 
and modifies pkg_add(1)'s man page accordingly.

Index: pkg_add.1
===
RCS file: /cvs/src/usr.sbin/pkg_add/pkg_add.1,v
retrieving revision 1.132
diff -u -p -r1.132 pkg_add.1
--- pkg_add.1   16 Apr 2015 20:01:39 -  1.132
+++ pkg_add.1   7 Jul 2015 00:51:22 -
@@ -371,7 +371,7 @@ Don't actually install a package, just r
 would be taken if it was.
 Will still copy packages to
 .Ev PKG_CACHE
-if applicable.
+if applicable, and if pkg_add has write permission to that directory.
 .It Fl P Ar type
 Check permissions for distribution, where
 .Ar type
Index: OpenBSD/PackageRepository.pm
===
RCS file: /cvs/src/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm,v
retrieving revision 1.113
diff -u -p -r1.113 PackageRepository.pm
--- OpenBSD/PackageRepository.pm4 Mar 2015 13:55:32 -   1.113
+++ OpenBSD/PackageRepository.pm7 Jul 2015 00:51:22 -
@@ -534,7 +534,7 @@ sub open_pipe
$object->{pid2} = $pid2;
} else {
open STDERR, '>', $object->{errors};
-   if (defined $object->{cache_dir}) {
+   if (defined $object->{cache_dir} and -w $object->{cache_dir}) {
my $pid3 = open(my $in, "-|");
$self->did_it_fork($pid3);
if ($pid3) {



Re: faq/current.html: Mention sudo removal

2015-07-06 Thread Theo de Raadt
> On Sun, Jul 05, 2015 at 05:52:54PM -0600, Theo de Raadt wrote:
> > >Why is sudo being removed from base? It is pretty useful. I imagine many
> > >use sudo
> > 
> > Sorry, we are making room in the tree so that lynx can come back.
> 
> An actual serious answer would make sense at this point, you know...

Marc, cut the BS.  Others, including Todd Miller, have seriously
explained the situation.

There is no need to explain it over, and over, and over again.  As
well there is little point in being trolled by a specific crowd of
users who do not understand the use of pkg_add.



Re: faq/current.html: Mention sudo removal

2015-07-06 Thread Marc Espie
On Sun, Jul 05, 2015 at 05:52:54PM -0600, Theo de Raadt wrote:
> >Why is sudo being removed from base? It is pretty useful. I imagine many
> >use sudo
> 
> Sorry, we are making room in the tree so that lynx can come back.

An actual serious answer would make sense at this point, you know...



syslogd receive over TCP

2015-07-06 Thread Alexander Bluhm
Hi,

This diff allows to send messages over TCP to syslogd.

ok?

bluhm

Index: usr.sbin/syslogd/privsep.c
===
RCS file: /data/mirror/openbsd/cvs/src/usr.sbin/syslogd/privsep.c,v
retrieving revision 1.53
diff -u -p -r1.53 privsep.c
--- usr.sbin/syslogd/privsep.c  6 Jul 2015 16:12:16 -   1.53
+++ usr.sbin/syslogd/privsep.c  6 Jul 2015 17:42:36 -
@@ -182,6 +182,8 @@ priv_init(char *conf, int numeric, int l
close(fd_udp6);
if (fd_bind != -1)
close(fd_bind);
+   if (fd_listen != -1)
+   close(fd_listen);
for (i = 0; i < nunix; i++)
if (fd_unix[i] != -1)
close(fd_unix[i]);
Index: usr.sbin/syslogd/syslogd.8
===
RCS file: /data/mirror/openbsd/cvs/src/usr.sbin/syslogd/syslogd.8,v
retrieving revision 1.36
diff -u -p -r1.36 syslogd.8
--- usr.sbin/syslogd/syslogd.8  30 Jun 2015 12:03:32 -  1.36
+++ usr.sbin/syslogd/syslogd.8  6 Jul 2015 21:31:24 -
@@ -46,6 +46,7 @@
 .Op Fl m Ar mark_interval
 .Op Fl p Ar log_socket
 .Op Fl s Ar reporting_socket
+.Op Fl T Ar listen_address
 .Op Fl U Ar bind_address
 .Ek
 .Sh DESCRIPTION
@@ -112,6 +113,20 @@ Specify path to an
 .Dv AF_LOCAL
 socket for use in reporting logs stored in memory buffers using
 .Xr syslogc 8 .
+.It Fl T Ar listen_address
+Create a TCP listen socket for receiving messages and bind it to
+the specified address.
+There is no well-known port for syslog over TCP, so a port number
+must be specified using the
+.Ar host:port
+syntax.
+IPv6 addresses can be used by surrounding the address portion with
+square brackets
+.Po
+.Ql [\&
+and
+.Ql ]\&
+.Pc .
 .It Fl U Ar bind_address
 Create a UDP socket for receiving messages and bind it to the
 specified address.
Index: usr.sbin/syslogd/syslogd.c
===
RCS file: /data/mirror/openbsd/cvs/src/usr.sbin/syslogd/syslogd.c,v
retrieving revision 1.170
diff -u -p -r1.170 syslogd.c
--- usr.sbin/syslogd/syslogd.c  6 Jul 2015 16:12:16 -   1.170
+++ usr.sbin/syslogd/syslogd.c  6 Jul 2015 18:15:07 -
@@ -60,6 +60,7 @@
 #define MAX_MEMBUF_NAME64  /* Max length of membuf log 
name */
 #define MAX_TCPBUF (256 * 1024)/* Maximum tcp event buffer size */
 #defineMAXSVLINE   120 /* maximum saved line length */
+#define MAXTCP 20  /* maximum incomming connections */
 #define DEFUPRI(LOG_USER|LOG_NOTICE)
 #define DEFSPRI(LOG_KERN|LOG_CRIT)
 #define TIMERINTVL 30  /* interval for checking flush, mark */
@@ -216,7 +217,8 @@ int IncludeHostname = 0;/* include RFC 
 intFamily = PF_UNSPEC; /* protocol family, may disable IPv4 or IPv6 */
 char   *bind_host = NULL;  /* bind UDP receive socket */
 char   *bind_port = NULL;
-
+char   *listen_host = NULL;/* listen on TCP receive socket */
+char   *listen_port = NULL;
 char   *path_ctlsock = NULL;   /* Path to control socket */
 
 struct tls_config *tlsconfig = NULL;
@@ -272,16 +274,30 @@ char  *linebuf;
 int linesize;
 
 int fd_ctlsock, fd_ctlconn, fd_klog, fd_sendsys,
-fd_udp, fd_udp6, fd_bind, fd_unix[MAXUNIX];
+fd_udp, fd_udp6, fd_bind, fd_listen, fd_unix[MAXUNIX];
 struct eventev_ctlaccept, ev_ctlread, ev_ctlwrite, ev_klog, ev_sendsys,
-ev_udp, ev_udp6, ev_bind, ev_unix[MAXUNIX],
+ev_udp, ev_udp6, ev_bind, ev_listen, ev_unix[MAXUNIX],
 ev_hup, ev_int, ev_quit, ev_term, ev_mark;
 
+LIST_HEAD(peer_list, peer) peers;
+struct peer {
+   LIST_ENTRY(peer) p_entry;
+   struct bufferevent  *p_bufev;
+   char*p_peername;
+   char*p_hostname;
+   int  p_fd;
+};
+int peernum = 0;
+char hostname_unknown[] = "???";
+
 voidklog_readcb(int, short, void *);
 voidudp_readcb(int, short, void *);
 voidunix_readcb(int, short, void *);
-int tcp_socket(struct filed *);
+voidtcp_acceptcb(int, short, void *);
 voidtcp_readcb(struct bufferevent *, void *);
+voidtcp_closecb(struct bufferevent *, short, void *);
+int tcp_socket(struct filed *);
+voidtcp_dropcb(struct bufferevent *, void *);
 voidtcp_writecb(struct bufferevent *, void *);
 voidtcp_errorcb(struct bufferevent *, short, void *);
 voidtcp_connectcb(int, short, void *);
@@ -328,7 +344,7 @@ main(int argc, char *argv[])
int  ch, i;
int  lockpipe[2] = { -1, -1}, pair[2], nullfd, fd;
 
-   while ((ch = getopt(argc, argv, "46a:C:dFf:hm:np:s:U:uV")) != -1)
+   while ((ch = getopt(argc, argv, "46a:C:dFf:hm:np:s:T:U:uV")) != -1)
switch (ch) {
case '4':   /* disable IPv6 */

Re: nsd.conf in /etc/changelist

2015-07-06 Thread Tim van der Molen
sven falempin (2015-07-06 22:00 +0200):
> On Mon, Jul 6, 2015 at 2:24 PM, Tim van der Molen  wrote:
> 
> > Ping.
> >
> > Tim van der Molen (2015-05-17 11:42 +0200):
> > > nsd.conf may contain keys, so store its checksum only. Also update the
> > > path to unbound's root.key.
> > >
> > > Index: changelist
> > > ===
> > > RCS file: /cvs/src/etc/changelist,v
> > > retrieving revision 1.103
> > > diff -u -r1.103 changelist
> > > --- changelist2 Oct 2014 09:02:48 -   1.103
> > > +++ changelist17 May 2015 09:26:59 -
> > > @@ -145,8 +145,8 @@
> > >  /var/cron/cron.allow
> > >  /var/cron/cron.deny
> > >  /var/cron/tabs/root
> > > -/var/nsd/etc/nsd.conf
> > > -/var/unbound/etc/root.key
> > > ++/var/nsd/etc/nsd.conf
> > > +/var/unbound/db/root.key
> > >  /var/unbound/etc/unbound.conf
> > >  /var/yp/Makefile.main
> > >  /var/yp/Makefile.yp
> > >
> >
> >
> The + is before the conf not the key

Yes, that is intended. As I wrote, nsd.conf may contain keys, hence it
needs the +.



Re: nsd.conf in /etc/changelist

2015-07-06 Thread sven falempin
On Mon, Jul 6, 2015 at 2:24 PM, Tim van der Molen  wrote:

> Ping.
>
> Tim van der Molen (2015-05-17 11:42 +0200):
> > nsd.conf may contain keys, so store its checksum only. Also update the
> > path to unbound's root.key.
> >
> > Index: changelist
> > ===
> > RCS file: /cvs/src/etc/changelist,v
> > retrieving revision 1.103
> > diff -u -r1.103 changelist
> > --- changelist2 Oct 2014 09:02:48 -   1.103
> > +++ changelist17 May 2015 09:26:59 -
> > @@ -145,8 +145,8 @@
> >  /var/cron/cron.allow
> >  /var/cron/cron.deny
> >  /var/cron/tabs/root
> > -/var/nsd/etc/nsd.conf
> > -/var/unbound/etc/root.key
> > ++/var/nsd/etc/nsd.conf
> > +/var/unbound/db/root.key
> >  /var/unbound/etc/unbound.conf
> >  /var/yp/Makefile.main
> >  /var/yp/Makefile.yp
> >
>
>
The + is before the conf not the key

Index: changelist
===
RCS file: /cvs/src/etc/changelist,v
retrieving revision 1.103
diff -u -r1.103 changelist
--- changelist  2 Oct 2014 09:02:48 -   1.103
+++ changelist  17 May 2015 09:26:59 -
@@ -145,8 +145,8 @@
 /var/cron/cron.allow
 /var/cron/cron.deny
 /var/cron/tabs/root
-/var/nsd/etc/nsd.conf
-/var/unbound/etc/root.key
+/var/nsd/etc/nsd.conf
++/var/unbound/db/root.key
 /var/unbound/etc/unbound.conf
 /var/yp/Makefile.main
 /var/yp/Makefile.yp


btw, this changelist is awesome, why not let package or admin use it more ?


--- ./libexec/security.orig Mon Jul  6 21:41:06 2015
+++ ./libexec/security  Mon Jul  6 21:57:19 2015
@@ -817,8 +817,20 @@
 # List of files that get backed up and checked for any modifications.  Each
 # file is expected to have two backups, /var/backups/file.{current,backup}.
 # Any changes cause the files to rotate.
+sub check_changelists {
+   check_changelist '/etc/changelist';
+   my $dirlist = '/etc/changelist.d';
+   opendir my $inclist, $dirlist;
+   while (readdir $inclist) {
+   check_changelist $dirlist.'/'.$_ if ( /^\w/ );
+   }
+   closedir $inclist;
+}
+
+
+
 sub check_changelist {
-   my $filename = '/etc/changelist';
+   my $filename = $_[0];
-s $filename or return;
nag !(open my $fh, '<', $filename), "open: $filename: $!" and
return;

@@ -917,7 +929,7 @@
 "Output format is:\n\tfilename:\n\t\tcriteria (shouldbe, reallyis)";
 check_mtree;
 $check_title = "Backing up and comparing configuration files.";
-check_changelist;
+check_changelists;
 $check_title = "Checking disklabels of mounted disks:";
 check_disklabels;
 check_pkglist;




-- 
-
() ascii ribbon campaign - against html e-mail
/\


Re: libpciaccess write combining fixes

2015-07-06 Thread Mike Larkin
On Mon, Jul 06, 2015 at 03:14:23PM +0200, Mark Kettenis wrote:
> My recent change in this area weren't quite right.  As a result
> non-kms pci video drivers might not have been working properly on
> various platforms.  I just committed a fix for an issue where on
> i386/amd64 a write combining mapping would be requested even if it
> shouldn't.
> 
> Another issue is that the change broke other platforms that don't
> support write-combining.  Since the define for the magic offset lives
> in , which exists for all platforms, it gets added for
> all platforms.  But  really only makes sense for
> i386/amd64.  So one way to fix the issue is to only include it on
> those platforms.
> 
> Other fixes are possible, like defining MEMRANGE_WC_RANGE to 0 on
> these platforms.  Or not installing this header file at all on other
> platforms.
> 
> opinions? ok?
> 

Looks ok to me. But I'm also ok with not installing it at all on other
platforms (may be easier said than done?)

-ml

> 
> Index: src/openbsd_pci.c
> ===
> RCS file: /cvs/xenocara/lib/libpciaccess/src/openbsd_pci.c,v
> retrieving revision 1.25
> diff -u -p -r1.25 openbsd_pci.c
> --- src/openbsd_pci.c 6 Jul 2015 12:49:35 -   1.25
> +++ src/openbsd_pci.c 6 Jul 2015 12:55:53 -
> @@ -16,7 +16,9 @@
>  
>  #include 
>  #include 
> +#if defined(__i386__) || defined(__amd64__)
>  #include 
> +#endif
>  #include 
>  #include 
>  #include 
> 



Re: nsd.conf in /etc/changelist

2015-07-06 Thread Tim van der Molen
Ping.

Tim van der Molen (2015-05-17 11:42 +0200):
> nsd.conf may contain keys, so store its checksum only. Also update the
> path to unbound's root.key.
> 
> Index: changelist
> ===
> RCS file: /cvs/src/etc/changelist,v
> retrieving revision 1.103
> diff -u -r1.103 changelist
> --- changelist2 Oct 2014 09:02:48 -   1.103
> +++ changelist17 May 2015 09:26:59 -
> @@ -145,8 +145,8 @@
>  /var/cron/cron.allow
>  /var/cron/cron.deny
>  /var/cron/tabs/root
> -/var/nsd/etc/nsd.conf
> -/var/unbound/etc/root.key
> ++/var/nsd/etc/nsd.conf
> +/var/unbound/db/root.key
>  /var/unbound/etc/unbound.conf
>  /var/yp/Makefile.main
>  /var/yp/Makefile.yp
> 



mail.local: don't send an extra NUL byte to comsat

2015-07-06 Thread Todd C. Miller
There's no need to send a NUL byte to comsat, it NUL-terminates the
buffer itself.

 - todd

Index: libexec/mail.local/mail.local.c
===
RCS file: /cvs/src/libexec/mail.local/mail.local.c,v
retrieving revision 1.34
diff -u -p -u -r1.34 mail.local.c
--- libexec/mail.local/mail.local.c 6 Jul 2015 15:02:51 -   1.34
+++ libexec/mail.local/mail.local.c 6 Jul 2015 15:03:55 -
@@ -324,7 +324,7 @@ notifybiff(char *msg)
return;
}
 
-   len = strlen(msg) + 1;  /* XXX */
+   len = strlen(msg);
if (sendto(f, msg, len, 0, res->ai_addr, res->ai_addrlen) != len)
merr(NOTFATAL, "sendto biff: %s", strerror(errno));
 }



comsat: fix botched strtonum() conversion

2015-07-06 Thread Todd C. Miller
The message sent by mail.local ends in a newline so we need to trim
it before calling strtonum().  Also adds some debugging syslogs
that were useful along the way (disabled by default).

 - todd

Index: libexec/comsat/comsat.c
===
RCS file: /cvs/src/libexec/comsat/comsat.c,v
retrieving revision 1.39
diff -u -p -u -r1.39 comsat.c
--- libexec/comsat/comsat.c 18 Apr 2015 18:28:37 -  1.39
+++ libexec/comsat/comsat.c 6 Jul 2015 14:56:23 -
@@ -191,6 +191,7 @@ doreadutmp(void)
}
(void)lseek(uf, 0, SEEK_SET);
nutmp = read(uf, utmp, statbf.st_size)/sizeof(struct utmp);
+   dsyslog(LOG_DEBUG, "read %d utmp entries", nutmp);
}
(void)alarm(15);
 }
@@ -204,15 +205,22 @@ mailfor(char *name)
char *cp;
off_t offset;
 
+   dsyslog(LOG_DEBUG, "mail for '%s'", name);
+   cp = name + strlen(name) - 1;
+   while (cp > name && isspace((unsigned char)*cp))
+   *cp-- = '\0';
if (!(cp = strchr(name, '@')))
return;
*cp = '\0';
offset = strtonum(cp + 1, 0, LLONG_MAX, &errstr);
-   if (errstr)
+   if (errstr) {
+   syslog(LOG_ERR, "'%s' is %s", cp + 1, errstr);
return;
+   }
while (--utp >= utmp) {
memcpy(utname, utp->ut_name, UT_NAMESIZE);
utname[UT_NAMESIZE] = '\0';
+   dsyslog(LOG_DEBUG, "check %s against %s", name, utname);
if (!strncmp(utname, name, UT_NAMESIZE))
notify(utp, offset);
}



mail.local: support IPv6 for biff notification

2015-07-06 Thread Todd C. Miller
Simple conversion to getaddrinfo.  Noticed while debugging a comsat
issue.

 - todd

Index: libexec/mail.local/mail.local.c
===
RCS file: /cvs/src/libexec/mail.local/mail.local.c,v
retrieving revision 1.33
diff -u -p -u -r1.33 mail.local.c
--- libexec/mail.local/mail.local.c 16 Jan 2015 06:39:50 -  1.33
+++ libexec/mail.local/mail.local.c 6 Jul 2015 13:09:00 -
@@ -289,32 +289,43 @@ bad:
 void
 notifybiff(char *msg)
 {
-   static struct sockaddr_in addr;
+   static struct addrinfo *res0;
+   struct addrinfo hints, *res;
static int f = -1;
-   struct hostent *hp;
-   struct servent *sp;
size_t len;
+   int error;
 
-   if (!addr.sin_family) {
-   /* Be silent if biff service not available. */
-   if (!(sp = getservbyname("biff", "udp")))
-   return;
-   if (!(hp = gethostbyname("localhost"))) {
-   merr(NOTFATAL, "localhost: %s", strerror(errno));
+   if (res0 == NULL) {
+   memset(&hints, 0, sizeof(hints));
+   hints.ai_family = PF_UNSPEC;
+   hints.ai_socktype = SOCK_DGRAM;
+
+   error = getaddrinfo("localhost", "biff", &hints, &res0);
+   if (error) {
+   /* Be silent if biff service not available. */
+   if (error != EAI_SERVICE) {
+   merr(NOTFATAL, "localhost: %s",
+   gai_strerror(error));
+   }
return;
}
-   addr.sin_len = sizeof(struct sockaddr_in);
-   addr.sin_family = hp->h_addrtype;
-   addr.sin_port = sp->s_port;
-   bcopy(hp->h_addr, &addr.sin_addr, (size_t)hp->h_length);
}
-   if (f < 0 && (f = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
+
+   if (f == -1) {
+   for (res = res0; res != NULL; res = res->ai_next) {
+   f = socket(res->ai_family, res->ai_socktype,
+   res->ai_protocol);
+   if (f != -1)
+   break;
+   }
+   }
+   if (f == -1) {
merr(NOTFATAL, "socket: %s", strerror(errno));
return;
}
+
len = strlen(msg) + 1;
-   if (sendto(f, msg, len, 0, (struct sockaddr *)&addr, sizeof(addr))
-   != len)
+   if (sendto(f, msg, len, 0, res->ai_addr, res->ai_addrlen) != len)
merr(NOTFATAL, "sendto biff: %s", strerror(errno));
 }
 



libpciaccess write combining fixes

2015-07-06 Thread Mark Kettenis
My recent change in this area weren't quite right.  As a result
non-kms pci video drivers might not have been working properly on
various platforms.  I just committed a fix for an issue where on
i386/amd64 a write combining mapping would be requested even if it
shouldn't.

Another issue is that the change broke other platforms that don't
support write-combining.  Since the define for the magic offset lives
in , which exists for all platforms, it gets added for
all platforms.  But  really only makes sense for
i386/amd64.  So one way to fix the issue is to only include it on
those platforms.

Other fixes are possible, like defining MEMRANGE_WC_RANGE to 0 on
these platforms.  Or not installing this header file at all on other
platforms.

opinions? ok?


Index: src/openbsd_pci.c
===
RCS file: /cvs/xenocara/lib/libpciaccess/src/openbsd_pci.c,v
retrieving revision 1.25
diff -u -p -r1.25 openbsd_pci.c
--- src/openbsd_pci.c   6 Jul 2015 12:49:35 -   1.25
+++ src/openbsd_pci.c   6 Jul 2015 12:55:53 -
@@ -16,7 +16,9 @@
 
 #include 
 #include 
+#if defined(__i386__) || defined(__amd64__)
 #include 
+#endif
 #include 
 #include 
 #include 



[libressl] Improve XMPP protocol support for starttls on s_client

2015-07-06 Thread Landry Breuil
Hi,

i'm not an ssl hacker at all, but while debugging openssl -starttls
issues against an xmpp server, i stumbled upon
https://rt.openssl.org/Ticket/Display.html?id=2860&user=guest&pass=guest
which fixes some issue with -starttls xmpp and adds the possibility to
use -xmpphost in case there's some virtualhost. Backported the patch to
libressl and applied style(9), works fine here in basic testing against
prosody, before -starttls xmpp host was just stalling. I havent touched
the documentation chunks since i dont really know if we still use the
pod format or...

comments/feedback welcome.

Landry
Index: s_client.c
===
RCS file: /cvs/src/usr.bin/openssl/s_client.c,v
retrieving revision 1.13
diff -u -r1.13 s_client.c
--- s_client.c  14 Apr 2015 12:56:36 -  1.13
+++ s_client.c  6 Jul 2015 11:36:07 -
@@ -335,6 +335,7 @@
char *port = PORT_STR;
int full_log = 1;
char *host = SSL_HOST_NAME;
+   char *xmpphost = NULL;
char *proxy = NULL, *connect = NULL;
char *cert_file = NULL, *key_file = NULL;
int cert_format = FORMAT_PEM, key_format = FORMAT_PEM;
@@ -415,6 +416,10 @@
if (--argc < 1)
goto bad;
proxy = *(++argv);
+   } else if (strcmp(*argv,"-xmpphost") == 0) {
+   if (--argc < 1)
+   goto bad;
+   xmpphost= *(++argv);
} else if (strcmp(*argv, "-verify") == 0) {
verify = SSL_VERIFY_PEER;
if (--argc < 1)
@@ -985,13 +990,16 @@
int seen = 0;
BIO_printf(sbio, "", host);
+   "xmlns='jabber:client' to='%s' version='1.0'>", xmpphost? 
xmpphost:host);
seen = BIO_read(sbio, mbuf, BUFSIZZ);
mbuf[seen] = 0;
-   while (!strstr(mbuf, ""))
-   goto shut;
+   while (!strstr(mbuf, "");