fcgi-auth.c 598 B

123456789101112131415161718192021222324252627282930313233
  1. #ifdef HAVE_CONFIG_H
  2. #include "config.h"
  3. #endif
  4. #ifdef HAVE_FASTCGI_FASTCGI_H
  5. #include <fastcgi/fcgi_stdio.h>
  6. #else
  7. #include <fcgi_stdio.h>
  8. #endif
  9. #include <stdlib.h>
  10. #include <unistd.h>
  11. #include <string.h>
  12. int main (void) {
  13. char* p;
  14. while (FCGI_Accept() >= 0) {
  15. /* wait for fastcgi authorizer request */
  16. printf("Content-type: text/html\r\n");
  17. if (((p = getenv("QUERY_STRING")) == NULL) ||
  18. strcmp(p, "ok") != 0) {
  19. printf("Status: 403 Forbidden\r\n\r\n");
  20. } else {
  21. printf("\r\n");
  22. /* default Status is 200 - allow access */
  23. }
  24. printf("foobar\r\n");
  25. }
  26. return 0;
  27. }