[issue19478] Add ability to prefix posix semaphore names created by multiprocessing module

2020-12-01 Thread Irit Katriel


Irit Katriel  added the comment:

Fixed in 3.4, won't be fixed in 2.7.

--
nosy: +iritkatriel
resolution:  -> fixed
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19478] Add ability to prefix posix semaphore names created by multiprocessing module

2013-11-02 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 1b5506fc6a50 by Richard Oudkerk in branch 'default':
Issue #19478: Make choice of semaphore prefix more flexible.
http://hg.python.org/cpython/rev/1b5506fc6a50

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19478] Add ability to prefix posix semaphore names created by multiprocessing module

2013-11-01 Thread Marc Liyanage

Marc Liyanage added the comment:

Great to hear that this is mostly supported in 3.4. I would definitely like to 
see the small change added that lets me insert a string before the leading 
slash.

It would also be helpful to have it in Python 2.7 as well.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19478] Add ability to prefix posix semaphore names created by multiprocessing module

2013-11-01 Thread Richard Oudkerk

Richard Oudkerk added the comment:

Although it is undocumented, in python 3.4 you can control the prefix used by 
doing

multiprocessing.current_process()._config['semprefix'] = 'myprefix'

in the main process at the beginning of the program.

Unfortunately, this will make the full prefix '/myprefix', so it will still 
start with '/'.  Changing this for 3.4 would be easy, but I don't know if it is 
a good idea to change 2.7.

Note that your suggested change can cause a buffer overflow.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19478] Add ability to prefix posix semaphore names created by multiprocessing module

2013-11-01 Thread Marc Liyanage

Marc Liyanage added the comment:

>From the description above, I would guess shared memory names as well, but I 
>don't know which parts of the Python library use those, if any.

In general, it's easy to adjust the Python code to deal with the restriction of 
the sandboxed environment (mostly file-system releated), and I haven't 
encountered any other issues that require changes to the C code.

The name generation for semaphores is one exception where it's not possible to 
work around it in pure Python code.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19478] Add ability to prefix posix semaphore names created by multiprocessing module

2013-11-01 Thread Ned Deily

Ned Deily added the comment:

I don't have any experience using OS X sandboxing yet but I wonder whether 
there are other instances of semaphores or other resources used elsewhere in 
the standard library that would benefit from a common solution.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19478] Add ability to prefix posix semaphore names created by multiprocessing module

2013-11-01 Thread Ned Deily

Changes by Ned Deily :


--
nosy: +ned.deily, ronaldoussoren

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19478] Add ability to prefix posix semaphore names created by multiprocessing module

2013-11-01 Thread Marc Liyanage

Marc Liyanage added the comment:

I'm thinking something along the lines of

char *env = Py_GETENV("PYTHONSEMAPHOREPREFIX");
if (env && *env != '\0') {
PyOS_snprintf(buffer, sizeof(buffer), "%s/mp%ld-%d", env, 
(long)getpid(), counter++);
} else {
PyOS_snprintf(buffer, sizeof(buffer), "/mp%ld-%d", (long)getpid(), 
counter++);
}

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19478] Add ability to prefix posix semaphore names created by multiprocessing module

2013-11-01 Thread Marc Liyanage

Marc Liyanage added the comment:

"leasing" -> "leading"

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19478] Add ability to prefix posix semaphore names created by multiprocessing module

2013-11-01 Thread Marc Liyanage

New submission from Marc Liyanage:

I'm running Python 2.7 in a sandboxed OS X app. There are restrictions on the 
naming of POSIX semaphores when running in the sandbox. Specifically, there is 
a mandatory prefix.

I would like the ability to inject this prefix into the part of the 
multiprocessing module that creates the semaphore, perhaps by way of an 
environment variable.

I see that this is how the module generates the semaphore name:

PyOS_snprintf(buffer, sizeof(buffer), "/mp%ld-%d", (long)getpid(), 
counter++);

Apple's documentation about the restrictions are here:

https://developer.apple.com/library/mac/documentation/security/conceptual/AppSandboxDesignGuide/AppSandboxInDepth/AppSandboxInDepth.html#//apple_ref/doc/uid/TP40011183-CH3-SW24

The relevant part:

"POSIX semaphores and shared memory names must begin with the application group 
identifier, followed by a slash (/), followed by a name of your choosing."

So if I could inject that string before the leasing slash, I could make this 
work.

--
components: Extension Modules
messages: 201936
nosy: Marc.Liyanage, jnoller, sbt
priority: normal
severity: normal
status: open
title: Add ability to prefix posix semaphore names created by multiprocessing 
module
type: enhancement
versions: Python 2.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com