Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
sshuttle
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pub
sshuttle
Commits
5bf6e406
Commit
5bf6e406
authored
Jan 01, 2011
by
Avery Pennarun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
daemonization: make sure the firewall subproc sends to syslog too.
parent
8a5ae1a4
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
24 deletions
+33
-24
client.py
client.py
+10
-21
firewall.py
firewall.py
+6
-2
main.py
main.py
+1
-1
ssyslog.py
ssyslog.py
+16
-0
No files found.
client.py
View file @
5bf6e406
import
struct
,
socket
,
select
,
errno
,
re
,
signal
import
compat.ssubprocess
as
ssubprocess
import
helpers
,
ssnet
,
ssh
import
helpers
,
ssnet
,
ssh
,
ssyslog
from
ssnet
import
SockWrapper
,
Handler
,
Proxy
,
Mux
,
MuxWrapper
from
helpers
import
*
_loggerp
=
None
def
start_syslog
():
global
_loggerp
_loggerp
=
ssubprocess
.
Popen
([
'logger'
,
'-p'
,
'daemon.info'
,
'-t'
,
'sshuttle'
],
stdin
=
ssubprocess
.
PIPE
)
def
stderr_to_syslog
():
sys
.
stdout
.
flush
()
sys
.
stderr
.
flush
()
os
.
dup2
(
_loggerp
.
stdin
.
fileno
(),
1
)
os
.
dup2
(
_loggerp
.
stdin
.
fileno
(),
2
)
def
got_signal
(
signum
,
frame
):
log
(
'exiting on signal
%
d
\n
'
%
signum
)
sys
.
exit
(
1
)
...
...
@@ -77,10 +62,10 @@ def daemonize():
si
=
open
(
'/dev/null'
,
'r+'
)
os
.
dup2
(
si
.
fileno
(),
0
)
os
.
dup2
(
si
.
fileno
(),
1
)
si
.
close
()
stderr_to_syslog
()
log
(
'daemonizing (
%
s).
\n
'
%
_pidname
)
ssyslog
.
stderr_to_syslog
()
def
daemon_cleanup
():
...
...
@@ -118,6 +103,8 @@ class FirewallClient:
argvbase
=
([
sys
.
argv
[
0
]]
+
[
'-v'
]
*
(
helpers
.
verbose
or
0
)
+
[
'--firewall'
,
str
(
port
)])
if
ssyslog
.
_p
:
argvbase
+=
[
'--syslog'
]
argv_tries
=
[
[
'sudo'
,
'-p'
,
'[local sudo] Password: '
]
+
argvbase
,
[
'su'
,
'-c'
,
' '
.
join
(
argvbase
)],
...
...
@@ -197,7 +184,7 @@ def _main(listener, fw, ssh_cmd, remotename, python, seed_hosts, auto_nets,
try
:
(
serverproc
,
serversock
)
=
ssh
.
connect
(
ssh_cmd
,
remotename
,
python
,
stderr
=
_logger
p
.
stdin
)
stderr
=
ssyslog
.
_p
and
ssyslog
.
_
p
.
stdin
)
except
socket
.
error
,
e
:
if
e
.
errno
==
errno
.
EPIPE
:
raise
Fatal
(
"failed to establish ssh session"
)
...
...
@@ -219,8 +206,10 @@ def _main(listener, fw, ssh_cmd, remotename, python, seed_hosts, auto_nets,
debug1
(
'connected.
\n
'
)
if
daemon
:
daemonize
()
log
(
'daemonizing (
%
s).
\n
'
%
_pidname
)
elif
syslog
:
stderr_to_syslog
()
debug1
(
'switching to syslog.
\n
'
)
ssyslog
.
stderr_to_syslog
()
def
onroutes
(
routestr
):
if
auto_nets
:
...
...
@@ -279,7 +268,7 @@ def _main(listener, fw, ssh_cmd, remotename, python, seed_hosts, auto_nets,
def
main
(
listenip
,
ssh_cmd
,
remotename
,
python
,
seed_hosts
,
auto_nets
,
subnets_include
,
subnets_exclude
,
syslog
,
daemon
,
pidfile
):
if
syslog
:
start_syslog
()
s
syslog
.
s
tart_syslog
()
if
daemon
:
try
:
check_daemon
(
pidfile
)
...
...
firewall.py
View file @
5bf6e406
import
re
,
errno
import
compat.ssubprocess
as
ssubprocess
import
helpers
import
helpers
,
ssyslog
from
helpers
import
*
...
...
@@ -216,7 +216,7 @@ def restore_etc_hosts(port):
# exit. In case that fails, it's not the end of the world; future runs will
# supercede it in the transproxy list, at least, so the leftover rules
# are hopefully harmless.
def
main
(
port
):
def
main
(
port
,
syslog
):
assert
(
port
>
0
)
assert
(
port
<=
65535
)
...
...
@@ -235,6 +235,10 @@ def main(port):
# can read from it.
os
.
dup2
(
1
,
0
)
if
syslog
:
ssyslog
.
start_syslog
()
ssyslog
.
stderr_to_syslog
()
debug1
(
'firewall manager ready.
\n
'
)
sys
.
stdout
.
write
(
'READY
\n
'
)
sys
.
stdout
.
flush
()
...
...
main.py
View file @
5bf6e406
...
...
@@ -82,7 +82,7 @@ try:
elif
opt
.
firewall
:
if
len
(
extra
)
!=
1
:
o
.
fatal
(
'exactly one argument expected'
)
sys
.
exit
(
firewall
.
main
(
int
(
extra
[
0
])))
sys
.
exit
(
firewall
.
main
(
int
(
extra
[
0
])
,
opt
.
syslog
))
elif
opt
.
hostwatch
:
sys
.
exit
(
hostwatch
.
hw_main
(
extra
))
else
:
...
...
ssyslog.py
0 → 100644
View file @
5bf6e406
import
sys
,
os
from
compat
import
ssubprocess
_p
=
None
def
start_syslog
():
global
_p
_p
=
ssubprocess
.
Popen
([
'logger'
,
'-p'
,
'daemon.info'
,
'-t'
,
'sshuttle'
],
stdin
=
ssubprocess
.
PIPE
)
def
stderr_to_syslog
():
sys
.
stdout
.
flush
()
sys
.
stderr
.
flush
()
os
.
dup2
(
_p
.
stdin
.
fileno
(),
2
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment