From andy@wega.interface-business.de  Thu Apr  3 09:36:58 2003
Return-Path: <andy@wega.interface-business.de>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id EA22837B401
	for <FreeBSD-gnats-submit@freebsd.org>; Thu,  3 Apr 2003 09:36:58 -0800 (PST)
Received: from innocence.interface-business.de (ns.interface-business.de [193.101.57.202])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 4DFB843FCB
	for <FreeBSD-gnats-submit@freebsd.org>; Thu,  3 Apr 2003 09:36:57 -0800 (PST)
	(envelope-from andy@wega.interface-business.de)
Received: from rathole (rathole-srv.interface-business.de [193.101.57.204])
	by innocence.interface-business.de (8.12.9/8.12.6/ifb evision: 1.24 $) with SMTP id h33Hau1Q024867
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 3 Apr 2003 19:36:56 +0200 (CEST)
	(envelope-from andy@wega.interface-business.de)
Received: from wega.interface-business.de ([193.101.57.19]) by rathole; Thu, 03 Apr 2003 19:37:32 +0200 (MEST)
Received: from wega.interface-business.de (localhost [127.0.0.1]) 	by wega.interface-business.de (8.12.6/8.12.3) with ESMTP id h33HamE6057040 	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 3 Apr 2003 19:36:48 +0200 (CEST) 	(envelope-from andy@wega.interfaReceived: (from andy@localhost) 	by wega.interface-business.de (8.12.6/8.12.3/Submit) id h33HalvT057039; 	Thu, 3 Apr 2003 19:36:47 +0200 (CEST) 	(envelope-from andy)
Message-Id: <200304031736.h33HalvT057039@wega.interface-business.de>
Date: Thu, 3 Apr 2003 19:36:47 +0200 (CEST)
From: Andreas Kasparz <andy@interface-projects.de>
Reply-To: Andreas Kasparz <andy@interface-projects.de>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: /bin/sh doesn't handles ${HOME}/.profile correctly
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         50569
>Category:       bin
>Synopsis:       sh(1) doesn't handles ${HOME}/.profile correctly
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    jilles
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Apr 03 09:40:07 PST 2003
>Closed-Date:    Mon Nov 05 12:49:15 UTC 2012
>Last-Modified:  Mon Nov 05 12:49:15 UTC 2012
>Originator:     Andreas Kasparz
>Release:        FreeBSD 4.7-STABLE i386
>Organization:
Interface:projects GmbH, Dresden, Germany
>Environment:
System: FreeBSD wayo 4.8-RC FreeBSD 4.8-RC #5: Tue Apr  1 12:30:48 CEST 2003     root@wayo:/usr/obj/usr/src/sys/WAYO  i386
>Description:
    Manual entry for sh(1), section 'Invocation':

        A login shell first reads commands from the
        files /etc/profile and then .profile if they exist.

    .profile will not be read, if a login shell is invoked from
    another point than the directory where the .profile is
    located. This case occurs if xterm(1) is started with the
    option '-ls' and the starting directory isn't the directory
    where .profile is located.
>How-To-Repeat:
    $ cd /tmp
    $ xterm -ls
>Fix:
    We have to build an full pathname for the .profile.

    The following patch fixes the problem; but it should be revisited
    my the maintainer in order to guarantee that there are no side
    effects (I'm not so familar with the internals of the sources).

$ ls -l main.c*
-rw-r--r--  1 root  wheel  8192 Apr  3 17:35 main.c
-rw-r--r--  1 root  wheel  8032 Jul 19  2002 main.c.orig
$ ident main.c.orig
main.c.orig:
     $FreeBSD: src/bin/sh/main.c,v 1.18.2.3 2002/07/19 04:38:51 tjr Exp $
$ diff -c main.c.orig main.c
*** main.c.orig Fri Jul 19 06:38:51 2002
--- main.c      Thu Apr  3 17:35:59 2003
*************** main(int argc, char *argv[])
*** 177,184 ****
                read_profile("/etc/profile");
  state1:
                state = 2;
!               if (privileged == 0)
!                       read_profile(".profile");
                else
                        read_profile("/etc/suid_profile");
        }
--- 177,189 ----
                read_profile("/etc/profile");
  state1:
                state = 2;
!               if (privileged == 0) {
!                       char userprofile[FILENAME_MAX+1];
!                       strcpy( userprofile, lookupvar("HOME") );
!                       strcat( userprofile, "/" );
!                       strcat( userprofile, ".profile" );
!                       read_profile( userprofile );
!               }
                else
                        read_profile("/etc/suid_profile");
        }
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->patched 
State-Changed-By: jilles 
State-Changed-When: Sun Jun 12 10:17:25 UTC 2011 
State-Changed-Why:  
Fixed in 9-current. 


Responsible-Changed-From-To: freebsd-bugs->jilles 
Responsible-Changed-By: jilles 
Responsible-Changed-When: Sun Jun 12 10:17:25 UTC 2011 
Responsible-Changed-Why:  
Take. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=50569 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/50569: commit references a PR
Date: Sun, 12 Jun 2011 10:13:59 +0000 (UTC)

 Author: jilles
 Date: Sun Jun 12 10:13:48 2011
 New Revision: 223005
 URL: http://svn.freebsd.org/changeset/base/223005
 
 Log:
   sh: Read .profile from the home directory (or / if HOME is not set).
   
   In most cases, login shells are started from the home directory, but not in
   all, such as xterm -ls.
   
   This commit depends on r222957 for read_profile() performing parameter
   expansion.
   
   PR:		bin/50569
 
 Modified:
   head/bin/sh/main.c
 
 Modified: head/bin/sh/main.c
 ==============================================================================
 --- head/bin/sh/main.c	Sun Jun 12 09:18:48 2011	(r223004)
 +++ head/bin/sh/main.c	Sun Jun 12 10:13:48 2011	(r223005)
 @@ -150,7 +150,7 @@ main(int argc, char *argv[])
  state1:
  		state = 2;
  		if (privileged == 0)
 -			read_profile(".profile");
 +			read_profile("${HOME-}/.profile");
  		else
  			read_profile("/etc/suid_profile");
  	}
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: jilles 
State-Changed-When: Mon Nov 5 12:49:14 UTC 2012 
State-Changed-Why:  
This is fixed in 9.0 and newer; no MFC to older branches is planned. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=50569 
>Unformatted:
