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

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

?? user.c++

?? fax相關的東西
?? C++
字號:
/*	$Id: User.c++,v 1.17 2005/12/22 14:41:33 aidan Exp $ *//* * Copyright (c) 1995-1996 Sam Leffler * Copyright (c) 1995-1996 Silicon Graphics, Inc. * HylaFAX is a trademark of Silicon Graphics * * Permission to use, copy, modify, distribute, and sell this software and  * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. *  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.   *  * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE  * OF THIS SOFTWARE. */#include "HylaFAXServer.h"#include "Sys.h"#include "RE.h"#include "config.h"#include <ctype.h>#include <pwd.h>#if HAS_CRYPT_H#include <crypt.h>#endif#include <math.h>#ifndef CHAR_BIT#ifdef NBBY#define	CHAR_BIT	NBBY#else#define	CHAR_BIT	8#endif#endif /* CHAR_BIT *//* * User Access Control Support. */gid_t	HylaFAXServer::faxuid = 0;		// reserved fax uid#define	FAXUID_RESV	HylaFAXServer::faxuid	// reserved fax uid#ifdef HAVE_PAMextern intpamconv(int num_msg, STRUCT_PAM_MESSAGE **msg, struct pam_response **resp, void *appdata);#endifboolHylaFAXServer::checkUser(const char* name){    bool check = false;    FILE* db = fopen(fixPathname(userAccessFile), "r");    if (db != NULL) {	check = checkuser(db, name) || checkuser(name);	fclose(db);    } else	logError("Unable to open the user access file %s: %s",	    (const char*) userAccessFile, strerror(errno));    /*     * This causes the user to be prompted for a password     * and then denied access.  We do this to guard against     * folks that probe the server looking for valid accounts.     */    return (true);}static boolnextRecord(FILE* db, char line[], u_int size){    while (fgets(line, size-1, db)) {	char* cp = strchr(line, '#');	if (cp) {			// trim trailing white space */	    for (cp = strchr(line, '\0'); cp > line; cp--)		if (!isspace(cp[-1]))		    break;	    *cp = '\0';	}	if ((cp = strchr(line, '\n')))	    *cp = '\0';	if (line[0] != '\0')	    return (true);    }    return (false);}boolHylaFAXServer::checkuser(const char* name){	bool retval=false;#ifdef HAVE_PAM	if (pam_chrooted) {	    logNotice("PAM authentication for %s can't be used for a re-issuance of USER command because of chroot jail\n", name);	    return false;	}	int pamret;	struct pam_conv conv = {pamconv, NULL};			pamret = pam_start(FAX_SERVICE, name, &conv, &pamh);	if (pamret == PAM_SUCCESS)		pamret = pam_authenticate(pamh, 0);	if (pamret == PAM_SUCCESS)		pamret = pam_acct_mgmt(pamh, 0);	if (pamret == PAM_SUCCESS) {		passwd = "";		pamEnd(pamret);	} else {	    passwd = "*";	    adminwd = "*";	}	retval = true;#endif //HAVE_PAM	return(retval);}/* * Check the user name and host name/address against * the list of users and hosts that are permitted to * user the server and setup password handling. */boolHylaFAXServer::checkuser(FILE* db, const char* name){    struct stat sb;    if (Sys::fstat(fileno(db), sb) < 0)	return (false);    if (sb.st_mode&077) {	// file must not be publicly readable	logError("Access control file not mode 600; access denied.");	return (false);    }    uid = FAXUID_ANON;		// anonymous user    adminwd = "*";		// disallow privileged access    fxStr dotform  = fxStr::format("%s@%s", name, (const char*) remoteaddr);    fxStr hostform = fxStr::format("%s@%s", name, (const char*) remotehost);    rewind(db);    char line[1024];    while (nextRecord(db, line, sizeof (line))) {	/*	 * Records are of the form:	 *	 *    [!]regex[:uid[:passwd[:adminwd]]]	 *	 * where regex is a regular expression that must	 * match a string of the form "user@host" or "user@addr"	 * (where addr is the dot-notation form of the client	 * host).  If subsequent fields are present then the	 * first is treated as the numeric ID for the user,	 * followed by the encrypted password that the client	 * must supply.  The next field is the password that	 * must be presented to gain administrative privileges.	 *	 * If the regex is a single word (no @ sign), we take it	 * as a host only short form for (^.*@<input>$)	 *	 * If the first character of the <regex> is a ``!''	 * then the line specifies user(s) to disallow; a match	 * causes the user to be rejected w/o a password prompt.	 * This facility is mainly for backwards compatibility.	 */	char* cp;	bool userandhost = false;	for (cp = line; *cp && *cp != ':'; cp++)	    if (*cp == '@') userandhost = true;	const char* base = &line[line[0] == '!'];	fxStr pattern(base, cp-base);	if (! userandhost) {	    pattern.insert("^.*@");	    pattern.append("$");	}	RE pat(pattern);	if (line[0] == '!') {		// disallow access on match	    if (pat.Find(dotform) || pat.Find(hostform))		return (false);	} else {			// allow access on match	    if (pat.Find(dotform) || pat.Find(hostform)) {		passwd = "";		// no password required		if (*cp == ':') {	// :uid[:passwd[:adminwd]]		    if (isdigit(*++cp)) {			uid = atoi(cp);			for (; *cp && *cp != ':'; cp++)			    ;		    }		    if (*cp == ':') {	// :passwd[:adminwd]			for (base = ++cp; *cp && *cp != ':'; cp++)			    ;			if (*cp == ':') {			    passwd = fxStr(base, cp-base);			    adminwd = cp+1;			} else			    passwd = base;		    } else			passwd = "";	// no password required		}		return (true);	    }	}    }    passwd = "*";    return (false);}fxDECLARE_PtrKeyDictionary(IDCache, u_int, fxStr)fxIMPLEMENT_PtrKeyObjValueDictionary(IDCache, u_int, fxStr)/* * Read the host access file and fill the ID cache * with entries that map fax UID to name.  We pick * names by stripping any host part from matching * regex's and by mapping ``.*'' user matches to a * generic ``anyone'' name. * * XXX Maybe should convert RE entries to numeric *     equivalent of ID to avoid funky names??? */voidHylaFAXServer::fillIDCache(void){    idcache = new IDCache;    FILE* db = fopen(fixPathname(userAccessFile), "r");    if (db != NULL) {	char line[1024];	while (nextRecord(db, line, sizeof (line))) {	    if (line[0] == '!')			// ignore ! entries		continue;	    char* cp;	    for (cp = line; *cp && *cp != ':'; cp++)		;	    fxStr name(line, cp-line);	    name.resize(name.next(0, '@'));	// strip @host part	    if (name == ".*")			// map .* -> ``anyone''		name = "anyone";	    if (*cp == ':')		cp++;	    u_int id;				// fax UID	    if (isdigit(*cp))		id = atoi(cp);	    else		id = FAXUID_ANON;	    (*idcache)[id] = name;	}	fclose(db);    }}/* * Map fax UID to user name. */const char*HylaFAXServer::userName(u_int id){    if (id == uid)				// user currently logged in	return (const char*) the_user;    if (id == FAXUID_ANON)			// anonymous user	return "fax";    if (idcache == NULL)			// load cache from file	fillIDCache();    const fxStr* hit = idcache->find(id);	// check cache    if (!hit) {					// create entry w/ numeric value	(*idcache)[id] = fxStr((int) id, "%u");	hit = idcache->find(id);		// new entry    }    return (*hit);}/* * Map user name to fax UID. */boolHylaFAXServer::userID(const char* name, u_int& id){    if (name == the_user)	id = uid;    else if (strcmp(name, "fax") == 0)	id = FAXUID_ANON;    else {	if (idcache == NULL)	    fillIDCache();	for (IDCacheIter iter(*idcache); iter.notDone(); iter++)	    if (iter.value() == name) {		id = iter.key();		return (true);	    }	return (false);    }    return (true);}static boolisAllLower(const char* cp){    while (*cp) {	if (!islower(*cp))	    return (false);	cp++;    }    return (true);}static voidto64(char* cp, long v, int len){    while (--len >= 0) {	*cp++ = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"[v&0x3f];	v >>= 6;    }}boolHylaFAXServer::cvtPasswd(const char* type, const char* pass, fxStr& result){    if (*pass == '\0') {		// null password *IS* permitted	result = "";	return (true);    }    if (strlen(pass) <= 5) {	reply(500, "%s password is too short; use 5-8 characters.", type);	return (false);    }    if (isAllLower(pass)) {	reply(500, "%s password is all lower-case; use something more.", type);	return (false);    }    srandom((int) Sys::now());    char salt[9];    /*     * Contemporary systems use an extended salt that     * is distinguished by a leading character (``_'').     * Older systems use a 2-character salt that results     * in encrypted strings that are easier to crack.     */#ifdef _PASSWORD_EFMT1    salt[0] = _PASSWORD_EFMT1;    to64(&salt[1], (long)(29 * 25), 4);    to64(&salt[5], random(), 4);#else    to64(&salt[0], random(), 2);#endif    result = crypt(pass, salt);    return (true);}#define	NBPL	(sizeof (u_long) * CHAR_BIT)	// bits/u_long#define	SetBit(b) (allocated[(b)/NBPL] |= ((u_long) 1)<<((b)%NBPL))#define	ClrBit(b) (allocated[(b)/NBPL] &= ~(((u_long) 1)<<((b)%NBPL)))#ifndef howmany#define	howmany(x, y)	(((x)+((y)-1))/(y))#endif#define	N(a)	(sizeof (a) / sizeof (a[0]))boolHylaFAXServer::findUser(FILE* db, const char* user, u_int& newuid){    rewind(db);    char line[1024];    u_long allocated[howmany(FAXUID_MAX,NBPL)];    memset(allocated, 0, sizeof (allocated));    if (faxuid < FAXUID_MAX)	SetBit(FAXUID_RESV);			// reserved uid    else	logError("Internal error, \"fax\" UID (%u) too large.", faxuid);    SetBit(FAXUID_ANON);			// anonymous uid is reserved    while (nextRecord(db, line, sizeof (line))) {	if (line[0] == '!')	    continue;	char* cp;	for (cp = line; *cp && *cp != ':'; cp++)	    ;	if (strncmp(user, line, cp-line) == 0)	    return (true);	if (*cp == ':' && isdigit(cp[1])) {	// mark uid as in-use	    u_int uid = (u_int) atoi(cp+1);	    SetBit(uid);	}    }    // find unallocated uid    for (u_int l = 0; l < N(allocated); l++)	if (allocated[l] != (u_long) -1) {	    u_int b = 0;	    for (u_long mask = 1; allocated[l] & mask; mask <<= 1) 		b++;	    newuid = (u_int) (l*NBPL + b);	    return (false);	}    newuid = (u_int) -1;			// no more space    return (false);}boolHylaFAXServer::addUser(FILE* db, const char* user, u_int uid, const char* upass, const char* apass){    const char* templ = "/" FAX_TMPDIR "/uaddXXXXXX";    char* buff = strcpy(new char[strlen(templ) + 1], templ);    int fd = Sys::mkstemp(buff);    fxStr tfile = buff;    delete [] buff;    if (fd < 0) {	reply(550, "Error creating temp file %s: %s.",	    (const char*) tfile, strerror(errno));	return (false);    }    rewind(db);    char buf[8*1024];    int cc;    while ((cc = Sys::read(fileno(db), buf, sizeof (buf))) > 0)	if (Sys::write(fd, buf, cc) != cc) {	    perror_reply(550, "Write error", errno);	    Sys::close(fd);	    (void) Sys::unlink(tfile);	    return (false);	}    fxStr line;    if (*apass != '\0')	line = fxStr::format("^%s@:%u:%s:%s\n", user, uid, upass, apass);    else if (*upass != '\0')	line = fxStr::format("^%s@:%u:%s\n", user, uid, upass);    else	line = fxStr::format("^%s@:%u\n", user, uid);    if (Sys::write(fd, line, line.length()) != (ssize_t)line.length()) {	perror_reply(550, "Write error", errno);	Sys::close(fd);	(void) Sys::unlink(tfile);	return (false);    }    Sys::close(fd);    if (Sys::rename(tfile, fixPathname(userAccessFile)) < 0) {	perror_reply(550, "Rename of temp file failed", errno);	(void) Sys::unlink(tfile);	return (false);    }    return (true);}/* * Add a new user to the access control file. */voidHylaFAXServer::addUserCmd(const char* user, const char* up, const char* ap){    logcmd(T_ADDUSER, "%s XXXX YYYY", user);    fxStr upass, apass;    if (!cvtPasswd("User", up, upass) || !cvtPasswd("Admin", ap, apass))	return;    FILE* db = fopen(fixPathname(userAccessFile), "r");    if (db != NULL) {	u_int newuid;	if (findUser(db, user, newuid))	    reply(500, "User %s is already present.", user);	else if (newuid == (u_int) -1)	    reply(500, "Unable to add user %s; out of user IDs.", user);	else if (addUser(db, user, newuid, upass, apass))	    reply(200, "User %s added with uid %u.", user, newuid);	fclose(db);    } else	reply(500, "Cannot open user access file %s: %s.",	    (const char*) userAccessFile, strerror(errno));}boolHylaFAXServer::deleteUser(FILE* db, const char* user){    const char* templ = "/" FAX_TMPDIR "/udelXXXXXX";    char* buff = strcpy(new char[strlen(templ) + 1], templ);    int fd = Sys::mkstemp(buff);    fxStr tfile = buff;    delete [] buff;    FILE* ftmp;    if (fd < 0 || (ftmp = fdopen(fd, "w")) == NULL) {        reply(550, "Error creating temp file %s: %s.",	        (const char*)tfile, strerror(errno));        return (false);    }    /*     * Scan the existing file for the specified user     * and copy other entries to the temporary file.     * Once the entry for the user is found, stop     * scanning line-by-line and just block-copy the     * remaining part of the file.     */    bool found = false;    rewind(db);    char line[8*1024];    while (fgets(line, sizeof (line)-1, db)) {	if (line[0] != '!') {	    const char* cp;	    for (cp = line; *cp && *cp != '\n' && *cp != ':'; cp++)		;	    if (strncmp(user, line, cp-line) == 0) {		found = true;		break;	    }	}	fputs(line, ftmp);    }    int cc;    while ((cc = fread(line, 1, sizeof (line), db)) > 0)	fwrite(line, cc, 1, ftmp);    bool ioError = (fclose(ftmp) != 0);    if (found) {	if (ioError)	    perror_reply(550, "I/O error", errno);	else if (Sys::rename(tfile, fixPathname(userAccessFile)) < 0)	    perror_reply(550, "Rename of temp file failed", errno);	else {	    return (true);        }    } else	reply(500, "User %s not found in access file.", user);    (void) Sys::unlink(tfile);    return (false);}/* * Remove a user from the access control file. */voidHylaFAXServer::delUserCmd(const char* user){    logcmd(T_DELUSER, "%s", user);    FILE* db = fopen(fixPathname(userAccessFile), "r");    if (db != NULL) {	if (deleteUser(db, user))	    reply(200, "User %s deleted.", user);	fclose(db);    } else	reply(500, "Cannot open user access file %s: %s.",	    (const char*) userAccessFile, strerror(errno));}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本久久一区二区| 亚洲五码中文字幕| 日韩色视频在线观看| 在线免费观看日本一区| 成人av免费在线观看| 国产美女在线精品| 国产精品一区二区在线播放| 青青草国产成人av片免费| 日韩和欧美一区二区三区| 亚洲成人免费看| 性做久久久久久免费观看欧美| 一区二区三区国产| 亚洲国产成人91porn| 午夜精品成人在线| 日本亚洲一区二区| 麻豆91小视频| 国产精品系列在线播放| 国产成人免费视频精品含羞草妖精 | 欧美日韩另类国产亚洲欧美一级| 色婷婷av一区二区三区gif| 欧美亚洲综合另类| 欧美一卡2卡三卡4卡5免费| 欧美一区二区视频免费观看| 欧美va在线播放| 国产精品毛片高清在线完整版| 国产欧美一区二区精品仙草咪 | 精品一区二区在线免费观看| 精品无人区卡一卡二卡三乱码免费卡| 国产在线国偷精品免费看| 成人毛片老司机大片| 欧美亚洲国产一区二区三区va| 91精品国产综合久久精品麻豆| 久久久三级国产网站| 亚洲激情图片一区| 美女一区二区三区在线观看| 国产精品资源在线| 在线免费观看日本一区| 精品国产成人系列| 一区二区视频免费在线观看| 免费看黄色91| 成+人+亚洲+综合天堂| 欧美日韩久久一区二区| 精品国产伦一区二区三区观看体验| 欧美韩日一区二区三区四区| 亚洲一区成人在线| 国产精品一区三区| 欧美精品在线观看一区二区| 国产精品污www在线观看| 夜夜精品浪潮av一区二区三区| 久久99久久99| 欧美性猛交xxxx黑人交| 欧美激情一区在线观看| 美女性感视频久久| 一本到不卡精品视频在线观看| 精品国产精品网麻豆系列 | 亚洲成a人v欧美综合天堂 | 色久综合一二码| 国产亚洲精品aa| 免费观看日韩电影| 欧洲精品一区二区三区在线观看| 久久久精品欧美丰满| 美腿丝袜在线亚洲一区| 欧美三级欧美一级| 亚洲卡通欧美制服中文| 懂色一区二区三区免费观看| 日韩精品一区在线| 亚洲v中文字幕| 91黄色激情网站| 国产精品不卡在线观看| 国产精品亚洲一区二区三区妖精| 日韩一级片在线播放| 亚洲一二三级电影| 日本精品一区二区三区高清| 成人免费小视频| 成人app在线观看| 欧美高清一级片在线观看| 国产高清成人在线| 精品免费视频.| 国产综合久久久久久鬼色 | 波多野结衣在线aⅴ中文字幕不卡| 精品少妇一区二区| 激情图区综合网| 精品伦理精品一区| 国产麻豆午夜三级精品| 久久久久国色av免费看影院| 国产一区二区精品久久91| 日韩欧美成人一区二区| 精品一区二区三区日韩| 久久久久久久久久美女| 国产成a人亚洲精| 中文一区二区完整视频在线观看| 成人高清av在线| 亚洲综合免费观看高清完整版 | 日韩亚洲欧美高清| 国产最新精品免费| 国产精品乱人伦一区二区| 99久久99久久免费精品蜜臀| 亚洲摸摸操操av| 欧美三级电影网| 美女高潮久久久| 久久久国产综合精品女国产盗摄| 国产成人免费视| 亚洲午夜av在线| 欧美精品一区二| 不卡在线观看av| 五月天激情综合| 久久久噜噜噜久久人人看| proumb性欧美在线观看| 香蕉久久夜色精品国产使用方法 | 亚洲综合小说图片| 欧美一区二区三区四区高清| 国产精品99久久久久久似苏梦涵| 中文字幕在线一区| 在线成人免费观看| 懂色av中文一区二区三区| 亚洲午夜羞羞片| 久久亚洲精精品中文字幕早川悠里 | 青青草97国产精品免费观看 | 一区二区三区色| 日韩欧美一区在线观看| 97久久精品人人澡人人爽| 午夜激情综合网| 国产精品网站一区| 日韩一区二区免费在线观看| 91伊人久久大香线蕉| 激情国产一区二区| 亚洲第一会所有码转帖| 国产视频一区二区在线观看| 欧美日韩一级二级三级| 国产91丝袜在线播放0| 日韩av在线发布| 一区二区三区在线视频免费 | 成人黄色小视频在线观看| 青草国产精品久久久久久| 一区二区三区四区不卡在线| 欧美成人免费网站| 欧美日韩电影在线| 色婷婷综合久久久久中文一区二区| 国产一区999| 久久精品国产亚洲一区二区三区 | 爽爽淫人综合网网站| 亚洲久草在线视频| 中文字幕一区在线观看| 国产午夜精品久久久久久免费视 | 亚洲国产精品ⅴa在线观看| 精品日韩一区二区三区免费视频| 欧美色倩网站大全免费| 一本色道久久加勒比精品| 99久久久国产精品| 成人中文字幕合集| 国产精品亚洲第一| 国产一区在线观看麻豆| 毛片av一区二区| 久久超碰97中文字幕| 青青青爽久久午夜综合久久午夜| 天天综合网 天天综合色| 亚洲高清免费在线| 亚洲sss视频在线视频| 亚洲国产精品一区二区www| 亚洲色欲色欲www| 国产精品久久久久7777按摩| 国产精品天天摸av网| 亚洲天堂成人网| 一区二区在线观看视频| 亚洲免费视频中文字幕| 一区二区三区高清在线| 亚洲电影一级片| 免费看欧美美女黄的网站| 蜜臀av性久久久久蜜臀av麻豆| 久久精品国产亚洲aⅴ| 国产一区二区三区国产| 成人永久免费视频| 91片在线免费观看| 欧美日韩黄色影视| 日韩三级中文字幕| 国产视频一区不卡| 亚洲精品v日韩精品| 日韩精品91亚洲二区在线观看| 玖玖九九国产精品| 成人动漫av在线| 精品视频在线看| 久久综合色婷婷| 亚洲男人的天堂在线观看| 亚洲大片精品永久免费| 国产一区中文字幕| 99精品久久99久久久久| 欧美久久久久中文字幕| 国产人久久人人人人爽| 亚洲欧美成人一区二区三区| 日产国产高清一区二区三区| 狠狠色伊人亚洲综合成人| a级高清视频欧美日韩| 欧美裸体bbwbbwbbw| 国产精品久久久久久久久快鸭| 夜夜亚洲天天久久| 成人午夜激情视频| 欧美一区二区三区爱爱| 国产精品美女久久久久高潮| 日本系列欧美系列| av不卡免费电影|