LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-16-2017, 05:23 AM   #1
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,307
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
Changing mode / group of WSGIServer socket in Python 2.7.x


I am quite unfamiliar with Python. Using Python 2.7.x, I have the following line which creates a socket:

Code:
WSGIServer(application,bindAddress="/var/www/run/sockets/moinmoin.sock").run()
I have looked at the online documentation for WSGIServer 1.3 but it does not seem to have its own way of changing the group and mode of the sockets it creates.

How can I change the group + permissions of a socket at the moment it is created? Or, failing that, how can those changes be done from within Python in any other way?
 
Old 07-16-2017, 05:40 AM   #2
audriusk
Member
 
Registered: Mar 2011
Location: Klaipėda, Lithuania
Distribution: Slackware
Posts: 360

Rep: Reputation: 199Reputation: 199
Where is that line of code you pasted coming from? I'm asking because WSGIServer class from the package that you linked to doesn't support bindAddress keyword argument, here's what I get when I try to run simple WSGI app using it:
Code:
Traceback (most recent call last):
  File "/tmp/foo.py", line 9, in <module>
    WSGIServer(application, bindAddress='/tmp/moinmoin.sock').run()
TypeError: __init__() got an unexpected keyword argument 'bindAddress'
This can only mean that WSGIServer class in your code is unrelated to the package you linked to and comes from another codebase.
 
Old 07-16-2017, 05:44 AM   #3
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,307

Original Poster
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
It's coming from the script moin.fcgi in moinmoin-1.9.8

The original line stood like this:

Code:
WSGIServer(application).run()
However, what I have in the original post works (for me at least) to specify the name of the socket to be used.
 
Old 07-16-2017, 06:22 AM   #4
audriusk
Member
 
Registered: Mar 2011
Location: Klaipėda, Lithuania
Distribution: Slackware
Posts: 360

Rep: Reputation: 199Reputation: 199
MoinMoin uses flup library for FCGI, its WSGIServer class accepts umask keyword argument, so you can use that to set required permissions:
Code:
# Prepend number with zero to treat it as an octal.
WSGIServer(application, bindAddress="/var/www/run/sockets/moinmoin.sock", umask=0077).run()
Regarding socket group, you could use os.chown() for that, but it must be called before WSGIServer().run() is called, because run() method won't terminate (it will listen to the socket forever unless interrupted) and the socket file itself is not created before run() method is called, so it's a bit of a chicken-and-egg problem. Of course, you could change socket group from another process.
 
1 members found this post helpful.
  


Reply

Tags
python, wsgiserver



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing Group user to anther group vidyasagar6 Linux - Server 2 12-04-2012 07:06 PM
python: socket with makefile Ephracis Programming 0 02-25-2009 08:57 AM
Python socket: does not recieve anything Hewson Programming 4 03-28-2008 12:53 PM
Changing FC6 a text mode installation to graphics mode. wbuik Fedora 2 06-19-2007 08:38 PM
LXer: Move to python 2.4 / Changing the packaging style for python packages LXer Syndicated Linux News 0 06-13-2006 07:54 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration