⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 env_unix.c

📁 广泛使用的邮件服务器!同时
💻 C
📖 第 1 页 / 共 5 页
字号:
/* ======================================================================== * Copyright 1988-2008 University of Washington * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * *     http://www.apache.org/licenses/LICENSE-2.0 * *  * ======================================================================== *//* * Program:	UNIX environment routines * * Author:	Mark Crispin *		UW Technology *		University of Washington *		Seattle, WA  98195 *		Internet: MRC@Washington.EDU * * Date:	1 August 1988 * Last Edited:	15 May 2008 */#include <grp.h>#include <signal.h>#include <sys/wait.h>/* in case stat.h is ancient */#ifndef S_IRUSR#define S_IRUSR S_IREAD#endif#ifndef S_IWUSR#define S_IWUSR S_IWRITE#endif#ifndef S_IXUSR#define S_IXUSR S_IEXEC#endif#ifndef S_IRGRP#define S_IRGRP (S_IREAD >> 3)#endif#ifndef S_IWGRP#define S_IWGRP (S_IWRITE >> 3)#endif#ifndef S_IXGRP#define S_IXGRP (S_IEXEC >> 3)#endif#ifndef S_IROTH#define S_IROTH (S_IREAD >> 6)#endif#ifndef S_IWOTH#define S_IWOTH (S_IWRITE >> 6)#endif#ifndef S_IXOTH#define S_IXOTH (S_IEXEC >> 6)#endif/* c-client environment parameters */static char *myUserName = NIL;	/* user name */static char *myHomeDir = NIL;	/* home directory name */static char *myServerName = NIL;/* server name */static char *myLocalHost = NIL;	/* local host name */static char *myNewsrc = NIL;	/* newsrc file name */static char *mailsubdir = NIL;	/* mailbox subdirectory name */static char *sysInbox = NIL;	/* system inbox name */static char *newsActive = NIL;	/* news active file */static char *newsSpool = NIL;	/* news spool */static char *blackBoxDir = NIL;	/* black box directory name */				/* black box default home directory */static char *blackBoxDefaultHome = NIL;static char *sslCApath = NIL;	/* non-standard CA path */static short anonymous = NIL;	/* is anonymous */static short blackBox = NIL;	/* is a black box */static short closedBox = NIL;	/* is a closed box (uses chroot() jail) */static short restrictBox = NIL;	/* is a restricted box */static short has_no_life = NIL;	/* is a cretin with no life */				/* block environment init */static short block_env_init = NIL;static short hideDotFiles = NIL;/* hide files whose names start with . */				/* advertise filesystem root */static short advertisetheworld = NIL;				/* only advertise own mailboxes and #shared */static short limitedadvertise = NIL;				/* disable automatic shared namespaces */static short noautomaticsharedns = NIL;static short no822tztext = NIL;	/* disable RFC [2]822 timezone text */				/* client principals include service name */static short kerb_cp_svr_name = NIL;static long locktimeout = 5;	/* default lock timeout in minutes */				/* default prototypes */static MAILSTREAM *createProto = NIL;static MAILSTREAM *appendProto = NIL;				/* default user flags */static char *userFlags[NUSERFLAGS] = {NIL};static NAMESPACE *nslist[3];	/* namespace list */static int logtry = 3;		/* number of server login tries */				/* block notification */static blocknotify_t mailblocknotify = mm_blocknotify;				/* logout function */static logouthook_t maillogouthook = NIL;				/* logout data */static void *maillogoutdata = NIL;				/* allow user config files */static short allowuserconfig = NIL;				/* 1 = disable plaintext, 2 = if not SSL */static long disablePlaintext = NIL;static long list_max_level = 20;/* maximum level of list recursion */				/* facility for syslog */static int syslog_facility = LOG_MAIL;/* Path of the privileged system lock program (mlock).  Normally set by * logic test. */static char *lockpgm = LOCKPGM;/* Directory used for shared locks.  MUST be the same for all users of the * system, and MUST be protected 1777.  /var/tmp may be preferable on some * systems. */static const char *tmpdir = "/tmp";/* Do not change shlock_mode.  Doing so can cause mailbox corruption and * denial of service.  It also defeats the entire purpose of the shared * lock mechanism.  The right way to avoid shared locks is to set up a * closed box (see the closedBox setting). */				/* shared lock mode */static const int shlock_mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH;/* It is STRONGLY recommended that you do not change dotlock_mode.  Doing so * can cause denial of service with old dot-lock files left lying around. * However, since dot-locks are only used with traditional UNIX and MMDF * formats which are not normally shared, it is much less harmful to tamper * with this than with shlock_mode. */				/* dot-lock mode */static long dotlock_mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH;/* File/directory access and protection policies *//* Unlike shlock_mode, the ????_protection modes are intended to be fully * customizable according to site policy.  The values here are recommended * settings, based upon the documented purposes of the namespaces. */	/* user space - only owner can read/write */static char *myMailboxDir = NIL;/* user space directory name */				/* default file protection */static long mbx_protection = S_IRUSR|S_IWUSR;				/* default directory protection */static long dir_protection = S_IRUSR|S_IWUSR|S_IXUSR;	/* user space for user "anonymous" */				/* anonymous home directory */static char *anonymousHome = NIL;	/* #ftp - everybody can read, only owner can write */static char *ftpHome = NIL;	/* ftp export home directory */				/* default ftp file protection */static long ftp_protection = S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH;static long ftp_dir_protection =/* default ftp directory protection */  S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;	/* #public - everybody can read/write */static char *publicHome = NIL;	/* public home directory */static long public_protection =	/* default public file protection */  S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH;				/* default public directory protection */static long public_dir_protection =  S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IWOTH|S_IXOTH;	/* #shared/ - owner and group members can read/write */static char *sharedHome = NIL;	/* shared home directory */				/* default shared file protection */static long shared_protection = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP;				/* default shared directory protection */static long shared_dir_protection =  S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP;/* OS bug workarounds - should be avoided at all cost *//* Don't set fcntlhangbug unless you really have to, since it risks mailbox * corruption.  The flocksim.c mechanism is designed to detect NFS access * and no-op in that cases only, so this flag should be unnecessary. */static short fcntlhangbug = NIL;/* flock() emulator using fcntl() is a no-op *//* Don't set netfsstatbug unless you really have to, since it dramatically * slows down traditional UNIX and MMDF mailbox performance. */static short netfsstatbug = NIL;/* compensate for broken stat() on network				 * filesystems (AFS and old NFS)				 *//* Note: setting disableLockWarning means that you assert that the * so-modified copy of this software will NEVER be used: *  1) in conjunction with any software which expects .lock files *  2) to access NFS-mounted files and directories * * Unless both of these conditions apply, then do not set this flag. * Instead, read the FAQ (item 7.10) and either use 1777 protection * on the mail spool, or install mlock. * * In addition, by setting this flag you also agree that you are fully * legally and morally responsible when (not if) mail files are damaged * as the result of your choice. * * The mlock tool exists for a reason.  Use it. */				/* disable warning if can't make .lock file */static short disableLockWarning = NIL;/* UNIX Namespaces */				/* personal mh namespace */static NAMESPACE nsmhf = {"#mh/",'/',NIL,NIL};static NAMESPACE nsmh = {"#mhinbox",NIL,NIL,&nsmhf};				/* home namespace */static NAMESPACE nshome = {"",'/',NIL,&nsmh};				/* UNIX other user namespace */static NAMESPACE nsunixother = {"~",'/',NIL,NIL};				/* black box other user namespace */static NAMESPACE nsblackother = {"/",'/',NIL,NIL};				/* public (anonymous OK) namespace */static NAMESPACE nspublic = {"#public/",'/',NIL,NIL};				/* netnews namespace */static NAMESPACE nsnews = {"#news.",'.',NIL,&nspublic};				/* FTP export namespace */static NAMESPACE nsftp = {"#ftp/",'/',NIL,&nsnews};				/* shared (no anonymous) namespace */static NAMESPACE nsshared = {"#shared/",'/',NIL,&nsftp};				/* world namespace */static NAMESPACE nsworld = {"/",'/',NIL,&nsshared};				/* only shared and public namespaces */static NAMESPACE nslimited = {"#shared/",'/',NIL,&nspublic};#include "write.c"		/* include safe writing routines */#include "crexcl.c"		/* include exclusive create */#include "pmatch.c"		/* include wildcard pattern matcher *//* Get all authenticators */#include "auths.c"/* Environment manipulate parameters * Accepts: function code *	    function-dependent value * Returns: function-dependent return value */void *env_parameters (long function,void *value){  void *ret = NIL;  switch ((int) function) {  case GET_NAMESPACE:    ret = (void *) nslist;    break;  case SET_USERNAME:    if (myUserName) fs_give ((void **) &myUserName);    myUserName = cpystr ((char *) value);  case GET_USERNAME:    ret = (void *) myUserName;    break;  case SET_HOMEDIR:    if (myHomeDir) fs_give ((void **) &myHomeDir);    myHomeDir = cpystr ((char *) value);  case GET_HOMEDIR:    ret = (void *) myHomeDir;    break;  case SET_LOCALHOST:    if (myLocalHost) fs_give ((void **) &myLocalHost);    myLocalHost = cpystr ((char *) value);  case GET_LOCALHOST:    ret = (void *) myLocalHost;    break;  case SET_NEWSRC:    if (myNewsrc) fs_give ((void **) &myNewsrc);    myNewsrc = cpystr ((char *) value);  case GET_NEWSRC:    ret = (void *) myNewsrc;    break;  case SET_NEWSACTIVE:    if (newsActive) fs_give ((void **) &newsActive);    newsActive = cpystr ((char *) value);  case GET_NEWSACTIVE:    ret = (void *) newsActive;    break;  case SET_NEWSSPOOL:    if (newsSpool) fs_give ((void **) &newsSpool);    newsSpool = cpystr ((char *) value);  case GET_NEWSSPOOL:    ret = (void *) newsSpool;    break;  case SET_ANONYMOUSHOME:    if (anonymousHome) fs_give ((void **) &anonymousHome);    anonymousHome = cpystr ((char *) value);  case GET_ANONYMOUSHOME:    if (!anonymousHome) anonymousHome = cpystr (ANONYMOUSHOME);    ret = (void *) anonymousHome;    break;  case SET_FTPHOME:    if (ftpHome) fs_give ((void **) &ftpHome);    ftpHome = cpystr ((char *) value);  case GET_FTPHOME:    ret = (void *) ftpHome;    break;  case SET_PUBLICHOME:    if (publicHome) fs_give ((void **) &publicHome);    publicHome = cpystr ((char *) value);  case GET_PUBLICHOME:    ret = (void *) publicHome;    break;  case SET_SHAREDHOME:    if (sharedHome) fs_give ((void **) &sharedHome);    sharedHome = cpystr ((char *) value);  case GET_SHAREDHOME:    ret = (void *) sharedHome;    break;  case SET_SYSINBOX:    if (sysInbox) fs_give ((void **) &sysInbox);    sysInbox = cpystr ((char *) value);  case GET_SYSINBOX:    ret = (void *) sysInbox;    break;  case SET_SSLCAPATH:		/* this can be set null */    if (sslCApath) fs_give ((void **) &sslCApath);    sslCApath = value ? cpystr ((char *) value) : value;    break;  case GET_SSLCAPATH:    ret = (void *) sslCApath;    break;  case SET_LISTMAXLEVEL:    list_max_level = (long) value;  case GET_LISTMAXLEVEL:    ret = (void *) list_max_level;    break;  case SET_MBXPROTECTION:    mbx_protection = (long) value;  case GET_MBXPROTECTION:    ret = (void *) mbx_protection;    break;  case SET_DIRPROTECTION:    dir_protection = (long) value;  case GET_DIRPROTECTION:    ret = (void *) dir_protection;    break;  case SET_LOCKPROTECTION:    dotlock_mode = (long) value;  case GET_LOCKPROTECTION:    ret = (void *) dotlock_mode;    break;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -