0

[Please, I don't want to know why I shouldn't edit it; I want to know why I can't edit it]

# pwd
/var/spool/cron/crontabs
# ll sysadmin
-rw------- 1 sysadmin crontab 210 Jun 17 16:05 sysadmin
# getcap sysadmin
# lsattr sysadmin
--------------e------- sysadmin
# filecap /var/spool/cron/crontabs/sysadmin
Unable to get capabilities of /var/spool/cron/crontabs/sysadmin: No data available

This is Ubuntu 22.04, ext4, LVM. I can delete the file, but I can't write to it.

EDIT

crontab -e successfully changes the file, as expected. However, editing the file with a text editor (in my case, emacs, while running as root) simply gives an error message ("Opening output file: Permission denied, /var/spool/cron/crontabs/sysadmin").

EDIT 2

This question isn't about emacs, or any other editor - it appears that crontab -e has some magic which I can't duplicate as a root user, and that the magic is unrelated to file capabilities. If I try echoing to the file as suggested in a comment:

root@vserver:/var/spool/cron/crontabs# echo "foo" >> sysadmin
bash: sysadmin: Permission denied

So what is it that's denying me permission?

14
  • You mean you can't edit it with crontab -u sysadmin -e as root? Commented Jun 17, 2024 at 15:34
  • @Kusalananda: I can't edit it with emacs - I assume that crontab -e would work. Commented Jun 17, 2024 at 15:53
  • Please edit your question and show us i) how you try to edit it and ii) how it fails. Is there an error? What error? Is there no error but your changes disappear? What happens? Commented Jun 17, 2024 at 16:09
  • 1
    You can (and should) use crontab -e regardless of which editor you want to use - just specify emacs via the EDITOR or VISUAL environment variable. See for example crontab -e doesnt shows option to select editor - what to do? Commented Jun 17, 2024 at 19:43
  • 1
    What does ls -ld /var/spool/cron/crontabs/ say? What is the fs.protected_regular sysctl set to? Commented Jun 18, 2024 at 14:53

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.