Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 7 Jun 2015 12:39:50 GMT
From:      def@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r286778 - soc2013/def/crashdump-head/sbin/savecore
Message-ID:  <201506071239.t57Cdo3e088139@socsvn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: def
Date: Sun Jun  7 12:39:50 2015
New Revision: 286778
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286778

Log:
  Remove encrypted flag and detect an encrypted dump.

Modified:
  soc2013/def/crashdump-head/sbin/savecore/savecore.c

Modified: soc2013/def/crashdump-head/sbin/savecore/savecore.c
==============================================================================
--- soc2013/def/crashdump-head/sbin/savecore/savecore.c	Sun Jun  7 11:38:26 2015	(r286777)
+++ soc2013/def/crashdump-head/sbin/savecore/savecore.c	Sun Jun  7 12:39:50 2015	(r286778)
@@ -90,7 +90,7 @@
 #define	STATUS_GOOD	1
 #define	STATUS_UNKNOWN	2
 
-static int checkfor, compress, clear, encrypted, force, keep, verbose;	/* flags */
+static int checkfor, compress, clear, force, keep, verbose;	/* flags */
 static int nfound, nsaved, nerr;			/* statistics */
 static int maxdumps;
 
@@ -315,8 +315,8 @@
 #define BLOCKMASK (~(BLOCKSIZE-1))
 
 static int
-DoRegularFile(int fd, off_t dumpsize, char *buf, const char *device,
-    const char *filename, FILE *fp)
+DoRegularFile(int fd, bool isencrypted, off_t dumpsize, char *buf,
+    const char *device, const char *filename, FILE *fp)
 {
 	int he, hs, nr, nw, wl;
 	off_t dmpcnt, origsize;
@@ -338,7 +338,7 @@
 			nerr++;
 			return (-1);
 		}
-		if (compress || encrypted) {
+		if (compress || isencrypted) {
 			nw = fwrite(buf, 1, wl, fp);
 		} else {
 			for (nw = 0; nw < nr; nw = he) {
@@ -471,6 +471,7 @@
 	u_int sectorsize, xostyle;
 	int istextdump;
 	uint32_t dumpkeysize;
+	bool isencrypted;
 
 	bounds = getbounds();
 	mediasize = 0;
@@ -705,7 +706,9 @@
 	xo_finish_h(xoinfo);
 	fclose(info);
 
-	if (encrypted) {
+	isencrypted = false;
+	if (dumpkeysize > 0) {
+		isencrypted = true;
 		kdk = (struct kerneldumpkey *)calloc(1, dumpkeysize);
 		if (kdk == NULL) {
 			syslog(LOG_ERR, "Unable to allocate kernel dump key.");
@@ -728,7 +731,7 @@
 	}
 
 	syslog(LOG_NOTICE, "writing %s%score to %s/%s",
-	    encrypted ? "encrypted " : "", compress ? "compressed " : "",
+	    isencrypted ? "encrypted " : "", compress ? "compressed " : "",
 	    savedir, corename);
 
 	if (istextdump) {
@@ -736,9 +739,10 @@
 		    corename, fp) < 0)
 			goto closeall;
 	} else {
-		if (DoRegularFile(fd, dumpsize, buf, device, corename, fp)
-		    < 0)
+		if (DoRegularFile(fd, isencrypted, dumpsize, buf, device,
+		    corename, fp) < 0) {
 			goto closeall;
+		}
 	}
 	if (verbose)
 		printf("\n");
@@ -811,7 +815,7 @@
 	struct fstab *fsp;
 	int i, ch, error;
 
-	checkfor = compress = clear = encrypted = force = keep = verbose = 0;
+	checkfor = compress = clear = force = keep = verbose = 0;
 	nfound = nsaved = nerr = 0;
 
 	openlog("savecore", LOG_PERROR, LOG_DAEMON);
@@ -821,7 +825,7 @@
 	if (argc < 0)
 		exit(1);
 
-	while ((ch = getopt(argc, argv, "Ccefkm:vz")) != -1)
+	while ((ch = getopt(argc, argv, "Ccfkm:vz")) != -1)
 		switch(ch) {
 		case 'C':
 			checkfor = 1;
@@ -829,9 +833,6 @@
 		case 'c':
 			clear = 1;
 			break;
-		case 'e':
-			encrypted = 1;
-			break;
 		case 'f':
 			force = 1;
 			break;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201506071239.t57Cdo3e088139>