Page MenuHomeFreeBSD

D38461.1790993066.diff
No OneTemporary

Size
7 KB
Referenced Files
None
Subscribers
None

D38461.1790993066.diff

Index: lang/python310/Makefile
===================================================================
--- lang/python310/Makefile
+++ lang/python310/Makefile
@@ -1,6 +1,6 @@
PORTNAME= python
DISTVERSION= ${PYTHON_DISTVERSION}
-PORTREVISION= 1
+PORTREVISION= 2
CATEGORIES= lang python
MASTER_SITES= PYTHON/ftp/python/${DISTVERSION:C/[a-z].*//}
PKGNAMESUFFIX= ${PYTHON_SUFFIX}
Index: lang/python310/files/patch-Python_initconfig.c
===================================================================
--- /dev/null
+++ lang/python310/files/patch-Python_initconfig.c
@@ -0,0 +1,38 @@
+From 16eb497620b7d1afa189c98e7ce4101dda634a52 Mon Sep 17 00:00:00 2001
+From: Charlie Li <vishwin@FreeBSD.org>
+Date: Thu, 9 Feb 2023 00:19:28 -0500
+Subject: [PATCH] [3.10] Do not write bytecode when running as root
+
+---
+ Python/initconfig.c | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git Python/initconfig.c Python/initconfig.c
+index 1e10e6659c..1c51818656 100644
+--- Python/initconfig.c
++++ Python/initconfig.c
+@@ -20,6 +20,9 @@
+ # include <fcntl.h> // O_BINARY
+ # endif
+ #endif
++#ifdef HAVE_UNISTD_H
++# include <unistd.h> // geteuid()
++#endif
+
+ #ifndef PLATLIBDIR
+ # error "PLATLIBDIR macro must be defined"
+@@ -749,6 +752,11 @@ config_init_defaults(PyConfig *config)
+ config->optimization_level = 0;
+ config->parser_debug= 0;
+ config->write_bytecode = 1;
++#ifdef HAVE_UNISTD_H
++ if (geteuid() == 0) {
++ config->write_bytecode = 0;
++ }
++#endif
+ config->verbose = 0;
+ config->quiet = 0;
+ config->user_site_directory = 1;
+--
+2.39.1
+
Index: lang/python311/Makefile
===================================================================
--- lang/python311/Makefile
+++ lang/python311/Makefile
@@ -1,6 +1,6 @@
PORTNAME= python
DISTVERSION= ${PYTHON_DISTVERSION}
-PORTREVISION= 1
+PORTREVISION= 2
CATEGORIES= lang python
MASTER_SITES= PYTHON/ftp/python/${DISTVERSION:C/[a-z].*//}
PKGNAMESUFFIX= ${PYTHON_SUFFIX}
Index: lang/python311/files/patch-Python_initconfig.c
===================================================================
--- /dev/null
+++ lang/python311/files/patch-Python_initconfig.c
@@ -0,0 +1,38 @@
+From fcee3b70f374d5c4041e4274632b2641990884ab Mon Sep 17 00:00:00 2001
+From: Charlie Li <vishwin@FreeBSD.org>
+Date: Thu, 9 Feb 2023 00:19:09 -0500
+Subject: [PATCH] [3.11] Do not write bytecode when running as root
+
+---
+ Python/initconfig.c | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git Python/initconfig.c Python/initconfig.c
+index d81cbaff7e..a807050ec1 100644
+--- Python/initconfig.c
++++ Python/initconfig.c
+@@ -22,6 +22,9 @@
+ # include <fcntl.h> // O_BINARY
+ # endif
+ #endif
++#if defined(HAVE_GETEUID) && defined(HAVE_UNISTD_H)
++# include <unistd.h> // geteuid()
++#endif
+
+ /* --- Command line options --------------------------------------- */
+
+@@ -799,6 +802,11 @@ config_init_defaults(PyConfig *config)
+ config->optimization_level = 0;
+ config->parser_debug= 0;
+ config->write_bytecode = 1;
++#if defined(HAVE_GETEUID) && defined(HAVE_UNISTD_H)
++ if (geteuid() == 0) {
++ config->write_bytecode = 0;
++ }
++#endif
+ config->verbose = 0;
+ config->quiet = 0;
+ config->user_site_directory = 1;
+--
+2.39.1
+
Index: lang/python37/Makefile
===================================================================
--- lang/python37/Makefile
+++ lang/python37/Makefile
@@ -1,5 +1,6 @@
PORTNAME= python
DISTVERSION= ${PYTHON_DISTVERSION}
+PORTREVISION= 1
CATEGORIES= lang python
MASTER_SITES= PYTHON/ftp/python/${DISTVERSION}
PKGNAMESUFFIX= ${PYTHON_SUFFIX}
Index: lang/python37/files/patch-Modules_main.c
===================================================================
--- /dev/null
+++ lang/python37/files/patch-Modules_main.c
@@ -0,0 +1,39 @@
+From a95d1847fb2efbba877c3b2344f2565719da1223 Mon Sep 17 00:00:00 2001
+From: Charlie Li <vishwin@FreeBSD.org>
+Date: Thu, 9 Feb 2023 01:32:45 -0500
+Subject: [PATCH] [3.7] Do not write bytecode when running as root
+
+---
+ Modules/main.c | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git Modules/main.c Modules/main.c
+index dfb6180179..d220034e00 100644
+--- Modules/main.c
++++ Modules/main.c
+@@ -23,6 +23,10 @@
+ # include <windows.h> /* STATUS_CONTROL_C_EXIT */
+ #endif
+
++#ifdef HAVE_UNISTD_H
++# include <unistd.h>
++#endif
++
+ #ifdef __FreeBSD__
+ # include <fenv.h>
+ #endif
+@@ -1540,6 +1544,11 @@ cmdline_set_global_config(_PyCmdline *cmdline)
+ Py_IsolatedFlag = cmdline->isolated;
+ Py_OptimizeFlag = cmdline->optimization_level;
+ Py_DontWriteBytecodeFlag = cmdline->dont_write_bytecode;
++#ifdef HAVE_UNISTD_H
++ if (geteuid() == 0) {
++ Py_DontWriteBytecodeFlag++;
++ }
++#endif
+ Py_NoUserSiteDirectory = cmdline->no_user_site_directory;
+ Py_NoSiteFlag = cmdline->no_site_import;
+ Py_UnbufferedStdioFlag = cmdline->use_unbuffered_io;
+--
+2.39.1
+
Index: lang/python38/Makefile
===================================================================
--- lang/python38/Makefile
+++ lang/python38/Makefile
@@ -1,5 +1,6 @@
PORTNAME= python
DISTVERSION= ${PYTHON_DISTVERSION}
+PORTREVISION= 1
CATEGORIES= lang python
MASTER_SITES= PYTHON/ftp/python/${DISTVERSION}
PKGNAMESUFFIX= ${PYTHON_SUFFIX}
Index: lang/python38/files/patch-Python_initconfig.c
===================================================================
--- /dev/null
+++ lang/python38/files/patch-Python_initconfig.c
@@ -0,0 +1,38 @@
+From 16dd43a54fda85380d828257682b1663fe99da3f Mon Sep 17 00:00:00 2001
+From: Charlie Li <vishwin@FreeBSD.org>
+Date: Thu, 9 Feb 2023 00:19:28 -0500
+Subject: [PATCH] [3.8] Do not write bytecode when running as root
+
+---
+ Python/initconfig.c | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git Python/initconfig.c Python/initconfig.c
+index 003ac76c6e..f598677fae 100644
+--- Python/initconfig.c
++++ Python/initconfig.c
+@@ -22,6 +22,9 @@
+ # include <fcntl.h> /* O_BINARY */
+ # endif
+ #endif
++#ifdef HAVE_UNISTD_H
++# include <unistd.h> // geteuid()
++#endif
+
+
+ /* --- Command line options --------------------------------------- */
+@@ -664,6 +667,11 @@ config_init_defaults(PyConfig *config)
+ config->optimization_level = 0;
+ config->parser_debug= 0;
+ config->write_bytecode = 1;
++#ifdef HAVE_UNISTD_H
++ if (geteuid() == 0) {
++ config->write_bytecode = 0;
++ }
++#endif
+ config->verbose = 0;
+ config->quiet = 0;
+ config->user_site_directory = 1;
+--
+2.39.1
+
Index: lang/python39/Makefile
===================================================================
--- lang/python39/Makefile
+++ lang/python39/Makefile
@@ -1,5 +1,6 @@
PORTNAME= python
DISTVERSION= ${PYTHON_DISTVERSION}
+PORTREVISION= 1
CATEGORIES= lang python
MASTER_SITES= PYTHON/ftp/python/${DISTVERSION}
PKGNAMESUFFIX= ${PYTHON_SUFFIX}
Index: lang/python39/files/patch-Python_initconfig.c
===================================================================
--- /dev/null
+++ lang/python39/files/patch-Python_initconfig.c
@@ -0,0 +1,38 @@
+From d7267c1c3626eba16557de2e69d160ebcfac08b3 Mon Sep 17 00:00:00 2001
+From: Charlie Li <vishwin@FreeBSD.org>
+Date: Thu, 9 Feb 2023 00:19:28 -0500
+Subject: [PATCH] [3.9] Do not write bytecode when running as root
+
+---
+ Python/initconfig.c | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git Python/initconfig.c Python/initconfig.c
+index 7ab52fb934..c167ee0897 100644
+--- Python/initconfig.c
++++ Python/initconfig.c
+@@ -24,6 +24,9 @@
+ # include <fcntl.h> // O_BINARY
+ # endif
+ #endif
++#ifdef HAVE_UNISTD_H
++# include <unistd.h> // geteuid()
++#endif
+
+ #ifndef PLATLIBDIR
+ # error "PLATLIBDIR macro must be defined"
+@@ -673,6 +676,11 @@ config_init_defaults(PyConfig *config)
+ config->optimization_level = 0;
+ config->parser_debug= 0;
+ config->write_bytecode = 1;
++#ifdef HAVE_UNISTD_H
++ if (geteuid() == 0) {
++ config->write_bytecode = 0;
++ }
++#endif
+ config->verbose = 0;
+ config->quiet = 0;
+ config->user_site_directory = 1;
+--
+2.39.1
+

File Metadata

Mime Type
text/plain
Expires
Sat, Oct 3, 2:04 AM (13 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30114290
Default Alt Text
D38461.1790993066.diff (7 KB)

Event Timeline