From owner-freebsd-doc@FreeBSD.ORG Tue May 15 16:30:02 2012 Return-Path: Delivered-To: freebsd-doc@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A32691065674 for ; Tue, 15 May 2012 16:30:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 6E77C8FC0C for ; Tue, 15 May 2012 16:30:02 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q4FGU2uM038628 for ; Tue, 15 May 2012 16:30:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q4FGU2ib038625; Tue, 15 May 2012 16:30:02 GMT (envelope-from gnats) Resent-Date: Tue, 15 May 2012 16:30:02 GMT Resent-Message-Id: <201205151630.q4FGU2ib038625@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-doc@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Guido Falsi Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 71503106566B for ; Tue, 15 May 2012 16:21:33 +0000 (UTC) (envelope-from mad@madpilot.net) Received: from megatron.madpilot.net (megatron.madpilot.net [88.149.173.206]) by mx1.freebsd.org (Postfix) with ESMTP id 0E4298FC0A for ; Tue, 15 May 2012 16:21:33 +0000 (UTC) Received: from megatron.madpilot.net (localhost [127.0.0.1]) by megatron.madpilot.net (Postfix) with ESMTP id 3VsPD62GQXz2Yc for ; Tue, 15 May 2012 18:21:26 +0200 (CEST) Received: from megatron.madpilot.net ([127.0.0.1]) by megatron.madpilot.net (megatron.madpilot.net [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id ucuimw1KFlHr for ; Tue, 15 May 2012 18:21:20 +0200 (CEST) Received: by megatron.madpilot.net (Postfix, from userid 1000) id 3VsPD05sWNz2Yb; Tue, 15 May 2012 18:21:20 +0200 (CEST) Message-Id: <3VsPD05sWNz2Yb@megatron.madpilot.net> Date: Tue, 15 May 2012 18:21:20 +0200 (CEST) From: Guido Falsi To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: docs/167932: [PATCH] examples/csh/dot.cshrc SSH_AUTH_SOCK example incorrect X-BeenThere: freebsd-doc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Guido Falsi List-Id: Documentation project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 May 2012 16:30:02 -0000 >Number: 167932 >Category: docs >Synopsis: [PATCH] examples/csh/dot.cshrc SSH_AUTH_SOCK example incorrect >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-doc >State: open >Quarter: >Keywords: >Date-Required: >Class: doc-bug >Submitter-Id: current-users >Arrival-Date: Tue May 15 16:30:02 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Guido Falsi >Release: FreeBSD 9.0-STABLE amd64 >Organization: >Environment: System: FreeBSD megatron.madpilot.net 9.0-STABLE FreeBSD 9.0-STABLE #5: Sun Apr 22 14:22:36 CEST 2012 root@megatron.madpilot.net:/usr/obj/usr/src/sys/MEGATRON amd64 >Description: While experimenting with the .cshrc examples I discovered that the sample for automatically setting SSH_AUTH_SOCK does not work as is. It's easily tricked by other processes and cut seems to split on every single space character, not grouping them. I was using this revision of the file: # $FreeBSD: stable/9/share/examples/csh/dot.cshrc 234978 2012-05-03 19:55:36Z eadler $ I tested a few possible solutions. I'm quite aware that none of these is rock solid, but they do perform better than the sample code in the file. I'm sure someone will come up with an even better implementation. It is my personal opinion that sample code should be as correctly working as possible. The simpliest and most legible (used in the attached patch): setenv SSH_AUTH_SOCK `sockstat | grep "${USER}" | grep ssh-agent | awk '{ print $6 }'` a slightly less legible one, but avoiding the double grep: setenv SSH_AUTH_SOCK `sockstat | egrep "${USER}.*ssh-agent" | awk '{ print $6 }'` and a simplier(but with horrible legibility) one relying only on sed: setenv SSH_AUTH_SOCK `sockstat | sed -n "/${USER}.*ssh-agent/s/[^\/]*\(.*\)/\1/p"` I know this is a minor glitch, but I thought it was worth reporting anyway. >How-To-Repeat: Enable the sample code to populate SSH_AUTH_SOCK. launch an ssh-agent on teh target machine. Login via ssh. Run "env" and notice that the SSH_AUTH_SOCK variable will be empty even if there is an ssh-agent running. >Fix: --- dot.cshrc.orig 2012-05-15 18:03:10.053581560 +0200 +++ dot.cshrc 2012-05-15 18:11:25.903582833 +0200 @@ -5,7 +5,7 @@ # Sets SSH_AUTH_SOCK to the user's ssh-agent socket path if running if (${?SSH_AUTH_SOCK} != "1") then - setenv SSH_AUTH_SOCK `sockstat | grep "${USER}" | cut -d ' ' -f 6` + setenv SSH_AUTH_SOCK `sockstat | grep "${USER}" | grep ssh-agent | awk '{ print $6 }'` endif # Change only root's prompt >Release-Note: >Audit-Trail: >Unformatted: