]> git.ipfire.org Git - thirdparty/asterisk.git/commit
asterisk.c: Use the euid's home directory to read/write cli history
authorGeorge Joseph <gjoseph@sangoma.com>
Fri, 15 Sep 2023 17:19:18 +0000 (11:19 -0600)
committerGeorge Joseph <gjoseph@sangoma.com>
Fri, 22 Sep 2023 13:34:18 +0000 (13:34 +0000)
commitfc516f5781bbf14ba3c4d3f27d614d6ca564a6cd
tree2837d41911dfb4f8e98276cbf119e53a81e2628d
parenta38add11e687b230d555d81084eca7d74d464f67
asterisk.c: Use the euid's home directory to read/write cli history

The CLI .asterisk_history file is read from/written to the directory
specified by the HOME environment variable. If the root user starts
asterisk with the -U/-G options, or with runuser/rungroup set in
asterisk.conf, the asterisk process is started as root but then it
calls setuid/setgid to set the new user/group. This does NOT reset
the HOME environment variable to the new user's home directory
though so it's still left as "/root". In this case, the new user
will almost certainly NOT have access to read from or write to the
history file.

* Added function process_histfile() which calls
  getpwuid(geteuid()) and uses pw->dir as the home directory
  instead of the HOME environment variable.
* ast_el_read_default_histfile() and ast_el_write_default_histfile()
  have been modified to use the new process_histfile()
  function.

Resolves: #337
main/asterisk.c