From owner-svn-src-head@freebsd.org Thu Aug 23 18:19:02 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8631F1094417; Thu, 23 Aug 2018 18:19:02 +0000 (UTC) (envelope-from arichardson@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3AB1280601; Thu, 23 Aug 2018 18:19:02 +0000 (UTC) (envelope-from arichardson@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 04E6025B01; Thu, 23 Aug 2018 18:19:02 +0000 (UTC) (envelope-from arichardson@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w7NIJ1YI071885; Thu, 23 Aug 2018 18:19:01 GMT (envelope-from arichardson@FreeBSD.org) Received: (from arichardson@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w7NIJ1ah071883; Thu, 23 Aug 2018 18:19:01 GMT (envelope-from arichardson@FreeBSD.org) Message-Id: <201808231819.w7NIJ1ah071883@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arichardson set sender to arichardson@FreeBSD.org using -f From: Alex Richardson Date: Thu, 23 Aug 2018 18:19:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r338267 - head/sbin/md5 X-SVN-Group: head X-SVN-Commit-Author: arichardson X-SVN-Commit-Paths: head/sbin/md5 X-SVN-Commit-Revision: 338267 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Aug 2018 18:19:03 -0000 Author: arichardson Date: Thu Aug 23 18:19:01 2018 New Revision: 338267 URL: https://svnweb.freebsd.org/changeset/base/338267 Log: Allow bootstrapping md5 on Linux, MacOS and FreeBSD < 12 In order to build on a Linux host we need to bootstrap md5 since the Linux md5sum command produces output in a different format. Reviewed By: emaste Approved By: brooks (mentor) Differential Revision: https://reviews.freebsd.org/D16846 Modified: head/sbin/md5/Makefile head/sbin/md5/md5.c Modified: head/sbin/md5/Makefile ============================================================================== --- head/sbin/md5/Makefile Thu Aug 23 18:18:52 2018 (r338266) +++ head/sbin/md5/Makefile Thu Aug 23 18:19:01 2018 (r338267) @@ -28,4 +28,12 @@ MLINKS= md5.1 rmd160.1 \ LIBADD= md +.ifndef(BOOTSTRAPPING) +# Avoid depending on capsicum during bootstrap. caph_limit_stdout() is not +# available when building for Linux/MacOS or older FreeBSD hosts. +# We need to bootstrap md5 when building on Linux since the md5sum command there +# produces different output. +CFLAGS+=-DHAVE_CAPSICUM +.endif + .include Modified: head/sbin/md5/md5.c ============================================================================== --- head/sbin/md5/md5.c Thu Aug 23 18:18:52 2018 (r338266) +++ head/sbin/md5/md5.c Thu Aug 23 18:19:01 2018 (r338267) @@ -21,11 +21,10 @@ __FBSDID("$FreeBSD$"); #include -#include #include #include -#include #include +#include #include #include #include @@ -41,6 +40,11 @@ __FBSDID("$FreeBSD$"); #include #include +#ifdef HAVE_CAPSICUM +#include +#include +#endif + /* * Length of test block, number of test blocks. */ @@ -162,7 +166,9 @@ Arguments (may be any combination): int main(int argc, char *argv[]) { +#ifdef HAVE_CAPSICUM cap_rights_t rights; +#endif int ch, fd; char *p; char buf[HEX_DIGEST_LENGTH]; @@ -215,8 +221,10 @@ main(int argc, char *argv[]) argc -= optind; argv += optind; +#ifdef HAVE_CAPSICUM if (caph_limit_stdout() < 0 || caph_limit_stderr() < 0) err(1, "unable to limit rights for stdio"); +#endif if (*argv) { do { @@ -232,10 +240,12 @@ main(int argc, char *argv[]) * earlier. */ if (*(argv + 1) == NULL) { +#ifdef HAVE_CAPSICUM cap_rights_init(&rights, CAP_READ); if ((cap_rights_limit(fd, &rights) < 0 && errno != ENOSYS) || caph_enter() < 0) err(1, "capsicum"); +#endif } if ((p = Algorithm[digest].Fd(fd, buf)) == NULL) { warn("%s", *argv); @@ -258,8 +268,10 @@ main(int argc, char *argv[]) } } while (*++argv); } else if (!sflag && (optind == 1 || qflag || rflag)) { +#ifdef HAVE_CAPSICUM if (caph_limit_stdin() < 0 || caph_enter() < 0) err(1, "capsicum"); +#endif MDFilter(&Algorithm[digest], 0); }