leiweibau / Pi.Alert

Scan the devices connected to your WIFI / LAN and alert you the connection of unknown devices. It also warns if a "always connected" device disconnects. In addition, it is possible to check web services for availability. For this purpose HTTP status codes and the response time of the service are evaluated.
https://leiweibau.net
GNU General Public License v3.0
418 stars 29 forks source link

Update error #157

Closed hspindel closed 1 year ago

hspindel commented 1 year ago

Ran the update script and it reports errors. Despite the errors, piAlert seems to be working fine.


Update process finished

leiweibau commented 1 year ago

Can you please check the pialert.conf if the line looks like PIHOLE_DB = '/etc/pihole/pihole-FTL.db'

leiweibau commented 1 year ago

Can you see this error in the scan log as well?

hspindel commented 1 year ago

Thank you.

There were no single quotes around the PIHOLE_DB path in my config file. I haven't touched that line, so it was installed that way. I added the quotes and I'll see how the next update goes.

I don't see any problems in the scan log.

Interestingly, after I edited the pialert.conf file, I attempted "Create Config Backup" and got "It is not possible to save the configuration.

leiweibau commented 1 year ago

This should be a permissions issue. During development this happens to me as well.

Check if you have set the following permission: -rw-rw-r-- 1 YOURUSER www-data 3601 13 Sep 08:11 pialert.conf or -rwxrwxr-x 1 YOURUSER www-data 3601 13 Sep 08:11 pialert.conf

I implemented a corresponding function also in the pialert-cli, but the config folder is not set correctly yet. The next update will fix this.

hspindel commented 1 year ago

Yes, it is a permissions issue. I could not get it to work until I did chmod a+w on the config directory.

I don't know what user pialert runs as. The owner of my config files is root, which would explain why pialert can't write them if it's running as a less privileged user. pialert is run from root's crontab.

I may have screwed up all my permissions now because basically the files are world-writable. What are they supposed to be?

leiweibau commented 1 year ago

There is no pialert user. If you installed pialert with sudo, root is the user, who runs pialert. Im my case it is the user pi.

hspindel commented 1 year ago

Okay, I don't understand what went wrong in my configuration. pialert was installed as root, so the config directory should have been writable by pialert running as root.

I guess it's not important since it's working now.

leiweibau commented 1 year ago

We get it back to work Can you show me the content of your pialert and config dir (ls -al)?

leiweibau commented 1 year ago

Okay, I don't understand what went wrong in my configuration. pialert was installed as root, so the config directory should have been writable by pialert running as root.

I guess it's not important since it's working now.

But the webinterface is running as www-data and needs write permissions too, in case you want to change something. www-data should be the group, also with write permissions. A future update resets the permissions anyway

hspindel commented 1 year ago

/root/pialert:

drwxr-xr-x 9 501 staff 4096 Sep 12 12:17 . drwx--x--x 9 root root 4096 Sep 12 23:08 .. drwxr-xr-x 3 501 staff 4096 Sep 12 17:21 back -rwxr-xr-x 1 501 staff 220 Aug 20 00:30 ._config drwxrwxrwx 2 root staff 4096 Sep 12 23:02 config drwxrwxr-x 3 501 www-data 4096 Sep 12 23:30 db drwxr-xr-x 3 501 staff 4096 Sep 12 17:21 docs -rwxr-xr-x 1 501 staff 220 Aug 20 00:30 ._front drwxr-xr-x 10 501 staff 4096 Sep 12 12:17 front -rwxr-xr-x 1 501 staff 220 Aug 20 00:30 ._install drwxr-xr-x 2 501 staff 4096 Sep 12 17:21 install -rw-r--r-- 1 501 staff 35149 Sep 12 12:17 LICENSE.txt -rwxr-xr-x 1 501 staff 220 Aug 20 00:30 ._log drwxr-xr-x 2 501 staff 4096 Sep 12 17:21 log -rw-r--r-- 1 501 staff 176 Aug 20 00:30 ._README.md -rw-r--r-- 1 501 staff 9134 Sep 12 12:17 README.md


/root/pialert/config:

drwxrwxrwx 2 root staff 4096 Sep 12 23:02 . drwxr-xr-x 9 501 staff 4096 Sep 12 12:17 .. -rwxrwxr-x 1 501 www-data 176 Aug 20 00:30 ._pialert.conf -rwxrwxrwx 1 root www-data 3424 Sep 12 23:01 pialert.conf -rwxrwxrwx 1 root www-data 3689 Sep 12 17:21 pialert.conf.back -rwxrwxr-x 1 root www-data 3713 Jul 9 23:50 pialert.conf.original -rwxrwxrwx 1 root www-data 3424 Sep 12 23:30 pialert-prev.bak -rwxrwxr-x 1 501 www-data 176 Aug 20 00:30 ._version.conf -rwxrwxr-x 1 501 staff 83 Sep 12 12:17 version.conf

Note that all of the above are changed from what they were since I messed with them trying to get it to work.

Let's just wait until the next update and see if this gets sorted out.

leiweibau commented 1 year ago

Yeah, that looks a little messed up. I am on the road right now. I will have a closer look later. To reset the permissions as far as possible, you could also apply the update again.

hspindel commented 1 year ago

I applied the update again.

Had a couple minor problems. The update process threw errors because it didn't like some lines in my pialert.conf:

SCAN_SUBNETS, DAYS_TO_KEEP_ONLINEHISTORY, and DAYS_TO_KEEP_EVENTS were all blank in my pialert.conf. I changed SCAN SUBNETS to '--localnet' and arbitrarily changed the other two to 14. That made the update process run without errors. Since I haven't changed those values in pialert.conf from previous versions something must have changed in the field validation.

Sadly, when I was done with that I was once unable to "Create Config Backup" from the GUI. I guess that that is due to your aforementioned forthcoming fix for permissions on the config directory, so I'll just wait for the next update.

leiweibau commented 1 year ago

Okay. And I'll try to figure out how it gets to the removed "'". The only component that I currently see being able to do this is the config editor in the web interface. But here I have built in checks that this should not happen. And if it does happen, it could really only happen with the Mac Ignore list and the Scan_Subnets option. I'll have to take a closer look at the process again.

leiweibau commented 1 year ago

This is the updated pialert-cli. It sets the permissions on ~/pialert/config and ~/pialert/db

https://github.com/leiweibau/Pi.Alert/blob/63ec4c3398dc7d8b5f01fdf15864f2ca36102aae/back/pialert-cli

Please check the original permissions first for comparison

leiweibau commented 1 year ago

Simply for the sake of completeness.

When installing on an Ubuntu server under the root user, the folder permissions in the /root/pialert/ folder are

pic_a

Here also the wrong permission is set, a configuration backup consequently not possible.

Now execute sudo chgrp -R www-data /root/pialert/config. Afterwards the directories should look like this.

pic_b pic_c

I will work on this in the next update.

hspindel commented 1 year ago

Working well now, thank you.