diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst index 8d94a9ff5441868..5f6229aa9b4043f 100644 --- a/Doc/whatsnew/3.8.rst +++ b/Doc/whatsnew/3.8.rst @@ -181,6 +181,9 @@ Other Language Changes and Windows use this to properly terminate scripts in interactive sessions. (Contributed by Google via Gregory P. Smith in :issue:`1054041`.) +* fcntl now has File Sealing operations.(Contributed by Joannah Nanjekye + in :issue:`26835`.) + New Modules =========== diff --git a/Misc/NEWS.d/next/Library/2019-04-29-21-33-12.bpo-26835.JYlsPS.rst b/Misc/NEWS.d/next/Library/2019-04-29-21-33-12.bpo-26835.JYlsPS.rst new file mode 100644 index 000000000000000..0852a97bc084879 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2019-04-29-21-33-12.bpo-26835.JYlsPS.rst @@ -0,0 +1 @@ +fcntl now has File Sealing operations. \ No newline at end of file diff --git a/Modules/fcntlmodule.c b/Modules/fcntlmodule.c index a938d9e88bf0174..4decd23cff55270 100644 --- a/Modules/fcntlmodule.c +++ b/Modules/fcntlmodule.c @@ -15,6 +15,33 @@ #include #endif +#ifndef F_LINUX_SPECIFIC_BASE +# define F_LINUX_SPECIFIC_BASE 1024 +#endif + +/* fcntl.h */ +#ifndef F_ADD_SEALS + +/* + * Set/Get seals + */ +#define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9) +#define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10) + +#endif /* F_ADD_SEALS */ + +#ifndef F_SEAL_SEAL + +/* + * Available Seals + */ +#define F_SEAL_SEAL 0x0001 /* prevent further seals from being set */ +#define F_SEAL_SHRINK 0x0002 /* prevent file from shrinking */ +#define F_SEAL_GROW 0x0004 /* prevent file from growing */ +#define F_SEAL_WRITE 0x0008 /* prevent writes */ + +#endif /* F_SEAL_SEAL */ + /*[clinic input] module fcntl [clinic start generated code]*/ @@ -454,6 +481,13 @@ all_ins(PyObject* m) if (PyModule_AddIntMacro(m, LOCK_EX)) return -1; if (PyModule_AddIntMacro(m, LOCK_NB)) return -1; if (PyModule_AddIntMacro(m, LOCK_UN)) return -1; + + if (PyModule_AddIntMacro(m, F_ADD_SEALS)) return -1; + if (PyModule_AddIntMacro(m, F_GET_SEALS)) return -1; + if (PyModule_AddIntMacro(m, F_SEAL_SEAL)) return -1; + if (PyModule_AddIntMacro(m, F_SEAL_SHRINK)) return -1; + if (PyModule_AddIntMacro(m, F_SEAL_GROW)) return -1; + if (PyModule_AddIntMacro(m, F_SEAL_WRITE)) return -1; /* GNU extensions, as of glibc 2.2.4 */ #ifdef LOCK_MAND if (PyModule_AddIntMacro(m, LOCK_MAND)) return -1;