NetBSD Problem Report #51844

From www@NetBSD.org  Fri Jan 13 05:08:14 2017
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 4AA3A7A111
	for <gnats-bugs@gnats.NetBSD.org>; Fri, 13 Jan 2017 05:08:14 +0000 (UTC)
Message-Id: <20170113050813.5732C7A2B6@mollari.NetBSD.org>
Date: Fri, 13 Jan 2017 05:08:13 +0000 (UTC)
From: yaneurabeya@gmail.com
Reply-To: yaneurabeya@gmail.com
To: gnats-bugs@NetBSD.org
Subject: [PATCH] tests/lib/libc/sys/t_truncate: use root-owned file created during build instead of /usr/bin/fpr
X-Send-Pr-Version: www-1.0

>Number:         51844
>Category:       bin
>Synopsis:       [PATCH] tests/lib/libc/sys/t_truncate: use root-owned file created during build instead of /usr/bin/fpr
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jan 13 05:10:01 +0000 2017
>Closed-Date:    Sun Jan 15 19:37:42 +0000 2017
>Last-Modified:  Sun Jan 15 19:37:42 +0000 2017
>Originator:     Ngie Cooper
>Release:        7.0.2
>Organization:
>Environment:
n/a
>Description:
The attached patch creates a 1-byte root-owned file instead of inspecting /usr/bin/fpr for the following 2 reasons:
- FreeBSD doesn't have /usr/bin/fpr
- /usr/bin/fpr might not be root owned if installed by a non-root user (both FreeBSD and NetBSD have that support).
>How-To-Repeat:

>Fix:

>Release-Note:

>Audit-Trail:
From: "Ngie Cooper (yaneurabeya)" <yaneurabeya@gmail.com>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/51844: [PATCH] tests/lib/libc/sys/t_truncate: use root-owned
 file created during build instead of /usr/bin/fpr
Date: Thu, 12 Jan 2017 21:11:14 -0800

 --Apple-Mail=_D46F3DB3-E3C8-4D1A-8057-4FA1DEF1671E
 Content-Transfer-Encoding: 7bit
 Content-Type: text/plain;
 	charset=us-ascii

 Patch attached.
 -Ngie

 --Apple-Mail=_D46F3DB3-E3C8-4D1A-8057-4FA1DEF1671E
 Content-Disposition: attachment;
 	filename=t_truncate-use-root-owned-file-instead-of-usr-bin-fpr.patch
 Content-Type: application/octet-stream;
 	x-unix-mode=0644;
 	name="t_truncate-use-root-owned-file-instead-of-usr-bin-fpr.patch"
 Content-Transfer-Encoding: 7bit

 Index: lib/libc/sys/Makefile
 ===================================================================
 RCS file: /cvsroot/src/tests/lib/libc/sys/Makefile,v
 retrieving revision 1.45
 diff -u -r1.45 Makefile
 --- lib/libc/sys/Makefile	11 Nov 2016 15:30:44 -0000	1.45
 +++ lib/libc/sys/Makefile	13 Jan 2017 05:06:31 -0000
 @@ -84,6 +84,18 @@

  CPPFLAGS.t_lwp_create.c += -D_KERNTYPES

 +FILESGROUPS+=		truncate_test_FILES
 +
 +truncate_test_FILES=	truncate_test.root_owned
 +truncate_test_FILESDIR=	${TESTSDIR}
 +truncate_test_FILESMODE= 0600
 +truncate_test_FILESOWNER= root
 +truncate_test_FILESGRP= wheel
 +
 +CLEANFILES=	truncate_test.root_owned
 +truncate_test.root_owned:
 +	dd if=/dev/null bs=1 count=1 of=${.TARGET}
 +
  WARNS=			4

  .include <bsd.test.mk>
 Index: lib/libc/sys/t_truncate.c
 ===================================================================
 RCS file: /cvsroot/src/tests/lib/libc/sys/t_truncate.c,v
 retrieving revision 1.2
 diff -u -r1.2 t_truncate.c
 --- lib/libc/sys/t_truncate.c	18 Aug 2011 19:48:03 -0000	1.2
 +++ lib/libc/sys/t_truncate.c	13 Jan 2017 05:06:31 -0000
 @@ -36,6 +36,7 @@
  #include <atf-c.h>
  #include <errno.h>
  #include <fcntl.h>
 +#include <limits.h>
  #include <stdio.h>
  #include <string.h>
  #include <unistd.h>
 @@ -149,6 +150,7 @@

  ATF_TC_BODY(truncate_err, tc)
  {
 +	char buf[PATH_MAX];

  	errno = 0;
  	ATF_REQUIRE_ERRNO(EFAULT, truncate((void *)-1, 999) == -1);
 @@ -160,7 +162,9 @@
  	ATF_REQUIRE_ERRNO(ENOENT, truncate("/a/b/c/d/e/f/g", 999) == -1);

  	errno = 0;
 -	ATF_REQUIRE_ERRNO(EACCES, truncate("/usr/bin/fpr", 999) == -1);
 +	snprintf(buf, sizeof(buf), "%s/truncate_test.root_owned",
 +	    atf_tc_get_config_var(tc, "srcdir"));
 +	ATF_REQUIRE_ERRNO(EACCES, truncate(buf, 999) == -1);
  }

  ATF_TP_ADD_TCS(tp)

 --Apple-Mail=_D46F3DB3-E3C8-4D1A-8057-4FA1DEF1671E--

From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/51844 CVS commit: src/tests/lib/libc/sys
Date: Fri, 13 Jan 2017 15:03:51 -0500

 Module Name:	src
 Committed By:	christos
 Date:		Fri Jan 13 20:03:51 UTC 2017

 Modified Files:
 	src/tests/lib/libc/sys: Makefile t_truncate.c

 Log Message:
 PR/51844: Ngie Cooper: use root-owned file created during build instead of
 /usr/bin/fpr


 To generate a diff of this commit:
 cvs rdiff -u -r1.45 -r1.46 src/tests/lib/libc/sys/Makefile
 cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/sys/t_truncate.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: snj@NetBSD.org
State-Changed-When: Sun, 15 Jan 2017 19:37:42 +0000
State-Changed-Why:
christos fixed it (with minor changes). thanks!


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.