Unable to save config with /znc saveconfig #1073

Closed
opened 2026-10-05 05:01:50 +02:00 by adam · 11 comments
Owner

Hello,
since last month or maybe two I've an issue with saving config in my ZNC (1.9.1 version, latest in Ubuntu 25.04 repositories). It happens each time when I want to shutdown znc from IRC client or with /znc saveconfig. Debug mode shows that there is an issue with permissions, but I've checked and tried with 777 for .znc/configs dir and 777 for config files (just for tests), all files and directories has properly configured user (chown).

[2025-07-14 21:16:31.417894] (inzaghi89/quakenet) CLI -> ZNC [PRIVMSG *status :saveconfig]
[2025-07-14 21:16:31.418121] Error while locking the new config file, errno says: Permission denied
[2025-07-14 21:16:31.418215] (inzaghi89/quakenet) ZNC -> CLI [:*status!status@znc.in PRIVMSG inzaghi89 :Błąd podczas próby zapisu konfiguracji.]

~/.znc

drwx------  2 inzaghi89 inzaghi89 4096 lip 14 21:16 configs
drwx------  5 inzaghi89 inzaghi89 4096 lip 14 21:05 moddata
drwx------  2 inzaghi89 inzaghi89 4096 wrz  2  2011 modules
drwxr-xr-x  3 inzaghi89 inzaghi89 4096 sie  5  2011 users
-rw-rw-r--  1 inzaghi89 inzaghi89 3038 wrz 17  2011 znc.pem

~/.znc/configs

drwx------ 2 inzaghi89 inzaghi89 4096 lip 14 21:16 .
drwxr-xr-x 6 inzaghi89 inzaghi89 4096 lip 14 21:05 ..
-rw------- 1 inzaghi89 inzaghi89 2479 lip 14 21:12 znc.conf
-rw------- 1 inzaghi89 inzaghi89 2899 lip 14 20:55 znc.conf_bak
-rw-r--r-- 1 inzaghi89 inzaghi89 1379 paź 10  2012 znc.conf.pre-1.000
-rw------- 1 inzaghi89 inzaghi89 1908 sie 25  2013 znc.conf.pre-1.1
-rw------- 1 inzaghi89 inzaghi89 1981 lis 14  2013 znc.conf.pre-1.2
-rw------- 1 inzaghi89 inzaghi89 2025 maj 27  2014 znc.conf.pre-1.4
-rw------- 1 inzaghi89 inzaghi89 2026 mar  7  2020 znc.conf.pre-1.7.4
-rw------- 1 inzaghi89 inzaghi89 2489 paź 25  2020 znc.conf.pre-1.8.2
-rw------- 1 inzaghi89 inzaghi89 2745 kwi 25  2024 znc.conf.pre-1.9.0

Before that I didn't make any changes in my ZNC configuration and it works well. Only changes which I made is today (14 july). Same issue is while I try to save config via www.

I can shutdown znc with shutdown force. But is there any solution for saving config? ;) Thanks in advance.

Hello, since last month or maybe two I've an issue with saving config in my ZNC (1.9.1 version, latest in Ubuntu 25.04 repositories). It happens each time when I want to shutdown znc from IRC client or with /znc saveconfig. Debug mode shows that there is an issue with permissions, but I've checked and tried with 777 for .znc/configs dir and 777 for config files (just for tests), all files and directories has properly configured user (chown). ``` [2025-07-14 21:16:31.417894] (inzaghi89/quakenet) CLI -> ZNC [PRIVMSG *status :saveconfig] [2025-07-14 21:16:31.418121] Error while locking the new config file, errno says: Permission denied [2025-07-14 21:16:31.418215] (inzaghi89/quakenet) ZNC -> CLI [:*status!status@znc.in PRIVMSG inzaghi89 :Błąd podczas próby zapisu konfiguracji.] ``` ~/.znc ``` drwx------ 2 inzaghi89 inzaghi89 4096 lip 14 21:16 configs drwx------ 5 inzaghi89 inzaghi89 4096 lip 14 21:05 moddata drwx------ 2 inzaghi89 inzaghi89 4096 wrz 2 2011 modules drwxr-xr-x 3 inzaghi89 inzaghi89 4096 sie 5 2011 users -rw-rw-r-- 1 inzaghi89 inzaghi89 3038 wrz 17 2011 znc.pem ``` ~/.znc/configs ``` drwx------ 2 inzaghi89 inzaghi89 4096 lip 14 21:16 . drwxr-xr-x 6 inzaghi89 inzaghi89 4096 lip 14 21:05 .. -rw------- 1 inzaghi89 inzaghi89 2479 lip 14 21:12 znc.conf -rw------- 1 inzaghi89 inzaghi89 2899 lip 14 20:55 znc.conf_bak -rw-r--r-- 1 inzaghi89 inzaghi89 1379 paź 10 2012 znc.conf.pre-1.000 -rw------- 1 inzaghi89 inzaghi89 1908 sie 25 2013 znc.conf.pre-1.1 -rw------- 1 inzaghi89 inzaghi89 1981 lis 14 2013 znc.conf.pre-1.2 -rw------- 1 inzaghi89 inzaghi89 2025 maj 27 2014 znc.conf.pre-1.4 -rw------- 1 inzaghi89 inzaghi89 2026 mar 7 2020 znc.conf.pre-1.7.4 -rw------- 1 inzaghi89 inzaghi89 2489 paź 25 2020 znc.conf.pre-1.8.2 -rw------- 1 inzaghi89 inzaghi89 2745 kwi 25 2024 znc.conf.pre-1.9.0 ``` Before that I didn't make any changes in my ZNC configuration and it works well. Only changes which I made is today (14 july). Same issue is while I try to save config via www. I can shutdown znc with shutdown force. But is there any solution for saving config? ;) Thanks in advance. <!-- github-sync-id:3229789262 -->
adam closed this issue 2026-10-05 05:01:50 +02:00
Author
Owner

Show output of ps aux|grep znc

Show output of `ps aux|grep znc` <!-- github-comment-id:3070711371 -->
Author
Owner
root@bubu:~# ps aux|grep znc
inzaghi+    1541  0.0  0.0  64880  5360 ?        Ssl  21:32   0:00 znc
root        1624  0.0  0.0   6308  1988 pts/1    S+   21:32   0:00 grep --color=auto znc
root@bubu:~# 

There is only one instance running

``` root@bubu:~# ps aux|grep znc inzaghi+ 1541 0.0 0.0 64880 5360 ? Ssl 21:32 0:00 znc root 1624 0.0 0.0 6308 1988 pts/1 S+ 21:32 0:00 grep --color=auto znc root@bubu:~# ``` There is only one instance running <!-- github-comment-id:3070724165 -->
Author
Owner

Some unusual filesystem, or mount options?

Some unusual filesystem, or mount options? <!-- github-comment-id:3070752342 -->
Author
Owner

Nope, / are mounted as ext4. I didn't change anything in this configuration. All runs on RaspberryPi5 since almost 2 years without any issue until last few months.

fstab

LABEL=writable  /       ext4    defaults        0       1
LABEL=system-boot       /boot/firmware  vfat    defaults        0       1
Nope, / are mounted as ext4. I didn't change anything in this configuration. All runs on RaspberryPi5 since almost 2 years without any issue until last few months. fstab ``` LABEL=writable / ext4 defaults 0 1 LABEL=system-boot /boot/firmware vfat defaults 0 1 ``` <!-- github-comment-id:3070760895 -->
Author
Owner

Raspberry is known to wear SD cards quickly. Maybe that's the reason?

Raspberry is known to wear SD cards quickly. Maybe that's the reason? <!-- github-comment-id:3070767992 -->
Author
Owner

I'm on NVMe drive with geekworm x1001. There is no issue with write new files/change settings in system.

I'm on NVMe drive with geekworm x1001. There is no issue with write new files/change settings in system. <!-- github-comment-id:3070773907 -->
Author
Owner

I'm on Ubuntu 25.10. I'm also on old-school hard disk, so it is not going to be SD wear, SSD wear, or NVM wear. (Are you going to suggest old-school hard disk wear too? 😅 )

I have found that the AppArmor profile for ZNC forgot to allow locking a file (e.g., /var/log/syslog has a relevant error message). Notice these lines somewhere in /etc/apparmor.d/znc :

owner @{HOME}/.znc/configs/znc.conf rwk,
# Tilde version is used when the config is updated by ZNC
owner @{HOME}/.znc/configs/znc.conf~ rw,

What it forgot is that tilde version should have "rwk" just like the not-tilde version. ("k" means allow locking.)

Adding "k" back solves the issue:

owner @{HOME}/.znc/configs/znc.conf rwk,
# Tilde version is used when the config is updated by ZNC
owner @{HOME}/.znc/configs/znc.conf~ rwk,

I may have to bring this up with Debian or Ubuntu...

I'm on Ubuntu 25.10. I'm also on old-school hard disk, so it is not going to be SD wear, SSD wear, or NVM wear. (Are you going to suggest old-school hard disk wear too? 😅 ) I have found that the AppArmor profile for ZNC forgot to allow locking a file (e.g., /var/log/syslog has a relevant error message). Notice these lines somewhere in /etc/apparmor.d/znc : ``` owner @{HOME}/.znc/configs/znc.conf rwk, # Tilde version is used when the config is updated by ZNC owner @{HOME}/.znc/configs/znc.conf~ rw, ``` What it forgot is that tilde version should have "rwk" just like the not-tilde version. ("k" means allow locking.) Adding "k" back solves the issue: ``` owner @{HOME}/.znc/configs/znc.conf rwk, # Tilde version is used when the config is updated by ZNC owner @{HOME}/.znc/configs/znc.conf~ rwk, ``` I may have to bring this up with Debian or Ubuntu... <!-- github-comment-id:3690690682 -->
Author
Owner

I'm on Ubuntu 25.10. I'm also on old-school hard disk, so it is not going to be SD wear, SSD wear, or NVM wear. (Are you going to suggest old-school hard disk wear too? 😅 )

I have found that the AppArmor profile for ZNC forgot to allow locking a file (e.g., /var/log/syslog has a relevant error message). Notice these lines somewhere in /etc/apparmor.d/znc :

owner @{HOME}/.znc/configs/znc.conf rwk,
# Tilde version is used when the config is updated by ZNC
owner @{HOME}/.znc/configs/znc.conf~ rw,

What it forgot is that tilde version should have "rwk" just like the not-tilde version. ("k" means allow locking.)

Adding "k" back solves the issue:

owner @{HOME}/.znc/configs/znc.conf rwk,
# Tilde version is used when the config is updated by ZNC
owner @{HOME}/.znc/configs/znc.conf~ rwk,

I may have to bring this up with Debian or Ubuntu...

It sounds like you have a different issue. But I don't think the apparmor rules are part of the ZNC source distro. You should file those bugs against Debian and Ubuntu respectively.

> I'm on Ubuntu 25.10. I'm also on old-school hard disk, so it is not going to be SD wear, SSD wear, or NVM wear. (Are you going to suggest old-school hard disk wear too? 😅 ) > > I have found that the AppArmor profile for ZNC forgot to allow locking a file (e.g., /var/log/syslog has a relevant error message). Notice these lines somewhere in /etc/apparmor.d/znc : > > ``` > owner @{HOME}/.znc/configs/znc.conf rwk, > # Tilde version is used when the config is updated by ZNC > owner @{HOME}/.znc/configs/znc.conf~ rw, > ``` > > What it forgot is that tilde version should have "rwk" just like the not-tilde version. ("k" means allow locking.) > > Adding "k" back solves the issue: > > ``` > owner @{HOME}/.znc/configs/znc.conf rwk, > # Tilde version is used when the config is updated by ZNC > owner @{HOME}/.znc/configs/znc.conf~ rwk, > ``` > > I may have to bring this up with Debian or Ubuntu... It sounds like you have a different issue. But I don't think the apparmor rules are part of the ZNC source distro. You should file those bugs against Debian and Ubuntu respectively. <!-- github-comment-id:3690808416 -->
Author
Owner

I'm on Ubuntu 25.10. I'm also on old-school hard disk, so it is not going to be SD wear, SSD wear, or NVM wear. (Are you going to suggest old-school hard disk wear too? 😅 )

...

Sorry to bring up an old issue. @treblacy did you ever file that issue with apparmor? I can confirm this happened for me as well on a fresh Ubuntu 25.10 image using the ZNC package deployed by apt.

If you did file the issue, please link it here, as this thread is the first result when Googling for znc "Error while locking the new config file, errno says: Permission denied", and given that we're waiting on the apparmor maintainers to fix their mistake, it'd be good to make sure that information is findable.

> I'm on Ubuntu 25.10. I'm also on old-school hard disk, so it is not going to be SD wear, SSD wear, or NVM wear. (Are you going to suggest old-school hard disk wear too? 😅 ) > > ... Sorry to bring up an old issue. @treblacy did you ever file that issue with apparmor? I can confirm this happened for me as well on a fresh Ubuntu 25.10 image using the ZNC package deployed by `apt`. If you did file the issue, please link it here, as this thread is the first result when Googling for `znc "Error while locking the new config file, errno says: Permission denied"`, and given that we're waiting on the apparmor maintainers to fix their mistake, it'd be good to make sure that information is findable. <!-- github-comment-id:4006762408 -->
Author
Owner

Try this https://keepmind.eu/brak-mozliwosci-zapisu-pliku-konfiguracyjnego-znc.html

Short version below: 👇
There is an issue with one of the flags in /etc/apparmor.d/znc where is missing "k" in this line:

owner @{HOME}/.znc/configs/znc.conf~ rw,

So it's should like like this

owner @{HOME}/.znc/configs/znc.conf~ rwk,

After that reload apparmor and all should work well ;)

sudo apparmor_parser -r /etc/apparmor.d/znc
Try this https://keepmind.eu/brak-mozliwosci-zapisu-pliku-konfiguracyjnego-znc.html Short version below: 👇 There is an issue with one of the flags in `/etc/apparmor.d/znc` where is missing "k" in this line: ```sh owner @{HOME}/.znc/configs/znc.conf~ rw, ``` So it's should like like this ```sh owner @{HOME}/.znc/configs/znc.conf~ rwk, ``` After that reload apparmor and all should work well ;) ```sh sudo apparmor_parser -r /etc/apparmor.d/znc ``` <!-- github-comment-id:4007402458 -->
Author
Owner

Try this https://keepmind.eu/brak-mozliwosci-zapisu-pliku-konfiguracyjnego-znc.html

Short version below: 👇 . . .

Yes, this is ultimately what I did. For anyone finding this on Google, this is the fix for newer versions of Ubuntu/Debian with AppArmor enabled.

Reviewing AppArmor's own code for the ZNC profile shows that AppArmor actually already fixed this issue (note the correct rwk on the appropriate lines), so the issue lies with Canonical/Debian for getting an updated version of AppArmor deployed. Unsure if they'd be willing to make a change like that in a stable release, so this is likely going to persist as an issue until there's a distro update.

At any rate, @DarthGandalf (or anyone else) can likely close this issue as it's not ZNC's fault.

> Try this https://keepmind.eu/brak-mozliwosci-zapisu-pliku-konfiguracyjnego-znc.html > > Short version below: 👇 . . . Yes, this is ultimately what I did. For anyone finding this on Google, this is the fix for newer versions of Ubuntu/Debian with AppArmor enabled. Reviewing [AppArmor's own code for the ZNC profile](https://gitlab.com/apparmor/apparmor/-/blob/master/profiles/apparmor.d/znc) shows that AppArmor actually already fixed this issue (note the correct `rwk` on the appropriate lines), so the issue lies with Canonical/Debian for getting an updated version of AppArmor deployed. Unsure if they'd be willing to make a change like that in a stable release, so this is likely going to persist as an issue until there's a distro update. At any rate, @DarthGandalf (or anyone else) can likely close this issue as it's not ZNC's fault. <!-- github-comment-id:4008175594 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/znc#1073