Hi folks,
I am unable to solve the following problem, which should not be new,
but I cannot find an appropriate solution anywhere:
One python process ("daemon") waits for messages. Another python
program ("client"), which is NOT forked off the daemon (but is on the
same Linux machine), sends that message to the daemon.
This of course can be nicely done with Unix domain sockets (AF_UNIX),
but additionally I want the daemon to know the process or user id of
the client. The client could of course include this info in the
message, but then it also could fake it, which I want to prevent.
Therefore it must come somewhere from the kernel.
My hope was that the address returned from socket.recvfrom would help,
but with python 2.3.3 on Debian, the returned address is always None
(a bit odd, python 2.1? at least returned a (meaningless?)
int,emptystring-tupel). I know that Unix domain sockets can return
those info (in structure called credentials), but obviously python
does not handle them?
So, for my question: What are my options? I cannot believe I am the
first with this problem. Preferable, only standard python packages
should be used.
Thanks in advance, Fossie 5 3761
On Mon, Feb 09, 2004 at 03:39:34PM -0800, Fossie wrote: So, for my question: What are my options? I cannot believe I am the first with this problem. Preferable, only standard python packages should be used.
My Linux manpage for unix(7) indicates that SCM_RIGHTS is not portable.
(I am not 100% sure this is what you're talking about, because it's
nothing I've ever done before) In any case, I looked but didn't find an
implementation of the needed sendmsg(2) .. I found only this: https://sourceforge.net/tracker/?fun...&group_id=5470
Wrapping sendmsg with pyrex, ctypes, or even with a new C module might
be a good first project in extending Python. If you do your work in
the form of a patch to Python, I suspect it would easily gain approval.
Once you'd tested your patch and added tests for it, you'd submit the
patch to the bug I mentioned above or as a new item in the Patch area.
best of luck,
Jeff go**@fossie.net (Fossie) writes: So, for my question: What are my options? I cannot believe I am the first with this problem. Preferable, only standard python packages should be used.
Unfortunately that capability is missing from the sockets package. I
have a bug in sourceforge about it and was invited to contribute a
patch but haven't gotten around to it. Maybe you'd like to take a turn?
Jeff Epler <je****@unpythonic.net> writes: On Mon, Feb 09, 2004 at 03:39:34PM -0800, Fossie wrote: So, for my question: What are my options? I cannot believe I am the first with this problem. Preferable, only standard python packages should be used.
My Linux manpage for unix(7) indicates that SCM_RIGHTS is not portable. (I am not 100% sure this is what you're talking about, because it's nothing I've ever done before) In any case, I looked but didn't find an implementation of the needed sendmsg(2) .. I found only this: https://sourceforge.net/tracker/?fun...&group_id=5470
Yes, that is the right way to do it, with a patch as suggested in that
bug report.
On Mon, Feb 09, 2004 at 07:22:30PM -0600, Jeff Epler wrote: On Mon, Feb 09, 2004 at 03:39:34PM -0800, Fossie wrote: So, for my question: What are my options? I cannot believe I am the first with this problem. Preferable, only standard python packages should be used.
My Linux manpage for unix(7) indicates that SCM_RIGHTS is not portable. (I am not 100% sure this is what you're talking about, because it's nothing I've ever done before) In any case, I looked but didn't find an implementation of the needed sendmsg(2) .. I found only this: https://sourceforge.net/tracker/?fun...&group_id=5470 Wrapping sendmsg with pyrex, ctypes, or even with a new C module might be a good first project in extending Python. If you do your work in the form of a patch to Python, I suspect it would easily gain approval. Once you'd tested your patch and added tests for it, you'd submit the patch to the bug I mentioned above or as a new item in the Patch area.
There's a wrapper for sendmsg(2) in Twisted's sandbox: http://cvs.twistedmatrix.com/cvs/sandbox/pahan/sendmsg/
This may be a good start. It'd be great to have this in the stdlib.
Jp
Thanks to all for your answers!
I had a look at the sendmsg wrapper from twistedmatrix, but without
any documentation (not even some short comments) it is a bit hard to
use. It seems to support file descriptor passing (SCM_RIGHTS) but
would need some extra coding to support the SCM_CREDENTIAL structure,
which seems to be system dependent anyway, as stated by Jeff (see unix
man page, I had another impression from a short glimpse into Richard
Stevens' networking books..)
All in all, since I am neither a linux nor a network/ipc nor a c
expert [thats why I am using Python ;) ], I was looking more for a
ready-to-use thing.
Therefore, I had a closer look at the system V shared memory (and
semaphore) module (shm), which I found at: http://gigue.peabody.jhu.edu/~mdboom...ource/shm.html
Its another kind of interprocess communication than I originally
wanted, but does what I need (giving uid/pid) without any
modification. It should be portable (ok, maybe not to windows) and is
good documented (at least sufficiently for me). This looks like a
candidate (useful, portable, documented) for the standard python
library to me..
Thanks again, Fossie This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: afalanga |
last post by:
Hi,
I seem to be unable to connect to my PostgreSQL database over UNIX
domain sockets, i.e. pg_connect("dbname=mydb");
No matter what I do to the pg_hba.conf file, or anything else, PHP...
|
by: Virgil Green |
last post by:
An associate has asked me to take a look a problem he's having with starting
mysql. I thought I'd give it a shot to learn some more about mySQL before
having him turn it over to someone more...
|
by: Alex Martinoff |
last post by:
Using the org.postgresql.Driver JDBC driver is it possible to connect
to Postgres using a unix domain socket instead of a TCP socket (so you
don't have to start the postmaster with -i)? Using a TCP...
|
by: David |
last post by:
Hi,
Ive been trying to work this out for the past 2 days now and im not
getting anywhere fast.
The problem i have is that i am using Asynchronous sockets to create a
Socket Client library....
|
by: Laxmikant Rashinkar |
last post by:
Is there any way to use a C# socket in promiscuous mode?
Any sample code that shows how this is done?
any assistance is much appreciated!
thanks
LK
| |
by: Alpha |
last post by:
I was told that Unix API can only be called using C++, ATL and MFC. However,
I was also told that C# can do that through Pinvoke to a DLL that interfaces
with the Unix API. Can someone direct me...
|
by: Tomas |
last post by:
Hey all,
I've worked with DB2 for a long time, but it looks like Windows and
user management is getting the better of me.
I'm trying to set up a DB2 9 Express-C system. It's installed and...
|
by: Tom Gur |
last post by:
Hi,
It's seems that csh and tcsh acts a bit different when handling
special characters in quotes.
i.e: if i'll supply my program with the following arguments: -winpath
"c:\\temp\\"
tcsh will...
|
by: Chris |
last post by:
Hi,
I am using PHP persistent sockets and have a problem with them. The
problem is that PHP only sends the data when the socket is closed. In
the code example below the counterparty process...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |