runtime: don't execute external commands when loading ftplugins

This is a followup to 816fbcc262687b81fc46f82f7bbeb1453addfe0c (patch
9.0.1833: [security] runtime file fixes)

It basically disables that external commands are run on loading of the
filetype plugin, **unless** the user has set the `g:plugin_exec = 1`
global variable in their configuration or for a specific filetype the
variable g:<filetype>_exec=1.

There are a few more plugins, that may execute system commands like
debchangelog, gitcommit, sh, racket, zsh, ps1 but those do at least
do not run those commands by default during loading of the filetype plugin
(there the command is mostly run as convenience for auto-completion or
to provide documentation lookup).

closes: #13034

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Tim Pope <vim@tpope.org>
diff --git a/runtime/ftplugin/changelog.vim b/runtime/ftplugin/changelog.vim
index e9df63f..a624333 100644
--- a/runtime/ftplugin/changelog.vim
+++ b/runtime/ftplugin/changelog.vim
@@ -55,13 +55,19 @@
     elseif $EMAIL_ADDRESS != ""
       return $EMAIL_ADDRESS
     endif
+    let s:default_login = 'unknown'
 
-    let login = s:login()
+    " Disabled by default for security reasons.  
+    if get(g:, 'changelog_exec', get(g:, 'plugin_exec', 0))
+      let login = s:login()
+    else
+      let login = s:default_login
+    endif
     return printf('%s <%s@%s>', s:name(login), login, s:hostname())
   endfunction
 
   function! s:login()
-    return s:trimmed_system_with_default('whoami', 'unknown')
+    return s:trimmed_system_with_default('whoami', s:default_login)
   endfunction
 
   function! s:trimmed_system_with_default(command, default)
@@ -71,7 +77,7 @@
   function! s:system_with_default(command, default)
     let output = system(a:command)
     if v:shell_error
-      return default
+      return a:default
     endif
     return output
   endfunction