From owner-freebsd-current@FreeBSD.ORG Wed Oct 17 18:32:33 2007 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1E21D16A418 for ; Wed, 17 Oct 2007 18:32:33 +0000 (UTC) (envelope-from matrix@itlegion.ru) Received: from corpmail.itlegion.ru (corpmail.itlegion.ru [84.21.226.211]) by mx1.freebsd.org (Postfix) with SMTP id 487D313C474 for ; Wed, 17 Oct 2007 18:32:31 +0000 (UTC) (envelope-from matrix@itlegion.ru) Received: (qmail 35162 invoked from network); 17 Oct 2007 22:32:29 +0400 Received: from unknown (HELO Artem) (192.168.0.12) by 84.21.226.211 with SMTP; 17 Oct 2007 22:32:29 +0400 X-AntiVirus: Checked by Dr.Web [version: 4.44, engine: 4.44.0.09170, virus records: 249943, updated: 17.10.2007] Message-ID: <00bd01c810ec$10371230$0c00a8c0@Artem> From: "Artem Kuchin" To: Date: Wed, 17 Oct 2007 22:32:16 +0400 Organization: IT Legion MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="koi8-r"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.3138 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 Subject: Broken su in current - trying to fix myself, help needed! X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Oct 2007 18:32:33 -0000 Hello! I really not at all good at any kind of system programming in FreeBSD or Un*x, but since my contacts with last commited of su could not be establish i decided to look at it myself. If you don't know what is the problem i'll describe it shortly: if you try to run a very simple perl script: #!/usr/bin/perl $com="/usr/bin/su root -c 'echo heck'"; system($com); print "done!\n"; it will print heck and then Suspended (tty output) and will hang in memory untill you type fg then you get done! I am working in csh, but i tested it in sh - result is the same. FreeBSD version is 7-PRERELEASE. So, I fetched su v. 1.76 from 6.2-STABLE and compiled it - it works like a charm. SO, i decided to figure what fails in 1.86. There are such like in the default: dection of switch child_pgrp = getpgid(child_pid); if (tcgetpgrp(STDERR_FILENO) == child_pgrp) tcsetpgrp(STDERR_FILENO, getpgrp()); The problem is here. getpgid(child_pid) simply fails with errno 3 (process doesn't exist) and tcgetpgrp(STDERR_FILENO) return 100000 (can it be THAT high? i though it is only in 0-65535 range). The weird thing is that if i just comment out those lines like this /* child_pgrp = getpgid(child_pid); if (tcgetpgrp(STDERR_FILENO) == child_pgrp) */ tcsetpgrp(STDERR_FILENO, getpgrp()); su starts working again just fine. Any idea why getpgid fails and why tcgetpgrp return 100000 (always the same number)? What will brak if i leave these lines commented? -- Regards, Artem