dtsfnyay300457 2013-04-17 06:07
浏览 78
已采纳

在Linux中写入命名管道的最佳,最安全的方法是什么?

What is the best, secure way to write to a named pipe in Linux? Or, how can I make a named pipe secure?

Here's how I write to the pipe on linux using PHP:

$con = fopen("/tmp/myFIFO", "w");
fwrite($con, "UP
");
fclose($con);

I wish to make it more secure.

This is how I create the pipe in 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
");
    printf("Exiting...
");
    exit(1);
}
else {
    printf("Success in Creating Pipe
");
    chmod("/tmp/myFIFO", i);
}
  • 写回答

1条回答 默认 最新

  • du155305 2013-04-17 06:26
    关注

    You can use umask to control the permissions of the files you create. You also have chmod in php as well.

    However, you also have posix_mkfifo available, which exactly fits your purpose:

    bool posix_mkfifo ( string $pathname , int $mode )

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services