From owner-freebsd-current@freebsd.org Mon May 28 03:26:54 2018 Return-Path: Delivered-To: freebsd-current@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 9FFA4EF6551 for ; Mon, 28 May 2018 03:26:54 +0000 (UTC) (envelope-from timur@bat.ru) Received: from mail-oi0-x22f.google.com (mail-oi0-x22f.google.com [IPv6:2607:f8b0:4003:c06::22f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3B4F279728 for ; Mon, 28 May 2018 03:26:53 +0000 (UTC) (envelope-from timur@bat.ru) Received: by mail-oi0-x22f.google.com with SMTP id e80-v6so9229646oig.11 for ; Sun, 27 May 2018 20:26:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=com-bat-ru.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=5iCKZ1ObhioI9RdWWNbQJeoso1Ztz4/T1x0A7ANJ/WE=; b=zewC7tGokBo1QdXATZXTEK6qf7wV9yvJvXeZ3SOsyq2shQjwWl2GhYfjsCkej5rDKd VljL2BxbxH4qKuh6okhWit/Y7ysoJMs5xxVGkd8Wujy9c5zXAOyXVJxq0l0yqFkL3/JO 42mKccE7tcvmC/DNfrTkypftx0XNiH3DXRfO2wnayoEiuz26MLUCRp9WfiAaWWoivN3I 8Nx95laaFldqF31vamnR0nDnx0vv2COE6jOrCV3hkUWVtCKZ6ieV0yU48ai7oPSPcE6f hkHwTNhFBRtm6nFxmr2O08M6sWZH777FTAKnOfLUKEvuU4BPWbCck8p+JVbnLZHIdlk9 PQfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=5iCKZ1ObhioI9RdWWNbQJeoso1Ztz4/T1x0A7ANJ/WE=; b=Pdo/xzKIVMOOtLuiX8eSDu0xIeEyssfyYfBhOjkNXZfpwLDgh6BwyRpDfEBGuWGRVA rzZZizQrpaGL81a8EmYfRRxFqF6nt5xrprtQeRuUtYTZorF4OnmhFC/z6bClvwSYByNd RZoBcLSvq3byx/3/C7AlyUXxdml470w50HxvsZm6syByQ716hQaVpBzGTEIH35gOf9tb NZ2xaPJ02LDOUkRcPX9aP8f8yxdKgylTfoMHoOP5Y319c366gOByccJkolHb3nWwKtad vo7BwfQ31xbiM3Rq04EsfbL1WD/S1VzVVBGTKWE8n8Llue5FRBJq9cw/OtCmt1ZWmWfA wozA== X-Gm-Message-State: ALKqPwfHc8sGJRUKQzEG63R9iNB8N3LclPUzjkLuqO+p0S1WZD6wI7QC eKhwfhD81rIArht6qd4rLNndX3Fs2Cpe67w+q2q3VsWUZzY= X-Google-Smtp-Source: ADUXVKISXT1yLR3MTI6YRavHYHME7ccoVF9u+Sm2WZ4BEEn81cLDnxTBPjV/j8NjrB5JDJVXkJRqCgOVFo6QcBKc2tA= X-Received: by 2002:aca:72d3:: with SMTP id p202-v6mr5966105oic.278.1527478012795; Sun, 27 May 2018 20:26:52 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a4a:1c2:0:0:0:0:0 with HTTP; Sun, 27 May 2018 20:26:22 -0700 (PDT) From: "Timur I. Bakeyev" Date: Mon, 28 May 2018 05:26:22 +0200 Message-ID: Subject: Odd w/who behavior for the last 12 years To: FreeBSD Current , Ed Schouten , Robert Watson , Alan Jude , Michal Mertl Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.26 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.26 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: Mon, 28 May 2018 03:26:54 -0000 Hi all! Recently I was trying to fix UTMP logging support in Samba, which supposed to add login entries for all authenticated Samba sessions, writing down user, session ID and remote host into the UTMP database(s). It used to work with Samba 3.x and FreeBSD 6/7, but got broken since then, apparently. Fixing Samba code to support "new" utmpx.h API was easy, but, despite that I couldn't see the active session in the "w" and "who" output. Still, "last" was showing the session normally: timur smb/3863840071 test-server1.local Fri May 25 14:20 - 14:37 (00:17) Quick look into the source code brought me to this 12 y.o. commit: https://svnweb.freebsd.org/base?view=revision&revision=155875 > In wall and who, check that the utmp entry isn't stalled, as it is done in w. > Apparently with the new pts code stalled entries are printed, when they are > not with the BSD ptys. > > Submitted by: Michal Mertl > > That can be tracked down to the https://docs.freebsd.org/cgi/getmsg.cgi?fetch=822832+0+/usr/local/www/mailindex/archive/2006/freebsd-current/20060205.freebsd-current While for the "wall" this patch has sense, it's quite broken for the "who"(and similar broken "fix" exists for "w"). First of all, both of those programs supposed to show information about ALL active sessions on the given machine. From the top of my head, besides "ssh" and other programs, that allocate ptys there is a bunch of other programs that write their sessions into UTMP, namely: xdm/gdm, vsftpd(and probably few other FTPDs), gnome-terminal(I wrote the BSD* code in gnome-pty-helper) and Samba. I'm pretty sure I miss some other software that also stores session info into UTMP, but I hope my point is clear. Next, while in 2006 ptmx/pts was pretty flanky, there was a large work done by Rober Watson ( https://docs.freebsd.org/cgi/getmsg.cgi?fetch=324362+0+archive/2007/freebsd-current/20071209.freebsd-current) and Ed Schouten ( https://docs.freebsd.org/cgi/getmsg.cgi?fetch=22996+0+archive/2008/freebsd-current/20080727.freebsd-current) that should fix the issues with ghost ptys. So I propose to remove the said patch(or make it verify only "pts/" devices). any objections? With regards, Timur Bakeyev.