Title: Issue about `os.homedir()` · Issue #5582 · nodejs/node · GitHub
Open Graph Title: Issue about `os.homedir()` · Issue #5582 · nodejs/node
X Title: Issue about `os.homedir()` · Issue #5582 · nodejs/node
Description: I saw os.homedir() is directly using uv_os_homedir and it has an strange feature. See here for the feature. It will check the environment variable first and then check for the real home directory. And someone discussed here for the reaso...
Open Graph Description: I saw os.homedir() is directly using uv_os_homedir and it has an strange feature. See here for the feature. It will check the environment variable first and then check for the real home directory. ...
X Description: I saw os.homedir() is directly using uv_os_homedir and it has an strange feature. See here for the feature. It will check the environment variable first and then check for the real home directory. ...
Opengraph URL: https://github.com/nodejs/node/issues/5582
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Issue about `os.homedir()`","articleBody":"I saw `os.homedir()` is directly using `uv_os_homedir` and it has an strange feature.\n\n\u003e See [here](https://github.com/libuv/libuv/blob/v1.x/src/unix/core.c#L1016) for the feature.\n\nIt will check the environment variable first and then check for the real home directory.\n\nAnd someone discussed [here](https://github.com/libuv/libuv/pull/350#issuecomment-102701904) for the reason.\n\n\u003e I wonder if this should check $HOME first? It's something of a UNIX tradition to be able to change your home directory on the fly. A problem with that is that getenv(\"HOME\") is not MT-safe.\n\u003e \n\u003e -- @bnoordhuis\n\nBut I think there's still a problem.\n\n---\n\nConsider one situation:\n\n\u003e If I wrote a CLI program and it will write some log file on user's home directory.\n\u003e \n\u003e Now I run the CLI like this:\n\u003e \n\u003e ``` sh\n\u003e $ sudo -u foo node mycli.js\n\u003e ```\n\u003e \n\u003e It should write log file on `/home/foo`. But the problem is - `os.homedir()` still got `process.env.HOME`.\n\nOne solution is to edit `/etc/sudoers`:\n\n```\n# env_keep+=\"HOME MAIL\"\n# comment env_keep += \"HOME\"\n```\n\nAnd another method is using `-i` argument.\n\n**_For further reading you can go to [this article](http://f10.moe/2016/03/07/%E4%B8%80%E4%B8%AA%E7%94%B1%E4%BA%8E%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F%E4%BA%A7%E7%94%9F%E7%9A%84bug/). (It was written in Chinese by @Amunu)**_\n\n---\n\n**But I think why don't we wrote a `os.realHomedir()` or removing checking `HOME` in `realhomedir()`? Not all of us (normal developers) have the permission to access configuration files on our online servers.**\n","author":{"url":"https://github.com/XadillaX","@type":"Person","name":"XadillaX"},"datePublished":"2016-03-07T08:27:41.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/5582/node/issues/5582"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:36f8473c-0edb-75b7-8088-ad254c1c8029 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DD08:39522F:1572AC9:1DB906F:6A4DF2A6 |
| html-safe-nonce | e0f00138f4ebf36ff152ccb3cfec3f149c336f894d4335736d8e073854fa6486 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERDA4OjM5NTIyRjoxNTcyQUM5OjFEQjkwNkY6NkE0REYyQTYiLCJ2aXNpdG9yX2lkIjoiNDE1ODcwMTM5MDA3NDM0NDEwMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 991ec2a0fd441433c00282711a77ca9ff01b6f6688e7dcef2056909cdd350da3 |
| hovercard-subject-tag | issue:138917888 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/5582/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b3b0d16a1d4df3f973d3ee18bfd67431640e8f202a596eedcc43f9348bfcc75e/nodejs/node/issues/5582 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b3b0d16a1d4df3f973d3ee18bfd67431640e8f202a596eedcc43f9348bfcc75e/nodejs/node/issues/5582 |
| og:image:alt | I saw os.homedir() is directly using uv_os_homedir and it has an strange feature. See here for the feature. It will check the environment variable first and then check for the real home directory. ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | XadillaX |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5818716c93c6a2925b815402541a32814e43a7b1261c322b0c2df75224289566 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f4bb89367ca678f057d79b1abc45d6675b1bd5b2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width