PERFORCE change 83801 for review

Christian S.J. Peron csjp at FreeBSD.org
Sat Sep 17 23:24:28 GMT 2005


http://perforce.freebsd.org/chv.cgi?CH=83801

Change 83801 by csjp at csjp_xor on 2005/09/17 23:24:26

	Introduce -f flag which, if an object has no checksum associated with
	it, will trigger the calculation and storage of the checksum by the
	kernel.

Affected files ...

.. //depot/projects/trustedbsd/mac/usr.sbin/getfhash/getfhash.c#15 edit

Differences ...

==== //depot/projects/trustedbsd/mac/usr.sbin/getfhash/getfhash.c#15 (text+ko) ====

@@ -51,6 +51,7 @@
 static int	 eval;
 
 static int	 dflag;
+static int	 fflag;
 static int	 rflag;
 static char	*mflag;
 static int	 Wflag;
@@ -216,9 +217,15 @@
 	u_char digest[64];
 	int (*checksum)(const char *, u_char *);
 
+again:
 	error = extattr_get_file(pathname, MAC_CHKEXEC_ATTRN,
 	    MAC_CHKEXEC, (void *)&sum, sizeof(sum));
-	if (error < 0) {
+	if (error < 0 && errno == ENOATTR && fflag) {
+		if (syscall(SYS_mac_syscall, "mac_chkexec", 0, pathname) < 0)
+			warn("%s", pathname);
+		else
+			goto again;
+        } else if (error < 0) {
 		warn("%s", pathname);
 		return;
 	}
@@ -279,11 +286,14 @@
 		handler = print_hash;
 	else
 		errx(1, "what program am I supposed to be?");
-	while ((ch = getopt(argc, argv, "dhm:rW")) != -1)
+	while ((ch = getopt(argc, argv, "dfhm:rW")) != -1)
 		switch(ch) {
 		case 'd':
 			dflag++;
 			break;
+		case 'f':
+			fflag++;
+			break;
 		case 'm':
 			mflag = optarg;
 			break;
To Unsubscribe: send mail to majordomo at trustedbsd.org
with "unsubscribe trustedbsd-cvs" in the body of the message



More information about the trustedbsd-cvs mailing list