/* * LOGIN.c - for use with PubcookieOnDemand */ #include #include #include #ifndef ONDEMANDKEY #define ONDEMANDKEY "ondemand" #endif /* ONDEMANDKEY */ int main () { const char *ref = getenv ("QUERY_STRING"); const char *server = getenv ("SERVER_NAME"); char hostname[1024]; char loc[2048]; if (! server) { if (gethostname (hostname, sizeof (hostname)) == -1) { (void) fprintf (stderr, "Unable to find server name!\n"); exit (1); } server = hostname; } if (ref && *ref) { (void) snprintf (loc, sizeof (loc) - 1, "http://%s%s", server, ref); ref = loc; } else if (! (ref = getenv ("HTTP_REFERER"))) { (void) snprintf (loc, sizeof (loc) - 1, "http://%s/", server); ref = loc; } (void) printf ("Location: %s\n" "Cache-control: no-store, no-cache, must-revalidate\n" "Expires: Sat, 1 Jan 2000 01:01:01 GMT\n" "Set-Cookie: OnDemandKey=" ONDEMANDKEY "; path=/\n\n", ref); exit (0); }