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 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分