![](/img/trans.png)
[英]What is the best/most secure way to pass an id from a page to another?
[英]What is the best, most secure way to write to a named pipe in Linux?
在Linux中写入命名管道的最佳安全方法是什么? 或者,如何使命名管道安全?
这是我使用PHP在Linux上写入管道的方式:
$con = fopen("/tmp/myFIFO", "w");
fwrite($con, "UP\n");
fclose($con);
我希望使其更加安全。
这就是我在C中创建管道的方法:
int pc;
char mode[] = "0777";
int i = strtol(mode, 0, 8);
pc = mkfifo(FIFO, 0);
if(pc < 0) {
printf("Failed in creating a pipe\n");
printf("Exiting...\n");
exit(1);
}
else {
printf("Success in Creating Pipe\n");
chmod("/tmp/myFIFO", i);
}
您可以使用umask
来控制所创建文件的权限。 您也有php中的chmod
。
但是,您也可以使用posix_mkfifo
,它完全符合您的目的:
bool posix_mkfifo (字符串$ pathname ,int $ mode )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.