Skip to content

Commit 8cbb5b6

Browse files
bpo-26835: Add file sealing constants to fcntl (GH-13694)
Co-authored-by: nanjekyejoannah <[email protected]>
1 parent ffed76b commit 8cbb5b6

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

Doc/library/fcntl.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ descriptor.
2828
Operations in this module used to raise an :exc:`IOError` where they now
2929
raise an :exc:`OSError`.
3030

31+
.. versionchanged:: 3.8
32+
The fcntl module now contains ``F_ADD_SEALS``, ``F_GET_SEALS``, and
33+
``F_SEAL_*`` constants for sealing of :func:`os.memfd_create` file
34+
descriptors.
3135

3236
The module defines the following functions:
3337

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The fcntl module now contains file sealing constants for sealing of memfds.

Modules/fcntlmodule.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,15 @@ all_ins(PyObject* m)
620620
if (PyModule_AddIntMacro(m, I_PLINK)) return -1;
621621
if (PyModule_AddIntMacro(m, I_PUNLINK)) return -1;
622622
#endif
623-
623+
#ifdef F_ADD_SEALS
624+
/* Linux: file sealing for memfd_create() */
625+
if (PyModule_AddIntMacro(m, F_ADD_SEALS)) return -1;
626+
if (PyModule_AddIntMacro(m, F_GET_SEALS)) return -1;
627+
if (PyModule_AddIntMacro(m, F_SEAL_SEAL)) return -1;
628+
if (PyModule_AddIntMacro(m, F_SEAL_SHRINK)) return -1;
629+
if (PyModule_AddIntMacro(m, F_SEAL_GROW)) return -1;
630+
if (PyModule_AddIntMacro(m, F_SEAL_WRITE)) return -1;
631+
#endif
624632
return 0;
625633
}
626634

0 commit comments

Comments
 (0)