crmsh icon indicating copy to clipboard operation
crmsh copied to clipboard

Fix: #977 crmsh not working when using ACL

Open heinervdm opened this issue 2 years ago • 1 comments

Set file user of logfile to current user und HA_GROUP, as changing the user to someone else is only allowed for root. Set umask to 002, to make log file group writable. Also add a GroupWriteRotatingFileHandler, taken from https://stackoverflow.com/a/6779307 to keep permissions when log file is rotated. I couldn't test the rotation, as my logfile was always empty...

heinervdm avatar Jul 07 '22 12:07 heinervdm

Hi @heinervdm Sorry for late!

Thanks for your PR!:)

I'm trying to use your code by these steps

  • Under root, run crm cluster init -y to setup a cluster
  • Under root, run crm configure show
  • Under root, run useradd -m -G haclient hatest
  • Run su - hatest
  • Under hatest, run /usr/sbin/crm cluster show, I got
Traceback (most recent call last):
  File "/usr/sbin/crm", line 31, in <module>
    log.setup_logging()
  File "/usr/lib/python3.8/site-packages/crmsh/log.py", line 458, in setup_logging
    shutil.chown(CRMSH_LOG_FILE, os.getuid(), constants.HA_GROUP)
  File "/usr/lib64/python3.8/shutil.py", line 1310, in chown
    os.chown(path, _user, _group)
PermissionError: [Errno 1] Operation not permitted: '/var/log/crmsh/crmsh.log'

liangxin1300 avatar Jul 21 '22 01:07 liangxin1300

Thank you for your contribution. Your commit has been cherry-picked to #1040 and merged to master.

nicholasyang2022 avatar Oct 27 '22 06:10 nicholasyang2022