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

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

?? user.c

?? PostgreSQL7.4.6 for Linux
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*------------------------------------------------------------------------- * * user.c *	  Commands for manipulating users and groups. * * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.128 2003/10/02 06:36:37 petere Exp $ * *------------------------------------------------------------------------- */#include "postgres.h"#include <sys/stat.h>#include <fcntl.h>#include <errno.h>#include <unistd.h>#include "access/heapam.h"#include "catalog/catname.h"#include "catalog/indexing.h"#include "catalog/pg_database.h"#include "catalog/pg_group.h"#include "catalog/pg_shadow.h"#include "catalog/pg_type.h"#include "commands/user.h"#include "libpq/crypt.h"#include "miscadmin.h"#include "storage/pmsignal.h"#include "utils/acl.h"#include "utils/array.h"#include "utils/builtins.h"#include "utils/fmgroids.h"#include "utils/guc.h"#include "utils/lsyscache.h"#include "utils/syscache.h"#define PWD_FILE		"pg_pwd"#define USER_GROUP_FILE "pg_group"extern bool Password_encryption;static bool user_file_update_needed = false;static bool group_file_update_needed = false;static void CheckPgUserAclNotNull(void);static void UpdateGroupMembership(Relation group_rel, HeapTuple group_tuple,					  List *members);static IdList *IdListToArray(List *members);static List *IdArrayToList(IdList *oldarray);/* *	fputs_quote * *	Outputs string in quotes, with double-quotes duplicated. *	We could use quote_ident(), but that expects a TEXT argument. */static voidfputs_quote(char *str, FILE *fp){	fputc('"', fp);	while (*str)	{		fputc(*str, fp);		if (*str == '"')			fputc('"', fp);		str++;	}	fputc('"', fp);}/* * group_getfilename --- get full pathname of group file * * Note that result string is palloc'd, and should be freed by the caller. */char *group_getfilename(void){	int			bufsize;	char	   *pfnam;	bufsize = strlen(DataDir) + strlen("/global/") +		strlen(USER_GROUP_FILE) + 1;	pfnam = (char *) palloc(bufsize);	snprintf(pfnam, bufsize, "%s/global/%s", DataDir, USER_GROUP_FILE);	return pfnam;}/* * Get full pathname of password file. * * Note that result string is palloc'd, and should be freed by the caller. */char *user_getfilename(void){	int			bufsize;	char	   *pfnam;	bufsize = strlen(DataDir) + strlen("/global/") +		strlen(PWD_FILE) + 1;	pfnam = (char *) palloc(bufsize);	snprintf(pfnam, bufsize, "%s/global/%s", DataDir, PWD_FILE);	return pfnam;}/* * write_group_file: update the flat group file */static voidwrite_group_file(Relation grel){	char	   *filename,			   *tempname;	int			bufsize;	FILE	   *fp;	mode_t		oumask;	HeapScanDesc scan;	HeapTuple	tuple;	TupleDesc	dsc = RelationGetDescr(grel);	/*	 * Create a temporary filename to be renamed later.  This prevents the	 * backend from clobbering the pg_group file while the postmaster	 * might be reading from it.	 */	filename = group_getfilename();	bufsize = strlen(filename) + 12;	tempname = (char *) palloc(bufsize);	snprintf(tempname, bufsize, "%s.%d", filename, MyProcPid);	oumask = umask((mode_t) 077);	fp = AllocateFile(tempname, "w");	umask(oumask);	if (fp == NULL)		ereport(ERROR,				(errcode_for_file_access(),			  errmsg("could not write to temporary file \"%s\": %m", tempname)));	/*	 * Read pg_group and write the file.  Note we use SnapshotSelf to	 * ensure we see all effects of current transaction.  (Perhaps could	 * do a CommandCounterIncrement beforehand, instead?)	 */	scan = heap_beginscan(grel, SnapshotSelf, 0, NULL);	while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)	{		Datum		datum,					grolist_datum;		bool		isnull;		char	   *groname;		IdList	   *grolist_p;		AclId	   *aidp;		int			i,					j,					num;		char	   *usename;		bool		first_user = true;		datum = heap_getattr(tuple, Anum_pg_group_groname, dsc, &isnull);		/* ignore NULL groupnames --- shouldn't happen */		if (isnull)			continue;		groname = NameStr(*DatumGetName(datum));		/*		 * Check for invalid characters in the group name.		 */		i = strcspn(groname, "\n");		if (groname[i] != '\0')		{			ereport(LOG,					(errmsg("invalid group name \"%s\"", groname)));			continue;		}		grolist_datum = heap_getattr(tuple, Anum_pg_group_grolist, dsc, &isnull);		/* Ignore NULL group lists */		if (isnull)			continue;		/* be sure the IdList is not toasted */		grolist_p = DatumGetIdListP(grolist_datum);		/* scan grolist */		num = IDLIST_NUM(grolist_p);		aidp = IDLIST_DAT(grolist_p);		for (i = 0; i < num; ++i)		{			tuple = SearchSysCache(SHADOWSYSID,								   PointerGetDatum(aidp[i]),								   0, 0, 0);			if (HeapTupleIsValid(tuple))			{				usename = NameStr(((Form_pg_shadow) GETSTRUCT(tuple))->usename);				/*				 * Check for illegal characters in the user name.				 */				j = strcspn(usename, "\n");				if (usename[j] != '\0')				{					ereport(LOG,						  (errmsg("invalid user name \"%s\"", usename)));					continue;				}				/*				 * File format is: "dbname"    "user1" "user2" "user3"				 */				if (first_user)				{					fputs_quote(groname, fp);					fputs("\t", fp);				}				else					fputs(" ", fp);				first_user = false;				fputs_quote(usename, fp);				ReleaseSysCache(tuple);			}		}		if (!first_user)			fputs("\n", fp);		/* if IdList was toasted, free detoasted copy */		if ((Pointer) grolist_p != DatumGetPointer(grolist_datum))			pfree(grolist_p);	}	heap_endscan(scan);	fflush(fp);	if (ferror(fp))		ereport(ERROR,				(errcode_for_file_access(),			  errmsg("could not write to temporary file \"%s\": %m", tempname)));	FreeFile(fp);	/*	 * Rename the temp file to its final name, deleting the old pg_pwd. We	 * expect that rename(2) is an atomic action.	 */	if (rename(tempname, filename))		ereport(ERROR,				(errcode_for_file_access(),				 errmsg("could not rename file \"%s\" to \"%s\": %m",						tempname, filename)));	pfree((void *) tempname);	pfree((void *) filename);}/* * write_user_file: update the flat password file */static voidwrite_user_file(Relation urel){	char	   *filename,			   *tempname;	int			bufsize;	FILE	   *fp;	mode_t		oumask;	HeapScanDesc scan;	HeapTuple	tuple;	TupleDesc	dsc = RelationGetDescr(urel);	/*	 * Create a temporary filename to be renamed later.  This prevents the	 * backend from clobbering the pg_pwd file while the postmaster might	 * be reading from it.	 */	filename = user_getfilename();	bufsize = strlen(filename) + 12;	tempname = (char *) palloc(bufsize);	snprintf(tempname, bufsize, "%s.%d", filename, MyProcPid);	oumask = umask((mode_t) 077);	fp = AllocateFile(tempname, "w");	umask(oumask);	if (fp == NULL)		ereport(ERROR,				(errcode_for_file_access(),			  errmsg("could not write to temporary file \"%s\": %m", tempname)));	/*	 * Read pg_shadow and write the file.  Note we use SnapshotSelf to	 * ensure we see all effects of current transaction.  (Perhaps could	 * do a CommandCounterIncrement beforehand, instead?)	 */	scan = heap_beginscan(urel, SnapshotSelf, 0, NULL);	while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)	{		Datum		datum;		bool		isnull;		char	   *usename,				   *passwd,				   *valuntil;		int			i;		datum = heap_getattr(tuple, Anum_pg_shadow_usename, dsc, &isnull);		/* ignore NULL usernames (shouldn't happen) */		if (isnull)			continue;		usename = NameStr(*DatumGetName(datum));		datum = heap_getattr(tuple, Anum_pg_shadow_passwd, dsc, &isnull);		/*		 * It can be argued that people having a null password shouldn't		 * be allowed to connect under password authentication, because		 * they need to have a password set up first. If you think		 * assuming an empty password in that case is better, change this		 * logic to look something like the code for valuntil.		 */		if (isnull)			continue;		passwd = DatumGetCString(DirectFunctionCall1(textout, datum));		datum = heap_getattr(tuple, Anum_pg_shadow_valuntil, dsc, &isnull);		if (isnull)			valuntil = pstrdup("");		else			valuntil = DatumGetCString(DirectFunctionCall1(abstimeout, datum));		/*		 * Check for illegal characters in the username and password.		 */		i = strcspn(usename, "\n");		if (usename[i] != '\0')		{			ereport(LOG,					(errmsg("invalid user name \"%s\"", usename)));			continue;		}		i = strcspn(passwd, "\n");		if (passwd[i] != '\0')		{			ereport(LOG,					(errmsg("invalid user password \"%s\"", passwd)));			continue;		}		/*		 * The extra columns we emit here are not really necessary. To		 * remove them, the parser in backend/libpq/crypt.c would need to		 * be adjusted.		 */		fputs_quote(usename, fp);		fputs(" ", fp);		fputs_quote(passwd, fp);		fputs(" ", fp);		fputs_quote(valuntil, fp);		fputs("\n", fp);		pfree(passwd);		pfree(valuntil);	}	heap_endscan(scan);	fflush(fp);	if (ferror(fp))		ereport(ERROR,				(errcode_for_file_access(),			  errmsg("could not write to temporary file \"%s\": %m", tempname)));	FreeFile(fp);	/*	 * Rename the temp file to its final name, deleting the old pg_pwd. We	 * expect that rename(2) is an atomic action.	 */	if (rename(tempname, filename))		ereport(ERROR,				(errcode_for_file_access(),				 errmsg("could not rename file \"%s\" to \"%s\": %m",						tempname, filename)));	pfree((void *) tempname);	pfree((void *) filename);}/* * This trigger is fired whenever someone modifies pg_shadow or pg_group * via general-purpose INSERT/UPDATE/DELETE commands. * * XXX should probably have two separate triggers. */Datumupdate_pg_pwd_and_pg_group(PG_FUNCTION_ARGS){	user_file_update_needed = true;	group_file_update_needed = true;	return PointerGetDatum(NULL);}/* * This routine is called during transaction commit or abort. * * On commit, if we've written pg_shadow or pg_group during the current * transaction, update the flat files and signal the postmaster. * * On abort, just reset the static flags so we don't try to do it on the * next successful commit. * * NB: this should be the last step before actual transaction commit. * If any error aborts the transaction after we run this code, the postmaster * will still have received and cached the changed data; so minimize the * window for such problems. */voidAtEOXact_UpdatePasswordFile(bool isCommit){	Relation	urel = NULL;	Relation	grel = NULL;	if (!(user_file_update_needed || group_file_update_needed))		return;	if (!isCommit)	{		user_file_update_needed = false;		group_file_update_needed = false;		return;	}	/*	 * We use ExclusiveLock to ensure that only one backend writes the	 * flat file(s) at a time.	That's sufficient because it's okay to	 * allow plain reads of the tables in parallel.  There is some chance	 * of a deadlock here (if we were triggered by a user update of	 * pg_shadow or pg_group, which likely won't have gotten a strong	 * enough lock), so get the locks we need before writing anything.	 */	if (user_file_update_needed)		urel = heap_openr(ShadowRelationName, ExclusiveLock);	if (group_file_update_needed)		grel = heap_openr(GroupRelationName, ExclusiveLock);	/* Okay to write the files */	if (user_file_update_needed)	{		user_file_update_needed = false;		write_user_file(urel);		heap_close(urel, NoLock);	}	if (group_file_update_needed)	{		group_file_update_needed = false;		write_group_file(grel);		heap_close(grel, NoLock);	}	/*	 * Signal the postmaster to reload its password & group-file cache.	 */	SendPostmasterSignal(PMSIGNAL_PASSWORD_CHANGE);}/* * CREATE USER */voidCreateUser(CreateUserStmt *stmt){	Relation	pg_shadow_rel;	TupleDesc	pg_shadow_dsc;	HeapScanDesc scan;	HeapTuple	tuple;	Datum		new_record[Natts_pg_shadow];	char		new_record_nulls[Natts_pg_shadow];	bool		user_exists = false,				sysid_exists = false,				havesysid = false;	int			max_id;	List	   *item,			   *option;	char	   *password = NULL;	/* PostgreSQL user password */	bool		encrypt_password = Password_encryption; /* encrypt password? */	char		encrypted_password[MD5_PASSWD_LEN + 1];	int			sysid = 0;		/* PgSQL system id (valid if havesysid) */	bool		createdb = false;		/* Can the user create databases? */	bool		createuser = false;		/* Can this user create users? */	List	   *groupElts = NIL;	/* The groups the user is a member of */	char	   *validUntil = NULL;		/* The time the login is valid										 * until */	DefElem    *dpassword = NULL;	DefElem    *dsysid = NULL;	DefElem    *dcreatedb = NULL;	DefElem    *dcreateuser = NULL;	DefElem    *dgroupElts = NULL;	DefElem    *dvalidUntil = NULL;	/* Extract options from the statement node tree */	foreach(option, stmt->options)	{		DefElem    *defel = (DefElem *) lfirst(option);		if (strcmp(defel->defname, "password") == 0 ||			strcmp(defel->defname, "encryptedPassword") == 0 ||			strcmp(defel->defname, "unencryptedPassword") == 0)		{			if (dpassword)				ereport(ERROR,						(errcode(ERRCODE_SYNTAX_ERROR),						 errmsg("conflicting or redundant options")));			dpassword = defel;			if (strcmp(defel->defname, "encryptedPassword") == 0)				encrypt_password = true;			else if (strcmp(defel->defname, "unencryptedPassword") == 0)				encrypt_password = false;		}		else if (strcmp(defel->defname, "sysid") == 0)		{			if (dsysid)				ereport(ERROR,						(errcode(ERRCODE_SYNTAX_ERROR),						 errmsg("conflicting or redundant options")));			dsysid = defel;		}		else if (strcmp(defel->defname, "createdb") == 0)		{			if (dcreatedb)				ereport(ERROR,						(errcode(ERRCODE_SYNTAX_ERROR),						 errmsg("conflicting or redundant options")));			dcreatedb = defel;		}		else if (strcmp(defel->defname, "createuser") == 0)		{			if (dcreateuser)				ereport(ERROR,						(errcode(ERRCODE_SYNTAX_ERROR),						 errmsg("conflicting or redundant options")));			dcreateuser = defel;		}		else if (strcmp(defel->defname, "groupElts") == 0)		{			if (dgroupElts)				ereport(ERROR,						(errcode(ERRCODE_SYNTAX_ERROR),						 errmsg("conflicting or redundant options")));			dgroupElts = defel;		}		else if (strcmp(defel->defname, "validUntil") == 0)		{			if (dvalidUntil)				ereport(ERROR,						(errcode(ERRCODE_SYNTAX_ERROR),						 errmsg("conflicting or redundant options")));			dvalidUntil = defel;		}		else			elog(ERROR, "option \"%s\" not recognized",				 defel->defname);	}	if (dcreatedb)		createdb = intVal(dcreatedb->arg) != 0;	if (dcreateuser)		createuser = intVal(dcreateuser->arg) != 0;	if (dsysid)	{		sysid = intVal(dsysid->arg);		if (sysid <= 0)

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩av午夜在线观看| 欧美午夜片在线看| 国产一区在线观看麻豆| 免费看欧美美女黄的网站| 亚洲午夜激情av| 亚洲一区二区三区自拍| 亚洲最新视频在线播放| 亚洲一区二区3| 亚洲国产毛片aaaaa无费看 | 国产女人18毛片水真多成人如厕| 日韩午夜电影av| 精品国产一区二区三区四区四| 3751色影院一区二区三区| 91麻豆精品国产91久久久资源速度| 欧美三级电影在线观看| 欧美绝品在线观看成人午夜影视| 欧美二区三区的天堂| 欧美一区二区在线不卡| 欧美成人a∨高清免费观看| 久久视频一区二区| 欧美国产一区二区| 亚洲欧美偷拍另类a∨色屁股| 夜夜嗨av一区二区三区四季av | 亚洲欧美日韩国产另类专区| 亚洲女爱视频在线| 亚洲视频狠狠干| 国产欧美日韩亚州综合| 在线观看国产一区二区| 成人免费视频视频在线观看免费 | 久久精品一区二区三区四区| 日本一区二区视频在线| 一区二区三区在线视频观看58| 亚洲成a人v欧美综合天堂| 免费av网站大全久久| 成人免费视频视频| 欧美日本在线播放| 国产亚洲女人久久久久毛片| 亚洲裸体在线观看| 麻豆视频一区二区| 成a人片亚洲日本久久| 欧美乱妇一区二区三区不卡视频| 欧美不卡激情三级在线观看| 毛片av中文字幕一区二区| 国产一区二区三区免费播放| 色综合色综合色综合 | 亚洲精品视频在线看| 日本欧美肥老太交大片| 国产精品一二三四五| 91视频观看视频| 91精品国产欧美一区二区 | 国产综合一区二区| 99re8在线精品视频免费播放| 欧美精三区欧美精三区| 欧美激情综合在线| 亚洲aⅴ怡春院| 国产成人午夜高潮毛片| 欧美在线观看一区二区| 精品少妇一区二区三区 | 国产成人午夜电影网| 欧美伊人久久大香线蕉综合69| 精品噜噜噜噜久久久久久久久试看| 国产精品麻豆视频| 日本特黄久久久高潮| av激情综合网| 久久久一区二区三区捆绑**| 亚洲综合在线免费观看| 国产一区二区美女诱惑| 欧美伊人久久久久久久久影院| 国产精品天天看| 日韩不卡手机在线v区| 99精品国产99久久久久久白柏| 久久综合一区二区| 日韩影院精彩在线| 欧美三级视频在线| 综合久久综合久久| 国产一区 二区 三区一级| 91麻豆精品国产91久久久使用方法| 亚洲男帅同性gay1069| 国产成人aaa| 精品日韩一区二区三区| 日韩av一区二| 欧美日韩精品二区第二页| 国产精品久久久久影院| 国产91精品入口| 久久久久国产成人精品亚洲午夜| 免费在线欧美视频| 欧美丰满嫩嫩电影| 亚州成人在线电影| 欧美网站一区二区| 亚洲精品乱码久久久久久久久| 99久久综合99久久综合网站| 国产亚洲1区2区3区| 国内偷窥港台综合视频在线播放| 日韩一级黄色片| 免费成人深夜小野草| 日韩欧美国产电影| 精品一区二区精品| 欧美mv和日韩mv国产网站| 精品制服美女丁香| 精品少妇一区二区三区在线播放 | 色噜噜偷拍精品综合在线| 国产精品全国免费观看高清| 5858s免费视频成人| 丝袜亚洲另类欧美综合| 欧美一区二区三区四区视频 | 欧美在线观看视频一区二区| 亚洲精品中文在线观看| 91福利视频网站| 亚洲成人在线观看视频| 日韩一区二区在线观看视频| 久久精品国产亚洲5555| 久久婷婷国产综合国色天香| 国产成人午夜视频| 亚洲欧洲性图库| 91免费国产视频网站| 亚洲在线一区二区三区| 3d成人h动漫网站入口| 久久99精品国产麻豆婷婷洗澡| 久久一区二区三区四区| 高清不卡一二三区| 亚洲精品写真福利| 91精品国产综合久久福利软件 | 欧美一区二区视频在线观看2022| 人人精品人人爱| 国产人久久人人人人爽| 色综合久久久久久久久| 日日夜夜精品视频天天综合网| 精品国产人成亚洲区| 国产v综合v亚洲欧| 亚洲欧美激情视频在线观看一区二区三区 | 三级久久三级久久久| 久久久夜色精品亚洲| 99精品久久只有精品| 日韩中文字幕av电影| 国产欧美日韩三区| 欧美在线视频你懂得| 蜜臂av日日欢夜夜爽一区| 国产拍欧美日韩视频二区 | 亚洲欧美在线视频观看| 欧美在线视频日韩| 精品在线免费观看| 国产一区二区三区不卡在线观看| 中文字幕一区二区三区蜜月| 欧美日韩卡一卡二| 国产激情精品久久久第一区二区 | 日日欢夜夜爽一区| 久久一日本道色综合| 91福利社在线观看| 精品无人区卡一卡二卡三乱码免费卡 | 欧美女孩性生活视频| 国产乱一区二区| 亚洲成人av中文| 日韩精品一区二区三区中文精品| 国产三级精品在线| 日韩在线一区二区| 国产宾馆实践打屁股91| 在线免费观看日韩欧美| 国产日本欧洲亚洲| 在线成人免费视频| 五月激情六月综合| 欧美午夜理伦三级在线观看| 亚洲制服丝袜av| 色一区在线观看| 亚洲一区二区欧美| 欧美日韩亚洲综合| 午夜欧美一区二区三区在线播放| 色av综合在线| 亚洲一区二区三区影院| 欧美巨大另类极品videosbest| 久久品道一品道久久精品| 亚洲成人777| 亚洲人一二三区| 国产成人av一区二区三区在线| 亚洲成av人片一区二区梦乃 | 久久久噜噜噜久久中文字幕色伊伊| 一区二区三区不卡在线观看 | 国产日韩欧美电影| 精品视频在线免费| k8久久久一区二区三区| 国产在线视视频有精品| 天堂一区二区在线免费观看| 亚洲精品国产高清久久伦理二区| 久久久午夜精品| 欧美一区二区三区免费在线看| 色综合色综合色综合| 成人av小说网| 国产宾馆实践打屁股91| 久久精品国产99国产精品| 天堂va蜜桃一区二区三区| 一区二区三区中文字幕| 国产精品国产三级国产aⅴ中文| 久久免费的精品国产v∧| 欧美一区二区性放荡片| 欧美日韩和欧美的一区二区| 日本久久精品电影| 91在线免费播放| 不卡的电视剧免费网站有什么| 高清不卡一区二区| 国产91丝袜在线18| 国产大片一区二区|