delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2011/03/08/21:03:24

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=2.1 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,T_TO_NO_BRKTS_FREEMAIL
X-Spam-Check-By: sourceware.org
Message-ID: <4D76DFDA.5040107@gmail.com>
Date: Tue, 08 Mar 2011 18:03:06 -0800
From: Jay Adams <jayadams0x1 AT gmail DOT com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Solution to using different usernames
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

My friend, Jeremy Bopp, let me know that if I use /etc/profile.d I could
still get updates for /etc/profile unlike when you edit it directly
(comment out USER="`id -un`"). I had to think of a way to change $USER
from a different file so I came up with:
</etc/profile.d/user.sh>
# use Windows's USERNAME variable
USER=$USERNAME
export USER

</cygwin.bat>
...
rem strip trailing slash on "directory paths"
set "dp=%~dp0"
if "%dp:~-1%" equ "\" (
 set "dp=%dp:~0,-1%"
)
...
set "USERNAME=[username]"
set "HOME=%dp%\home\%USERNAME%"
...

I made the USER variable use the Windows variable USERNAME (standard
variable). From there I could change the USERNAME variable simply by
setting to what I like. I included the HOME variable in my code snippet.
I don't know if editting /etc/passwd will have the same behaviour as
editting /etc/profile and I don't know if /etc/passwd will change if I
take my Cygwin install to another computer. The main need for this hack
was that I use Cygwin from a USB and the default behaviour of Cygwin is
to use the currently logged in user which would mean I would have tons
of different profiles.

I thought this maybe useful for others to know so I decided to post
here. Also, if anybody has suggestions please let me and everybody know.

P.S. Still doesn't seem to work for SSH (ssh [user_to_use]@[machine]).
Maybe problem with SSH?

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019