Catching user switching and getting current active user from root on linux

S

Stefan Sonnenberg-Carstens

Am 22.12.2010 20:28, schrieb mpnordland:
ok, I'll give one more chance.
First, to pacify those who hate google groups: What is a good usenet
client?
second, How should I set up this proxy so that when a connection is
made, it request's authentication, and then log's the request, if
authentication is not gotten, how do I have it block (or firewall) the
request? Furthermore, I would like for the proxy to be squid. So all
of the nitty gritty should have to do with squid.
Just install Squid, enable user authentication and grant access only to
authenticated people.
Now, configure logrotated and tell to rotate logs every day/week/month
(your mileage will vary).
After rotating run a program such as webalizer to get stats (even on a
per user basis).
If you have smart guys under your users, set up a) a transparent proxy
intercepting http/https requests
or b) set up a iptables firewall with redirection to the squid port.

There are many, many, many how-to documents on the net describing
exactly what you want to do.

A first starting point could be
http://www.comfsm.fm/computing/squid/FAQ.html

And your problems are solved a long time ago:

http://www.faqs.org/docs/Linux-mini/TransparentProxy.html

And, the most important thing:

Check your local laws for this intention.
Some, like our german law, require these things to be under clear rules.

Cheers
 
S

Stefan Sonnenberg-Carstens

Sorry, this one is cross post.
I posted my question below some time ago to then jython ml, because this
hit me first with jython.
Anyway, time passed, problem not solved.

So, I'd like to know if some of you know where my error lies:


Hi all,

I've played around with some code-kata of mine from the past.
It's a toy http server:

import socket
import select
import sys
import time
srv = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
srv.setblocking(0)
srv.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,True) # Not sure if
this is needed. I only remember I've started once for some reason.
Commenting out does no change
if srv:
srv.bind(('',8080))
srv.setblocking(0)
srv.listen(5)
conns = [srv]
buffers = {}
while True:
reader,writer,failed = select.select(conns,conns,[],1)
if failed:
sys.exit(1)

if srv in reader:
client,(ip,port) = srv.accept()
client.setblocking(False)
conns += [client]
for r in reader:
if r is not srv:
data = r.recv(1024)
if not data:
conns.remove(r)
else:
if r in buffers:
buffers[r] += data
else:
buffers[r] = data
for w in writer:
if w is not srv:
if w in buffers and buffers[w][-2:] == '\r\n':
msg = 'HTTP/1.0 200 OK\r\nServer:
Jython/2.5\r\nContent-type: text/plain\r\n\r\nThe answer is: 42\r\n'
w.send(msg)
w.close() # THIS ONLY WORKS WHEN THIS LINE IS PRESENT
conns.remove(w) # AND THEN THIS IS MUST
buffers[w] = ''

But today I was asking myself why I should always close the socket, and
if wouldn't be more efficient if
I let it open.
To make a long story short: it does not work.
If I comment out the lines with the comment all upper case,
jython consumes one core in my laptop completely and ab.exe from apache
bails out after a while.

Changing send() to sendall() did not do the trick.

I've searched the web and did not find anything meaningful.

Perhaps someone here can switch the light on.
 
M

MRAB

Sorry, this one is cross post.
I posted my question below some time ago to then jython ml, because this
hit me first with jython.
Anyway, time passed, problem not solved.

So, I'd like to know if some of you know where my error lies:
[snip]
What happens if the conns list contains a writer that's ready?

The select function returns immediately with that writer in the writer
list. If it's not srv then nothing is done with it, so execution just
loops back to the select function with that writer still in the conns
list, and the select function then returns immediately with that writer
in the writer list again.

Infinite loop!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top