叉/的chroot相当于为Windows服务器应用程序 [英] fork/chroot equivalent for Windows server application

查看:466
本文介绍了叉/的chroot相当于为Windows服务器应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用C编写的Linux上运行一个小的自定义Web服务器应用程序。当应用程序接收到一个请求它调用fork()和处理在单独的进程,这是chroot的入含我想提供这些文件的特定目录的要求。

I have written a small custom web server application in C running on Linux. When the application receives a request it calls fork() and handles the request in a separate process, which is chrooted into a specific directory containing the files I want to make available.

我想端口的应用程序到Windows,但既不fork()的,也不执行chroot()可在此平台上,有似乎没有任何直接等效。你可以点我一个简单的(preferably写得很好)例如code的,将在Windows中提供这个功能?我的C是不是所有的好,所以越简单越好。

I want to port the application to Windows, but neither fork() nor chroot() are available on this platform, and there don't seem to be any direct equivalents. Can you point me to a simple (and preferably well written) example of code that will provide this functionality in Windows? My C isn't all that good, so the simpler the better.

推荐答案

首先,在Windows相当于的chroot RUNAS 这是这里记录。如果你需要从程序做到这一点,那么学习这个C ++源$ C ​​$ C 应该帮助您了解如何使用Windows API。它不是precisely一样的chroot()但Windows民间用它用极其有限的权限创建一个用户,并只给,要创造这样一个chroot监牢用户阅读应用程序文件夹权限,写权限的一个文件夹数据。

First of all, the Windows equivalent of chroot is RUNAS which is documented here. If you need to do this from a program, then studying this C++ source code should help you understand how to use the Windows API. It is not precisely the same as chroot() but Windows folk use it to create something like a chroot jail by creating a user with extremely limited permissions and only giving that user read permission on the application folder, and write permission on one folder for data.

您可能不希望确切地模仿叉()在Windows上,因为它听起来并不像你需要去那么远。要了解Windows API创建过程和从的区别叉()检查的先生。皮博迪解释fork()的。实际电流源$ C ​​$ C的<一个href=\"http://cygwin.com/cgi-bin/cvsweb.cgi/src/winsup/cygwin/fork.cc?rev=1.208&content-type=text/x-cvsweb-markup&cvsroot=src\">Cygwin's叉实现显示了艺术的当前状态。

You probably don't want to exactly emulate fork() on Windows because it doesn't sound like you need to go that far. To understand the Windows API for creating processes and how it differs from fork(), check Mr. Peabody Explains fork(). The actual current source code for Cygwin's fork implementation shows you the current state of the art.

微软文档的CreateProcess()的CreateThread()是找对更多信息的地方它们之间的区别。

The Microsoft documentation for CreateProcess() and CreateThread() are the place to look for more info on the differences between them.

最后,如果你不想去学习所有的事实真相平台详细信息,只写在Windows和Unix的工作移植程序,为什么不直接使用的 Apache可移植运行库本身。 这里是进程创建的一些文档一些样品code ,在C,创建一个新的进程。

And finally, if you don't want to learn all the nitty-gritty platform details, just write portable programs that work on Windows and Unix, why not just use the Apache Portable Runtime library itself. Here are some docs on process creation with some sample code, in C, to create a new process.

这篇关于叉/的chroot相当于为Windows服务器应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆