/********************************************************************
* wilkinson
* 3.6VMS
* 1995/09/25 14:35
* gopher_root1:[gopher.g2.vms2_13.gopherd]openers.c,v
* Exp
*
* Paul Lindner, University of Minnesota CIS.
*
* Copyright 1991, 1992 by the Regents of the University of Minnesota
* see the file "Copyright" in the distribution for conditions of use.
*********************************************************************
* MODULE: openers.c
* See below
*********************************************************************
* Revision History:
* openers.c,v
* Revision 3.6VMS 1995/09/25 14:35 wilkinson
* Consolodate VMS/Unix source code for server as well as client
*
* Revision 3.6 1995/02/07 07:02:46 lindner
* performance fixes
*
* Revision 3.5 1993/09/18 03:26:17 lindner
* Important Security fix
*
* Revision 3.4 1993/07/27 05:27:54 lindner
* Mondo Debug overhaul from Mitra
*
* Revision 3.3 1993/04/09 16:23:12 lindner
* Additional debug stuff
*
* Revision 3.2 1993/02/19 21:22:05 lindner
* Fixed problems with non-chroot() use
*
* Revision 3.1.1.1 1993/02/11 18:02:52 lindner
* Gopher+1.2beta release
*
* Revision 1.2 1993/01/30 23:57:44 lindner
* Fixes so that opening a file doesn't depend on what the current
* directory is.
*
* Revision 1.1 1992/12/10 23:13:27 lindner
* gopher 1.1 release
*
*
*********************************************************************/
/*
* Routines that implement safe "openers" so that we can do without
* the chroot(). This is an advantage because then you can have
* symbolic links from your gopher server directory to other files
* that are elsewhere on your system, without (if we've done this right)
* compromising your security, or allowing access to any files that
* you don't want made available.
*
* The "r" in the names is meant to indicate "restricted".
* The "u" in the names is meant to indicate "unrestricted".
*/
newpath += strlen(Data_Dir);
}
else {
strcpy(newpath, "/");
}
/* set errno to EPERM in case we reject the request */
errno = EPERM;
/*
** rip any .. or . entries out, so they can't sneak up out of
** the gopher directory. Need to use dedot2() so we don't clobber
** the string they sent us originally.
*/
dedot2(name,newpath);
if (*newpath == '/' || *newpath == '\0')
return(newpathbuf);
else
return(newpath);
#else
return(name);
#endif
}
#ifdef VMS_SERVER
/**********************
* Emulate functionality of ropendir() and readdir() for VMS wildcarded search
*/
char *
VMS$Wild_Search(char *path)
{
static struct FAB wild_fab; /* Used in wildcard search */
static struct NAM wild_nam; /* Used in conjunction with wild_fab */
static char fullname[256]; /* ropendir() input, readdir() output */
static char expanded[256]; /* filespec after logical expansion */
static char result[256]; /* result from search */
register status;
char *cp;
/* Validate path, initialize for wildcarded search of directory */