]> 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)
committerAsterisk Development Team <asteriskteam@digium.com>
Fri, 12 Jan 2024 18:29:18 +0000 (18:29 +0000)
commit97674e1d20c241df06cfd2194c905ceb73f9eb91
tree68eeb712688211992b07b72b278a415669b805d5
parenta86376fe6824b59876f8dde4dd2348532bc5d6bc
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
(cherry picked from commit 07cf37531a5cd5d6deb70fd6d71507c0ff6d9fd3)
main/asterisk.c