I am writing a daemon process that reads data from the serial port /
dev/ttyS0. I am using pyserial & the method for setting up a daemon
described in "Chris' Python Page" ( http://homepage.hispeed.ch/py430/
python/) on an Ubuntu linux pc.
Everything works great EXCEPT...
in the daemon script, there are two lines to change the uid & gid that
the script runs as:
os.setegid(10)
os.seteuid(1000 )
If I comment these out, so that the daemon runs as root, then
everything works fine. I can also manually run the script that the
daemon process kicks off from my own id just fine.
If I put these back in and try to run the daemon, the script fails
when I try to connect to the serial port, with this error:
serial.serialut il.SerialExcept ion: Could not open port: [Errno 13]
Permission denied: '/dev/ttyS0'
In my debugging I have tried setting the uid to my own uid, and the
gid to a variety of different groups that I belong to. None of them
work.
I could certainly run the daemon as root, but I would rather not.
What really confuses me is that if I manually run the script as myself
(without using the daemon script), it connects fine, but when root
uses os.seteuid() to my uid, it fails.
What do I need to do to get this to work?
Many thanks,
Paul 3 4289
paul wrote:
If I put these back in and try to run the daemon, the script fails
when I try to connect to the serial port, with this error:
serial.serialut il.SerialExcept ion: Could not open port: [Errno 13]
Permission denied: '/dev/ttyS0'
Did you check the permissions on this file? Often you have to be
member of a "dialout" group or similar to get access.
Regards,
Björn
--
BOFH excuse #172:
pseudo-user on a pseudo-terminal
On Aug 26, 5:20 pm, Bjoern Schliessmann <usenet-
mail-0306.20.chr0n.. .@spamgourmet.c omwrote:
paul wrote:
If I put these back in and try to run the daemon, the script fails
when I try to connect to the serial port, with this error:
serial.serialut il.SerialExcept ion: Could not open port: [Errno 13]
Permission denied: '/dev/ttyS0'
Did you check the permissions on this file? Often you have to be
member of a "dialout" group or similar to get access.
Regards,
Björn
--
BOFH excuse #172:
pseudo-user on a pseudo-terminal
THANKS! That did it, but perhaps can you explain to me why...
Before I had posted this question first thing I did was to look at /
dev/ttyS0, and indeed the group is dialout (gid=20), so I tried a
couple of things:
1. checked my id to see if I was a member of dialout, and indeed I
am. So, I edited the daemon script to use my id and set the gid to
dialout (ie: os.setegid(20) & os.seteuid(1000 )) and it still failed.
2. made the id I really want to use (pydaemon, uid=110) a member of
dialout, and set the daemon script to use those (ie: os.setegid(20) &
os.seteuid(110) ) and it still failed...
After reading your comment, I went and did a chgrp to set the various
script file groups to dialout, and indeed it now works. What confuses
me is that if the script needed that group, why doesn't the setegid or
seteuid fail? Why does the script keep running okay until the
connect, and fail then?
Thanks!
Paul
In message <11************ **********@w3g2 000hsg.googlegr oups.com>, paul
wrote:
Before I had posted this question first thing I did was to look at /
dev/ttyS0, and indeed the group is dialout (gid=20)...
What are the full protections on the serial port? That is, can you post the
output of
ls -l /dev/ttyS0
please? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Joshua Beall |
last post by:
Hi All,
I am working on a mailing list program for a client, and I am wondering
what tbe hest way to deal with script timeouts is. I realize that I
could use set_time_limit() to increase the script timeout, but that
doesn't handle situations where 1) safe mode is on, or 2) Apache's
timeout is exceeded. These mailings go out to between 5000 and 10000
email addresses, so timeouts are a concern.
It seems to me that the best thing to do...
|
by: Rob Hunter |
last post by:
Hi all.
I want to run a Python daemon that manages a "to-do" queue. I want it
so that the daemon is always running, where its running consists of
looking at the queue to see if it has any jobs, and if it does, remove
the job from the queue and "do the job".
This all seems quite doable using the synchronized Queue.py module and
this page
(http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66012) which
|
by: Joe Wong |
last post by:
Hi,
I am developing two app on Windows, one is a GUI using wxPython and the other is like a daemon process. The GUI app will have a start/stop button to control the excution of the daemon. While I know how to use os.popen2() to start my daemon, I can't figure out a way to stop it 'nicely'... Is there anything that I can do?
Regards,
-- Wong
|
by: Joe Wong |
last post by:
Hi,
I am developing two app on Windows, one is a GUI using wxPython and the other is like a daemon process. The GUI app will have a start/stop button to control the excution of the daemon. While I know how to use os.popen2() to start my daemon, I can't figure out a way to stop it 'nicely'... Is there anything that I can do?
Regards,
-- Wong
|
by: Thomas Dybdahl Ahle |
last post by:
Hi, I'm writing a program, using popen4(gnuchess),
The problem is, that gnuchess keeps running after program exit.
I know about the atexit module, but in java, you could make a process a
daemon process, and it would only run as long as the real processes ran. I
think this is a better way to stop gnuchess, as you are 100% sure, that
it'll stop.
Can you do this with popen?
| |
by: Sakagami Hiroki |
last post by:
Hi,
What is the easiest way to create a daemon process in Python? Google
says I should call fork() and other system calls manually, but is
there no os.daemon() and the like?
Regards,
--
Sakagami Hiroki
|
by: Ben Finney |
last post by:
Howdy all,
For making a Python program calve off an independent daemon process of
itself, I found Carl J. Schroeder's recipe in the ASPN Python Cookbook.
<URL:http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/278731>
This is a thorough approach, and I'm cribbing a simpler process from
this example. One thing that strikes me is that the algorithm seems to
depend on running the program as the root user.
|
by: rahul |
last post by:
Hello all
I have written a chat server. It is invoked as follows -
$ ./server -start
It becomes a daemon. I want to implement a stop call-
$ ./server -stop
The approach I am following is to write the PID of the running server
in a flat file when server starts. When it needs to be stopped,
kill(SIGUSR1, pid) is sent to the server. The signal handler closes
all the open sockets and exits.
|
by: turtleRider |
last post by:
Hi,
I am new to Python and non-web programming. I am using pySerial in OSX 10.5.2 (Python 2.5) to access a bluetooth module that is mapped to a device file.
I can access the device with screen /dev/tty.BTdevice 115200 and I correctly get a stream of 3 digit numbers (data from a sensor). I wrote a Python script to read the numbers and print them.
My problem comes when I have a bug in my program or I don't close the serial object in the...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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 we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |