Skip to content

gpg: create homedir with 700 permissions#2823

Merged
berbiche merged 1 commit intonix-community:masterfrom
ncfavier:gpg-create-homedir
Apr 5, 2022
Merged

gpg: create homedir with 700 permissions#2823
berbiche merged 1 commit intonix-community:masterfrom
ncfavier:gpg-create-homedir

Conversation

@ncfavier
Copy link
Copy Markdown
Member

@ncfavier ncfavier commented Mar 23, 2022

It can happen in some cases that home-manager first runs before gpg creates its homedir, and it creates it with 755 permissions which the user then needs to change by hand.

Do this in the module instead: before linking files, make sure the homedir exists, and if it doesn't, create it with the right permissions.

We might drop the mkMerge if #2822 gets merged first. (EDIT: done)

Checklist

  • Change is backwards compatible.

  • Code formatted with ./format.

  • Code tested through nix-shell --pure tests -A run.all.

  • Test cases updated/added. See example.

  • Commit messages are formatted like

    {component}: {description}
    
    {long description}
    

    See CONTRIBUTING for more information and recent commit messages for examples.

@ncfavier ncfavier requested a review from rycee as a code owner March 23, 2022 05:06
It can happen in some cases that home-manager first runs before gpg
creates its homedir, and it creates it with 755 permissions which the
user then needs to change by hand.

Do this in the module instead: before linking files, make sure the
homedir exists, and if it doesn't, create it with the right permissions.
@ncfavier ncfavier force-pushed the gpg-create-homedir branch from d5d222d to da6e43b Compare March 30, 2022 22:01
Copy link
Copy Markdown
Member

@berbiche berbiche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks

@berbiche berbiche merged commit 399a3df into nix-community:master Apr 5, 2022
@ncfavier ncfavier deleted the gpg-create-homedir branch April 5, 2022 09:51
jficz pushed a commit to jficz/home-manager that referenced this pull request Apr 7, 2022
It can happen in some cases that home-manager first runs before gpg
creates its homedir, and it creates it with 755 permissions which the
user then needs to change by hand.

Do this in the module instead: before linking files, make sure the
homedir exists, and if it doesn't, create it with the right permissions.
@dhess
Copy link
Copy Markdown

dhess commented Apr 17, 2022

I'm fairly certain this commit broke programs.gpg on macOS. I now get this error during activation:

mkdir: cannot create directory ‘/var/empty/.gnupg’: Operation not permitted

I have to set programs.gpg.homedir explicitly to my own homedir to make it stop complaining.

@berbiche
Copy link
Copy Markdown
Member

berbiche commented Apr 17, 2022

@dhess
I'm not sure where the problem lies: the default value for gpg's home directory uses home.homeDirectory, an option that is required to be set since home.stateVersion > 20.09
Do you have a value set for this option?

@dhess
Copy link
Copy Markdown

dhess commented Apr 17, 2022

No, and I never have.

@berbiche
Copy link
Copy Markdown
Member

berbiche commented Apr 17, 2022

If you set a value for this option, does it solve the issue?

IRRC the users.users option in nix-darwin does not set the right home directory for your user (and Home Manager uses the value from nix-darwin to set a default value for home.homeDirectory). I cannot find the issue but it has happened before to other Darwin users.

edit: I have this in my own config:

  # Fix xdg.{dataHome,cacheHome} being empty in home-manager
  users.users.nicolas = {
    home = "/Users/nicolas";
    isHidden = false;
    shell = pkgs.zsh;
  };

@dhess
Copy link
Copy Markdown

dhess commented Apr 17, 2022

Thanks, I'll try that. It's odd that I've never had that set explicitly (nor home.homeDirectory) and never run into a problem before this.

@ncfavier
Copy link
Copy Markdown
Member Author

ncfavier commented Apr 17, 2022

Was your gpg.conf created? If your gpg.homedir was /var/empty/.gnupg it shouldn't have been...

@dhess
Copy link
Copy Markdown

dhess commented Apr 17, 2022

Was your gpg.conf created? If your gpg.homedir was /var/empty/.gnupg it shouldn't have been...

I don't understand your question. Since long before this change, I have configured programs.gpg.settings and programs.gpg.scdaemonSettings and everything worked fine.

@dhess
Copy link
Copy Markdown

dhess commented Apr 17, 2022

edit: I have this in my own config:

  # Fix xdg.{dataHome,cacheHome} being empty in home-manager
  users.users.nicolas = {
    home = "/Users/nicolas";
    isHidden = false;
    shell = pkgs.zsh;
  };

Thanks, that fixed the issue.

@dhoppe
Copy link
Copy Markdown

dhoppe commented Apr 26, 2022

Is there a particular reason why this has not been backported to release-21.11?

ncfavier added a commit to ncfavier/home-manager that referenced this pull request Apr 26, 2022
It can happen in some cases that home-manager first runs before gpg
creates its homedir, and it creates it with 755 permissions which the
user then needs to change by hand.

Do this in the module instead: before linking files, make sure the
homedir exists, and if it doesn't, create it with the right permissions.

(cherry picked from commit 399a3df)
@ncfavier
Copy link
Copy Markdown
Member Author

#2919

@teto teto mentioned this pull request Aug 22, 2022
7 tasks
teto pushed a commit to teto/home-manager that referenced this pull request Aug 22, 2022
It can happen in some cases that home-manager first runs before gpg
creates its homedir, and it creates it with 755 permissions which the
user then needs to change by hand.

Do this in the module instead: before linking files, make sure the
homedir exists, and if it doesn't, create it with the right permissions.
spacekookie pushed a commit to spacekookie/home-manager that referenced this pull request Feb 10, 2023
It can happen in some cases that home-manager first runs before gpg
creates its homedir, and it creates it with 755 permissions which the
user then needs to change by hand.

Do this in the module instead: before linking files, make sure the
homedir exists, and if it doesn't, create it with the right permissions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants