This forum has been archived. All content is frozen. Please use KDE Discuss instead.

[SOLVED] cupsd cannot write to /var/log/cups

Tags: None
(comma "," separated)
User avatar
sparhawk
Registered Member
Posts
433
Karma
0
OS
I just reinstalled kubuntu 12.10 on my new SSD. In order to reduce wear (probably unnecessary), I used symlinks to change the location of /var/log (and others) to my secondary HDD (I'm not sure if this is related to the problem).

if I look at /var/log/syslog, I see entries every few seconds much like the following:
Code: Select all
Dec 18 01:26:24 sparhawk-XPS-17 cupsd: Unable to change ownership of "/var/log/cups" - Permission denied
Dec 18 01:26:24 sparhawk-XPS-17 cupsd: Unable to open log file "/var/log/cups/access_log" - Permission denied
Dec 18 01:26:24 sparhawk-XPS-17 kernel: [  328.573264] type=1400 audit(1355754384.220:325): apparmor="DENIED" operation="open" parent=1 profile="/usr/sbin/cupsd" name="/HDD/.SDDsymlinks/var/log/cups/access_log" pid=1018 comm="cupsd" requested_mask="rac" denied_mask="rac" fsuid=0 ouid=0
Dec 18 01:26:24 sparhawk-XPS-17 kernel: [  328.573274] type=1400 audit(1355754384.220:326): apparmor="DENIED" operation="chown" parent=1 profile="/usr/sbin/cupsd" name="/HDD/.SDDsymlinks/var/log/cups/" pid=1018 comm="cupsd" requested_mask="w" denied_mask="w" fsuid=0 ouid=0
Dec 18 01:26:24 sparhawk-XPS-17 kernel: [  328.573296] type=1400 audit(1355754384.220:327): apparmor="DENIED" operation="open" parent=1 profile="/usr/sbin/cupsd" name="/HDD/.SDDsymlinks/var/log/cups/access_log" pid=1018 comm="cupsd" requested_mask="rac" denied_mask="rac" fsuid=0 ouid=0


Code: Select all
$ ls -dl cups
drwxr-xr-x 2 root root 4096 Dec 17 11:47 cups


I googled, but could only really find five-year-old references to a bug that's supposedly fixed. Is there a way to fix this issue? Thanks in advance.

EDIT
I've also just noticed that anacron is failing to load on startup. I tried to run anacron manually.
Code: Select all
$ anacron
anacron: Can't chdir to /var/spool/anacron: No such file or directory
$ ls -l /var/spool/
total 0
drwxr-xr-x 3 root root 60 Dec 18 01:21 cron
drwx--x--- 3 root lp   60 Dec 18 01:21 cups

Perhaps this is related, as /var/spool is also symlinked to my spindle HDD. FWIW when I was setting it up, I moved the current directory to the HDD (using `mv`), then created the symlink to there. I didn't touch permissions at all.

Last edited by sparhawk on Thu Dec 20, 2012 12:43 pm, edited 1 time in total.
User avatar
google01103
Manager
Posts
6668
Karma
25
I think your issue is apparmor, cups and *buntu related, try google'ing apparmor cups ubuntu OR kubuntu

a possible solution might be to uninstall and then reinstall apparmor, cups (also related packages) and anacron - think you might have confused apparmor with the linking

for anacron if reinstalling does not work create the spool dir, permissions should be rwxr-xr-x root root


OpenSuse Leap 42.1 x64, Plasma 5.x

User avatar
sparhawk
Registered Member
Posts
433
Karma
0
OS
Thanks for the reply. I purged all three, restarted, reinstalled all, then restarted again.

I'm still getting the cups/apparmor messages, but my startup screen is now very strange. I checked /var/log/boot.log, and I've now got all these empty "starting" messages (see below), and no sign of anacron at all.

Code: Select all
Begin: Loading essential drivers ... done.
Begin: Running /scripts/init-premount ... done.
Begin: Mounting root file system ... Begin: Running /scripts/local-top ... done.
Begin: Running /scripts/local-premount ... done.
Begin: Running /scripts/local-bottom ... done.
done.
Begin: Running /scripts/init-bottom ... done.
fsck from util-linux 2.20.1
fsck from util-linux 2.20.1
fsck from util-linux 2.20.1
root: clean, 284970/1638400 files, 2380844/6553600 blocks
home: clean, 41935/7208960 files, 7280071/28835840 blocks
linuxHDD: clean, 545069/29491200 files, 64000870/117964800 blocks
 * Starting mDNS/DNS-SD daemon [ OK ]
 * Starting Mount network filesystems [ OK ]
 * Stopping Mount network filesystems [ OK ]
 * Starting configure network device security [ OK ]
 * Starting Uncomplicated firewall [ OK ]
 * Starting configure network device [ OK ]
 * Starting configure network device [ OK ]
 * Starting System V initialisation compatibility [ OK ]
 * Starting modem connection manager [ OK ]
 * Starting configure network device security [ OK ]
 * Stopping Failsafe Boot Delay [ OK ]
 * Starting configure network device [ OK ]
Skipping profile in /etc/apparmor.d/disable: usr.bin.firefox
Skipping profile in /etc/apparmor.d/disable: usr.sbin.rsyslogd
 * Starting network connection manager [ OK ]
 * Starting Bridge socket events into upstart [ OK ]
 * Starting AppArmor profiles         
 [ OK ]
Loading the saved-state of the serial devices...
 * Stopping System V initialisation compatibility [ OK ]
 * Starting dictionary server dictd         
 [ OK ]
 * Starting System V runlevel compatibility [ OK ]
 * Starting  [ OK ]
 * Starting automatic crash report generation [ OK ]
 * Starting  [ OK ]
 * Starting Bumblebee supporting nVidia Optimus cards [ OK ]
 * Starting regular background program processing daemon [ OK ]
 * Starting LightDM Display Manager [ OK ]
 * Starting ACPI daemon [ OK ]
 * Starting  [ OK ]
 * Starting  [ OK ]
 * Starting save kernel messages [ OK ]
 * Starting  [ OK ]
 * Starting  [ OK ]
 * Starting deferred execution scheduler [ OK ]
 * Stopping save kernel messages [ OK ]
 * Starting configure network device security [ OK ]
 * Starting CPU interrupts balancing daemon [ OK ]
 * Starting configure virtual network devices [ OK ]
User avatar
google01103
Manager
Posts
6668
Karma
25
my /var/log/cups shows lp lp as owner and group, not root root, possible the printer daemon (user=lp) needs ownership - try changing owner and group to lp

what do you mean no signs of anacron? there should be a folder called /var/spool/anacron (re: you first post)


OpenSuse Leap 42.1 x64, Plasma 5.x

User avatar
sparhawk
Registered Member
Posts
433
Karma
0
OS
Code: Select all
$ ls -dlh /var/log/cups
drwxr-xr-x  2 root root 4.0K Dec  5 02:21 /var/log/cups
$ sudo chown lp /var/log/cups/
$ sudo chgrp lp /var/log/cups/
$ ls -dl /var/log/cups
drwxr-xr-x 2 lp lp 4096 Dec  5 02:21 /var/log/cups

but I still get similar error messages. Perhaps even more than before in syslog.
Code: Select all
Dec 20 00:40:23 sparhawk-XPS-17 cupsd: Unable to change ownership of "/var/log/cups" - Permission denied
Dec 20 00:40:23 sparhawk-XPS-17 cupsd: Unable to open log file "/var/log/cups/access_log" - Permission denied
Dec 20 00:40:23 sparhawk-XPS-17 kernel: [ 3685.315470] type=1400 audit(1355924423.069:6358): apparmor="DENIED" operation="mknod" parent=1 profile="/usr/sbin/cupsd" name="/HDD/.SDDsymlinks/var/log/cups/access_log" pid=1398 comm="cupsd" requested_mask="c" denied_mask="c" fsuid=0 ouid=0
Dec 20 00:40:23 sparhawk-XPS-17 kernel: [ 3685.315486] type=1400 audit(1355924423.069:6359): apparmor="DENIED" operation="chown" parent=1 profile="/usr/sbin/cupsd" name="/HDD/.SDDsymlinks/var/log/cups/" pid=1398 comm="cupsd" requested_mask="w" denied_mask="w" fsuid=0 ouid=7
Dec 20 00:40:23 sparhawk-XPS-17 kernel: [ 3685.315521] type=1400 audit(1355924423.069:6360): apparmor="DENIED" operation="mknod" parent=1 profile="/usr/sbin/cupsd" name="/HDD/.SDDsymlinks/var/log/cups/access_log" pid=1398 comm="cupsd" requested_mask="c" denied_mask="c" fsuid=0 ouid=0
Dec 20 00:40:23 sparhawk-XPS-17 cupsd: Unable to change ownership of "/var/log/cups" - Permission denied
Dec 20 00:40:23 sparhawk-XPS-17 cupsd: Unable to open log file "/var/log/cups/access_log" - Permission denied
Dec 20 00:40:23 sparhawk-XPS-17 kernel: [ 3685.637111] type=1400 audit(1355924423.389:6361): apparmor="DENIED" operation="mknod" parent=1 profile="/usr/sbin/cupsd" name="/HDD/.SDDsymlinks/var/log/cups/access_log" pid=1398 comm="cupsd" requested_mask="c" denied_mask="c" fsuid=0 ouid=0


As for anacron, I meant that there was nothing on the boot screen (i.e. /var/log/boot.log that I quoted above) that mentioned anacron. Normally I get "Starting anac(h)ronistic cron [ OK ]", and my original complaint was that it said "Starting anac(h)ronistic cron [ failed ]". Now I see no entry for anacron at all. Re-reading the error from my OP when I tried to manually start anacron, perhaps I just need to create the directory /var/spool/anacron
Code: Select all
$ ls -la /var/spool
total 4
drwxrwxrwt 4 root root   80 Dec 19 23:38 .
drwxr-xr-x 9 root root 4096 Dec 19 21:38 ..
drwxr-xr-x 3 root root   60 Dec 19 23:38 cron
drwx--x--- 3 root lp     60 Dec 19 23:38 cups

However, there are two issues here. Firstly, how will I know it's working if the boot screen isn't logging anacron properly now? Secondly, I feel that there's probably a larger problem here with permissions, presumably when I moved and symlinked the folders. I've caught two errors now, but I wonder if there are more errors lurking. I just did a `ls -l` in /var , and noticed several entries were blocked in green. Does this mean that something is wrong there? I've attached a screenshot.
Image
Oddly enough, the only symlinks I created were /var/cache /var/log /var/tmp , but other items are green.
User avatar
google01103
Manager
Posts
6668
Karma
25
cups - you have one less error message (the unable to change ownership), now you have a permission error in a file in that folder I'd suggest removing the files in that folder and letting them be recreated hopefully with the correct permissions. that file should be: rw-r--r-- 1 root lp

the green blocking - interesting question and not easily found Google'ing so no real idea but seems amongst other things it indicates sticky bit is on


OpenSuse Leap 42.1 x64, Plasma 5.x

User avatar
sparhawk
Registered Member
Posts
433
Karma
0
OS
google01103 wrote:cups - you have one less error message (the unable to change ownership), now you have a permission error in a file in that folder I'd suggest removing the files in that folder and letting them be recreated hopefully with the correct permissions. that file should be: rw-r--r-- 1 root lp

I'm not sure if I follow you here. I see that same error message in both logs? Are you referring to "Unable to change ownership of "/var/log/cups" - Permission denied"? In any case, as I'll state below, it might not be worth us pursuing this angle.

google01103 wrote:the green blocking - interesting question and not easily found Google'ing so no real idea but seems amongst other things it indicates sticky bit is on

I actually forgot to mention the real reason why I performed the `ls` on /var was to compare permissions there. For example, it seems that anacron cannot create a directory in /var/spool , which seems odd. What should the permissions be for that folder? I also find it odd that moving the directories and symlinking them borked numerous things. I would've thought the permissions would have been maintained. If I can't manage some global-type fix, then I might just reinstate the directories and stop symlinking. Also, I might just have to reinstall kubuntu if I can't get the boot screen behaving, but this is the last option, since I've just spent about 8 hours fixing up my system after the last install!!!

Thanks again for all your help.
User avatar
google01103
Manager
Posts
6668
Karma
25
anacron permissions should be rwxr-xr-x root root - the error message is "can't chdir", not "can't create" so you need to create the folder


OpenSuse Leap 42.1 x64, Plasma 5.x

User avatar
sparhawk
Registered Member
Posts
433
Karma
0
OS
I'm not really sure what is going on here. The anacron permissions are and were all set correctly. The /var/log/cups permissions were changed to be consistent with a clean install, but that didn't exactly work either. As I mentioned, I'm more concerned that there are other problems caused by the symlinks and fstabs that I've set up here. Hence, I tried deleting the symlinks to the /var/ subdirectories, and moving them back.
Code: Select all
for i in '/var/tmp' '/var/log' '/var/cache' ; do sudo rm $i && sudo mv /HDD/.SDDsymlinks$i $i ; done


I also stopped putting /var/spool (and /tmp) on a RAM disk, by commenting out lines in /etc/fstab
Code: Select all
# RAM disk for /tmp
# tmpfs   /tmp       tmpfs   defaults,noatime,mode=1777   0  0
# RAM disk for /var/spool
# tmpfs   /var/spool tmpfs   defaults,noatime,mode=1777   0  0


Doing this fixed the cups/apparmor issue (i.e. syslog is no longer reporting issues every couple of seconds) and also fixed the anacron issue, which is now starting up fine.

Code: Select all
$ grep cron /var/log/boot.log
 * Starting anac(h)ronistic cron [ OK ]


I guess I'll just deal with the possible excess writes to the SSD, since linux didn't seem to like all this symlinking and RAM-disking. The only possible issue now is the strangeness in my boot screen. I still have several empty "starting" lines as per my comment above. Do you see anything like this in your /var/log/boot.log ?
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Instead of symlinks, you may want to try bind mounts instead, which should work fine.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
sparhawk
Registered Member
Posts
433
Karma
0
OS
bcooksley wrote:Instead of symlinks, you may want to try bind mounts instead, which should work fine.


Thank you very much! That works great! (I think.) I have some issues that I'll mention at the end, but I'll just say how I set up the bind mount, in case it's useful to anyone.
First, move the directories and create the bind mounts immediately, in case it's necessary during reboot.
Code: Select all
$ for i in '/var/tmp' '/var/log' '/var/cache' ; do sudo mkdir -p /HDD/.SDDsymlinks$i && sudo rmdir /HDD/.SDDsymlinks$i && sudo mv $i /HDD/.SDDsymlinks$i && sudo mkdir $i && sudo mount --bind /HDD/.SDDsymlinks$i $i ; done
$ mount # this gives a quick list of what's mounted
$ cat /etc/mtab # this tells you what to put in fstab; I removed rw, but it seems it's implied anyway.
/HDD/.SDDsymlinks/var/tmp /var/tmp none rw,bind 0 0
/HDD/.SDDsymlinks/var/log /var/log none rw,bind 0 0
/HDD/.SDDsymlinks/var/cache /var/cache none rw,bind 0 0
$ sudo vim /etc/fstab # or instead of vim use nano/kate/etc. Paste the above three lines in, then reboot.


After reboot, my syslog isn't complaining any more, but I'm getting yet another iteration on the boot screen.
Code: Select all
$ grep cron /var/log/boot.log
 * Starting anac(h)ronistic cron [ OK ]
 * Stopping anac(h)ronistic cron [ OK ]

It seems like anacron is stopping now for some reason. And I'm still getting the empty "Starting" messages too... I'm not sure if any of this is related to the mount bind, or just a general screwiness of my system.
User avatar
google01103
Manager
Posts
6668
Karma
25
do you have have any anacron tasks defined? if it doesn't find any it exists according to anacron.sourceforge.net


OpenSuse Leap 42.1 x64, Plasma 5.x

User avatar
sparhawk
Registered Member
Posts
433
Karma
0
OS
Nice find, but that's really strange on my system. AFAIK, by default anacron has jobs set up to replace cron. i.e.
Code: Select all
1       5       cron.daily      run-parts --report /etc/cron.daily
7       10      cron.weekly     run-parts --report /etc/cron.weekly
@monthly        15      cron.monthly    run-parts --report /etc/cron.monthly

I did have an additional job previously, that must've been wiped when I did the purge/install. I added that back, and now anacron starts up fine (without stopping). I'm not sure why that's considered a job and the others are not, but it's all working fine now, thanks...

(I'm still getting the empty "Starting" messages, but I won't worry about that until I notice something failing. I guess I'll just do another clean install when 13.04 comes out.)

Thank you both for all your help!
User avatar
google01103
Manager
Posts
6668
Karma
25
pre this did you have empty startup messages? since I don't use Kubuntu don't know if it's normal or not


OpenSuse Leap 42.1 x64, Plasma 5.x

User avatar
sparhawk
Registered Member
Posts
433
Karma
0
OS
Honestly, I can't remember for sure. I've certainly never noticed blank entries before, but I've not specifically looked for them. AFAIK there is no way of looking at old logs ( /var/log/boot.log )? I presume that once you reboot the old log is wiped?


Bookmarks



Who is online

Registered users: bancha, Bing [Bot], Evergrowing, Google [Bot], lockheed, mesutakcan, Sogou [Bot]