Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pihole-admin.conf to debug log #5144

Merged
merged 4 commits into from
Feb 9, 2023
Merged

Conversation

yubiuser
Copy link
Member

What does this PR aim to accomplish?:

Adds the "new" lighttpd pihole-admin.conf to the debug output.

Additionally, fixed a bug where we try to list_files_in_dir even if dir_check says there is no directory (we never checked the output of dir_check().


By submitting this pull request, I confirm the following:

  1. I have read and understood the contributors guide, as well as this entire template. I understand which branch to base my commits and Pull Requests against.
  2. I have commented my proposed changes within the code and I have tested my changes.
  3. I am willing to help maintain this change if there are issues with it later.
  4. It is compatible with the EUPL 1.2 license
  5. I have squashed any insignificant commits. (git rebase)
  6. I have checked that another pull request for this purpose does not exist.
  7. I have considered, and confirmed that this submission will be valuable to others.
  8. I accept that this submission may not be used, and the pull request closed at the will of the maintainer.
  9. I give this submission freely, and claim no ownership to its content.

  • I have read the above and my PR is ready for review. Check this box to confirm

Signed-off-by: Christian König <ckoenig@posteo.de>
@yubiuser yubiuser requested a review from a team January 22, 2023 21:39
@yubiuser yubiuser added the PR: Approval Required Open Pull Request, needs approval label Jan 22, 2023
@rdwebdesign
Copy link
Member

rdwebdesign commented Jan 24, 2023

I like the idea, but I have questions:

  • The /etc/lighttpd/conf.d directory only exist on Fedora/CentOS.
    Do you think we should avoid this test on Debian derivatives to avoid confusing users?

    *** [ DIAGNOSING ]: contents of /etc/lighttpd/conf.d
    /etc/lighttpd/conf.d does not exist.
    
  • The same applies to 15-pihole-admin.conf on Fedora/CentOS (this file only exist on Debian).

  • Should we preferably read the files inside /etc/lighttpd/conf-enabled?
    The files on /etc/lighttpd/conf-available are symlinked to /etc/lighttpd/conf-enabled, but users can modify the files inside /etc/lighttpd/conf-enabled and the debug log will be looking at the unchanged version.

@yubiuser
Copy link
Member Author

Do you think we should avoid this test on Debian derivatives to avoid confusing users?

Do, I don't think so. Adding a logic in the very clear and well organized structure of the debug script for a particular case seems a bit overkill. We won't be able to re-use the function anywhere else. We know which directory exists on which distro, most users won't even notice one skipped dir.


Should we preferably read the files inside /etc/lighttpd/conf-enabled?
The files on /etc/lighttpd/conf-available are symlinked to /etc/lighttpd/conf-enabled, but users can modify the files inside /etc/lighttpd/conf-enabled and the debug log will be looking at the unchanged versi

Isn't it the other way round conf-enabled is symliked to conf-available? And if I edit one of two symlinked files, the changes should be reflected in the other file as well?

Signed-off-by: Christian König <ckoenig@posteo.de>
@rdwebdesign
Copy link
Member

Isn't it the other way round conf-enabled is symliked to conf-available? And if I edit one of two symlinked files, the changes should be reflected in the other file as well?

The changes made to /conf-available will be reflected on /conf-enabled, but if the user decides to delete the symlink (for whatever reason) the debug log will show the original file, but the config will not really use it.

Signed-off-by: Christian König <ckoenig@posteo.de>
@yubiuser
Copy link
Member Author

Added the output of lighttpd -tt -f /etc/lighttpd/lighttpd.conf to the debug log.

rdwebdesign
rdwebdesign previously approved these changes Jan 24, 2023
@rdwebdesign rdwebdesign requested a review from a team January 24, 2023 21:53
Signed-off-by: Christian König <ckoenig@posteo.de>
@yubiuser
Copy link
Member Author

Last commit will print all files (not their content) of the lighttpd config directories.

@rdwebdesign rdwebdesign requested a review from a team February 2, 2023 16:02
@yubiuser yubiuser added PR: Approved Open Pull Request, Approved by required number of reviewers and removed PR: Approval Required Open Pull Request, needs approval labels Feb 2, 2023
@yubiuser
Copy link
Member Author

yubiuser commented Feb 2, 2023

Sample output

*** [ DIAGNOSING ]: Lighttpd configuration test
[✓] No error in lighttpd configuration

*** [ DIAGNOSING ]: Setup variables

...

*** [ DIAGNOSING ]: contents of /etc/lighttpd

-rw-r--r-- 1 root root 2,2K 19. Jan 2022  /etc/lighttpd/lighttpd.conf
   server.modules = (
   	"mod_indexfile",
   	"mod_access",
   	"mod_alias",
    	"mod_redirect",
   )
   server.document-root        = "/var/www/html"
   server.upload-dirs          = ( "/var/cache/lighttpd/uploads" )
   server.errorlog             = "/var/log/lighttpd/error.log"
   server.pid-file             = "/run/lighttpd.pid"
   server.username             = "www-data"
   server.groupname            = "www-data"
   server.port                 = 80
   server.feature-flags       += ("server.h2proto" => "enable")
   server.feature-flags       += ("server.h2c"     => "enable")
   server.feature-flags       += ("server.graceful-shutdown-timeout" => 5)
   server.http-parseopts = (
     "header-strict"           => "enable",# default
     "host-strict"             => "enable",# default
     "host-normalize"          => "enable",# default
     "url-normalize-unreserved"=> "enable",# recommended highly
     "url-normalize-required"  => "enable",# recommended
     "url-ctrls-reject"        => "enable",# recommended
     "url-path-2f-decode"      => "enable",# recommended highly (unless breaks app)
     "url-path-dotseg-remove"  => "enable",# recommended highly (unless breaks app)
   )
   index-file.names            = ( "index.php", "index.html" )
   url.access-deny             = ( "~", ".inc" )
   static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
   include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
   include_shell "/usr/share/lighttpd/create-mime.conf.pl"
   include "/etc/lighttpd/conf-enabled/*.conf"
   server.modules += (
   	"mod_dirlisting",
   	"mod_staticfile",
   )

*** [ DIAGNOSING ]: contents of /etc/lighttpd/conf.d
/etc/lighttpd/conf.d does not exist.

*** [ DIAGNOSING ]: contents of /etc/lighttpd/conf-enabled
insgesamt 0
lrwxrwxrwx 1 root root 32  2. Feb 10:48 05-setenv.conf -> ../conf-available/05-setenv.conf
lrwxrwxrwx 1 root root 35  2. Feb 10:48 10-accesslog.conf -> ../conf-available/10-accesslog.conf
lrwxrwxrwx 1 root root 33  2. Feb 10:48 10-fastcgi.conf -> ../conf-available/10-fastcgi.conf
lrwxrwxrwx 1 root root 38  2. Feb 10:48 15-pihole-admin.conf -> ../conf-available/15-pihole-admin.conf
lrwxrwxrwx 1 root root 38  2. Feb 10:47 99-unconfigured.conf -> ../conf-available/99-unconfigured.conf

lrwxrwxrwx 1 root root 38  2. Feb 10:48 /etc/lighttpd/conf-enabled/15-pihole-admin.conf -> ../conf-available/15-pihole-admin.conf
   server.errorlog := "/var/log/lighttpd/error-pihole.log"
   $HTTP["url"] =~ "^/admin/" {
       server.document-root = "/var/www/html"
       server.stream-response-body = 1
       accesslog.filename = "/var/log/lighttpd/access-pihole.log"
       accesslog.format = "%{%s}t|%h|%V|%r|%s|%b"
       fastcgi.server = (
           ".php" => (
               "localhost" => (
                   "socket" => "/run/lighttpd/pihole-php-fastcgi.socket",
                   "bin-path" => "/usr/bin/php-cgi",
                   "min-procs" => 1,
                   "max-procs" => 1,
                   "bin-environment" => (
                       "PHP_FCGI_CHILDREN" => "4",
                       "PHP_FCGI_MAX_REQUESTS" => "10000",
                   ),
                   "bin-copy-environment" => (
                       "PATH", "SHELL", "USER"
                   ),
                   "broken-scriptfilename" => "enable",
               )
           )
       )
       setenv.add-response-header = (
           "X-Pi-hole" => "The Pi-hole Web interface is working!",
           "X-Frame-Options" => "DENY",
           "X-XSS-Protection" => "0",
           "X-Content-Type-Options" => "nosniff",
           "Content-Security-Policy" => "default-src 'self' 'unsafe-inline';",
           "X-Permitted-Cross-Domain-Policies" => "none",
           "Referrer-Policy" => "same-origin"
       )
       $HTTP["url"] =~ "^/admin/\." {
           url.access-deny = ("")
       }
       $HTTP["url"] =~ "/(teleporter|api_token)\.php$" {
           $HTTP["referer"] =~ "/admin/settings\.php" {
               setenv.set-response-header = ( "X-Frame-Options" => "SAMEORIGIN" )
           }
       }
   }
   else $HTTP["url"] == "/admin" {
       url.redirect = ("" => "/admin/")
   }
   $HTTP["host"] == "pi.hole" {
       $HTTP["url"] == "/" {
           url.redirect = ("" => "/admin/")
       }
   }
   server.modules += ( "mod_access", "mod_accesslog", "mod_redirect", "mod_fastcgi", "mod_setenv" )

*** [ DIAGNOSING ]: contents of /etc/cron.d



@PromoFaux PromoFaux merged commit 788e7cc into development Feb 9, 2023
@PromoFaux PromoFaux deleted the debug/pihole-admin.conf branch February 9, 2023 18:35
@pralor-bot
Copy link

This pull request has been mentioned on Pi-hole Userspace. There might be relevant details there:

https://discourse.pi-hole.net/t/pi-hole-ftl-v5-21-web-v5-18-4-and-core-v5-15-4-released/61096/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: Approved Open Pull Request, Approved by required number of reviewers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants