-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix admin profile config and support APPDATA. #42
Conversation
The |
@akuropka Your input here would be appreciated.
Consider the usual case, user installs Windows and his user is an admin user, in an elevated shell his home directory is the same but the |
How about checking if the directory pointed to by |
It's the same on Linux; a sudo'd nano reads As said above, it's probably better to use |
It is not the same on Linux, a Linux user is aware that sudo runs as root, while Windows allows actual admin users with their own profile directory. UNIX ports usually do not do anything special here. |
Also the Administrator user is not equivalent to another admin user, they are separate users. |
This is correct. However, please take a look at the default
which suggests a different color scheme be used for nano running as root for distinction.
One notable difference is that if a user logs in as Administrator, they by default create elevated processes using the Run command. One reason for not using |
I just want my
Is this really important right now? Perhaps in the future, when your project makes an installer package with a default
And for the reason that As |
I am wondering why not just using However, I created a batch wrapper starting |
That's what I'll end up doing for my installer script and possibly the chocolatey package if I ever update that if I can't get any traction here. |
It is necessary to have a distinct color scheme for elevated instances. This is not specific to nano; almost all modern text editors have |
Ok, but what is your solution to the much more annoying problem of your nanorc not being read in an elevated shell. |
Why don't you make a copy of your nanorc to where an elevated instance will read, just like what others do on Linux? |
Because I don't want to maintain or install two copies, and there is no reason to do this. I had some suggestions for more reasonable locations and behavior above. |
While I understand your emergency, this behavior does not come without a reason. If maintaining two copies of nanorc is an issue for you, please file a feature request at https://savannah.gnu.org/bugs/?group=nano, or send a message to [email protected]. |
This has nothing to do with Linux or nano as I explained in great detail here already. The behavior of your port is wrong and your code is wrong. Why are you purposefully insisting on a huge inconvenience for your users? There isn't even any documentation for this. |
It is not clear which exact targets are supported by the upstream project. They will have legitimate reasons to reject any changes relying on the targets not ever supposed to be support officially, unless you merge this project to the upstream. |
You are talking about It is true that impersonating in an elevated process would be dangnerous for an editor which may occasionally overwrite some files unexpectedly, but the problem of the resulted file permissions in such cases should already be advertised and users should have been educated to use it anywhere. Ruling out the user profile directory (indicated by The default behavior (with default configurations) chosen by |
The real issue here is that this original code is a misguided effort to match the behavior on Linux, but is wrong because Windows works differently. On Linux, On Windows, an admin user that is elevated does not become another user, he is simply elevated and both Please fix this, either merge my PR or do your own fix. I can work with you on improving the whole situation with finding the config file, if you like. I had some suggestions above. |
How do you define 'wrong'? Something that looks wrong to you might not look so to others.
This is valid. There are indeed issues in the current approach: But, as explained many times already, it is necessary for an elevated instance to load nanorc from a location that does not depend on the current user (one possible candidate could even be
The |
Only use ALLUSERPROFILE for home dir when USERPROFILE is not set, even for admin users. Fix lhmouse#34. Also on Windows when looking for the rc, look in getenv("APPDATA") instead of getenv("XDG_CONFIG_HOME"), which is mostly equivalent. Signed-off-by: Rafael Kitover <[email protected]>
This looks wrong to anyone but you, because you refuse to admit that your code is wrong and needs to be fixed. It's wrong because:
Why is using an environment variable unsafe? You are just using another environment variable. If you prefer, you can use an API to get the user's profile directory.
Why should it not depend on the current user, that's exactly what it does on Linux. The root user uses root's home directory.
That would still use the user's profile directory, I don't have time to fork this crap, I have enough to do, I was only interested in writing an installer script and possibly updating the chocolatey package, if this pile of crap would even be usable and not subject to incomprehensible undocumented behavior. Bad enough it doesn't support Unicode, for an editor that's pretty bad. |
It's too subjective. I mostly work on Linux, and it is reasonable to tell whether the editor is elevated (checking the the EUID) or not; OTOH, which UID that has effected the process is less important. I am not saying that Note it is possible to change the EUID. You may try this one yourself:
This starts an elevated shell like on Windows. The real UID is me. I can start nano without becoming root, and it still reads So, an instance, whose UID is not root, but is impersonating root, reads the root's nanorc. It's probably less common, but it does exist.
Because I don't think it is unsafe here. Someone else may think so.
Thank you for the update.
MSVCRT doesn't support UTF-8. In order to get UTF-8 support it is necessary to link against UCRT and attach a manifest. Haven't tried it though. |
This is not the same thing as an elevated shell on Windows. Windows does not change the UID or EUID, if it even has the concept of EUID, the user remains the same but runs with admin privileges. I don't see how any of this is relevant. Vim/NVim on Windows does not do anything like this, nothing does anything like this.
You first said it's unsafe now you're saying it's safe.
MSYS2 now has the UCRT64 environment for using MINGW with UCRT. https://www.msys2.org/docs/environments/ Usage is almost exactly the same as MINGW64. |
Ok, I'm closing this. I recommend making this change, but for my purposes I'll just find the config in a If you want help redoing the config locations more sanely, regardless of whether you want to use a separate admin config or not, I made some suggestions above, let me know. |
Would please propose a PR for the change for |
I will open an issue with some suggestions, and we can go from there. |
Only use ALLUSERPROFILE for home dir when USERPROFILE is not set, even
for admin users.
Fix #34.
Also on Windows when looking for the rc, look in getenv("APPDATA")
instead of getenv("XDG_CONFIG_HOME"), which is mostly equivalent.
Signed-off-by: Rafael Kitover [email protected]