{"action":"created","comment":{"url":"https://api.github.com/repos/puppetlabs/puppet-server/pulls/comments/41601181","id":41601181,"diff_hunk":"@@ -557,11 +610,31 @@\n                                                extensions)]\n     (write-cert-to-inventory! hostcert (:cert-inventory ca-settings))\n     (utils/key->pem! public-key (:hostpubkey settings))\n-    (utils/key->pem! private-key (:hostprivkey settings))\n+    (utils/key->pem! private-key\n+     (create-file-with-perms (:hostprivkey settings) p-key-perms))\n     (utils/cert->pem! hostcert (:hostcert settings))\n     (utils/cert->pem! hostcert\n                       (path-to-cert (:signeddir ca-settings) certname))))\n \n+(schema/defn ^:always-validate\n+  ensure-master-file-perms!\n+  [settings :- MasterSettings]\n+  (let [p-key-dir (:privatekeydir settings)\n+        cur-dir-perms (get-file-perms p-key-dir)]\n+    (when-not (= p-key-dir-perms cur-dir-perms)\n+      (set-file-perms p-key-dir p-key-dir-perms)\n+      (log/warnf (str \"The private key directory at '%s' had permissions set as \"\n+                      \"'%s' and should be set to '%s' this has been corrected\")\n+                 p-key-dir cur-dir-perms p-key-dir-perms))\n+    (doseq [key-file (fs/find-files p-key-dir #\".*pem$\")]\n+      (let [key-path (.getPath key-file)\n+            cur-key-perms (get-file-perms key-path)]\n+        (when-not (= p-key-perms cur-key-perms)\n+          (set-file-perms key-path p-key-perms)\n+          (log/warnf (str \"The private key located at '%s' had permissions set as \"\n+                          \"'%s' and should be set to '%s' this has been fixed.\")","path":"src/clj/puppetlabs/puppetserver/certificate_authority.clj","position":119,"original_position":119,"commit_id":"a71ba1eeb7ce34a93527eef6e2bbfc4de076d792","original_commit_id":"a71ba1eeb7ce34a93527eef6e2bbfc4de076d792","user":{"login":"camlow325","id":5652737,"avatar_url":"https://avatars.githubusercontent.com/u/5652737?v=3","gravatar_id":"","url":"https://api.github.com/users/camlow325","html_url":"https://github.com/camlow325","followers_url":"https://api.github.com/users/camlow325/followers","following_url":"https://api.github.com/users/camlow325/following{/other_user}","gists_url":"https://api.github.com/users/camlow325/gists{/gist_id}","starred_url":"https://api.github.com/users/camlow325/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/camlow325/subscriptions","organizations_url":"https://api.github.com/users/camlow325/orgs","repos_url":"https://api.github.com/users/camlow325/repos","events_url":"https://api.github.com/users/camlow325/events{/privacy}","received_events_url":"https://api.github.com/users/camlow325/received_events","type":"User","site_admin":false},"body":"On second thought, I think it might be better to remove the logic from this PR which resets the permissions on the `privatekeydir` and master/agent private key pem files within it.  I had forgotten that the Puppet settings which map to this directory and files can be specified with an explicit mode in the `puppet.conf` file.  From https://docs.puppetlabs.com/references/latest/configuration.html#configuration-settings:\r\n\r\n> Settings that take a single file or directory can optionally set the owner, group, and mode for their value: rundir = $vardir/run { owner = puppet, group = puppet, mode = 644 }\r\n\r\nIf we were to reset these permissions at startup, we could overwrite an alternate mode that the user may have set in their `puppet.conf` file.  To avoid this, I don't think we should try to figure out how to have Puppet Server extract the mode value for Ruby Puppet settings and use that to set permissions.  Since Ruby Puppet code isn't managing the CA private key mode when running under Puppet Server, I do still think it would be good to retain the logic which resets the permissions to 0640 for the CA private key mode at startup.  For the `privatekeydir` and its subordinate pems, though, I now think it might be better to just let Ruby Puppet handle resetting permissions, if needed, at startup as it already does / knows how to do.  From Puppet Server's perspective, then, the only thing we'd additionally need to handle for the `privatekeydir` and subordinate pems is setting world-inaccessible permissions as the directory/files are first generated.","created_at":"2015-10-09T06:36:58Z","updated_at":"2015-10-09T06:36:58Z","html_url":"https://github.com/puppetlabs/puppet-server/pull/730#discussion_r41601181","pull_request_url":"https://api.github.com/repos/puppetlabs/puppet-server/pulls/730","_links":{"self":{"href":"https://api.github.com/repos/puppetlabs/puppet-server/pulls/comments/41601181"},"html":{"href":"https://github.com/puppetlabs/puppet-server/pull/730#discussion_r41601181"},"pull_request":{"href":"https://api.github.com/repos/puppetlabs/puppet-server/pulls/730"}}},"pull_request":{"url":"https://api.github.com/repos/puppetlabs/puppet-server/pulls/730","id":47080731,"html_url":"https://github.com/puppetlabs/puppet-server/pull/730","diff_url":"https://github.com/puppetlabs/puppet-server/pull/730.diff","patch_url":"https://github.com/puppetlabs/puppet-server/pull/730.patch","issue_url":"https://api.github.com/repos/puppetlabs/puppet-server/issues/730","number":730,"state":"open","locked":false,"title":"(SERVER-910) make private keys unreadable by all","user":{"login":"dankreek","id":1510128,"avatar_url":"https://avatars.githubusercontent.com/u/1510128?v=3","gravatar_id":"","url":"https://api.github.com/users/dankreek","html_url":"https://github.com/dankreek","followers_url":"https://api.github.com/users/dankreek/followers","following_url":"https://api.github.com/users/dankreek/following{/other_user}","gists_url":"https://api.github.com/users/dankreek/gists{/gist_id}","starred_url":"https://api.github.com/users/dankreek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dankreek/subscriptions","organizations_url":"https://api.github.com/users/dankreek/orgs","repos_url":"https://api.github.com/users/dankreek/repos","events_url":"https://api.github.com/users/dankreek/events{/privacy}","received_events_url":"https://api.github.com/users/dankreek/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-10-07T20:54:52Z","updated_at":"2015-10-09T06:36:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d3c20ad621028a0f3a45a4b6936e016427dd5adb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/puppetlabs/puppet-server/pulls/730/commits","review_comments_url":"https://api.github.com/repos/puppetlabs/puppet-server/pulls/730/comments","review_comment_url":"https://api.github.com/repos/puppetlabs/puppet-server/pulls/comments{/number}","comments_url":"https://api.github.com/repos/puppetlabs/puppet-server/issues/730/comments","statuses_url":"https://api.github.com/repos/puppetlabs/puppet-server/statuses/a71ba1eeb7ce34a93527eef6e2bbfc4de076d792","head":{"label":"dankreek:SERVER-910/make-private-keys-unaccessible","ref":"SERVER-910/make-private-keys-unaccessible","sha":"a71ba1eeb7ce34a93527eef6e2bbfc4de076d792","user":{"login":"dankreek","id":1510128,"avatar_url":"https://avatars.githubusercontent.com/u/1510128?v=3","gravatar_id":"","url":"https://api.github.com/users/dankreek","html_url":"https://github.com/dankreek","followers_url":"https://api.github.com/users/dankreek/followers","following_url":"https://api.github.com/users/dankreek/following{/other_user}","gists_url":"https://api.github.com/users/dankreek/gists{/gist_id}","starred_url":"https://api.github.com/users/dankreek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dankreek/subscriptions","organizations_url":"https://api.github.com/users/dankreek/orgs","repos_url":"https://api.github.com/users/dankreek/repos","events_url":"https://api.github.com/users/dankreek/events{/privacy}","received_events_url":"https://api.github.com/users/dankreek/received_events","type":"User","site_admin":false},"repo":{"id":24694952,"name":"puppet-server","full_name":"dankreek/puppet-server","owner":{"login":"dankreek","id":1510128,"avatar_url":"https://avatars.githubusercontent.com/u/1510128?v=3","gravatar_id":"","url":"https://api.github.com/users/dankreek","html_url":"https://github.com/dankreek","followers_url":"https://api.github.com/users/dankreek/followers","following_url":"https://api.github.com/users/dankreek/following{/other_user}","gists_url":"https://api.github.com/users/dankreek/gists{/gist_id}","starred_url":"https://api.github.com/users/dankreek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dankreek/subscriptions","organizations_url":"https://api.github.com/users/dankreek/orgs","repos_url":"https://api.github.com/users/dankreek/repos","events_url":"https://api.github.com/users/dankreek/events{/privacy}","received_events_url":"https://api.github.com/users/dankreek/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dankreek/puppet-server","description":"Server automation framework and application","fork":true,"url":"https://api.github.com/repos/dankreek/puppet-server","forks_url":"https://api.github.com/repos/dankreek/puppet-server/forks","keys_url":"https://api.github.com/repos/dankreek/puppet-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dankreek/puppet-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dankreek/puppet-server/teams","hooks_url":"https://api.github.com/repos/dankreek/puppet-server/hooks","issue_events_url":"https://api.github.com/repos/dankreek/puppet-server/issues/events{/number}","events_url":"https://api.github.com/repos/dankreek/puppet-server/events","assignees_url":"https://api.github.com/repos/dankreek/puppet-server/assignees{/user}","branches_url":"https://api.github.com/repos/dankreek/puppet-server/branches{/branch}","tags_url":"https://api.github.com/repos/dankreek/puppet-server/tags","blobs_url":"https://api.github.com/repos/dankreek/puppet-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dankreek/puppet-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dankreek/puppet-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/dankreek/puppet-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dankreek/puppet-server/statuses/{sha}","languages_url":"https://api.github.com/repos/dankreek/puppet-server/languages","stargazers_url":"https://api.github.com/repos/dankreek/puppet-server/stargazers","contributors_url":"https://api.github.com/repos/dankreek/puppet-server/contributors","subscribers_url":"https://api.github.com/repos/dankreek/puppet-server/subscribers","subscription_url":"https://api.github.com/repos/dankreek/puppet-server/subscription","commits_url":"https://api.github.com/repos/dankreek/puppet-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/dankreek/puppet-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/dankreek/puppet-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/dankreek/puppet-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/dankreek/puppet-server/contents/{+path}","compare_url":"https://api.github.com/repos/dankreek/puppet-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dankreek/puppet-server/merges","archive_url":"https://api.github.com/repos/dankreek/puppet-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dankreek/puppet-server/downloads","issues_url":"https://api.github.com/repos/dankreek/puppet-server/issues{/number}","pulls_url":"https://api.github.com/repos/dankreek/puppet-server/pulls{/number}","milestones_url":"https://api.github.com/repos/dankreek/puppet-server/milestones{/number}","notifications_url":"https://api.github.com/repos/dankreek/puppet-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dankreek/puppet-server/labels{/name}","releases_url":"https://api.github.com/repos/dankreek/puppet-server/releases{/id}","created_at":"2014-10-01T20:51:06Z","updated_at":"2015-05-11T19:44:49Z","pushed_at":"2015-10-07T20:53:56Z","git_url":"git://github.com/dankreek/puppet-server.git","ssh_url":"git@github.com:dankreek/puppet-server.git","clone_url":"https://github.com/dankreek/puppet-server.git","svn_url":"https://github.com/dankreek/puppet-server","homepage":"https://tickets.puppetlabs.com/browse/SERVER","size":3363,"stargazers_count":0,"watchers_count":0,"language":"Clojure","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"puppetlabs:1.x","ref":"1.x","sha":"1b37a56dc3a4bb4c6691f5627293321355b71e6a","user":{"login":"puppetlabs","id":234268,"avatar_url":"https://avatars.githubusercontent.com/u/234268?v=3","gravatar_id":"","url":"https://api.github.com/users/puppetlabs","html_url":"https://github.com/puppetlabs","followers_url":"https://api.github.com/users/puppetlabs/followers","following_url":"https://api.github.com/users/puppetlabs/following{/other_user}","gists_url":"https://api.github.com/users/puppetlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/puppetlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/puppetlabs/subscriptions","organizations_url":"https://api.github.com/users/puppetlabs/orgs","repos_url":"https://api.github.com/users/puppetlabs/repos","events_url":"https://api.github.com/users/puppetlabs/events{/privacy}","received_events_url":"https://api.github.com/users/puppetlabs/received_events","type":"Organization","site_admin":false},"repo":{"id":19546488,"name":"puppet-server","full_name":"puppetlabs/puppet-server","owner":{"login":"puppetlabs","id":234268,"avatar_url":"https://avatars.githubusercontent.com/u/234268?v=3","gravatar_id":"","url":"https://api.github.com/users/puppetlabs","html_url":"https://github.com/puppetlabs","followers_url":"https://api.github.com/users/puppetlabs/followers","following_url":"https://api.github.com/users/puppetlabs/following{/other_user}","gists_url":"https://api.github.com/users/puppetlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/puppetlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/puppetlabs/subscriptions","organizations_url":"https://api.github.com/users/puppetlabs/orgs","repos_url":"https://api.github.com/users/puppetlabs/repos","events_url":"https://api.github.com/users/puppetlabs/events{/privacy}","received_events_url":"https://api.github.com/users/puppetlabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/puppetlabs/puppet-server","description":"Server automation framework and application","fork":false,"url":"https://api.github.com/repos/puppetlabs/puppet-server","forks_url":"https://api.github.com/repos/puppetlabs/puppet-server/forks","keys_url":"https://api.github.com/repos/puppetlabs/puppet-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/puppetlabs/puppet-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/puppetlabs/puppet-server/teams","hooks_url":"https://api.github.com/repos/puppetlabs/puppet-server/hooks","issue_events_url":"https://api.github.com/repos/puppetlabs/puppet-server/issues/events{/number}","events_url":"https://api.github.com/repos/puppetlabs/puppet-server/events","assignees_url":"https://api.github.com/repos/puppetlabs/puppet-server/assignees{/user}","branches_url":"https://api.github.com/repos/puppetlabs/puppet-server/branches{/branch}","tags_url":"https://api.github.com/repos/puppetlabs/puppet-server/tags","blobs_url":"https://api.github.com/repos/puppetlabs/puppet-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/puppetlabs/puppet-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/puppetlabs/puppet-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/puppetlabs/puppet-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/puppetlabs/puppet-server/statuses/{sha}","languages_url":"https://api.github.com/repos/puppetlabs/puppet-server/languages","stargazers_url":"https://api.github.com/repos/puppetlabs/puppet-server/stargazers","contributors_url":"https://api.github.com/repos/puppetlabs/puppet-server/contributors","subscribers_url":"https://api.github.com/repos/puppetlabs/puppet-server/subscribers","subscription_url":"https://api.github.com/repos/puppetlabs/puppet-server/subscription","commits_url":"https://api.github.com/repos/puppetlabs/puppet-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/puppetlabs/puppet-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/puppetlabs/puppet-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/puppetlabs/puppet-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/puppetlabs/puppet-server/contents/{+path}","compare_url":"https://api.github.com/repos/puppetlabs/puppet-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/puppetlabs/puppet-server/merges","archive_url":"https://api.github.com/repos/puppetlabs/puppet-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/puppetlabs/puppet-server/downloads","issues_url":"https://api.github.com/repos/puppetlabs/puppet-server/issues{/number}","pulls_url":"https://api.github.com/repos/puppetlabs/puppet-server/pulls{/number}","milestones_url":"https://api.github.com/repos/puppetlabs/puppet-server/milestones{/number}","notifications_url":"https://api.github.com/repos/puppetlabs/puppet-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/puppetlabs/puppet-server/labels{/name}","releases_url":"https://api.github.com/repos/puppetlabs/puppet-server/releases{/id}","created_at":"2014-05-07T19:00:24Z","updated_at":"2015-10-09T05:39:54Z","pushed_at":"2015-10-08T23:03:52Z","git_url":"git://github.com/puppetlabs/puppet-server.git","ssh_url":"git@github.com:puppetlabs/puppet-server.git","clone_url":"https://github.com/puppetlabs/puppet-server.git","svn_url":"https://github.com/puppetlabs/puppet-server","homepage":"https://tickets.puppetlabs.com/browse/SERVER","size":9009,"stargazers_count":122,"watchers_count":122,"language":"Clojure","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":68,"mirror_url":null,"open_issues_count":2,"forks":68,"open_issues":2,"watchers":122,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/puppetlabs/puppet-server/pulls/730"},"html":{"href":"https://github.com/puppetlabs/puppet-server/pull/730"},"issue":{"href":"https://api.github.com/repos/puppetlabs/puppet-server/issues/730"},"comments":{"href":"https://api.github.com/repos/puppetlabs/puppet-server/issues/730/comments"},"review_comments":{"href":"https://api.github.com/repos/puppetlabs/puppet-server/pulls/730/comments"},"review_comment":{"href":"https://api.github.com/repos/puppetlabs/puppet-server/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/puppetlabs/puppet-server/pulls/730/commits"},"statuses":{"href":"https://api.github.com/repos/puppetlabs/puppet-server/statuses/a71ba1eeb7ce34a93527eef6e2bbfc4de076d792"}}}}