NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.31k stars 13.54k forks source link

Kate doesn't ask for privileged escalation when editing a file owned by root #176409

Open Superfly-Johnson opened 2 years ago

Superfly-Johnson commented 2 years ago

Describe the bug

When editing a file (for instance configuration.nix) with KDE's text editor Kate, the editor would ask for root password when saving the file by using kauth. On NixOS however, Kate simply complains that the user isn't the owner of the file and refuses to overwrite it.

Steps To Reproduce

Steps to reproduce the behavior:

  1. install Kate (nix-env -i kate)
  2. Open a configuration file in /etc/
  3. Attempt saving it. Kate will simply complain the user doesn't own the file instead of asking for escalation.

Expected behavior

On other distros, Kate would ask for root password before saving the file.

Additional context

Nix 22.05

Notify maintainers

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
output here
Superfly-Johnson commented 2 years ago

Sorry for the lack of more details I am currently on mobile

cfitz25 commented 2 years ago

I am having the same issue and cant seem to get around it. I saw that partition-manager that had a similar issue of not asking for permission for me which worked after enabling it as a program.

nix-shell -p nix-info --run "nix-info -m"
this path will be fetched (0.06 MiB download, 0.30 MiB unpacked):
  /nix/store/n564hnvmn4589d6a6q9aylznk7nkvaky-bash-interactive-5.1-p16-dev
copying path '/nix/store/n564hnvmn4589d6a6q9aylznk7nkvaky-bash-interactive-5.1-p16-dev' from 'https://cache.nixos.org'...
 - system: `"x86_64-linux"`
 - host os: `Linux 5.15.43, NixOS, 22.05 (Quokka), 22.05.866.1f8d88087a3`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.8.1`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
praduca commented 2 years ago

I just confirmed that this is not exclusive from kate, it is also ocurring when trying to open the same file with kwrite. Don't know if this is because they are basically the same soft, or if it is something related to other kde applications

sneakygecko commented 1 year ago

You can run kate using sudoedit

In your /etc/nioxos/configuration.nix add the following:

  environment.sessionVariables = {
   SUDO_EDITOR= "/run/current-system/sw/bin/kate";
  };

and then in a terminal: sudoedit /etc/nixos/configuration.nix

It will show the filename at the to with some random characters in it and the location will /var/tmp/configurationXXXXXXXX.nix but when you save it, it will update the file correctly.

bobajeff commented 11 months ago

I can confirm this bug is still present.

I suspect nix isn't building ktexteditor with ENABLE_KAUTH on. Which enables KAuth integration. Could @tteggel or @nyanloutre confirm this?

see: https://github.com/KDE/ktexteditor/blob/master/CMakeLists.txt#L43

JonathanBrouwer commented 6 months ago

From looking at the CMakeLists, ENABLE_KAUTH should be on if NOT WIN32.

I'm also encountering this bug and tried figuring out what is causing this but haven't made any progress yet.

Running KDE 6 on nix unstable

JonathanBrouwer commented 6 months ago

I figured out the problem, I had to add kdePackages.ktexteditor to my list of system packages. I feel like this should've been enabled by default

praduca commented 6 months ago

this doesnt work on gnome tried adding kdepackages.kauth but also not work i'm using gnome on nixos unstable