NetBSD Problem Report #18642

Received: (qmail 24542 invoked by uid 605); 13 Oct 2002 10:43:50 -0000
Message-Id: <20021013092747.05E7A140703@alanis.mafr.de>
Date: Sun, 13 Oct 2002 11:27:47 +0200 (CEST)
From: matt@mafr.de
Sender: gnats-bugs-owner@netbsd.org
To: gnats-bugs@gnats.netbsd.org
Subject: sendfiled does not work
X-Send-Pr-Version: 3.95

>Number:         18642
>Category:       pkg
>Synopsis:       sendfiled does not work
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    pkg-manager
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Oct 13 10:44:00 +0000 2002
>Closed-Date:    Thu Oct 17 19:19:36 +0000 2002
>Last-Modified:  Thu Oct 17 19:20:01 +0000 2002
>Originator:     Matthias Friedrich
>Release:        NetBSD 1.6
>Organization:

>Environment:


System: NetBSD alanis.mafr.de 1.6 NetBSD 1.6 (GENERIC) #0: Sun Sep 8 19:43:40 UTC 2002 autobuild@tgm.daemon.org:/autobuild/i386/OBJ/autobuild/src/sys/arch/i386/compile/GENERIC i386
Architecture: i386
Machine: i386
>Description:
	sendfiled is not able to receive files both from local and
	remote hosts. The server says:
		490 Internal error on setegid(100): Operation not permitted

	The Makefile's CVS ID:
		$NetBSD: Makefile,v 1.7 2001/10/25 19:02:47 agc Exp $

>How-To-Repeat:
	Send a file.
>Fix:
	Unknown.
>Release-Note:
>Audit-Trail:

From: Thomas Klausner <wiz@danbala.ifoer.tuwien.ac.at>
To: matt@mafr.de
Cc: gnats-bugs@netbsd.org
Subject: Re: pkg/18642: sendfiled does not work
Date: Sun, 13 Oct 2002 18:29:58 +0200

 On Sun, Oct 13, 2002 at 11:27:47AM +0200, matt@mafr.de wrote:
 > >Description:
 > 	sendfiled is not able to receive files both from local and
 > 	remote hosts. The server says:
 > 		490 Internal error on setegid(100): Operation not permitted
 > 
 > 	The Makefile's CVS ID:
 > 		$NetBSD: Makefile,v 1.7 2001/10/25 19:02:47 agc Exp $

 Are you running sendfiled as root?
  Thomas

 -- 
 Thomas Klausner - wiz@danbala.ifoer.tuwien.ac.at
 Main Rule of Usenet:  Never argue with idiots.  They drag you down to
 their level, then beat you with experience.

From: Matthias Friedrich <matt@mafr.de>
To: Thomas Klausner <wiz@danbala.ifoer.tuwien.ac.at>
Cc: gnats-bugs@netbsd.org
Subject: Re: pkg/18642: sendfiled does not work
Date: Sun, 13 Oct 2002 23:44:28 +0200

 On Sunday, 2002-10-13, Thomas Klausner wrote:
 > On Sun, Oct 13, 2002 at 11:27:47AM +0200, matt@mafr.de wrote:

 >>> Description:

 >> 	sendfiled is not able to receive files both from local and
 >> 	remote hosts. The server says:
 >> 		490 Internal error on setegid(100): Operation not permitted

 >> 	The Makefile's CVS ID:
 >> 		$NetBSD: Makefile,v 1.7 2001/10/25 19:02:47 agc Exp $

 > Are you running sendfiled as root?

 Sure. Otherwise I wouldn't expect it to work. My inetd.conf entry:

 saft    stream  tcp     nowait  root    /usr/pkg/sbin/sendfiled sendfiled

 Group ID 100 (users) exists.

 I could of course easily remove some offending setreugid() calls and
 do some chmod(2)s to get permissions right, but that's not the way it is
 supposed to work.

 At the moment, I haven't got an idea of what's wrong. Does this very
 version work somewhere else? I'd provide any additional information that
 might help, although I don't think there's something wrong in my
 environment. It is almost vanilla 1.6, even with the GENERIC kernel.

 bye,
 	Matthias

From: Matthias Friedrich <matt@mafr.de>
To: Thomas Klausner <wiz@danbala.ifoer.tuwien.ac.at>
Cc: gnats-bugs@netbsd.org
Subject: Re: pkg/18642: sendfiled does not work
Date: Thu, 17 Oct 2002 21:08:10 +0200

 On Sunday, 2002-10-13, Thomas Klausner wrote:
 > On Sun, Oct 13, 2002 at 11:27:47AM +0200, matt@mafr.de wrote:

 >>> Description:
 >> 	sendfiled is not able to receive files both from local and
 >> 	remote hosts. The server says:
 >> 		490 Internal error on setegid(100): Operation not permitted

 >> 	The Makefile's CVS ID:
 >> 		$NetBSD: Makefile,v 1.7 2001/10/25 19:02:47 agc Exp $

 I asked the program's author but he couldn't solve the problem.

 After thorogh debugging I finally found the bug: sendfiled tries to
 change uid/gid *twice* (from 0/0 to 1000/100). The first time, it
 succeeds, but the second time its effective user id is already 1000, so
 it doesn't have the permission to do so (although the program wants to
 change from 1000/100 to 1000/100). On Linux, this call succeeds.

 The following patch solves this problem. I hope this or a better
 solution will be included in the next release of sendfile.

 bye,
 	Matthias


 diff -cr sendfile-2.1a/src/sendfiled.c sendfile-2.1a_fixed/src/sendfiled.c
 *** sendfile-2.1a/src/sendfiled.c	Mon Jul 23 16:08:03 2001
 --- sendfile-2.1a_fixed/src/sendfiled.c	Thu Oct 17 20:49:40 2002
 ***************
 *** 4000,4005 ****
 --- 4000,4007 ----
    * RETURN: nothing, but terminates program on error
    */
   void setreugid() {
 +   if ( getegid() == rgid && geteuid() == ruid )
 + 	  return;
     if (rgid && setegid(rgid)<0) {
       printf("490 Internal error on setegid(%u): %s\r\n",
   	   (unsigned int)rgid,strerror(errno));
State-Changed-From-To: open->closed 
State-Changed-By: wiz 
State-Changed-When: Thu Oct 17 12:18:54 PDT 2002 
State-Changed-Why:  
I added the patch you provided to pkgsrc -- thanks for tracking this down! 

From: Thomas Klausner <wiz@netbsd.org>
To: gnats-bugs@gnats.netbsd.org
Cc:  
Subject: pr/18642 CVS commit: pkgsrc/net/sendfile
Date: Thu, 17 Oct 2002 22:18:04 +0300 (EEST)

 Module Name:	pkgsrc
 Committed By:	wiz
 Date:		Thu Oct 17 19:18:03 UTC 2002

 Modified Files:
 	pkgsrc/net/sendfile: Makefile distinfo
 Added Files:
 	pkgsrc/net/sendfile/patches: patch-ad

 Log Message:
 Add patch to make sendfiled work again, provided by Matthias Friedrich
 in relation with his PR 18642.
 Bump to 2.1.0.2.


 To generate a diff of this commit:
 cvs rdiff -r1.8 -r1.9 pkgsrc/net/sendfile/Makefile
 cvs rdiff -r1.4 -r1.5 pkgsrc/net/sendfile/distinfo
 cvs rdiff -r0 -r1.1 pkgsrc/net/sendfile/patches/patch-ad

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

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.