CVS commit: src/usr.sbin/veriexecgen

2019-08-01 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Thu Aug  1 08:51:52 UTC 2019

Modified Files:
src/usr.sbin/veriexecgen: veriexecgen.c

Log Message:
Move case 'f' to go right after case 'F'.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/veriexecgen/veriexecgen.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/veriexecgen

2019-08-01 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Thu Aug  1 08:51:52 UTC 2019

Modified Files:
src/usr.sbin/veriexecgen: veriexecgen.c

Log Message:
Move case 'f' to go right after case 'F'.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/veriexecgen/veriexecgen.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/veriexecgen/veriexecgen.c
diff -u src/usr.sbin/veriexecgen/veriexecgen.c:1.20 src/usr.sbin/veriexecgen/veriexecgen.c:1.21
--- src/usr.sbin/veriexecgen/veriexecgen.c:1.20	Wed Jul 31 15:02:39 2019
+++ src/usr.sbin/veriexecgen/veriexecgen.c	Thu Aug  1 08:51:52 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: veriexecgen.c,v 1.20 2019/07/31 15:02:39 alnsn Exp $ */
+/* $NetBSD: veriexecgen.c,v 1.21 2019/08/01 08:51:52 alnsn Exp $ */
 
 /*-
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 
 #ifndef lint
 #ifdef __RCSID
-__RCSID("$NetBSD: veriexecgen.c,v 1.20 2019/07/31 15:02:39 alnsn Exp $");
+__RCSID("$NetBSD: veriexecgen.c,v 1.21 2019/08/01 08:51:52 alnsn Exp $");
 #endif
 #endif /* not lint */
 
@@ -468,9 +468,6 @@ main(int argc, char **argv)
 			Fflag = 1;
 			break;
 #endif /* notyet */
-		case 'h':
-			usage();
-			return EXIT_SUCCESS;
 		case 'f':
 			if (strcmp(optarg, "-") == 0) {
 v.from_file = stdin;
@@ -485,6 +482,9 @@ main(int argc, char **argv)
 v.from_filename = strdup(optarg);
 			}
 			break;
+		case 'h':
+			usage();
+			return EXIT_SUCCESS;
 		case 'o':
 			v.dbfile = optarg;
 			break;



CVS commit: src/usr.sbin/veriexecgen

2019-07-31 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Jul 31 21:50:26 UTC 2019

Modified Files:
src/usr.sbin/veriexecgen: veriexecgen.8

Log Message:
Fix punctuation formatting nits.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.sbin/veriexecgen/veriexecgen.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/veriexecgen/veriexecgen.8
diff -u src/usr.sbin/veriexecgen/veriexecgen.8:1.21 src/usr.sbin/veriexecgen/veriexecgen.8:1.22
--- src/usr.sbin/veriexecgen/veriexecgen.8:1.21	Wed Jul 31 15:02:39 2019
+++ src/usr.sbin/veriexecgen/veriexecgen.8	Wed Jul 31 21:50:25 2019
@@ -1,4 +1,4 @@
-.\" $NetBSD: veriexecgen.8,v 1.21 2019/07/31 15:02:39 alnsn Exp $
+.\" $NetBSD: veriexecgen.8,v 1.22 2019/07/31 21:50:25 wiz Exp $
 .\"
 .\" Copyright (c) 2006 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -84,11 +84,11 @@ Multiple uses of this flag can specify m
 .\" Try to guess the correct flags for every file.
 .It Fl f Ar file
 Read files from
-.Ar file,
+.Ar file ,
 or if
 .Ar file
 is "-" read from
-.Ar stdin.
+.Ar stdin .
 .It Fl h
 Display the help screen.
 .It Fl o Ar fingerprintdb



CVS commit: src/usr.sbin/veriexecgen

2019-07-31 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Jul 31 21:50:26 UTC 2019

Modified Files:
src/usr.sbin/veriexecgen: veriexecgen.8

Log Message:
Fix punctuation formatting nits.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.sbin/veriexecgen/veriexecgen.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/veriexecgen

2019-07-31 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Wed Jul 31 15:02:39 UTC 2019

Modified Files:
src/usr.sbin/veriexecgen: veriexecgen.8 veriexecgen.c

Log Message:
Add an option to read entries from a file.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/veriexecgen/veriexecgen.8
cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/veriexecgen/veriexecgen.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/veriexecgen

2019-07-31 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Wed Jul 31 15:02:39 UTC 2019

Modified Files:
src/usr.sbin/veriexecgen: veriexecgen.8 veriexecgen.c

Log Message:
Add an option to read entries from a file.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/veriexecgen/veriexecgen.8
cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/veriexecgen/veriexecgen.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/veriexecgen/veriexecgen.8
diff -u src/usr.sbin/veriexecgen/veriexecgen.8:1.20 src/usr.sbin/veriexecgen/veriexecgen.8:1.21
--- src/usr.sbin/veriexecgen/veriexecgen.8:1.20	Tue Jan  8 01:31:49 2019
+++ src/usr.sbin/veriexecgen/veriexecgen.8	Wed Jul 31 15:02:39 2019
@@ -1,4 +1,4 @@
-.\" $NetBSD: veriexecgen.8,v 1.20 2019/01/08 01:31:49 gutteridge Exp $
+.\" $NetBSD: veriexecgen.8,v 1.21 2019/07/31 15:02:39 alnsn Exp $
 .\"
 .\" Copyright (c) 2006 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd January 8, 2019
+.Dd July 31, 2019
 .Dt VERIEXECGEN 8
 .Os
 .Sh NAME
@@ -37,6 +37,7 @@
 .Nm
 .Op Fl AaDrSTvW
 .Op Fl d Pa dir
+.Op Fl f Pa file
 .Op Fl o Pa fingerprintdb
 .Op Fl p Pa prefix
 .Op Fl t Ar algorithm
@@ -81,6 +82,13 @@ Scan for files in
 Multiple uses of this flag can specify more than one directory.
 .\" .It Fl F
 .\" Try to guess the correct flags for every file.
+.It Fl f Ar file
+Read files from
+.Ar file,
+or if
+.Ar file
+is "-" read from
+.Ar stdin.
 .It Fl h
 Display the help screen.
 .It Fl o Ar fingerprintdb

Index: src/usr.sbin/veriexecgen/veriexecgen.c
diff -u src/usr.sbin/veriexecgen/veriexecgen.c:1.19 src/usr.sbin/veriexecgen/veriexecgen.c:1.20
--- src/usr.sbin/veriexecgen/veriexecgen.c:1.19	Tue Apr 23 22:35:42 2019
+++ src/usr.sbin/veriexecgen/veriexecgen.c	Wed Jul 31 15:02:39 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: veriexecgen.c,v 1.19 2019/04/23 22:35:42 sevan Exp $ */
+/* $NetBSD: veriexecgen.c,v 1.20 2019/07/31 15:02:39 alnsn Exp $ */
 
 /*-
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 
 #ifndef lint
 #ifdef __RCSID
-__RCSID("$NetBSD: veriexecgen.c,v 1.19 2019/04/23 22:35:42 sevan Exp $");
+__RCSID("$NetBSD: veriexecgen.c,v 1.20 2019/07/31 15:02:39 alnsn Exp $");
 #endif
 #endif /* not lint */
 
@@ -84,6 +84,8 @@ typedef struct veriexecgen_t {
 	int	 scan_system_dirs;	/* just scan system directories */
 	int	 verbose;	/* verbosity level */
 	int	 stamp;		/* put a timestamp */
+	FILE	*from_file;	/* read from a file or stdin */
+	char	*from_filename;
 } veriexecgen_t;
 
 /* this struct describes a directory entry to generate a hash for */
@@ -123,7 +125,7 @@ static void
 usage(void)
 {
 	(void)fprintf(stderr,
-	"usage:  %s [-AaDrSTvW] [-d dir] [-o fingerprintdb] [-p prefix]\n"
+	"usage:  %s [-AaDrSTvW] [-d dir] [-f file] [-o fingerprintdb] [-p prefix]\n"
 	"\t\t[-t algorithm]\n"
 	"\t%s [-h]\n", getprogname(), getprogname());
 }
@@ -136,8 +138,15 @@ banner(veriexecgen_t *vp, hash_t *hash_t
 
 	(void)printf("Fingerprinting ");
 
-	for (j = 0; search_path[j] != NULL; j++)
-		(void)printf("%s ", search_path[j]);
+	if (search_path) {
+		for (j = 0; search_path[j] != NULL; j++)
+			(void)printf("%s ", search_path[j]);
+	} else if (vp->from_file == stdin) {
+		(void)printf("files from stdin ");
+	} else {
+		(void)printf("files from %s ",
+			vp->from_filename ? vp->from_filename : "???");
+	}
 
 	(void)printf("(%s) (%s) using %s\n",
 	vp->all_files ? "all files" : "executables only",
@@ -194,7 +203,41 @@ check_dup(char *filename)
 
 /* add a new entry to the list for `file' */
 static void
-add_new_entry(veriexecgen_t *vp, FTSENT *file, hash_t *hash)
+add_new_path_entry(veriexecgen_t *vp, const char *file, hash_t *hash)
+{
+	struct stat sb;
+	struct fentry *e;
+
+	if (stat(file, &sb) == -1) {
+		gripe(vp, "Cannot stat file `%s'", file);
+		return;
+	}
+
+	if (!vp->all_files && !IS_EXEC(sb.st_mode))
+		return;
+
+	e = ecalloc(1UL, sizeof(*e));
+
+	if (realpath(file, e->filename) == NULL) {
+		gripe(vp, "Cannot find absolute path `%s'", file);
+		return;
+	}
+	if (check_dup(e->filename)) {
+		free(e);
+		return;
+	}
+	if ((e->hash_val = do_hash(e->filename, hash)) == NULL) {
+		gripe(vp, "Cannot calculate hash `%s'", e->filename);
+		return;
+	}
+	e->flags = figure_flags(e->filename, sb.st_mode);
+
+	TAILQ_INSERT_TAIL(&fehead, e, f);
+}
+
+/* add a new entry to the list for `file' */
+static void
+add_new_ftsent_entry(veriexecgen_t *vp, FTSENT *file, hash_t *hash)
 {
 	struct fentry *e;
 	struct stat sb;
@@ -263,13 +306,33 @@ walk_dir(veriexecgen_t *vp, char **searc
 strerror(file->fts_errno));
 			}
 		} else {
-			add_new_entry(vp, file, hash);
+			add_new_ftsent_entry(vp, file, hash);
 		}
 	}
 
 	fts_close(fh);
 }
 
+/* read files from `file' */
+static void
+read_fro