亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? mod_cas.c

?? cas 客戶端文件
?? C
?? 第 1 頁 / 共 3 頁
字號:
/* * "Require NetID Authentication" module that allows a server to act as a * client of the Central Authentication Service. * * Original author: Shawn Bayern <shawn.bayern@yale.edu> * Original version: February, 2001 * * Current maintainer: Drew Mazurek <drew.mazurek@yale.edu> * * Note: the "LOG" messages are entirely for debugging and should not be * enabled for any production deployment.  They're somewhat arbitrary; * we've found them useful at Yale for debugging new features, so I've * left them in in case they're useful. */#include "httpd.h"#include "http_config.h"#include "http_core.h"#include "http_log.h"#include "http_main.h"#include "http_protocol.h"#include "util_script.h"#include "apr_strings.h"#include "http_connection.h"#include "ap_config.h"#include <sys/file.h>#include <sys/mman.h>#include <sys/stat.h>#include <sys/types.h>#include <unistd.h>#include <fcntl.h>#include <stdio.h>#include <grp.h>#include <pwd.h>#include "cas.h"#include "ticketcache.h"#define URLBUFSIZE 4096#define USERBUFSIZE 20#define TICKETBUFSIZE 60// support two different cookie names to allow secure and insecure cookies// to exist side-by-side#define COOKIENAME "MODCASID"#define COOKIENAME_SECURE "MODCASIDS"#define COOKIEPATH "/"#define DEFAULT_CASLocalCacheFile NULL#define DEFAULT_CASLocalCacheSize 1000#define DEFAULT_CASLocalCacheTimeout 3600#define DEFAULT_CASLocalCacheInsecure 0#define DEFAULT_CASLogoutParameter NULL#define DEFAULT_CASLogoutLocalURL NULL//#define DEBUG#undef DEBUG#ifdef DEBUG# define LOG(X) log(X)#else# define LOG(X) #endif/* Utility function declarations */static char *get_service(request_rec *r, char *buf, int buflen);static char *get_ticket(request_rec *r);static char *get_ticket_from_cookies(request_rec *r);static void log(const char *msg);static void logout(request_rec *r);static void cache_invalidate(char *ticket);static int is_user_in_group(const char *user, const char *group, apr_pool_t *p);static int is_parameter_true(request_rec *r, char *param);static void write_lock(int fd);static void read_lock(int fd);static void un_lock(int fd);/* Our exported link to Apache. */module AP_MODULE_DECLARE_DATA cas_module;/* our "configuration record" */typedef struct {   char *CASLocalCacheFile;   char *CASLogoutParameter;   char *CASLogoutLocalURL;   char *CASEGDFile;   int CASLocalCacheSize;   time_t CASLocalCacheTimeout;   char CASLocalCacheInsecure;} mod_cas_conf;/* support functions that we want to prototype here */static int check_individual_cookie(void *netid, char *key, char *value);static int check_individual_cookie_for_ticket(void *netid, char *key, char *value);static char *get_netid_from_cookies(request_rec *r);static void create_and_send_new_ticket(request_rec *r);/* effectively per-process local pointer to our mmap()'d ticket cache */static char *ticket_cache = NULL;static size_t ticket_cache_size = 0;static int ticket_cache_fd;/* * Reads CASLocalCacheFile from the configuration file. */static const char *read_CASLocalCacheFile(	cmd_parms *cmd, void *dummy, const char *word) {    mod_cas_conf *c = (mod_cas_conf *) ap_get_module_config(	cmd->server->module_config, &cas_module);    c->CASLocalCacheFile = (char *) word;    return NULL;}/* * Reads CASLogoutParameter from the configuration file. */static const char *read_CASLogoutParameter(	cmd_parms *cmd, void *dummy, const char *word) {    mod_cas_conf *c = (mod_cas_conf *) ap_get_module_config(	cmd->server->module_config, &cas_module);    c->CASLogoutParameter = (char *) word;    return NULL;}/* * Reads CASLogoutLocalURL from the configuration file. */static const char *read_CASLogoutLocalURL(	cmd_parms *cmd, void *dummy, const char *word) {    mod_cas_conf *c = (mod_cas_conf *) ap_get_module_config(	cmd->server->module_config, &cas_module);    c->CASLogoutLocalURL = (char *) word;    return NULL;}/* * Reads CASEGDFile from the configuration file. */static const char *read_CASEGDFile(	cmd_parms *cmd, void *dummy, const char *word) {    mod_cas_conf *c = (mod_cas_conf *) ap_get_module_config(	cmd->server->module_config, &cas_module);    c->CASEGDFile = (char *) word;    return NULL;}/* * Reads CASLocalCacheSize from the configuration file. */static const char *read_CASLocalCacheSize(	cmd_parms *cmd, void *dummy, const char *word) {    mod_cas_conf *c = (mod_cas_conf *) ap_get_module_config(	cmd->server->module_config, &cas_module);    c->CASLocalCacheSize = atoi(word);    if (c->CASLocalCacheSize <= 0)	return "CASLocalCacheSize must be a positive number";    return NULL;}/* * Reads CASLocalCacheTimeout from the configuration file. */static const char *read_CASLocalCacheTimeout(	cmd_parms *cmd, void *dummy, const char *word) {    mod_cas_conf *c = (mod_cas_conf *) ap_get_module_config(	cmd->server->module_config, &cas_module);    c->CASLocalCacheTimeout = atoi(word);    if (c->CASLocalCacheTimeout <= 0)	return "CASLocalCacheTimeout must be a positive number";    return NULL;}/* * Reads CASLocalCacheInsecure from the configuration file. */static const char *read_CASLocalCacheInsecure(	cmd_parms *cmd, void *dummy, int bool) {    mod_cas_conf *c = (mod_cas_conf *) ap_get_module_config(	cmd->server->module_config, &cas_module);    c->CASLocalCacheInsecure = (!(!bool));    return NULL;}/* * Returns a newly allocated server configuration record, filled in with the * default values.  Since we provide no "merge" routine, we expect that * more specific settings will occlude less specific settings.  This may * be important -- for instance, if there is a virtual server configured * for SSL support on a server that is otherwise unprotected. */static void *init_server_config(apr_pool_t *p, server_rec *s) {    mod_cas_conf *c = apr_pcalloc(p, sizeof(mod_cas_conf));    c->CASLocalCacheFile = DEFAULT_CASLocalCacheFile;    c->CASLocalCacheSize = DEFAULT_CASLocalCacheSize;    c->CASLocalCacheTimeout = DEFAULT_CASLocalCacheTimeout;    c->CASLocalCacheInsecure = DEFAULT_CASLocalCacheInsecure;    c->CASLogoutParameter = DEFAULT_CASLogoutParameter;    c->CASLogoutLocalURL = DEFAULT_CASLogoutLocalURL;    return c;}/* * Called upon the exit of a child process.  mod_cas currently takes this * opportunity to munmap() our cache database if one was previously * mmap()'d. */static apr_status_t cleanup_child(void *server_rec) {    if (ticket_cache)	munmap(ticket_cache, ticket_cache_size);    return APR_SUCCESS;}/* * Called upon the initializaion of a child process.  mod_cas currently * takes this opportunity to mmap() our cache database if one has been * requested. */static void init_child(apr_pool_t *p, server_rec *s) {    int fd;    mod_cas_conf *c;    apr_pool_cleanup_register(p, s, cleanup_child, cleanup_child);    LOG("in init_child()\n");    // if ticket_cache is already initialized, don't bother re-mapping it    if (ticket_cache)	return;    // retrieve our configuration    c = (mod_cas_conf *) ap_get_module_config(s->module_config, &cas_module);    if (c != NULL)         LOG("-> c is not null\n");    else        LOG("-> c is null\n");    // don't do anything if the server admin doesn't want a cache    if (!(c->CASLocalCacheFile))	return;    LOG("-> dereferenced c\n");    // if a cache file is requested, mmap() it and store its in-memory    // location in our static, per-process cell    fd = open(c->CASLocalCacheFile, O_RDWR | O_CREAT, 0600);    if (fd < 0) {	LOG("-> couldn't open CAS cache file\n");	return;					// open() failure    }    // make sure the file is as large as we need it to be    ticket_cache_size =	sizeof(int) + (c->CASLocalCacheSize * sizeof(TicketEntry));    lseek(fd, ticket_cache_size, SEEK_SET);    write(fd, "", 1);    ticket_cache =	mmap(0, ticket_cache_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);    /*      * If mmap() failed, there's really not much we can do other than     * abandon the idea of a ticket cache, at least for us.  But at least     * we can set ticket_cache back to NULL as a marker.     */    if (ticket_cache == MAP_FAILED) {	ticket_cache = NULL;	LOG("-> mmap() failed\n");	return;    }    ticket_cache_fd = fd;    LOG("-> init_child() done\n");}/* * Handles CAS authentication.  Redirects to CAS if we can't authenticate * the user, and expects a ticket back.  Sets r->user with * a validated user.  Operates only when the AuthType is set to "CAS." * * Once past this point, we never directly return DECLINED; we return * success with OK and, if we can't authenticate the user, merely redirect * to the CAS with HTTP_MOVED_TEMPORARILY.  On error, we return * HTTP_INTERNAL_SERVER_ERROR.  If we return OK, no other modules are * supposed to handle this request during the "check user" phase. */static int do_cas(request_rec *r){    // it's okay to use these buffers since we're single-threaded    char *urlbuf = (char *) apr_pcalloc(r->pool, URLBUFSIZE);    char *userbuf = (char *) apr_pcalloc(r->connection->pool, USERBUFSIZE);    char *service, *ticket;    const char *auth_type = ap_auth_type(r);    char *p;    int validate_status = 0;    LOG("in do_cas()\n");    /* We only have something to do if "CAS" is the AuthType. */    if (auth_type && strcmp(auth_type, "CAS"))      return DECLINED;    /*     * Okay, we're relevant.  Now, if we've been handed a cookie that     * identifies the user (with the help of the ticket cache), we can     * simply honor the user's preauthenticated status.  (This call     * uses the ticket cache behind the scenes.  Separately, as a nice     * side effect, this sets r->user to NULL if we don't     * find a cookie; that way, if we proceed, we know that r->connnection->     * user doesn't have some bogus value in in.     */    if (r->user = get_netid_from_cookies(r)) {        mod_cas_conf *c;        // retrieve our configuration        c = (mod_cas_conf *) ap_get_module_config(	    r->server->module_config, &cas_module);	if (c->CASLogoutParameter && c->CASLogoutLocalURL 		&& is_parameter_true(r,c->CASLogoutParameter)) {	    LOG("-> logout parameter set... logging user out\n");	    logout(r);	    LOG("-> redirecting to logout page\n");	    apr_table_set(r->headers_out, "Location", c->CASLogoutLocalURL);	    return HTTP_MOVED_TEMPORARILY;	} else {	    LOG("-> authenticated from cookie\n");	    return OK;	}    }    /*     * "CAS" is the AuthType, so we consider the request in terms of     * a service and a ticket.     */    service = get_service(r, urlbuf, URLBUFSIZE);    ticket = get_ticket(r);    LOG("  service = '"); LOG(service);    LOG("'; ticket = '");    if (ticket)        LOG(ticket);    else        LOG("(null)");    LOG("'\n");    if (service == NULL) {      ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, "mod_cas: null "		   "service");      return HTTP_INTERNAL_SERVER_ERROR;	/* shouldn't happen */    }    LOG("about to call CAS_validate()\n");    if (ticket != NULL        && (validate_status = CAS_validate(ticket, service, userbuf, USERBUFSIZE)) == 1) {      LOG("-> successful primary authentication for '");      LOG(userbuf);      LOG("'\n");      // Successful authentication      r->user = userbuf;      // If relevant, send a cookie since we authenticated the user with      // a real CAS ticket      create_and_send_new_ticket(r);      // Remove ticket from query string      p = r->args;      if (p != NULL)	if (p == strstr(p, "ticket="))			// a comparison...	  *p = '\0';	else if (p = strstr(p, "&ticket="))		// yes, we're setting p	  *p = '\0';      return OK;    } else if (validate_status == BAD_CERT) {      LOG("-> certificate error\n");      ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, "mod_cas: certificate "		"error: bad cert or verisignserverca.pem is not available.");      return HTTP_INTERNAL_SERVER_ERROR;    } else {      /* Bad or missing ticket, so bounce the user to CAS. */      char *temp = alloca(strlen(CAS_LOGIN_URL) + strlen("?service=")          + strlen(service) + 1);      if (!temp) {	ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, "mod_cas: alloca "		     "failed in function create_and_send_new_ticket()");	return HTTP_INTERNAL_SERVER_ERROR;      }      strcpy(temp, CAS_LOGIN_URL);      strcat(temp, "?service=");      strcat(temp, service);      apr_table_set(r->headers_out, "Location", temp);      return HTTP_MOVED_TEMPORARILY;    }}/* * Compares the authenticated user (from CAS) with the list of users (and * groups) authorized by the "Require" directives.  NOTE: We implement * set union here because that's how Apache modules typically work; the word * "Require" might incorrectly lead you to assume that we perform set

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
天堂资源在线中文精品| 欧美精品第1页| 极品少妇xxxx精品少妇偷拍| 天堂一区二区在线免费观看| 一区二区三区欧美激情| 一区二区三区**美女毛片| 一区二区三区四区蜜桃| 亚洲欧美日韩国产手机在线| 亚洲日本在线天堂| 亚洲一区免费视频| 日韩中文字幕不卡| 老司机精品视频导航| 精品系列免费在线观看| 国产露脸91国语对白| 成人开心网精品视频| 99久久国产综合精品女不卡| 色综合激情五月| 欧美日韩国产综合草草| 欧美一区二区免费视频| 久久综合久色欧美综合狠狠| 欧美激情一区二区三区在线| 亚洲人成影院在线观看| 日日嗨av一区二区三区四区| 精品亚洲aⅴ乱码一区二区三区| 高清免费成人av| 色哟哟一区二区在线观看| 777色狠狠一区二区三区| 精品三级av在线| 最新欧美精品一区二区三区| 亚洲国产精品久久不卡毛片| 精品一区二区三区免费| av中文字幕在线不卡| 7777精品伊人久久久大香线蕉的| 欧美mv日韩mv亚洲| 亚洲视频网在线直播| 免费久久精品视频| 91免费看`日韩一区二区| 91精品国产综合久久精品app| 欧美极品aⅴ影院| 亚洲6080在线| 成人av一区二区三区| 在线成人免费视频| 国产精品久久久久婷婷| 免费欧美日韩国产三级电影| 91色视频在线| 国产亚洲视频系列| 午夜不卡在线视频| 99久久免费国产| 亚洲精品一区二区三区影院 | 亚洲人被黑人高潮完整版| 午夜精品影院在线观看| 成人av片在线观看| 日韩无一区二区| 夜夜操天天操亚洲| 成人91在线观看| 久久综合九色综合97婷婷 | 人人爽香蕉精品| 色婷婷av久久久久久久| 欧美激情艳妇裸体舞| 久久精品国产99国产| 欧美日韩和欧美的一区二区| 日韩美女视频一区二区| 国产成人精品影视| 欧美电影免费观看高清完整版在线观看 | 欧美日韩不卡视频| 亚洲欧洲美洲综合色网| 粉嫩一区二区三区性色av| 精品国产不卡一区二区三区| 日产国产高清一区二区三区| 欧美性三三影院| 亚洲伊人伊色伊影伊综合网| 91在线视频网址| 亚洲欧美日韩电影| av亚洲精华国产精华精| 国产精品久久久一本精品| 粉嫩高潮美女一区二区三区| 国产色91在线| 成人看片黄a免费看在线| 欧美激情一二三区| av激情亚洲男人天堂| 中文字幕一区二区三区色视频| 从欧美一区二区三区| 国产喷白浆一区二区三区| 国产激情精品久久久第一区二区 | 日韩欧美亚洲国产精品字幕久久久 | 一级女性全黄久久生活片免费| 99久久精品免费| 亚洲人吸女人奶水| 在线观看亚洲一区| 激情综合色播激情啊| 日韩欧美成人激情| 国产成人精品www牛牛影视| 国产欧美va欧美不卡在线| 成人精品视频网站| 亚洲老妇xxxxxx| 欧美日韩成人综合| 久久99精品国产.久久久久久| 精品国产乱码91久久久久久网站| 国产精品一线二线三线精华| 国产精品久久影院| 欧美日韩一区三区| 精品一区二区在线视频| 国产精品视频第一区| 欧美三日本三级三级在线播放| 日韩中文字幕亚洲一区二区va在线| 欧美成人国产一区二区| 成人av电影在线网| 亚洲国产成人高清精品| 久久久久国产免费免费| 色综合久久88色综合天天6| 日本 国产 欧美色综合| 亚洲国产高清在线| 91.com视频| 成人h精品动漫一区二区三区| 亚洲国产精品久久艾草纯爱| 精品国产伦一区二区三区观看方式| 成人免费高清视频| 美女视频黄久久| 日韩理论片中文av| 欧美本精品男人aⅴ天堂| 色综合久久久久综合体桃花网| 青青草一区二区三区| 中文字幕在线不卡| 欧美刺激脚交jootjob| 91成人看片片| 成人自拍视频在线| 久久激情五月婷婷| 亚洲高清在线视频| 国产精品高潮久久久久无| 精品免费视频.| 欧美精品自拍偷拍动漫精品| 99久久久久久| 风间由美一区二区av101| 秋霞影院一区二区| 亚洲观看高清完整版在线观看| 国产精品久久久久久久久久久免费看| 日韩精品一区国产麻豆| 欧美日本韩国一区二区三区视频| av一区二区久久| 国产91精品在线观看| 国内精品久久久久影院薰衣草| 丝袜脚交一区二区| 一区二区不卡在线视频 午夜欧美不卡在 | 欧美一级片在线看| 欧美午夜片在线看| 色哟哟亚洲精品| 一本久久综合亚洲鲁鲁五月天| 波多野结衣的一区二区三区| 国产成人综合亚洲网站| 国产一区欧美二区| 久久福利资源站| 韩国欧美一区二区| 精品一区二区三区影院在线午夜| 日本不卡视频在线| 免费在线看成人av| 九九国产精品视频| 国模一区二区三区白浆| 国产一区二区三区电影在线观看 | 国产日韩欧美麻豆| 日本一区二区三区免费乱视频| 久久人人爽爽爽人久久久| 久久婷婷成人综合色| 久久精品人人做人人综合| 欧美激情一区二区三区四区| 亚洲国产精品精华液ab| 国产精品久久久久一区二区三区| 亚洲色图视频免费播放| 亚洲欧美一区二区三区国产精品| 精品无人码麻豆乱码1区2区| 国产自产视频一区二区三区| 国产最新精品免费| 国产成人免费在线视频| 92精品国产成人观看免费| 91欧美一区二区| 欧美三日本三级三级在线播放| 91精品国产综合久久久蜜臀图片| 久久综合视频网| 18欧美亚洲精品| 三级成人在线视频| 国产高清精品久久久久| 99精品一区二区| 日韩一区二区三区免费观看| 国产色综合一区| 偷拍日韩校园综合在线| 国产在线不卡一卡二卡三卡四卡| 99r国产精品| 日韩一二三四区| 亚洲欧美一区二区三区国产精品 | 久久久精品免费观看| 亚洲人午夜精品天堂一二香蕉| 午夜欧美2019年伦理| 国产成人在线免费| 欧美久久久久中文字幕| 国产色产综合色产在线视频| 亚洲一区二区三区四区在线免费观看| 九九精品视频在线看| 欧美在线观看视频一区二区| 337p日本欧洲亚洲大胆精品| 亚洲国产日日夜夜| 成人免费视频视频在线观看免费|