Extend description of protected-subnet in iked.conf(5)

2019-02-22 Thread Sevan Janiyan
Hi,
Attached patch adds more details about what protected-subnet's role is
in configuration file, it may be useful for someone unfamiliar with the
terminology used in IKEv2.

Sevan
Index: sbin/iked/iked.conf.5
===
RCS file: /cvs/src/sbin/iked/iked.conf.5,v
retrieving revision 1.53
diff -u -p -u -r1.53 iked.conf.5
--- sbin/iked/iked.conf.5   31 Jan 2018 13:25:55 -  1.53
+++ sbin/iked/iked.conf.5   22 Feb 2019 11:55:15 -
@@ -572,7 +572,12 @@ This option is provided for compatibilit
 .It Ic dhcp-server Ar address
 The address of an internal DHCP server for further configuration.
 .It Ic protected-subnet Ar address/prefix
-The address of the protected subnet within the internal network.
+The address of subnets in prefix notation which destined traffic for should be
+sent over the established tunnel.
+This option can be specified multiple times to compose a series of individual
+routes which are pushed to peers.
+If this option is not specified, the established tunnel is used as a
+default gateway for all traffic by peers.
 .It Ic access-server Ar address
 The address of an internal remote access server.
 .El


Re: minor changes to isakmpd(8)

2019-02-18 Thread Sevan Janiyan


On 18/02/2019 14:35, Sevan Janiyan wrote:
> I've dropped the changes with the exception of
> s/CERTIP/CERTFQDN that is an actual bug and changing the file name to
> indicate a copy.
> 
> If you look at /etc/x509v3.cnf you'll see that for the x509v3_FQDN
> extension, the subjectAltName field is populated using $ENV::CERTFQDN,
> not $ENV::CERTIP

Sorry about the noise, updated diff.


Sevan
Index: sbin/isakmpd/isakmpd.8
===
RCS file: /cvs/src/sbin/isakmpd/isakmpd.8,v
retrieving revision 1.120
diff -u -p -r1.120 isakmpd.8
--- sbin/isakmpd/isakmpd.8  17 Apr 2018 12:13:29 -  1.120
+++ sbin/isakmpd/isakmpd.8  18 Feb 2019 14:45:19 -
@@ -630,14 +630,14 @@ with 10.0.0.1, then run:
-extensions x509v3_IPAddr -out 10.0.0.1.crt
 .Ed
 .Pp
-For a FQDN certificate, replace
-.Dv $ENV::CERTIP
+For an FQDN certificate, replace
+.Dv $ENV::CERTFQDN
 with the hostname and run:
 .Bd -literal -offset indent
 # openssl x509 -req \e
-days 365 -in somehost.somedomain.csr \e
-CA /etc/ssl/ca.crt -CAkey /etc/ssl/private/ca.key \e
-   -CAcreateserial -extfile /etc/ssl/x509v3.cnf \e
+   -CAcreateserial -extfile ~/tmp_x509v3.cnf \e
-extensions x509v3_FQDN -out somehost.somedomain.crt
 .Ed
 .Pp


Re: minor changes to isakmpd(8)

2019-02-18 Thread Sevan Janiyan
Hi Jason,

On 18/02/2019 07:23, Jason McIntyre wrote:
> if you agree with my comments below, could you mail us an updated diff
> and i'll try to prod some folks for oks.

Thanks for taking a look. I've dropped the changes with the exception of
s/CERTIP/CERTFQDN that is an actual bug and changing the file name to
indicate a copy.

If you look at /etc/x509v3.cnf you'll see that for the x509v3_FQDN
extension, the subjectAltName field is populated using $ENV::CERTFQDN,
not $ENV::CERTIP


Sevan
Index: sbin/isakmpd/isakmpd.8
===
RCS file: /cvs/src/sbin/isakmpd/isakmpd.8,v
retrieving revision 1.120
diff -u -p -r1.120 isakmpd.8
--- sbin/isakmpd/isakmpd.8  17 Apr 2018 12:13:29 -  1.120
+++ sbin/isakmpd/isakmpd.8  18 Feb 2019 14:19:42 -
@@ -626,12 +626,12 @@ with 10.0.0.1, then run:
 # openssl x509 -req \e
-days 365 -in 10.0.0.1.csr \e
-CA /etc/ssl/ca.crt -CAkey /etc/ssl/private/ca.key \e
-   -CAcreateserial -extfile /etc/ssl/x509v3.cnf \e
+   -CAcreateserial -extfile ~/tmp_x509v3.cnf \e
-extensions x509v3_IPAddr -out 10.0.0.1.crt
 .Ed
 .Pp
-For a FQDN certificate, replace
-.Dv $ENV::CERTIP
+For an FQDN certificate, replace
+.Dv $ENV::CERTFQDN
 with the hostname and run:
 .Bd -literal -offset indent
 # openssl x509 -req \e


minor changes to isakmpd(8)

2019-02-15 Thread Sevan Janiyan
Use an It tag to label the additional steps referred to at the beginning
of step 2:
"This step, as well as the next one, needs to be done for every peer.
Furthermore the last step will need to be done once for each ID you want
the peer to have"

Change the file name passed to openssl for extfile to indicate cloned
file is used.

For FQDN certificates use change the CERTFQDN field.

Add instructions on how to check the subjectAltName field of a certificate.

s/fashion/convention.


Sevan
Index: sbin/isakmpd/isakmpd.8
===
RCS file: /cvs/src/sbin/isakmpd/isakmpd.8,v
retrieving revision 1.120
diff -u -p -r1.120 isakmpd.8
--- sbin/isakmpd/isakmpd.8  17 Apr 2018 12:13:29 -  1.120
+++ sbin/isakmpd/isakmpd.8  16 Feb 2019 02:27:13 -
@@ -607,6 +607,8 @@ Encoding the ID in the common name is re
 # openssl req -new -key /etc/isakmpd/private/local.key \e
-out /etc/isakmpd/private/10.0.0.1.csr
 .Ed
+.It
+Generate signed certificates from Certificate Signing Requests (CSRs)
 .Pp
 Now take these certificate signing requests to your CA and process
 them as below.
@@ -626,12 +628,12 @@ with 10.0.0.1, then run:
 # openssl x509 -req \e
-days 365 -in 10.0.0.1.csr \e
-CA /etc/ssl/ca.crt -CAkey /etc/ssl/private/ca.key \e
-   -CAcreateserial -extfile /etc/ssl/x509v3.cnf \e
+   -CAcreateserial -extfile ~/tmp_x509v3.cnf \e
-extensions x509v3_IPAddr -out 10.0.0.1.crt
 .Ed
 .Pp
 For a FQDN certificate, replace
-.Dv $ENV::CERTIP
+.Dv $ENV::CERTFQDN
 with the hostname and run:
 .Bd -literal -offset indent
 # openssl x509 -req \e
@@ -651,6 +653,18 @@ in
 A similar setup will be required if
 .Xr isakmpd.conf 5
 is being used instead.
+To verify the
+.Va subjectAltName
+of the certificate matches the
+.Ic srcid
+referenced in
+.Xr ipsec.conf 5
+use:
+.Bd -literal -offset indent
+# openssl x509 -noout -text -in somehost.somedomain.crt
+.Ed
+.It
+Copy certificates into place
 .Pp
 Put the certificate (the file ending in .crt) in
 .Pa /etc/isakmpd/certs/
@@ -721,7 +735,7 @@ has the same mode requirements as
 .Pa isakmpd.conf .
 .It Pa /etc/isakmpd/pubkeys/
 The directory in which trusted public keys are kept.
-The keys must be named in the fashion described above.
+The keys must be named in the convention described above.
 .It Pa /var/run/isakmpd.fifo
 The FIFO used to manually control
 .Nm isakmpd .


DragonFly BSD fingerprint

2017-12-16 Thread Sevan Janiyan
Hello,
Attached patch adds the fingerprints for DragonFly to pf.os. From
http://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/947927fb129de774317974bc923ca1ade3d4cc60:/etc/pf.os

Sevan
Index: etc/pf.os
===
RCS file: /cvs/src/etc/pf.os,v
retrieving revision 1.27
diff -u -p -r1.27 pf.os
--- etc/pf.os   3 Sep 2016 17:08:57 -   1.27
+++ etc/pf.os   16 Dec 2017 07:45:09 -
@@ -317,6 +317,14 @@ S22:64:1:52:M*,N,N,S,N,W0: Linux:2.2:ts:
 16384:64:1:64:M*,N,N,S,N,W6,N,N,T:  OpenBSD:6.1::OpenBSD 6.1
 16384:64:0:64:M*,N,N,S,N,W6,N,N,T:  OpenBSD:6.1:no-df:OpenBSD 6.1 (scrub 
no-df)
 
+# - DragonFly BSD -
+
+57344:64:1:60:M*,N,W0,N,N,T:   DragonFly:1.0:A:DragonFly 1.0A
+57344:64:0:64:M*,N,W0,N,N,S,N,N,T: DragonFly:1.2-1.12::DragonFly 1.2-1.12
+5840:64:1:60:M*,S,T,N,W4:  DragonFly:2.0-2.1::DragonFly 2.0-2.1
+57344:64:0:64:M*,N,W0,N,N,S,N,N,T: DragonFly:2.2-2.3::DragonFly 2.2-2.3
+57344:64:0:64:M*,N,W5,N,N,S,N,N,T: DragonFly:2.4-2.7::DragonFly 2.4-2.7
+
 # - Solaris -
 
 S17:64:1:64:N,W3,N,N,T0,N,N,S,M*:  Solaris:8:RFC1323:Solaris 8 RFC1323


Re: Add HISTORY section to clri(8)

2016-09-12 Thread Sevan Janiyan


On 13/09/2016 01:43, Theo de Raadt wrote:
> I honestly don't see the value these annotations add, especially for
> such tiny commands.

Ok, fair enough.


Sevan



Add HISTORY section to clri(8)

2016-09-12 Thread Sevan Janiyan
Hello,
clri showed up in V6 UNIX
http://minnie.tuhs.org/cgi-bin/utree.pl?file=V6/usr/man/man8/clri.8
Attached patch adds a history section to man page.

Sevan
Index: sbin/clri/clri.8
===
RCS file: /cvs/src/sbin/clri/clri.8,v
retrieving revision 1.13
diff -u -p -u -r1.13 clri.8
--- sbin/clri/clri.86 Aug 2007 19:16:05 -   1.13
+++ sbin/clri/clri.813 Sep 2016 00:31:50 -
@@ -72,6 +72,11 @@ will be able to clean up the resulting m
 .Xr fsck 8 ,
 .Xr fsdb 8 ,
 .Xr ncheck 8
+.Sh HISTORY
+The
+.Nm
+utility first appeared in
+.At v6 .
 .Sh BUGS
 If the file is open, the work of
 .Nm


Re: Drop main() prototype

2016-09-09 Thread Sevan Janiyan


On 05/09/2016 11:05, Marc Espie wrote:
> On Mon, Sep 05, 2016 at 04:04:23AM -0400, Ted Unangst wrote:
>> Sevan Janiyan wrote:
>>> Hello,
>>> Attached patches remove the main() prototype from
>>> src/{sbin,usr.bin,usb.sbin}
>>
>> yes!
> 
> I'm 100% certain I added those prototypes because some version of gcc
> with the appropriate warning flags would flag main as missing a prototype.
> 
> If that era is now gone, I'm all too happy for it to vanish.


Happy to do a build run with the relevant flags, need to fish those out
from history if they do not come to mind after all this time :)


Sevan



usr.bin/fgen/fgen.l - ANSIfy

2016-09-04 Thread Sevan Janiyan
Hello,
Attached patch removes the K style function & main() prototype.


Sevan
Index: usr.bin/fgen/fgen.l
===
RCS file: /cvs/src/usr.bin/fgen/fgen.l,v
retrieving revision 1.12
diff -u -p -r1.12 fgen.l
--- usr.bin/fgen/fgen.l 9 Oct 2015 01:37:07 -   1.12
+++ usr.bin/fgen/fgen.l 5 Sep 2016 02:40:17 -
@@ -297,7 +297,6 @@ int emit(char *);
 int spit(long);
 void sspit(char *);
 int apply_macros(YY_BUFFER_STATE, char *);
-int main(int argc, char *argv[]);
 
 /*
  * Standard FCode names and numbers.  Includes standard
@@ -722,8 +721,7 @@ struct macro macros[] = {
  */
 
 void
-push(val)
-Cell val;
+push(Cell val)
 {
parse_stack[parse_stack_ptr++] = val;
if (parse_stack_ptr >= PSTKSIZ) {
@@ -749,8 +747,7 @@ depth()
  * Insert fcode into dictionary.
  */
 int
-fadd(dict, new)
-struct fcode *dict, *new;
+fadd(struct fcode *dict, struct fcode *new)
 {
int res = strcmp(dict->name, new->name);
 
@@ -792,9 +789,7 @@ struct fcode *dict, *new;
  * Look for a code in the dictionary.
  */
 struct fcode *
-flookup(dict, str)
-struct fcode *dict;
-char *str;
+flookup(struct fcode *dict, char *str)
 {
int res;
if (!dict) return (dict);
@@ -818,8 +813,7 @@ char *str;
  * Insert alias into macros.
  */
 int
-aadd(dict, new)
-   struct macro *dict, *new;
+aadd(struct macro *dict, struct macro *new)
 {
int res = strcmp(dict->name, new->name);
 
@@ -861,9 +855,7 @@ aadd(dict, new)
  * Look for a macro in the aliases.
  */
 struct macro *
-alookup(dict, str)
-struct macro *dict;
-char *str;
+alookup(struct macro *dict, char *str)
 {
int res;
if (!dict) return (dict);
@@ -922,9 +914,7 @@ initdic()
 }
 
 int
-apply_macros(input, str) 
-   YY_BUFFER_STATE input;
-   char *str;
+apply_macros(YY_BUFFER_STATE input, char *str) 
 {
struct macro *xform = alookup(aliases, str);

@@ -941,17 +931,14 @@ apply_macros(input, str) 
 }
 
 void
-usage(me)
-   char *me;
+usage(char *me)
 {
(void)fprintf(stderr, "usage: %s [-d level] [-o outfile] infile\n", me);
exit(1);
 }
 
 int
-main(argc, argv)
-   int argc;
-   char *argv[];
+main(int argc, char *argv[])
 {
int bflag, ch;
FILE *inf;
@@ -1041,8 +1028,7 @@ main(argc, argv)
  */
 
 void
-tokenize(input) 
-   YY_BUFFER_STATE input;
+tokenize(YY_BUFFER_STATE input) 
 {
FILE *inf;
YY_BUFFER_STATE inbuf;
@@ -1992,8 +1978,7 @@ token_err(int lineno, char *infile, char
  * Fcode must be in dictionary.  No alias conversion done.
  */
 int
-emit(str)
-   char *str;
+emit(char *str)
 {
struct fcode *code;
if ((code = flookup( dictionary, str)))
@@ -2016,8 +2001,7 @@ emit(str)
  * non-zero.
  */
 int
-spit(n)
-   long n;
+spit(long n)
 {
int count = 1;
 
@@ -2039,8 +2023,7 @@ spit(n)
  * Spit out an FCode string.
  */
 void
-sspit(s)
-   char *s;
+sspit(char *s)
 {
int len = strlen(s);
 


Drop main() prototype

2016-09-04 Thread Sevan Janiyan
Hello,
Attached patches remove the main() prototype from
src/{sbin,usr.bin,usb.sbin}

Next sweep will be to mark usage() as static __dead.


Sevan
Index: usr.bin/cap_mkdb/cap_mkdb.c
===
RCS file: /cvs/src/usr.bin/cap_mkdb/cap_mkdb.c,v
retrieving revision 1.22
diff -u -p -r1.22 cap_mkdb.c
--- usr.bin/cap_mkdb/cap_mkdb.c 4 Dec 2015 19:15:54 -   1.22
+++ usr.bin/cap_mkdb/cap_mkdb.c 5 Sep 2016 02:22:41 -
@@ -50,7 +50,6 @@ void   db_build(char **);
 voiddounlink(void);
 voidusage(void);
 int igetnext(char **, char **);
-int main(int, char *[]);
 
 DB *capdbp;
 int verbose;
Index: usr.bin/login/login.c
===
RCS file: /cvs/src/usr.bin/login/login.c,v
retrieving revision 1.68
diff -u -p -r1.68 login.c
--- usr.bin/login/login.c   21 Aug 2016 03:26:04 -  1.68
+++ usr.bin/login/login.c   5 Sep 2016 02:22:41 -
@@ -109,7 +109,6 @@ void sighup(int);
 voidsleepexit(int);
 char   *stypeof(char *);
 voidtimedout(int);
-int main(int, char **);
 
 extern int check_failedlogin(uid_t);
 extern void log_failedlogin(uid_t, char *, char *, char *);
Index: usr.bin/m4/main.c
===
RCS file: /cvs/src/usr.bin/m4/main.c,v
retrieving revision 1.86
diff -u -p -r1.86 main.c
--- usr.bin/m4/main.c   3 Nov 2015 16:21:47 -   1.86
+++ usr.bin/m4/main.c   5 Sep 2016 02:22:41 -
@@ -157,8 +157,6 @@ static void reallyputchar(int);
 
 static void enlarge_stack(void);
 
-int main(int, char *[]);
-
 int exit_code = 0;
 
 int
Index: usr.bin/make/main.c
===
RCS file: /cvs/src/usr.bin/make/main.c,v
retrieving revision 1.119
diff -u -p -r1.119 main.c
--- usr.bin/make/main.c 4 Jan 2016 10:59:23 -   1.119
+++ usr.bin/make/main.c 5 Sep 2016 02:22:41 -
@@ -624,7 +624,6 @@ read_all_make_rules(bool noBuiltins, boo
 }
 
 
-int main(int, char **);
 /*-
  * main --
  * The main function, for obvious reasons. Initializes variables
Index: usr.bin/make/regress.c
===
RCS file: /cvs/src/usr.bin/make/regress.c,v
retrieving revision 1.8
diff -u -p -r1.8 regress.c
--- usr.bin/make/regress.c  15 Nov 2015 06:01:39 -  1.8
+++ usr.bin/make/regress.c  5 Sep 2016 02:22:41 -
@@ -33,7 +33,6 @@
 #include "defines.h"
 #include "str.h"
 
-int main(void);
 #define CHECK(s)   \
 do {   \
 printf("%-65s", #s);   \
Index: usr.bin/midiplay/midiplay.c
===
RCS file: /cvs/src/usr.bin/midiplay/midiplay.c,v
retrieving revision 1.18
diff -u -p -r1.18 midiplay.c
--- usr.bin/midiplay/midiplay.c 5 May 2016 09:18:12 -   1.18
+++ usr.bin/midiplay/midiplay.c 5 Sep 2016 02:22:41 -
@@ -86,7 +86,6 @@ u_long getvar(struct track *);
 void playfile(FILE *, char *);
 void playdata(u_char *, u_int, char *);
 void sigalrm(int);
-int main(int argc, char **argv);
 
 extern char *__progname;
 
Index: usr.bin/rdist/rdist.c
===
RCS file: /cvs/src/usr.bin/rdist/rdist.c,v
retrieving revision 1.30
diff -u -p -r1.30 rdist.c
--- usr.bin/rdist/rdist.c   8 Feb 2015 23:40:34 -   1.30
+++ usr.bin/rdist/rdist.c   5 Sep 2016 02:22:42 -
@@ -58,7 +58,6 @@ char *path_remsh = NULL;
 
 static void addhostlist(char *, struct namelist **);
 static void usage(void);
-int main(int, char **, char **);
 
 /*
  * Add a hostname to the host list
Index: usr.bin/rdistd/rdistd.c
===
RCS file: /cvs/src/usr.bin/rdistd/rdistd.c,v
retrieving revision 1.10
diff -u -p -r1.10 rdistd.c
--- usr.bin/rdistd/rdistd.c 8 Feb 2015 23:40:34 -   1.10
+++ usr.bin/rdistd/rdistd.c 5 Sep 2016 02:22:42 -
@@ -35,7 +35,6 @@
 
 #include "server.h"
 
-int main(int, char **, char **);
 static void usage(void);
 
 /*
Index: usr.bin/renice/renice.c
===
RCS file: /cvs/src/usr.bin/renice/renice.c,v
retrieving revision 1.19
diff -u -p -r1.19 renice.c
--- usr.bin/renice/renice.c 22 Oct 2015 07:52:29 -  1.19
+++ usr.bin/renice/renice.c 5 Sep 2016 02:22:42 -
@@ -41,7 +41,6 @@ struct renice_param {
id_t id;
 };
 
-int main(int, char **);
 static int renice(struct renice_param *, struct renice_param *);
 __dead void usage(void);
 
Index: usr.bin/tsort/tsort.c
===
RCS file: /cvs/src/usr.bin/tsort/tsort.c,v
retrieving revision 1.35
diff -u -p -r1.35 tsort.c
--- usr.bin/tsort/tsort.c   5 Jan 2016 16:10:57 -   1.35
+++ usr.bin/tsort/tsort.c   5 Sep 2016 02:22:42 -
@@ -160,8 +160,6 @@ 

Re: Amend history & authors info in bin/expr/expr.1

2016-08-29 Thread Sevan Janiyan
Hi Ingo,

On 27/08/2016 14:40, Ingo Schwarze wrote:
>> -This version was written by
>> +It was largely rewritten by
>>  .An John T. Conklin
>> -in 1994.
>> +in 1993.
> 
> That's outright misleading.  OpenBSD uses Conklin's NetBSD 1.1
> version (written in C in 1994).  NetBSD uses jdolecek@'s NetBSD 1.6
> version (written in yacc(1) in 2000).  Neither uses Conklin's NetBSD
> 1.0 version (written in yacc(1) in 1993).
> 
>   http://cvsweb.netbsd.org/bsdweb.cgi/src/bin/expr/Attic/expr.c


As with real life, if you're looking for something, don't forget to
check the attic!
You're right, in the context of OpenBSD's history it does not make
sense. My findings was on the basis of the history of expr.y which
doesn't apply to OpenBSD. The difference in file extension would've been
another clue that there are further differences to investigate but it
did not click at the time.


Sevan



Adjust HISTORY for src/bin/stty/stty.1

2016-08-18 Thread Sevan Janiyan
Hello,
The 2nd Edition UNIX source is incomplete over at TUHS[1] however there
is a scan of a printed draft copy of the 2nd Edition manual[2], stty
appears to be listed in the table of contents (page 7).

Attached patch amends the HISTORY section of stty(1) to say v2 rather
than v3 and bumps date.


Sevan
[1] http://www.tuhs.org/cgi-bin/utree.pl?file=V2
[2]
http://www.tuhs.org/Archive/PDP-11/Distributions/research/1972_stuff/unix_2nd_edition_manual.pdf
Index: bin/stty/stty.1
===
RCS file: /cvs/src/bin/stty/stty.1,v
retrieving revision 1.46
diff -u -p -r1.46 stty.1
--- bin/stty/stty.1 22 Sep 2015 09:13:25 -  1.46
+++ bin/stty/stty.1 18 Aug 2016 23:17:58 -
@@ -33,7 +33,7 @@
 .\"
 .\" @(#)stty.1 8.5 (Berkeley) 6/1/94
 .\"
-.Dd $Mdocdate: September 22 2015 $
+.Dd $Mdocdate: August 19 2016 $
 .Dt STTY 1
 .Os
 .Sh NAME
@@ -736,4 +736,4 @@ differs.
 A
 .Nm
 command appeared in
-.At v3 .
+.At v2 .


Re: Add / Amend history info for some utilities in /bin

2016-08-18 Thread Sevan Janiyan


On 18/08/2016 06:07, Theo de Raadt wrote:
> It appears the goal here is to be accurate regarding minor amusing
> documentation details.  That's good, the same detailing will reflects
> in code as well.
> 
> Well, then don't send a diff alone.  Provide all the proof.  History
> is complicated and full of gaps.  By providing the full proof, the
> maximum number of reviewers can argue over the gappy data and come to
> a shared conclusion.
> 
> Do supply the original diff though -- if everyone agrees, it will be
> agreed upon that the original judgement was correct, avoiding a fuss.

Understood, will follow up with more detail in subsequent patches.


Sevan



Re: Add / Amend history info for some utilities in /bin

2016-08-14 Thread Sevan Janiyan


On 12/08/2016 05:21, Sevan Janiyan wrote:
> Hello,
> Attached diff adds history sections to chio(1), dd(1), echo(1), pax(1),
> sleep(1) and test(1).
> 
> Corrects the version info in sync(8).
> 
> Ammends kill(1) to note originally the command appeared in section eight.
> 
> Info obtained from the CSRG CD set and hosted copies of man pages at TUHS.
> 
> By the way, should the dates be bumped in the man pages?

While the source and man pages for the 2nd edition UNIX are incomplete,
TUHS has a scan of a draft copy of the manual.
I was able to confirm that echo shipped with v2 & not 3 based on the ToC
from
http://www.tuhs.org/Archive/PDP-11/Distributions/research/1972_stuff/unix_2nd_edition_manual.pdf

New version of patch attached.


Sevan
Index: bin/chio/chio.1
===
RCS file: /cvs/src/bin/chio/chio.1,v
retrieving revision 1.33
diff -u -p -u -r1.33 chio.1
--- bin/chio/chio.1 15 Jan 2015 19:06:31 -  1.33
+++ bin/chio/chio.1 12 Aug 2016 04:11:54 -
@@ -240,6 +240,11 @@ Configure the changer to use picker 2 (t
 .Xr ch 4 ,
 .Xr st 4 ,
 .Xr chio.conf 5
+.Sh HISTORY
+A
+.Nm
+utility appeared in
+.Nx 1.3 .
 .Sh AUTHORS
 The
 .Nm
Index: bin/dd/dd.1
===
RCS file: /cvs/src/bin/dd/dd.1,v
retrieving revision 1.32
diff -u -p -u -r1.32 dd.1
--- bin/dd/dd.1 15 Jan 2015 19:06:31 -  1.32
+++ bin/dd/dd.1 12 Aug 2016 04:11:54 -
@@ -378,3 +378,8 @@ handling
 are all extensions to the
 .St -p1003.1-2008
 specification.
+.Sh HISTORY
+A
+.Nm
+utility appeared in
+.At v1 .
Index: bin/echo/echo.1
===
RCS file: /cvs/src/bin/echo/echo.1,v
retrieving revision 1.22
diff -u -p -u -r1.22 echo.1
--- bin/echo/echo.1 15 Feb 2014 09:57:31 -  1.22
+++ bin/echo/echo.1 12 Aug 2016 04:11:54 -
@@ -98,3 +98,8 @@ though with a different syntax.
 .Pp
 Where portability is paramount, use
 .Xr printf 1 .
+.Sh HISTORY
+An
+.Nm
+utility appeared in
+.At v2 .
Index: bin/kill/kill.1
===
RCS file: /cvs/src/bin/kill/kill.1,v
retrieving revision 1.38
diff -u -p -u -r1.38 kill.1
--- bin/kill/kill.1 16 Jan 2015 21:31:27 -  1.38
+++ bin/kill/kill.1 12 Aug 2016 04:11:54 -
@@ -180,4 +180,5 @@ though with a different syntax.
 A
 .Nm
 command appeared in
-.At v3 .
+.At v3
+in section 8 of the manual.
Index: bin/pax/pax.1
===
RCS file: /cvs/src/bin/pax/pax.1,v
retrieving revision 1.71
diff -u -p -u -r1.71 pax.1
--- bin/pax/pax.1   15 Mar 2015 05:16:56 -  1.71
+++ bin/pax/pax.1   12 Aug 2016 04:11:54 -
@@ -1116,6 +1116,11 @@ additions to the
 flag,
 and the flawed archive handling during list and read operations
 are extensions to that specification.
+.Sh HISTORY
+A
+.Nm
+utility appeared in
+.Bx 4.4 .
 .Sh AUTHORS
 .An Keith Muller
 at the University of California, San Diego.
Index: bin/sleep/sleep.1
===
RCS file: /cvs/src/bin/sleep/sleep.1,v
retrieving revision 1.21
diff -u -p -u -r1.21 sleep.1
--- bin/sleep/sleep.1   27 May 2014 13:50:52 -  1.21
+++ bin/sleep/sleep.1   12 Aug 2016 04:11:54 -
@@ -110,3 +110,8 @@ specification.
 .Pp
 The handling of fractional arguments is provided as an extension to that
 specification.
+.Sh HISTORY
+A
+.Nm
+utility appeared in
+.At v4 .
Index: bin/sync/sync.8
===
RCS file: /cvs/src/bin/sync/sync.8,v
retrieving revision 1.13
diff -u -p -u -r1.13 sync.8
--- bin/sync/sync.8 9 Jan 2016 21:27:28 -   1.13
+++ bin/sync/sync.8 12 Aug 2016 04:11:54 -
@@ -69,4 +69,4 @@ function.
 A
 .Nm
 command appeared in
-.At v6 .
+.At v4 .
Index: bin/test/test.1
===
RCS file: /cvs/src/bin/test/test.1,v
retrieving revision 1.32
diff -u -p -u -r1.32 test.1
--- bin/test/test.1 6 Nov 2015 21:56:46 -   1.32
+++ bin/test/test.1 12 Aug 2016 04:11:54 -
@@ -355,3 +355,8 @@ as part of X/Open System Interfaces and 
 also exists as a built-in to
 .Xr ksh 1 ,
 though with a different syntax.
+.Sh HISTORY
+A
+.Nm
+utility appeared in
+.At v7 .


Add / Amend history info for some utilities in /bin

2016-08-11 Thread Sevan Janiyan
Hello,
Attached diff adds history sections to chio(1), dd(1), echo(1), pax(1),
sleep(1) and test(1).

Corrects the version info in sync(8).

Ammends kill(1) to note originally the command appeared in section eight.

Info obtained from the CSRG CD set and hosted copies of man pages at TUHS.

By the way, should the dates be bumped in the man pages?


Sevan
Index: bin/chio/chio.1
===
RCS file: /cvs/src/bin/chio/chio.1,v
retrieving revision 1.33
diff -u -p -u -r1.33 chio.1
--- bin/chio/chio.1 15 Jan 2015 19:06:31 -  1.33
+++ bin/chio/chio.1 12 Aug 2016 04:11:54 -
@@ -240,6 +240,11 @@ Configure the changer to use picker 2 (t
 .Xr ch 4 ,
 .Xr st 4 ,
 .Xr chio.conf 5
+.Sh HISTORY
+A
+.Nm
+utility appeared in
+.Nx 1.3 .
 .Sh AUTHORS
 The
 .Nm
Index: bin/dd/dd.1
===
RCS file: /cvs/src/bin/dd/dd.1,v
retrieving revision 1.32
diff -u -p -u -r1.32 dd.1
--- bin/dd/dd.1 15 Jan 2015 19:06:31 -  1.32
+++ bin/dd/dd.1 12 Aug 2016 04:11:54 -
@@ -378,3 +378,8 @@ handling
 are all extensions to the
 .St -p1003.1-2008
 specification.
+.Sh HISTORY
+A
+.Nm
+utility appeared in
+.At v1 .
Index: bin/echo/echo.1
===
RCS file: /cvs/src/bin/echo/echo.1,v
retrieving revision 1.22
diff -u -p -u -r1.22 echo.1
--- bin/echo/echo.1 15 Feb 2014 09:57:31 -  1.22
+++ bin/echo/echo.1 12 Aug 2016 04:11:54 -
@@ -98,3 +98,8 @@ though with a different syntax.
 .Pp
 Where portability is paramount, use
 .Xr printf 1 .
+.Sh HISTORY
+An
+.Nm
+utility appeared in
+.At v3 .
Index: bin/kill/kill.1
===
RCS file: /cvs/src/bin/kill/kill.1,v
retrieving revision 1.38
diff -u -p -u -r1.38 kill.1
--- bin/kill/kill.1 16 Jan 2015 21:31:27 -  1.38
+++ bin/kill/kill.1 12 Aug 2016 04:11:54 -
@@ -180,4 +180,5 @@ though with a different syntax.
 A
 .Nm
 command appeared in
-.At v3 .
+.At v3
+in section 8 of the manual.
Index: bin/pax/pax.1
===
RCS file: /cvs/src/bin/pax/pax.1,v
retrieving revision 1.71
diff -u -p -u -r1.71 pax.1
--- bin/pax/pax.1   15 Mar 2015 05:16:56 -  1.71
+++ bin/pax/pax.1   12 Aug 2016 04:11:54 -
@@ -1116,6 +1116,11 @@ additions to the
 flag,
 and the flawed archive handling during list and read operations
 are extensions to that specification.
+.Sh HISTORY
+A
+.Nm
+utility appeared in
+.Bx 4.4 .
 .Sh AUTHORS
 .An Keith Muller
 at the University of California, San Diego.
Index: bin/sleep/sleep.1
===
RCS file: /cvs/src/bin/sleep/sleep.1,v
retrieving revision 1.21
diff -u -p -u -r1.21 sleep.1
--- bin/sleep/sleep.1   27 May 2014 13:50:52 -  1.21
+++ bin/sleep/sleep.1   12 Aug 2016 04:11:54 -
@@ -110,3 +110,8 @@ specification.
 .Pp
 The handling of fractional arguments is provided as an extension to that
 specification.
+.Sh HISTORY
+A
+.Nm
+utility appeared in
+.At v4 .
Index: bin/sync/sync.8
===
RCS file: /cvs/src/bin/sync/sync.8,v
retrieving revision 1.13
diff -u -p -u -r1.13 sync.8
--- bin/sync/sync.8 9 Jan 2016 21:27:28 -   1.13
+++ bin/sync/sync.8 12 Aug 2016 04:11:54 -
@@ -69,4 +69,4 @@ function.
 A
 .Nm
 command appeared in
-.At v6 .
+.At v4 .
Index: bin/test/test.1
===
RCS file: /cvs/src/bin/test/test.1,v
retrieving revision 1.32
diff -u -p -u -r1.32 test.1
--- bin/test/test.1 6 Nov 2015 21:56:46 -   1.32
+++ bin/test/test.1 12 Aug 2016 04:11:54 -
@@ -355,3 +355,8 @@ as part of X/Open System Interfaces and 
 also exists as a built-in to
 .Xr ksh 1 ,
 though with a different syntax.
+.Sh HISTORY
+A
+.Nm
+utility appeared in
+.At v7 .


Re: Amend history info for some utilities in /bin

2016-08-11 Thread Sevan Janiyan
Thanks Ingo, will man.openbsd.org update automatically at some point or 
is it a manual process?



Sevan



Amend history info for some utilities in /bin

2016-08-10 Thread Sevan Janiyan
Hello,
Attached diff corrects the version info utilities first appears in the
man pages of df, ln, ls, ps.

Version information was obtained from TUHS and cat-v.org which host
copies of the man pages.


Sevan
Index: bin/df/df.1
===
RCS file: /cvs/src/bin/df/df.1,v
retrieving revision 1.47
diff -u -p -u -r1.47 df.1
--- bin/df/df.1 17 Mar 2014 21:32:12 -  1.47
+++ bin/df/df.1 10 Aug 2016 19:09:49 -
@@ -176,4 +176,4 @@ specification.
 A
 .Nm
 utility appeared in
-.At v3 .
+.At v1 .
Index: bin/ln/ln.1
===
RCS file: /cvs/src/bin/ln/ln.1,v
retrieving revision 1.32
diff -u -p -u -r1.32 ln.1
--- bin/ln/ln.1 11 Sep 2015 18:58:16 -  1.32
+++ bin/ln/ln.1 10 Aug 2016 19:09:49 -
@@ -220,7 +220,7 @@ are extensions to that specification.
 An
 .Nm
 utility appeared in
-.At v3 .
+.At v1 .
 .Sh CAVEATS
 Since the
 .Ar source
Index: bin/ls/ls.1
===
RCS file: /cvs/src/bin/ls/ls.1,v
retrieving revision 1.76
diff -u -p -u -r1.76 ls.1
--- bin/ls/ls.1 17 Mar 2016 07:18:33 -  1.76
+++ bin/ls/ls.1 10 Aug 2016 19:09:49 -
@@ -514,4 +514,4 @@ specification.
 An
 .Nm
 utility appeared in
-.At v3 .
+.At v1 .
Index: bin/ps/ps.1
===
RCS file: /cvs/src/bin/ps/ps.1,v
retrieving revision 1.106
diff -u -p -u -r1.106 ps.1
--- bin/ps/ps.1 25 Apr 2016 20:34:55 -  1.106
+++ bin/ps/ps.1 10 Aug 2016 19:09:49 -
@@ -638,7 +638,7 @@ and
 A
 .Nm
 command appeared in
-.At v3
+.At v4
 in section 8 of the manual.
 .Sh CAVEATS
 When printing using the


patch to bin/cat/cat.c to align output between -be & -ne

2016-06-26 Thread Sevan Janiyan
Hello,
The attached patch amends bin/cat/cat.c so the output is the same aside
from blank lines being numbered or unnumbered, depending on whether cat
was invoked with -ne or -be.

At present, when cat is invoked with -be, there is an aditional
difference that the '$' on blank lines is placed on the far left of the
script.

The patch originates from r1.17 of bin/cat/cat.c from NetBSD.

Following from that there is the addition of a regress test to check for
this issue.

The regress changes also includes a test previously mentioned here[1]
for the fix applied in r1.13 of OpenBSD bin/cat/cat.c.


[1] http://marc.info/?l=openbsd-tech=146665028627169=2


Regards


Sevan Janiyan
Index: cat.c
===
RCS file: /cvs/src/bin/cat/cat.c,v
retrieving revision 1.24
diff -u -p -u -r1.24 cat.c
--- bin/cat/cat.c   4 Nov 2015 21:28:01 -   1.24
+++ bin/cat/cat.c   27 Jun 2016 00:27:47 -
@@ -153,10 +153,16 @@ cook_buf(FILE *fp)
} else
gobble = 0;
}
-   if (nflag && (!bflag || ch != '\n')) {
-   (void)fprintf(stdout, "%6d\t", ++line);
-   if (ferror(stdout))
-   break;
+   if (nflag) {
+   if (!bflag || ch != '\n') {
+   (void)fprintf(stdout, "%6d\t", ++line);
+   if (ferror(stdout))
+   break;
+   } else if (eflag) {
+   (void)fprintf(stdout, "%6s\t", "");
+   if (ferror(stdout))
+   break;
+   }
}
}
if (ch == '\n') {
Index: regress/bin/Makefile
===
RCS file: /cvs/src/regress/bin/Makefile,v
retrieving revision 1.9
diff -u -p -u -r1.9 Makefile
--- regress/bin/Makefile15 Jun 2015 09:25:22 -  1.9
+++ regress/bin/Makefile27 Jun 2016 00:37:19 -
@@ -1,6 +1,6 @@
 #  $OpenBSD: Makefile,v 1.9 2015/06/15 09:25:22 florian Exp $
 
-SUBDIR+= chmod ksh ln md5 pax ps systrace test
+SUBDIR+= cat chmod ksh ln md5 pax ps systrace test
 
 install:
 
Index: regress/bin/cat/Makefile
===
RCS file: regress/bin/cat/Makefile
diff -N regress/bin/cat/Makefile
--- /dev/null   1 Jan 1970 00:00:00 -
+++ regress/bin/cat/Makefile27 Jun 2016 00:37:19 -
@@ -0,0 +1,11 @@
+# $OpenBSD$
+
+REGRESS_TARGETS=cat_be cat_se
+
+cat_be:
+   cat -be ${.CURDIR}/cat_be.in | cmp -s ${.CURDIR}/cat_be.out /dev/stdin
+
+cat_se:
+   cat -se ${.CURDIR}/cat_se.in | cmp -s ${.CURDIR}/cat_se.out /dev/stdin
+
+.include 
Index: regress/bin/cat/cat_be.in
===
RCS file: regress/bin/cat/cat_be.in
diff -N regress/bin/cat/cat_be.in
--- /dev/null   1 Jan 1970 00:00:00 -
+++ regress/bin/cat/cat_be.in   27 Jun 2016 00:37:19 -
@@ -0,0 +1,5 @@
+free,
+
+functional
+
+and secure
Index: regress/bin/cat/cat_be.out
===
RCS file: regress/bin/cat/cat_be.out
diff -N regress/bin/cat/cat_be.out
--- /dev/null   1 Jan 1970 00:00:00 -
+++ regress/bin/cat/cat_be.out  27 Jun 2016 00:37:19 -
@@ -0,0 +1,5 @@
+ 1 free,$
+   $
+ 2 functional$
+   $
+ 3 and secure$
Index: regress/bin/cat/cat_se.in
===
RCS file: regress/bin/cat/cat_se.in
diff -N regress/bin/cat/cat_se.in
--- /dev/null   1 Jan 1970 00:00:00 -
+++ regress/bin/cat/cat_se.in   27 Jun 2016 00:37:19 -
@@ -0,0 +1,3 @@
+
+Free, functional and secure
+
Index: regress/bin/cat/cat_se.out
===
RCS file: regress/bin/cat/cat_se.out
diff -N regress/bin/cat/cat_se.out
--- /dev/null   1 Jan 1970 00:00:00 -
+++ regress/bin/cat/cat_se.out  27 Jun 2016 00:37:19 -
@@ -0,0 +1,3 @@
+$
+Free, functional and secure$
+$


unit test for fix included in r1.13 of bin/cat/cat.c

2016-06-22 Thread Sevan Janiyan
Hello,
The patch below adds a regress test to check the behaviour of cat when
invoked with the flags '-se' to ensure blank lines contain a dollar sign.
The attached patch reverts the fix from r1.13 on the latest version of
cat which allowed me to perform a comparison test.

This fix was committed to the tree over 14 years ago, I understand if
it's not of interest, I benefited from putting together the test.


Sevan Janiyan

Index: regress/bin/Makefile
===
RCS file: /cvs/src/regress/bin/Makefile,v
retrieving revision 1.9
diff -u -p -u -r1.9 Makefile
--- regress/bin/Makefile15 Jun 2015 09:25:22 -  1.9
+++ regress/bin/Makefile23 Jun 2016 02:43:46 -
@@ -1,6 +1,6 @@
 #  $OpenBSD: Makefile,v 1.9 2015/06/15 09:25:22 florian Exp $

-SUBDIR+= chmod ksh ln md5 pax ps systrace test
+SUBDIR+= cat chmod ksh ln md5 pax ps systrace test

 install:

Index: regress/bin/cat/Makefile
===
RCS file: regress/bin/cat/Makefile
diff -N regress/bin/cat/Makefile
--- /dev/null   1 Jan 1970 00:00:00 -
+++ regress/bin/cat/Makefile23 Jun 2016 02:43:46 -
@@ -0,0 +1,8 @@
+# $OpenBSD$
+
+REGRESS_TARGETS=cat_se
+
+cat_se:
+   cat -se ${.CURDIR}/cat_se.in | cmp -s ${.CURDIR}/cat_se.out /dev/stdin
+
+.include 
Index: regress/bin/cat/cat_se.in
===
RCS file: regress/bin/cat/cat_se.in
diff -N regress/bin/cat/cat_se.in
--- /dev/null   1 Jan 1970 00:00:00 -
+++ regress/bin/cat/cat_se.in   23 Jun 2016 02:43:46 -
@@ -0,0 +1,3 @@
+
+Free, functional and secure
+
Index: regress/bin/cat/cat_se.out
===
RCS file: regress/bin/cat/cat_se.out
diff -N regress/bin/cat/cat_se.out
--- /dev/null   1 Jan 1970 00:00:00 -
+++ regress/bin/cat/cat_se.out  23 Jun 2016 02:43:46 -
@@ -0,0 +1,3 @@
+$
+Free, functional and secure$
+$
Index: cat.c
===
RCS file: /cvs/src/bin/cat/cat.c,v
retrieving revision 1.24
diff -u -p -u -r1.24 cat.c
--- cat.c   4 Nov 2015 21:28:01 -   1.24
+++ cat.c   23 Jun 2016 02:35:15 -
@@ -145,23 +145,29 @@ cook_buf(FILE *fp)
line = gobble = 0;
for (prev = '\n'; (ch = getc(fp)) != EOF; prev = ch) {
if (prev == '\n') {
-   if (sflag) {
-   if (ch == '\n') {
-   if (gobble)
-   continue;
+   if (ch == '\n') {
+   if (sflag) {
+   if (!gobble && putchar(ch) == EOF)
+   break;
gobble = 1;
-   } else
-   gobble = 0;
-   }
-   if (nflag && (!bflag || ch != '\n')) {
+   continue;
+   }
+   if (nflag && !bflag) {
+   (void)fprintf(stdout, "%6d\t", ++line);
+   if (ferror(stdout))
+   break;
+   }
+   } else if (nflag) {
(void)fprintf(stdout, "%6d\t", ++line);
if (ferror(stdout))
break;
}
}
+   gobble = 0;
if (ch == '\n') {
-   if (eflag && putchar('$') == EOF)
-   break;
+   if (eflag)
+   if (putchar('$') == EOF)
+   break;
} else if (ch == '\t') {
if (tflag) {
if (putchar('^') == EOF || putchar('I') == EOF)


eradicate "fat diminisher system" in spamd.conf(5)

2016-05-31 Thread Sevan Janiyan
Hello,
spews.org which is referenced in spamd.conf(5) is dead & now redirects
to a dieting system.
Attached diff swaps the spews reference in the man page to nixspam list
actually found in spamd.conf

Second diff removes the pointer to spamlinks.net which is also dead.


Sevan
Index: etc/mail/spamd.conf
===
RCS file: /cvs/src/etc/mail/spamd.conf,v
retrieving revision 1.7
diff -u -p -u -r1.7 spamd.conf
--- etc/mail/spamd.conf 11 May 2016 06:33:48 -  1.7
+++ etc/mail/spamd.conf 31 May 2016 16:02:37 -
@@ -13,8 +13,6 @@
 # Lists specified with the :white: capability apply to the previous
 # list with a :black: capability.
 #
-# As of November 2004, a place to search for blacklists is
-# http://spamlinks.net/filter-bl.htm
 
 all:\
:nixspam:
Index: share/man/man5/spamd.conf.5
===
RCS file: /cvs/src/share/man/man5/spamd.conf.5,v
retrieving revision 1.15
diff -u -p -r1.15 spamd.conf.5
--- share/man/man5/spamd.conf.5 14 Sep 2015 20:06:59 -  1.15
+++ share/man/man5/spamd.conf.5 31 May 2016 16:06:25 -
@@ -53,14 +53,14 @@ follows the syntax of configuration data
 Here is an example:
 .Bd -literal -offset indent
 all:\e
-   :spews1:override:myblack:
+   :nixspam:override:myblack:
 
-spews1:\e
+nixspam:\e
:black:\e
-   :msg="SPAM. Your address \&%A is in the spews\e
-   level 1 database\ensee http://www.spews.org/ask.cgi?x=\&%A\en":\e
+   :msg="Your address %A is in the nixspam list\n\
+   See http://www.heise.de/ix/nixspam/dnsbl_en/ for details":\
:method=http:\e
-   :file=www.spews.org/spews_list_level1.txt:
+   :file=www.openbsd.org/spamd/nixspam.gz
 
 override:\e
:white:\e
@@ -90,13 +90,13 @@ The addresses in such a list are removed
 In the above example,
 if an address was present in all three lists,
 blacklists
-.Ar spews1
+.Ar nixspam
 and
 .Ar myblack ,
 as well as the exceptions list
 .Ar override ,
 the address would be removed from list
-.Ar spews1
+.Ar nixspam
 by the subsequent
 .Ar override
 list.
@@ -111,7 +111,7 @@ the following configuration
 would be used instead:
 .Bd -literal -offset indent
 all:\e
-   :spews1:override:myblack:override:
+   :nixspam:override:myblack:override:
 .Ed
 .Pp
 The source of the addresses for lists is


Re: fan control on macppc G5 smu

2016-03-19 Thread Sevan Janiyan

On 18/03/2016 12:02, Martin Pieuchot wrote:

Could you test the diff below and tell me if it also helps?  It is
adapted from a submission from Dominic Marks:
https://marc.info/?l=openbsd-ppc=142836014007157=2


It definitely helps here.
As the kernel works its way through probing various devices, the fans 
slow down gradually but continue to run at a much slower rate.

System is a first gen iMac G5.



Sevan


Before:
[ using 560540 bytes of bsd ELF symbol table ]
console out [NVDA,Display-A] console in [keyboard], using USB
using parent NVDA,Parent:: memaddr a000, size 1000 : consaddr 
a0008000 : ioaddr 9100, size 100: width 1440 linebytes 1536 
height 900 depth 8

Copyright (c) 1982, 1986, 1989, 1991, 1993
The Regents of the University of California.  All rights reserved.
Copyright (c) 1995-2016 OpenBSD. All rights reserved. 
http://www.OpenBSD.org


OpenBSD 5.9 (GENERIC) #913: Fri Feb 26 03:34:07 MST 2016
dera...@macppc.openbsd.org:/usr/src/sys/arch/macppc/compile/GENERIC
real mem = 2147483648 (2048MB)
avail mem = 2055131136 (1959MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root: model PowerMac8,1
cpu0 at mainbus0: 970FX (Revision 0x300): 1800 MHz
mem0 at mainbus0
spdmem0 at mem0: 1GB DDR SDRAM non-parity PC3200CL3.0
spdmem1 at mem0: 1GB DDR SDRAM non-parity PC3200CL3.0
memc0 at mainbus0: u3 rev 0x39
kiic0 at memc0 offset 0xf8001000
iic0 at kiic0
"dart" at memc0 offset 0xf8033000 not configured
"mpic" at memc0 offset 0xf804 not configured
mpcpcibr0 at mainbus0 pci: u3-agp
pci0 at mpcpcibr0 bus 0
pchb0 at pci0 dev 11 function 0 "Apple U3L AGP" rev 0x00
appleagp0 at pchb0
agp0 at appleagp0: aperture at 0x0, size 0x1000
vgafb0 at pci0 dev 16 function 0 "NVIDIA GeForce FX Go 5200" rev 0xa1
wsdisplay0 at vgafb0 mux 1: console (std, vt100 emulation)
wsdisplay0: screen 1-5 added (std, vt100 emulation)
ht0 at mainbus0: u3-ht, 4 devices
pci1 at ht0 bus 0
hpb0 at pci1 dev 1 function 0 "Apple Shasta PCI" rev 0x00: 85 sources
pci2 at hpb0 bus 3
gem0 at pci2 dev 15 function 0 "Apple Shasta GMAC" rev 0x00: irq 40, 
address 00:0d:93:

bmtphy0 at gem0 phy 0: BCM5221 100baseTX PHY, rev. 4
ppb0 at pci1 dev 2 function 0 "Apple Shasta PCI" rev 0x00
pci3 at ppb0 bus 1
macobio0 at pci3 dev 7 function 0 "Apple Shasta" rev 0x00
openpic0 at macobio0 offset 0x4: version 0x4614 feature 7b0302 LE
macgpio0 at macobio0 offset 0x50
"smu-doorbell" at macgpio0 offset 0x12 not configured
"smu-interrupt" at macgpio0 offset 0xd not configured
"programmer-switch" at macgpio0 offset 0xc not configured
"modem-reset" at macgpio0 offset 0x8 not configured
"modem-power" at macgpio0 offset 0x16 not configured
"slewing-done" at macgpio0 offset 0x38 not configured
"amp-mute" at macgpio0 offset 0x30 not configured
"combo-out-sense" at macgpio0 offset 0x29 not configured
"hw-reset" at macgpio0 offset 0x34 not configured
"linein-detect" at macgpio0 offset 0x2a not configured
"lineout-detect" at macgpio0 offset 0x28 not configured
"lineout-mute" at macgpio0 offset 0x2e not configured
"internal-speaker-id" at macgpio0 offset 0x33 not configured
"escc-legacy" at macobio0 offset 0x12000 not configured
zs0 at macobio0 offset 0x13000: irq 23,24
zstty0 at zs0 channel 0
zstty1 at zs0 channel 1
kiic1 at macobio0 offset 0x18000
iic1 at kiic1
onyx0 at macobio0 offset 0x0: irq 28,11,12
"timer" at macobio0 offset 0x15000 not configured
"backlight" at macobio0 offset 0xf300 not configured
audio0 at onyx0
bwi0 at pci3 dev 1 function 0 "Broadcom BCM4306" rev 0x03: irq 60, 
address 00:0a:95:

ohci0 at pci3 dev 11 function 0 "NEC USB" rev 0x43: irq 70, version 1.0
ohci1 at pci3 dev 11 function 1 "NEC USB" rev 0x43: irq 70, version 1.0
ehci0 at pci3 dev 11 function 2 "NEC USB" rev 0x04: irq 70
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 "NEC EHCI root hub" rev 2.00/1.00 addr 1
usb1 at ohci0: USB revision 1.0
uhub1 at usb1 "NEC OHCI root hub" rev 1.00/1.00 addr 1
usb2 at ohci1: USB revision 1.0
uhub2 at usb2 "NEC OHCI root hub" rev 1.00/1.00 addr 1
ppb1 at pci1 dev 3 function 0 "Apple Shasta PCI" rev 0x00
pci4 at ppb1 bus 2
pciide0 at pci4 dev 12 function 0 "ServerWorks K2 SATA" rev 0x00: DMA
pciide0: using irq 10 for native-PCI interrupt
pciide0: port 0: 1.5Gb/s
wd0 at pciide0 channel 0 drive 0: 
wd0: 16-sector PIO, LBA48, 305244MB, 625140335 sectors
wd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 6
pciide0: port 1: PHY offline
kauaiata0 at pci4 dev 13 function 0 "Apple Shasta ATA" rev 0x00
wdc0 at kauaiata0 irq 38: DMA
atapiscsi0 at wdc0 channel 0 drive 0
scsibus1 at atapiscsi0: 2 targets
cd0 at scsibus1 targ 0 lun 0:  ATAPI 
5/cdrom removable

cd0(wdc0:0:0): using PIO mode 4, DMA mode 2, Ultra-DMA mode 4
"Apple Shasta Firewire" rev 0x00 at pci4 dev 14 function 0 not configured
smu0 at mainbus0
iic2 at smu0
lmtemp0 at iic2 addr 0x49: lm75
"smu-pulsar" at iic2 addr 0x6a not configured
uhub3 at uhub0 port 1 "Apple, Inc. Keyboard Hub" rev 2.00/95.15 addr 2
uhidev0 at 

Re: Grammatical changes to httpd.conf(5)

2016-03-08 Thread Sevan Janiyan


On 08/03/2016 07:04, Jason McIntyre wrote:
> i think it's better to submit changes where there is a clear
> improvement, or where we can definitely say what's there now is
> incorrect.

Ok, no worries.


Sevan



Re: Grammatical changes to httpd.conf(5)

2016-03-07 Thread Sevan Janiyan


On 07/03/2016 19:14, Jason McIntyre wrote:
> all of your changes appear to be for the sake of preference, rather than
> that what's there is incorrect. it would be better then to state why you
> think your change is neccessary. i don;t feel any of these changes are
> improvements.
> 
> language is flexible, that's all. i'm not generally in favour of
> changing something just because we can.

Sure thing.
1) An interface is not a type of address, referencing the interface
triggers the system to look up the address associated with the interface.
2) you reference in a particular syntax, not of a particular syntax
3) I agree for the changes in the last paragraph doesn't add anything
but changes style. twice is succinct :)


Regards


Sevan



Grammatical changes to httpd.conf(5)

2016-03-07 Thread Sevan Janiyan
Hi,
Attached diff makes some grammatical adjustments to httpd.conf(5)



Sevan
Index: src/usr.sbin/httpd/httpd.conf.5
===
RCS file: /cvs/src/usr.sbin/httpd/httpd.conf.5,v
retrieving revision 1.68
diff -u -p -u -r1.68 httpd.conf.5
--- src/usr.sbin/httpd/httpd.conf.5 19 Jul 2015 05:17:27 -  1.68
+++ src/usr.sbin/httpd/httpd.conf.5 7 Mar 2016 18:43:12 -
@@ -45,7 +45,7 @@ a host
 .Ar address
 can be specified by IPv4 address, IPv6 address, interface name,
 interface group, or DNS hostname.
-If the address is an interface name,
+If an interface name is referenced,
 .Xr httpd 8
 will look up the first IPv4 address and any other IPv4 and IPv6
 addresses of the specified network interface.
@@ -501,7 +501,7 @@ and
 .Pp
 The
 .Ic types
-section must include one or more lines of the following syntax:
+section must include one or more lines in the following syntax:
 .Bl -tag -width Ds
 .It Ar type/subtype Ar name Op Ar name ...
 Set the media
@@ -517,9 +517,9 @@ Include types definitions from an extern
 .Pa /usr/share/misc/mime.types .
 .El
 .Sh EXAMPLES
-The following example will start one server that is pre-forked two
-times and is listening on all local IP addresses.
-It additionally defines some media types overriding the defaults.
+The following example will start one server that is pre-forked twice
+and is listening on all local IP addresses.
+Additionally, it defines some media types, overriding the defaults.
 .Bd -literal -offset indent
 prefork 2
 


Typo in smtpd.conf(5)

2016-03-06 Thread Sevan Janiyan
Hi,
Attached diff corrects a typo to correspond with the commit message.
s/ca/certificate

http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.sbin/smtpd/smtpd.conf.5?rev=1.142=text/x-cvsweb-markup


Sevan
Index: usr.sbin/smtpd/smtpd.conf.5
===
RCS file: /cvs/src/usr.sbin/smtpd/smtpd.conf.5,v
retrieving revision 1.155
diff -u -p -r1.155 smtpd.conf.5
--- usr.sbin/smtpd/smtpd.conf.5 13 Feb 2016 23:15:00 -  1.155
+++ usr.sbin/smtpd/smtpd.conf.5 7 Mar 2016 01:47:19 -
@@ -577,7 +577,7 @@ bounce-warn 1h, 6h, 2d
 will generate a failure report when an envelope is in the queue for more
 than one hour, six hours and two days.
 The default is 4h.
-.It Ic ca Ar hostname Ic ca Ar cafile
+.It Ic ca Ar hostname Ic certificate Ar cafile
 Associate a custom CA certificate located in
 .Ar cafile
 with


Re: /32 routes don't stick

2016-02-26 Thread Sevan Janiyan


On 26/02/2016 16:53, Sevan Janiyan wrote:
> in my hostname.if I have
> !/sbin/route add -net 192.168.0.1 -netmask 255.255.255.255 -link
> -cloning -iface vio0
> !/sbin/route add default -ifa 10.0.0.1 192.168.0.1
> 
> Which works.

To clarify
192.168.0.1 is the address assigned to my interface

inet 192.168.0.1 255.255.255.255 NONE



Sevan



Re: /32 routes don't stick

2016-02-26 Thread Sevan Janiyan


On 26/02/2016 16:38, Matthieu Herrb wrote:
> hostname.em0:
> 
> inet 92.224.149.DDD/32
> ! route add 91.224.148.0/32 -link -iface em0


in my hostname.if I have
!/sbin/route add -net 192.168.0.1 -netmask 255.255.255.255 -link
-cloning -iface vio0
!/sbin/route add default -ifa 10.0.0.1 192.168.0.1

Which works.


Sevan



Re: Detect more keyboard cases when starting X

2015-12-26 Thread Sevan Janiyan

Hi Anthony,

On 26/12/2015 00:55, Anthony J. Bentley wrote:

As X starts, it will attempt to detect features from the kbd(8)
setting--for example, us.dvorak will enable dvorak in X, and
fr.dvorak will enable French dvorak in X. However, it detects
these features with equality checks, which will fail if multiple
options are set, as in the case of us.dvorak.swapctrlcaps or
fr.dvorak.swapctrlcaps.

Instead of checking for equality, this diff instead checks if the
bits are set. Now us.dvorak.swapctrlcaps and fr.dvorak.swapctrlcaps
work, us.swapctrlcaps.iopener swaps ctrl/caps, and the ones that
already worked (de.nodead, etc) still do.

This was reported on misc@ by "Sevan / Venture37" back in June.


Thanks for looking into it, I'm checking out the Xenocara consolidation 
as I type this. Will test & report back :)



Sevan



Re: Detect more keyboard cases when starting X

2015-12-26 Thread Sevan Janiyan


On 26/12/2015 17:37, Sevan Janiyan wrote:
> Hi Anthony,
> 
> On 26/12/2015 00:55, Anthony J. Bentley wrote:
>> As X starts, it will attempt to detect features from the kbd(8)
>> setting--for example, us.dvorak will enable dvorak in X, and
>> fr.dvorak will enable French dvorak in X. However, it detects
>> these features with equality checks, which will fail if multiple
>> options are set, as in the case of us.dvorak.swapctrlcaps or
>> fr.dvorak.swapctrlcaps.
>>
>> Instead of checking for equality, this diff instead checks if the
>> bits are set. Now us.dvorak.swapctrlcaps and fr.dvorak.swapctrlcaps
>> work, us.swapctrlcaps.iopener swaps ctrl/caps, and the ones that
>> already worked (de.nodead, etc) still do.
>>
>> This was reported on misc@ by "Sevan / Venture37" back in June.
> 
> Thanks for looking into it, I'm checking out the Xenocara consolidation
> as I type this. Will test & report back :)

I checkout xenocara to my home directory on OpenBSD/i386 December 3rd
-current snapshot.
Made the changes in your patch.
As per xenocara/README I ran make bootstrap, obj and build.
The build process, fails with

===> data/xkeyboard-config/rules/compat
touch parts_done
HDR="/home/sme/xenocara/data/xkeyboard-config/rules/../../../dist/xkeyboard-config/rules/HDR"
/bin/sh
/home/sme/xenocara/data/xkeyboard-config/rules/../../../dist/xkeyboard-config/rules/merge.sh
base base.hdr.part base.lists.part  base.lists.base.part
compat/base.lists.part  HDR base.m_k.part  HDR base.l1_k.part  HDR
base.l_k.part  HDR base.o_k.part  HDR base.ml_g.part  HDR base.m_g.part
 HDR compat/base.mlv_s.partbase.mlv_s.part  HDR
compat/base.ml_s.part base.ml_s.part   HDR compat/base.ml1_s.part
 base.ml1_s.part  HDR compat/base.ml1v1_s.part  HDR
compat/base.ml2_s.partbase.ml2_s.part  HDR compat/base.ml3_s.part
 base.ml3_s.part  HDR compat/base.ml4_s.partbase.ml4_s.part  HDR
compat/base.ml2v2_s.part  HDR compat/base.ml3v3_s.part  HDR
compat/base.ml4v4_s.part  HDR base.m_s.part  HDR base.ml_s1.part  HDR
compat/base.lv_c.partHDR compat/base.l1v1_c.part  HDR
compat/base.l2v2_c.part  HDR compat/base.l3v3_c.part  HDR
compat/base.l4v4_c.part  HDR base.ml_c.part  HDR base.ml1_c.part  HDR
base.m_t.part  HDR base.lo_s.part  HDR base.l1o_s.part  HDR
base.l2o_s.part  HDR base.l3o_s.part  HDR base.l4o_s.part  HDR
compat/base.o_s.part base.o_s.part  HDR base.o_c.part  HDR base.o_t.part
cat:
/home/sme/xenocara/data/xkeyboard-config/rules/../../../dist/xkeyboard-config/rules/compat/base.mlv_s.part:
No such file or directory
*** Error 1 in data/xkeyboard-config/rules (Makefile:99 'base')
*** Error 1 in data/xkeyboard-config (:48 'all')
*** Error 1 in data/xkeyboard-config
(/usr/X11R6/share/mk/bsd.xorg.mk:211 'build')
*** Error 1 in data (:48 'build')
*** Error 1 in . (:48 'realbuild')
*** Error 1 in /home/sme/xenocara (Makefile:41 'build')

I haven't ruled out PEBKAC, this is the first time I've attempted to
build xenocara I believe.


Sevan



Permitting the override of MACHINE_ARCH in amd64/param.h

2015-10-12 Thread Sevan Janiyan
Hi,
I was wondering if it would be possible to allow the override the
definition of MACHINE_ARCH /__MACHINE_ARCH in amd64/param.h by wrapping
them around ifndef statement.

Index: sys/arch/amd64/include/param.h
===
RCS file: /cvs/src/sys/arch/amd64/include/param.h,v
retrieving revision 1.22
diff -u -p -u -r1.22 param.h
--- sys/arch/amd64/include/param.h  26 Mar 2013 05:04:10 -  1.22
+++ sys/arch/amd64/include/param.h  12 Oct 2015 15:17:03 -
@@ -45,8 +45,12 @@

 #define_MACHINEamd64
 #defineMACHINE "amd64"
+#ifndef _MACHINE_ARCH
 #define_MACHINE_ARCH   amd64
+#endif
+#ifndef MACHINE_ARCH
 #defineMACHINE_ARCH"amd64"
+#endif
 #defineMID_MACHINE MID_AMD64

 #definePAGE_SHIFT  12

Being able to override is useful in scenarios where you group arch name
variants under a common alias, at the moment using such a mechanism
fails under OpenBSD/amd64 as whatever is passed in during build time is
overwritten by the inclusion of .

Is this viable?

Regards,

Sevan Janiyan



Re: Permitting the override of MACHINE_ARCH in amd64/param.h

2015-10-12 Thread Sevan Janiyan


On 12/10/2015 16:30, Theo de Raadt wrote:
> You have failed to explain the usage case; I don't believe there is
> any scenario where people benefit from more architecture divergence.

As an example, in pkgsrc, CPUs architectures are grouped under a common
alias so they can be addressed once rather than addressing each variant
individually amongst all the supported architectures eg if {OPSYS} ==
"x86_64" rather than {OPSYS} == "x86_64" || {OPSYS} == "amd64"
There are some situations where OpenBSD is specifically accounted for
but if it was possible to override the MACHINE_ARCH definition, it would
not need to be addressed specifically & any such cases could be removed.


Sevan



Re: Permitting the override of MACHINE_ARCH in amd64/param.h

2015-10-12 Thread Sevan Janiyan


On 12/10/2015 17:11, Theo de Raadt wrote:
> You want 10 layers up of high level software, to redefine fields in
> a system .h file -- for an ecosystem that isn't part of OpenBSD at
> all.

OpenBSD is the exception to the rule within the framework, there is no
specific changes needed to the said 10 layers of high level software.
The change also works as intended.

> That is ridiculous.  It isn't going to happen.

Ok, I wont press any further.


Sevan



Re: Permitting the override of MACHINE_ARCH in amd64/param.h

2015-10-12 Thread Sevan Janiyan


On 12/10/2015 18:32, Ted Unangst wrote:
> just don't include or look at param.h.

Looking into doing that now.


Sevan



Re: fixes for coverity warnings to cat(1)

2015-07-29 Thread Sevan Janiyan


On 21/07/2015 00:16, Sevan Janiyan wrote:
 Hi,
 Attached is a diff for a couple of issues raised by coverity, obtained
 from NetBSD src/bin/cat/cat.c r1.53  r1.54
 
From the commit message in NetBSD CVS:
 bin/cat/cat.c 976654 Argument cannot be negative
  (missing check for fileno result, stdout)
 bin/cat/cat.c 976653 Improper use of negative value
  (missing check for fileno result, stdin)
 
 Diff also adds a skip label used by the changes which appeared in NetBSD
 at a different revision in the past.
 
 
 Sevan Janiyan

Just following up on this to check it hadn't been missed due to my bad
timing with the hackathon finishing.



Sevan
From NetBSD
cat.c r1.53 r1.54

Index: bin/cat/cat.c
===
RCS file: /cvs/src/bin/cat/cat.c,v
retrieving revision 1.21
diff -u -r1.21 cat.c
--- bin/cat/cat.c   16 Jan 2015 06:39:28 -  1.21
+++ bin/cat/cat.c   20 Jul 2015 23:08:00 -
@@ -200,15 +200,20 @@
filename = stdin;
do {
if (*argv) {
-   if (!strcmp(*argv, -))
+   if (!strcmp(*argv, -)) {
fd = fileno(stdin);
-   else if ((fd = open(*argv, O_RDONLY, 0))  0) {
+   if (fd  0)
+   goto skip;
+   } else if ((fd = open(*argv, O_RDONLY, 0))  0) {
+skip:
warn(%s, *argv);
rval = 1;
++argv;
continue;
}
filename = *argv++;
+   } else if (fd  0) {
+   err(1, stdin);
}
raw_cat(fd);
if (fd != fileno(stdin))
@@ -226,6 +231,8 @@
struct stat sbuf;
 
wfd = fileno(stdout);
+   if (wfd  0)
+   err(1, stdout);
if (buf == NULL) {
if (fstat(wfd, sbuf))
err(1, stdout);


Re: fixes for coverity warnings to cat(1)

2015-07-29 Thread Sevan Janiyan


On 29/07/2015 23:24, Todd C. Miller wrote:
 I don't really see any need for this diff.

ugh, sorry if I wasted your time, thanks for the explanation.


Sevan



Re: Patch to add -l flag to cat(1)

2015-07-22 Thread Sevan Janiyan
Hi Philip,

On 23/07/2015 00:54, Philip Guenther wrote:
 This is the second time you've sent a patching adding a feature
 without saying *why* the feature should be added.  That's not very
 helpful.

Apologies.

 Your first patch for cat added a feature (-f option) to solve problem
 in NetBSD which had to be solved in a different way in OpenBSD.  As as
 result, we're not adding the -f option to OpenBSD.

The reason that patch was raised was not to fix issues in security(8) in
OpenBSD, I understood it as you came the realisation that you're
vulnerable to the same problem that the NetBSD folks were trying to fix
by adding -f to their cat(1).

 So, what's the story with the -l option?  What change/fix in OpenBSD
 base requires it?

Nothing requires it explicitly, more the question of if having the
ability for cat to set exclusive locks on its stdout so that multiple
calls to the same cat command will cause the the output to be arranged
in sequence is useful.

 (It's not portable, so any portable program should be doing this via a
 more powerful, portable tool, like perl, python, or C.)

Understood.


Sevan



Patch to add -l flag to cat(1)

2015-07-22 Thread Sevan Janiyan
Hi,
Attached patch adds the -l flag to cat
This option causes cat(1) to use fcntl(2) to set an exclusive advisory
lock on stdout. which was used to guarantee orderly writing to file.
Obtained from NetBSD cat.c r1.26


Sevan Janiyan
From NetBSD
cat.c r1.32
cat.1 r1.26

Index: bin/cat/cat.1
===
RCS file: /cvs/src/bin/cat/cat.1,v
retrieving revision 1.34
diff -u -r1.34 cat.1
--- bin/cat/cat.1   15 Jan 2015 19:06:31 -  1.34
+++ bin/cat/cat.1   22 Jul 2015 23:17:57 -
@@ -41,7 +41,7 @@
 .Nd concatenate and print files
 .Sh SYNOPSIS
 .Nm cat
-.Op Fl benstuv
+.Op Fl belnstuv
 .Op Ar
 .Sh DESCRIPTION
 The
@@ -70,6 +70,15 @@
 option and also prints a dollar sign
 .Pq Ql \$
 at the end of each line.
+.It Fl l
+Set an exclusive advisory lock on the standard output file descriptor.
+This lock is set using
+.Xr fcntl 2
+with the
+.Dv F_SETLKW
+command. If the output file is already locked,
+.Nm
+will block until the lock is acquired.
 .It Fl n
 Number the output lines, starting at 1.
 .It Fl s
Index: bin/cat/cat.c
===
RCS file: /cvs/src/bin/cat/cat.c,v
retrieving revision 1.21
diff -u -r1.21 cat.c
--- bin/cat/cat.c   16 Jan 2015 06:39:28 -  1.21
+++ bin/cat/cat.c   22 Jul 2015 23:17:57 -
@@ -50,7 +50,7 @@
 
 extern char *__progname;
 
-int bflag, eflag, nflag, sflag, tflag, vflag;
+int bflag, eflag, lflag, nflag, sflag, tflag, vflag;
 int rval;
 char *filename;
 
@@ -63,10 +63,11 @@
 main(int argc, char *argv[])
 {
int ch;
+   struct flock stdout_lock;
 
setlocale(LC_ALL, );
 
-   while ((ch = getopt(argc, argv, benstuv)) != -1)
+   while ((ch = getopt(argc, argv, belnstuv)) != -1)
switch (ch) {
case 'b':
bflag = nflag = 1;  /* -b implies -n */
@@ -74,6 +75,9 @@
case 'e':
eflag = vflag = 1;  /* -e implies -v */
break;
+   case 'l':
+   lflag = 1;
+   break;
case 'n':
nflag = 1;
break;
@@ -91,11 +95,20 @@
break;
default:
(void)fprintf(stderr,
-   usage: %s [-benstuv] [file ...]\n, __progname);
+   usage: %s [-belnstuv] [file ...]\n, __progname);
exit(1);
/* NOTREACHED */
}
argv += optind;
+
+   if (lflag) {
+   stdout_lock.l_len = 0;
+   stdout_lock.l_start = 0;
+   stdout_lock.l_type = F_WRLCK;
+   stdout_lock.l_whence = SEEK_SET;
+   if (fcntl(STDOUT_FILENO, F_SETLKW, stdout_lock) == -1)
+   err(1, stdout);
+   }
 
if (bflag || eflag || nflag || sflag || tflag || vflag)
cook_args(argv);


fixes for coverity warnings to cat(1)

2015-07-20 Thread Sevan Janiyan
Hi,
Attached is a diff for a couple of issues raised by coverity, obtained
from NetBSD src/bin/cat/cat.c r1.53  r1.54

From the commit message in NetBSD CVS:
bin/cat/cat.c 976654 Argument cannot be negative
 (missing check for fileno result, stdout)
bin/cat/cat.c 976653 Improper use of negative value
 (missing check for fileno result, stdin)

Diff also adds a skip label used by the changes which appeared in NetBSD
at a different revision in the past.


Sevan Janiyan
From NetBSD
cat.c r1.53 r1.54

Index: bin/cat/cat.c
===
RCS file: /cvs/src/bin/cat/cat.c,v
retrieving revision 1.21
diff -u -r1.21 cat.c
--- bin/cat/cat.c   16 Jan 2015 06:39:28 -  1.21
+++ bin/cat/cat.c   20 Jul 2015 23:08:00 -
@@ -200,15 +200,20 @@
filename = stdin;
do {
if (*argv) {
-   if (!strcmp(*argv, -))
+   if (!strcmp(*argv, -)) {
fd = fileno(stdin);
-   else if ((fd = open(*argv, O_RDONLY, 0))  0) {
+   if (fd  0)
+   goto skip;
+   } else if ((fd = open(*argv, O_RDONLY, 0))  0) {
+skip:
warn(%s, *argv);
rval = 1;
++argv;
continue;
}
filename = *argv++;
+   } else if (fd  0) {
+   err(1, stdin);
}
raw_cat(fd);
if (fd != fileno(stdin))
@@ -226,6 +231,8 @@
struct stat sbuf;
 
wfd = fileno(stdout);
+   if (wfd  0)
+   err(1, stdout);
if (buf == NULL) {
if (fstat(wfd, sbuf))
err(1, stdout);


Re: Patch to add -f flag to cat(1)

2015-07-19 Thread Sevan Janiyan


On 18/07/2015 07:40, Philip Guenther wrote:
 You have in mind a place where this would be used?  Where are there
 bugs that this would resolve?

Hi Philip,
I originally thought it was meant to be a performance thing in busy
environments but that's because I'd misinterpreted things due to
O_NONBLOCK flag.
The feature was actually added to ensure whatever cat was meant to be
reading from was indeed a plain file and not another which could block a
process.
Use cat -f to avoid denial of service attacks by people who make
.rhosts files fifos.
http://mail-index.netbsd.org/source-changes/2000/01/14/0069.html

This diff as it stands has 2 flaws:
1) The new flag doesn't actually work as intended because the OpenBSD
fopen(3) doesn't support the f mode.
2) It passes the f flag to fopen by default, I need integrate the
changes from r1.24 which makes it so that the flag is only passed if it
has been specified by the use.

I'm happy to follow up with a new diff, the question is, is the
functionality it provides of interest?


Sevan



Re: Patch to add -f flag to cat(1)

2015-07-19 Thread Sevan Janiyan


On 19/07/2015 16:13, Ted Unangst wrote:
 I could maybe be convinced. However, fopen is the C standard stdio function.
 One reason you may be using stdio is because you want portability, so
 adding nonportable extensions to it seems counter productive.

Understood, I'll leave it as it's not required.

 If you need to know about all sorts of fifos vs sockets vs files, there are a
 variety of posix APIs for that, portable to all posix systems.

Noted :)

Thanks.


Sevan



Patch to add -f flag to cat(1)

2015-07-17 Thread Sevan Janiyan
Hi,
Attached is a patch to add the -f flag to cat(1).
-f ensures that cat is opening a regular file in non blocking mode 
aborts otherwise.
Obtained from NetBSD src/bin/cat/cat.c r1.22  r1.34


Sevan Janiyan
From NetBSD
cat.c r1.22, r1.34
cat.1 r1.18, r1.25

Index: bin/cat/cat.c
===
RCS file: /cvs/src/bin/cat/cat.c,v
retrieving revision 1.21
diff -u -r1.21 cat.c
--- bin/cat/cat.c   16 Jan 2015 06:39:28 -  1.21
+++ bin/cat/cat.c   18 Jul 2015 01:45:14 -
@@ -50,7 +50,7 @@
 
 extern char *__progname;
 
-int bflag, eflag, nflag, sflag, tflag, vflag;
+int bflag, eflag, fflag, nflag, sflag, tflag, vflag;
 int rval;
 char *filename;
 
@@ -66,7 +66,7 @@
 
setlocale(LC_ALL, );
 
-   while ((ch = getopt(argc, argv, benstuv)) != -1)
+   while ((ch = getopt(argc, argv, befnstuv)) != -1)
switch (ch) {
case 'b':
bflag = nflag = 1;  /* -b implies -n */
@@ -74,6 +74,9 @@
case 'e':
eflag = vflag = 1;  /* -e implies -v */
break;
+   case 'f':
+   fflag = 1;
+   break;
case 'n':
nflag = 1;
break;
@@ -91,7 +94,7 @@
break;
default:
(void)fprintf(stderr,
-   usage: %s [-benstuv] [file ...]\n, __progname);
+   usage: %s [-befnstuv] [file ...]\n, __progname);
exit(1);
/* NOTREACHED */
}
@@ -118,7 +121,7 @@
if (*argv) {
if (!strcmp(*argv, -))
fp = stdin;
-   else if ((fp = fopen(*argv, r)) == NULL) {
+   else if ((fp = fopen(*argv, rf)) == NULL) {
warn(%s, *argv);
rval = 1;
++argv;
@@ -202,8 +205,26 @@
if (*argv) {
if (!strcmp(*argv, -))
fd = fileno(stdin);
+   else if (fflag) {
+   struct stat st;
+   fd = open(*argv, O_RDONLY|O_NONBLOCK, 0);
+   if (fd  0)
+   goto skip;
+
+   if (fstat(fd, st) == -1) {
+   close(fd);
+   goto skip;
+   }
+   if (!S_ISREG(st.st_mode)) {
+   close(fd);
+   warnx(%s: not a regular file, *argv);
+   goto skipnomsg;
+   }
+   }
else if ((fd = open(*argv, O_RDONLY, 0))  0) {
+skip:
warn(%s, *argv);
+skipnomsg:
rval = 1;
++argv;
continue;
Index: bin/cat/cat.1
===
RCS file: /cvs/src/bin/cat/cat.1,v
retrieving revision 1.34
diff -u -r1.34 cat.1
--- bin/cat/cat.1   15 Jan 2015 19:06:31 -  1.34
+++ bin/cat/cat.1   18 Jul 2015 02:02:23 -
@@ -33,7 +33,7 @@
 .\
 .\ @(#)cat.1  8.3 (Berkeley) 5/2/95
 .\
-.Dd $Mdocdate: January 15 2015 $
+.Dd $Mdocdate: July 18 2015 $
 .Dt CAT 1
 .Os
 .Sh NAME
@@ -41,7 +41,7 @@
 .Nd concatenate and print files
 .Sh SYNOPSIS
 .Nm cat
-.Op Fl benstuv
+.Op Fl befnstuv
 .Op Ar
 .Sh DESCRIPTION
 The
@@ -70,6 +70,8 @@
 option and also prints a dollar sign
 .Pq Ql \$
 at the end of each line.
+.It Fl f
+Only attempt to display regular files.
 .It Fl n
 Number the output lines, starting at 1.
 .It Fl s