RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 861113 - FTP client does not expand home directory correctly after sudo or su
Summary: FTP client does not expand home directory correctly after sudo or su
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: ftp
Version: 6.1
Hardware: Unspecified
OS: Linux
unspecified
medium
Target Milestone: rc
: ---
Assignee: Jan Synacek
QA Contact: Lukas "krteknet" Novy
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-09-27 14:26 UTC by Danny Oscar Kip
Modified: 2014-02-18 23:56 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-05-21 08:16:49 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
[Patch] don't use getlogin() (1.05 KB, patch)
2012-10-03 07:42 UTC, Jan Synacek
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2013:0845 0 normal SHIPPED_LIVE ftp bug fix update 2013-05-21 12:15:49 UTC

Description Danny Oscar Kip 2012-09-27 14:26:56 UTC
Description of problem:
When using FTP client from a shell with elevated rights through sudo (or su for that matter), FTP client assumes the uid from /proc/self/loginuid to be the uid of the user, and expands ~ to the originating user, not the user initiating the FTP client.

Version-Release number of selected component (if applicable):
Seen on both RHEL6.1 and RHEL5.3, no other version tested yet.


How reproducible:

Start an ftp client after sudo, and try an lcd command.

Steps to Reproduce:
1. use sudo or su to open a shell as another user (in this example: 'appl5')
2. start ftp client
3. type 'lcd ~/', 'lcd' or 'lcd ~'
  
Actual results:
[user3@host ~]$ sudo -i -u appl5
Password: 
[appl5@host ~]$ ftp
ftp> lcd
local: /home/user3: Permission denied
ftp> 

Expected results:

Local directory now /home/appl5
ftp> 


Additional info:

This bug does not appear in lftp or the ftp version supplied by Debian (both tested)

Comment 2 Danny Oscar Kip 2012-09-28 07:15:35 UTC
The fact that FTP client takes itΕ› user from /proc/self/loginuid also causes it to propose that originating user as the login user, which is also not correct. But that is not usually a problem, since you can easily supply the user.

Comment 3 Jan Synacek 2012-10-03 07:42:19 UTC
Created attachment 620658 [details]
[Patch] don't use getlogin()

Quoting man getlogin(3):

"getlogin() returns a pointer to a string containing the name of the user logged in on the controlling terminal of the process"

"Unfortunately, it is often rather easy to fool getlogin(). Sometimes it does not work at all, because some program messed up the utmp file. Often, it gives only the first 8 characters of the login name. The user currently logged in on the controlling tty of our program need not be the user who started it. Avoid getlogin() for security-related purposes."

Comment 4 Danny Oscar Kip 2012-10-04 11:17:36 UTC
Just in case nobody noticed: my example was incorrectly pasted, there is a ~ missing after the 'lcd' command. 

Just issueing 'lcd' will only display your current local dir, not change it. Though I would consider this unexpected behaviour (as 'cd' would take you to your homedir in a shell), and it really would need a 'lpwd' to replace this, the example of this bug as I provided would be an incorrect representation of the actual bug. 

So please use 'lcd ~' to reproduce correctly.

Comment 5 Jan Synacek 2012-10-04 11:27:38 UTC
Even the default username just after the connection was not correct. Ftp was using getlogin() which simply doesn't work correctly in this case.

Comment 6 Danny Oscar Kip 2012-10-04 11:51:03 UTC
The ftp client from the Kerberos workstation package exhibits the same behaviour.
In my particular case: 
/usr/kerberos/bin/ftp from krb5-workstation-1.6.1-31.el5_3.3.i386

Interestingly, that implementation does in fact go to the homedir when entering just 'lcd', instead of just behaving like a local 'pwd' (as /usr/bin/ftp does)

The plot thickens :)

Comment 13 errata-xmlrpc 2013-05-21 08:16:49 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2013-0845.html


Note You need to log in before you can comment on or make changes to this bug.