PERFORCE change 171213 for review

Gleb Kurtsou gk at FreeBSD.org
Mon Nov 30 21:41:17 UTC 2009


http://p4web.freebsd.org/chv.cgi?CH=171213

Change 171213 by gk at gk_h1 on 2009/11/30 21:40:21

	add -f option to *chain commands. to make'em work on unmounted filesystems
	add pefs.8 man page

Affected files ...

.. //depot/projects/soc2009/gk_pefs/sbin/pefs/Makefile#8 edit
.. //depot/projects/soc2009/gk_pefs/sbin/pefs/pefs.8#1 add
.. //depot/projects/soc2009/gk_pefs/sbin/pefs/pefs_ctl.c#13 edit

Differences ...

==== //depot/projects/soc2009/gk_pefs/sbin/pefs/Makefile#8 (text+ko) ====

@@ -8,7 +8,7 @@
 SRCS+=	hmac_sha512.c sha2.c
 SRCS+=	pkcs5v2.c
 
-NO_MAN=
+MAN=	pefs.8
 
 CFLAGS+=-I${SYS}
 WARNS?=	6

==== //depot/projects/soc2009/gk_pefs/sbin/pefs/pefs_ctl.c#13 (text+ko) ====

@@ -72,6 +72,8 @@
 typedef int (*keyop_func_t)(struct pefs_keychain_head *kch, int fd,
     int verbose);
 
+static int ignore_fscheck = 0;
+
 struct command {
 	const char *name;
 	command_func_t func;
@@ -113,6 +115,7 @@
 pefs_getfsroot(const char *path, char *fsroot, size_t size)
 {
 	struct statfs fs;
+	const char *realfsroot;
 	int error;
 
 	if (statfs(path, &fs) == -1) {
@@ -121,13 +124,18 @@
 		return (error);
 	}
 
+	realfsroot = fs.f_mntonname;
 	if (strcmp(PEFS_FSTYPE, fs.f_fstypename) != 0) {
-		warnx("invalid filesystem type: %s", path);
-		return (EINVAL);
+		if (ignore_fscheck != 0) {
+			realfsroot = path;
+		} else {
+			warnx("invalid filesystem type: %s", path);
+			return (EINVAL);
+		}
 	}
 
 	if (fsroot != NULL)
-		strlcpy(fsroot, fs.f_mntonname, size);
+		strlcpy(fsroot, realfsroot, size);
 
 	return (0);
 }
@@ -547,11 +555,14 @@
 
 	pefs_keyparam_init(&p[0].kp);
 	pefs_keyparam_init(&p[1].kp);
-	while ((i = getopt(argc, argv, "pPvZa:A:i:I:k:K:")) != -1)
+	while ((i = getopt(argc, argv, "a:A:i:I:k:K:fpPvZ")) != -1)
 		switch(i) {
 		case 'v':
 			verbose = 1;
 			break;
+		case 'f':
+			ignore_fscheck = 1;
+			break;
 		case 'Z':
 			zerochainedkey = 1;
 			break;
@@ -681,6 +692,7 @@
 	while ((i = getopt(argc, argv, "fvpi:k:")) != -1)
 		switch(i) {
 		case 'f':
+			ignore_fscheck = 1;
 			force = 1;
 			break;
 		case 'v':
@@ -748,8 +760,11 @@
 	int error, i;
 
 	pefs_keyparam_init(&kp);
-	while ((i = getopt(argc, argv, "pi:k:")) != -1)
+	while ((i = getopt(argc, argv, "fpi:k:")) != -1)
 		switch(i) {
+		case 'f':
+			ignore_fscheck = 1;
+			break;
 		case 'p':
 			kp.kp_nopassphrase = 1;
 			break;
@@ -808,6 +823,9 @@
 		case 'v':
 			verbose = 1;
 			break;
+		case 'f':
+			ignore_fscheck = 1;
+			break;
 		case 'n':
 			if ((nmin = atoi(optarg)) <= 0) {
 				warnx("invalid lower bound argument: %s",
@@ -885,11 +903,11 @@
 "	pefs delkey [-cCpv] [-i iterations] [-k keyfile] filesystem\n"
 "	pefs flushkeys filesystem\n"
 "	pefs showkeys [-t] filesystem\n"
-"	pefs addchain [-pPvZ] [-a alg] [-i iterations] [-k keyfile]\n"
+"	pefs addchain [-fpPvZ] [-a alg] [-i iterations] [-k keyfile]\n"
 "		[-A alg] [-I iterations] [-K keyfile] filesystem\n"
-"	pefs delchain [-pv] [-i iterations] [-k keyfile] filesystem\n"
-"	pefs randomchain [-v] [-a alg] [-n min] [-N max] filesystem\n"
-"	pefs showchains [-p] [-i iterations] [-k keyfile] filesystem\n"
+"	pefs delchain [-fpv] [-i iterations] [-k keyfile] filesystem\n"
+"	pefs randomchain [-fv] [-n min] [-N max] filesystem\n"
+"	pefs showchains [-fp] [-i iterations] [-k keyfile] filesystem\n"
 "	pefs showalgs\n"
 );
 	exit(EX_USAGE);


More information about the p4-projects mailing list