Closed Bug 1847572 Opened 3 years ago Closed 2 years ago

Unix file path `~foo` should expand to `/home/foo`

Categories

(Core :: XPCOM, defect, P3)

Firefox 118
Desktop
Linux
defect

Tracking

()

RESOLVED FIXED
120 Branch
Tracking Status
firefox118 --- wontfix
firefox119 --- wontfix
firefox120 --- fixed

People

(Reporter: vinny.diehl, Assigned: vinny.diehl)

References

(Regressed 1 open bug)

Details

Attachments

(1 file)

While implementing Bug 93141 I noticed that home directories for arbitrary users do not expand properly, e.g. ~foo/bar should expand to /home/foo/bar. We will need to modify nsLocalFile::InitWithNativePath.

Assignee: nobody → vinny.diehl
Status: NEW → ASSIGNED

I've added a patch for this. The /home/<USERNAME> syntax is hardcoded and thus this relies on the default home directory having not been changed. We could parse the actual home directory out of /etc/passwd I suppose, but according to my testing Chrome doesn't go this far, so this patch achieves parity as implemented.

Posix provides getpwnam_r to find the home of a given user.

Attachment #9348571 - Attachment description: Bug 1847572 - Expand home directory paths for arbitrary users r?#xpcom-reviewers → Bug 1847572 - Expand home directory paths for arbitrary users r?nika,#xpcom-reviewers

(In reply to Mike Hommey [:glandium] from comment #3)

Posix provides getpwnam_r to find the home of a given user.

My latest revision implements this suggestion. Chromium explicitly avoids such an implementation, calling it a "nasty blocking call". Do you think there is any merit to this aversion? I don't see much of a risk here.

Flags: needinfo?(mh+mozilla)

Yeah, there's merit to it, considering the password database might be coming from the NIS authentication server, with non-deterministic overhead. BUT, relying on something else than that would be unreliable.

Flags: needinfo?(mh+mozilla)
Pushed by nlayzell@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/65e974428cdb Expand home directory paths for arbitrary users r=xpcom-reviewers,nika

Backed out for causing gtest crashes.

  • Backout link
  • Push with failures
  • Failure Log
  • Failure line: PROCESS-CRASH | MOZ_ASSERT(mRawPtr != nullptr) (You can't dereference a NULL nsCOMPtr with operator->().) [@ nsCOMPtr<nsIFile>::operator->] | gtest
Flags: needinfo?(vinny.diehl)

Looks like these tests are busted on Android. Would you mind vouching for me for try access so I can work this out?

Flags: needinfo?(vinny.diehl) → needinfo?(sstanca)

Hello Vinny! Sorry, but unfortunately I'm not able to vouch for you.. Maybe Aryx could help you in this matter.

Flags: needinfo?(sstanca) → needinfo?(aryx.bugmail)

Hi Vinny. To be able to use Try, you need commit access. Please read here how to get access and mention the bug here or put me into the CC to make aware of it and I can then vouch for you.

Flags: needinfo?(aryx.bugmail) → needinfo?(vinny.diehl)

Hi :aryx, thank you! I've opened a commit access request at Bug 1852188.

Flags: needinfo?(vinny.diehl)

There is an r+ patch which didn't land and no activity in this bug for 2 weeks.
:vinny.diehl, could you have a look please?
If you still have some work to do, you can add an action "Plan Changes" in Phabricator.
For more information, please visit BugBot documentation.

Flags: needinfo?(vinny.diehl)
Flags: needinfo?(nika)

:nika I think this is ready to re-land :)

Edit: sorry, this ni? shouldn't have been cleared.

Flags: needinfo?(vinny.diehl)
Flags: needinfo?(nika)
Flags: needinfo?(nika)
Pushed by nlayzell@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/e0d4d00811af Expand home directory paths for arbitrary users r=xpcom-reviewers,nika

re-landed :-)

Flags: needinfo?(nika)
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 120 Branch

Since nightly and release are affected, beta will likely be affected too.
For more information, please visit BugBot documentation.

The patch landed in nightly and beta is affected.
:vinny.diehl, is this bug important enough to require an uplift?

  • If yes, please nominate the patch for beta approval.
  • If no, please set status-firefox119 to wontfix.

For more information, please visit BugBot documentation.

Flags: needinfo?(vinny.diehl)

This is a somewhat fringe feature, much less common than ~. This can ride the trains.

Flags: needinfo?(vinny.diehl)
Regressions: 1863974
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: