From e293de18a2ff78b43640e4aa80da7979ea77662b Mon Sep 17 00:00:00 2001 From: nanjekyejoannah Date: Mon, 29 Apr 2019 17:25:15 -0400 Subject: [PATCH 1/5] Add file-sealing ops to fcntl --- Doc/whatsnew/3.8.rst | 3 +++ Modules/fcntlmodule.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst index 8d94a9ff5441868..d21a5854ef4eeb0 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 File Sealing operations.(Contributed by Joannah Nanjekye +in :issue:`26835`.) + New Modules =========== 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; From de7d73a842eb3925790dbc6c53149bf700f14d8f Mon Sep 17 00:00:00 2001 From: Joannah Nanjekye <33177550+nanjekyejoannah@users.noreply.github.com> Date: Mon, 29 Apr 2019 17:31:33 -0400 Subject: [PATCH 2/5] Update 3.8.rst --- Doc/whatsnew/3.8.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst index d21a5854ef4eeb0..cb93a124bda598b 100644 --- a/Doc/whatsnew/3.8.rst +++ b/Doc/whatsnew/3.8.rst @@ -181,7 +181,7 @@ 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 File Sealing operations.(Contributed by Joannah Nanjekye +* fcntl now has File Sealing operations.(Contributed by Joannah Nanjekye in :issue:`26835`.) From 056befd9e45cd6f74680a023b2f70b2f5030febe Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" Date: Mon, 29 Apr 2019 21:33:15 +0000 Subject: [PATCH 3/5] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NEWS.d/next/Library/2019-04-29-21-33-12.bpo-26835.JYlsPS.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2019-04-29-21-33-12.bpo-26835.JYlsPS.rst 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 From 1e12edc491cac7312ff29ed7d6e12b98b7397bc9 Mon Sep 17 00:00:00 2001 From: nanjekyejoannah Date: Mon, 29 Apr 2019 17:40:43 -0400 Subject: [PATCH 4/5] fix space in Doc --- Doc/whatsnew/3.8.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst index cb93a124bda598b..ede68218cf1c257 100644 --- a/Doc/whatsnew/3.8.rst +++ b/Doc/whatsnew/3.8.rst @@ -181,7 +181,7 @@ 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 +* fcntl now has File Sealing operations.(Contributed by Joannah Nanjekye in :issue:`26835`.) From 052de6408dc3730548c675223c9c108d6f353f95 Mon Sep 17 00:00:00 2001 From: nanjekyejoannah Date: Mon, 29 Apr 2019 18:00:25 -0400 Subject: [PATCH 5/5] Fix 3.8.rst --- Doc/whatsnew/3.8.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst index ede68218cf1c257..5f6229aa9b4043f 100644 --- a/Doc/whatsnew/3.8.rst +++ b/Doc/whatsnew/3.8.rst @@ -182,7 +182,7 @@ Other Language Changes (Contributed by Google via Gregory P. Smith in :issue:`1054041`.) * fcntl now has File Sealing operations.(Contributed by Joannah Nanjekye -in :issue:`26835`.) + in :issue:`26835`.) New Modules