コード例 #1
0
ファイル: io.c プロジェクト: BackupTheBerlios/premake-svn
int io_mkdir(const char* path)
{
	/* Remember the current directory */
	char cwd[8192];
	platform_getcwd(cwd, 8192);

	/* Split the path and check each part in turn */
	strcpy(buffer, path);
	path = buffer;

	while (path != NULL)
	{
		char* ptr = strchr(path, '/');
		if (ptr != NULL)
			*ptr = '\0';

		platform_mkdir(path);
		platform_chdir(path);

		path = (ptr != NULL) ? ptr + 1 : NULL;
	}

	/* Restore the original working directory */
	platform_chdir(cwd);
	return 1;
}
コード例 #2
0
ファイル: platform.c プロジェクト: woohooyeah/openvpn
/* Redefine the top level directory of the filesystem
 * to restrict access to files for security */
void
platform_chroot(const char *path)
{
    if (path)
    {
#ifdef HAVE_CHROOT
        const char *top = "/";
        if (chroot(path))
        {
            msg(M_ERR, "chroot to '%s' failed", path);
        }
        if (platform_chdir(top))
        {
            msg(M_ERR, "cd to '%s' failed", top);
        }
        msg(M_INFO, "chroot to '%s' and cd to '%s' succeeded", path, top);
#else  /* ifdef HAVE_CHROOT */
        msg(M_FATAL, "Sorry but I can't chroot to '%s' because this operating system doesn't appear to support the chroot() system call", path);
#endif
    }
}
コード例 #3
0
ファイル: io.c プロジェクト: BackupTheBerlios/premake-svn
int io_chdir(const char* path)
{
	return platform_chdir(path);
}