Cannot access /var/log/lighttpd/ with Logstalgia "Permission denied"

Hello,
The issue I am facing:
I cannot access the /var/log/lighttpd/ folder:

$ cd /var/log/lighttpd/
bash: cd: /var/log/lighttpd/: Permission denied

Not sure if this helps:
$ ls -lha /var/log/
...
drwxr-x--- 2 www-data www-data 4.0K Sep 3 00:00 lighttpd
...

Details about my system:
Pi-hole version is v5.1.2 (Latest: v5.1.2)
AdminLTE version is v5.1.1 (Latest: v5.1.1)
FTL version is v5.2 (Latest: v5.2)

What I have changed since installing Pi-hole:
Only the password.

Thanks

That's normal behaviour, as that directory is owned by www-data by default.

You can list the content with sudo powers, e.g. via sudo ls -lah /var/log/lighttpd/.

Thank you so much for the quick response.

I am able to see the contents. Is it possible to access the 'access.log' file? Or to switch to the 'www-data' user?

Thanks again.

This (edit: switching ownership) is possible in principle, of course, but it may well interrupt Pi-hole's UI operation, so I would advise strongly against it.

What is the motivation behind your request?

I was trying to get Logstalgia to work but it needs to read the access.log file in order to do so.

This is what I was trying to achieve:

But I like the Pi-hole and that it works well and I'd rather not mess anything up.

Thank you for your time!

You wouldn't have to change ownership for www-data. Just prepending sudo to the tail command should do what you want.

Since you are referring to instructions from a 2016 topic, I wouldn't know if that still works in 2020. :thinking:
If you are willing to try it, please consider sharing if it actually does so with the sudo variation.

The ownership/permissions for the /var/log/lighttpd/ folder prevents other users from reading the files:

pi@ph5:~ $ stat -c "%U:%G %A %a %n" /var/log/lighttpd/
www-data:www-data drwxr-x--- 750 /var/log/lighttpd/

For the owner www-data , permissions are:
rwx = 111 = 7

For the group www-data:
r-x = 101 = 5

And everyone else:
--- = 000 = 0

If you can figure out the user under which this Logstalgia is trying to access the logs, you could add that user to the www-data group so it would be able to do a "r-x".
You can figure out user/group for the currently running processes with below:

ps -o user,group,cmd -e

To add a <USER> to the www-data group:

sudo usermod -a -G www-data <USER>

Check groups to which a user is a member of with:

groups <USER>

To remove a user from a particular group:

sudo deluser <USER> <GROUP>

@Bucking_Horn pointed out to me that Logstalgia is pulling logs via below construction:

ssh pi@192.168.1.114 "tail -f /var/log/lighttpd/access.log" | logstalgia --sync

So get this working, you just have to add the pi user to the www-date group with below:

sudo usermod -a -G www-data pi

But ... that tail -f will work until the logs are rotated by logrotate and from then on, no new logs will be recorded.
It should be tail -F instead if want to keep tailing the log rotated files:

1 Like

Thank you both for the help. I was able to add the 'pi' user to 'www-data' and access the file. I'm having trouble running Logstalgia (access.log was empty, then populated) but the issue in this ticket has been addressed and resolved. I'll tinker around and see if I can get it to work.

Once again, thanks.

2 Likes

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.