English 中文(简体)
Simulating O_NOFOLOW (2): Is this other approach safe?
原标题:Simulating O_NOFOLLOW (2): Is this other approach safe?

作为https://stackoverflow.com/questions/2917395/”的后续问题,我想到另一种做法,即,如果我想要append<>>>> /em> 存档,即,并在没有这种方式的情况下创建。

这里我要谈谈:

  1. Create a temporary directory with mode 0700 in a system temporary directory on the same filesystem as file name.
  2. Open file name for reading only and O_CREAT. The OS may follow name if it is a symbolic link.

    Use mkstemp to create a temporary file in the temporary directory and attempt to rename the temporary file that was created by mkstemp to file name.

    Open file name for reading only and O_CREAT | O_EXCL.
  3. Iteratively attempt to make a hard link to name at a temporary name within the temporary directory. If ever the link call fails due to an error other than "the link target exists" (errno EEXIST), then exit. (Maybe someone has come along and removed the file at name, who knows?)
  4. Use lstat on temp_name (the hard link). If S_ISLNK(lst.st_mode), then exit.
  5. open temp_name for writing & append (O_WRONLY | O_APPEND).
  6. Write everything out. Close the file descriptor.
  7. unlink the hard link.
  8. Remove the temporary directory.

(通过这一方式,所有这些都涉及我正在讨论的开放源项目https://signpad.net/wronly” rel=“nofollow noreferer”。 您可以看到我执行这一办法的来源:here

这一程序是否可防止象征性的联系攻击? 例如,有可能发生恶意过程,以确保<代码>的正本<>。 http://www. opengroup.org/onlinepubs/000095399/Functions/lstat.html” rel=“nofollow noreferer”>lstat。 接着核对,使现场成为与<代码>temp_name的象征链接。 现在与新的象征联系的硬联系?

我假定恶意过程不会影响<代码>temp_name。

rel=“nofollow noretinger”>不超出设定“承租人”临时档案的目标。 我此后更新了我的法典,并更新了上述步骤。

<><><>>>>> 我现在正在使用第2步的备用程序,以创建文件 姓名/代码>。 如果不存在,我并不认为可以

<<>strong>EDIT3: 甚至比重新命名一个临时的、空的经常文件> 姓名/代码>更好,该编号也具有互不联系效应, 姓名,then renaming,我可以打开文件。 O_RDONLY AO_CREAT code EXCL>。

<代码>开放<>/代码> 国家:

O_EXCLO_CREAT均予以确定,path则以象征链接标示, open(<><>>/code> 失效,并设定erno to EEXIST/code>,而不论该链接的内容如何。

最佳回答
问题回答

暂无回答




相关问题
Fastest method for running a binary search on a file in C?

For example, let s say I want to find a particular word or number in a file. The contents are in sorted order (obviously). Since I want to run a binary search on the file, it seems like a real waste ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Tips for debugging a made-for-linux application on windows?

I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

Encoding, decoding an integer to a char array

Please note that this is not homework and i did search before starting this new thread. I got Store an int in a char array? I was looking for an answer but didn t get any satisfactory answer in the ...