Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 17 Sep 2005 23:24:28 GMT
From:      "Christian S.J. Peron" <csjp@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 83801 for review
Message-ID:  <200509172324.j8HNOSOK072862@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=83801

Change 83801 by csjp@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;



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