[Twisted-web] default file creation when using reactor.spawnProcess
Stephan
schenette at gmail.com
Mon Aug 29 11:20:26 EDT 2011
I still have the issue, but I've found out that it has something to do
with the fact that the twisted daemon isn't starting as the user I've
asked it to start as.
I know this because I dumped os.environ
145 for k,v in os.environ.items():
146 logging.debug("%s : %s", k, v)
147
148 subprocess = reactor.spawnProcess(self.pp, args[0], args,
env = os.environ, usePTY=1)
and this is what I see:
2011-08-29 08:07:58,263 DEBUG:USERNAME : root
2011-08-29 08:07:58,263 DEBUG:LANG : en_US.UTF-8
2011-08-29 08:07:58,263 DEBUG:SUDO_GID : 1000
2011-08-29 08:07:58,263 DEBUG:SHELL : /bin/bash
2011-08-29 08:07:58,263 DEBUG:SUDO_COMMAND : /etc/init.d/fireshark start
2011-08-29 08:07:58,263 DEBUG:PYTHONPATH :
2011-08-29 08:07:58,263 DEBUG:SUDO_UID : 1000
2011-08-29 08:07:58,263 DEBUG:TERM : xterm
2011-08-29 08:07:58,263 DEBUG:PATH :
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
2011-08-29 08:07:58,263 DEBUG:PWD : /usr/sbin
2011-08-29 08:07:58,263 DEBUG:LOGNAME : root
2011-08-29 08:07:58,264 DEBUG:USER : root
2011-08-29 08:07:58,264 DEBUG:HOME : /home/fireshark
2011-08-29 08:07:58,264 DEBUG:MAIL : /var/mail/stephan
2011-08-29 08:07:58,264 DEBUG:SUDO_USER : stephan
The daemon should be running as user fireshark, as that's what I have
it start as in the /etc/init.d/fireshark script (shown below) does
twisted follow a different convention for me to start the daemon as a
different user?
code from /etc/init.d/fireshark:
14 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
15 DAEMON=/usr/bin/twistd
16 RUNAS=fireshark
17 SERVICE_NAME=fireshark
18 SERVICE_PATH=/usr/sbin/fireshark.py
19 PIDFILE=/home/fireshark/fireshark.pid
20 LOGFILE=/home/fireshark/fireshark.log
21 DAEMON_OPTS="--pidfile=${PIDFILE} --logfile=${LOGFILE} --python
${SERVICE_PA TH}"
22
23 # Set python path so twistd can find the plugin
24 # See: http://twistedmatrix.com/projects/core/documentation/howto/plugin.htm
l
25 export PYTHONPATH=$SERVICE_DIR
26
27 if [ ! -x $DAEMON ]; then
28 echo "ERROR: Can't execute $DAEMON."
29 exit 1
30 fi
31
32 if [ ! -x $SERVICE_PATH ]; then
33 echo "ERROR: Can't execute: $SERVICE_PATH"
34 exit 1
35 fi
36
37 start_service() {
38 echo -n " * Starting $SERVICE_NAME... "
39 start-stop-daemon -Sq --chuid ${RUNAS} --group ${RUNAS} -p
$PIDFILE -x $DA EMON -- $DAEMON_OPTS
40 e=$?
41 if [ $e -eq 1 ]; then
42 echo "already running"
43 return
On Sun, Aug 28, 2011 at 11:50 PM, Stephan <schenette at gmail.com> wrote:
> I'm attempting to move over PERL code to python code using the twisted
> framework.
> so far a few hiccups but this mailing list has helped me quite figure it out.
>
> I have a few few more hurdles, one being that since moving from Perl's
>
> my $cmd = "xvfb-run --auto-servernum firefox -P $profile_id";
> $pid = open2($infh, $outfh, $cmd);
>
> to twisted's reactor.spawnProcess:
>
> subprocess = reactor.spawnProcess(self.pp, args[0], args, env =
> os.environ, usePTY=1, childFDs=None)
>
> when the xvfb/firefox processes create files they do so with root
> read/write, owner no permissions and group
> no permissions,
>
> using the the perl implementation the twisted daemon is run as a
> particular user and the file creation via firefox is rw rw rw which is
> what my goal is.
>
> What code would help those on the list willing to help? the daemon
> script code in init.d?
>
> Thanks in advance, so far this list has been golden!
> Stephan
>
More information about the Twisted-web
mailing list