OpenBSD Support
Do you have any plans to add OpenBSD support?
I don't see any reason why Gate One wouldn't run on OpenBSD. Are you having trouble? As long as you have Python 2.6+ and Tornado installed it should work.
I have the following packages installed:
python-2.7.3p0 py-tornado-2.3
Like the Mac, OpenBSD doesn't have a /proc directory so I changed the string of line 42 of utils.py from Darwin to OpenBSD. I didn't look at changing the _macos functions yet.
The next error was due to no /dev/ptmx. I modified line 3065 of gateone.py to look for /dev/ptm instead. This deals with a lower level of the OS than I am familiar with, so I don't know if this was the right change to make.
After these two changes it starts up, but when I try to connect to the local SSH server I get the following error:
Got Exception: [Errno 14] Bad address
Traceback (most recent call last):
File "/opt/gateone/plugins/ssh/scripts/ssh_connect.py", line 771, in
Wow, this is going to be far more complicated than I thought. I'll see if I can get an OpenBSD VM up and running to see if I can get it to work. No promises though... That "Bad address" thing looks like a serious hurdle.
Hi,
I also have this issue when trying gateone on NetBSD 6.0.1, details:
. tornado-2.4.1 . Python 2.7.3
Host/IP or ssh:// URL [localhost]: Port [22]: User: imil Connecting to ssh://imil@localhost:22
Got Exception: [Errno 14] Bad address
Traceback (most recent call last):
File "/usr/pkg/gateone/plugins/ssh/scripts/ssh_connect.py", line 771, in
Maybe a hint, it seems there are some oddities with IPv6, nevertheless, I'm actually testing (or trying) with IPv4 hosts/addresses. Any hint ? That project really is great, I'd love to promote it !
ok, passing an empty list to execvpe() is what is failing, now this works:
os.execvpe(script_path, [''], env)
@iMilnb: Thanks for figuring that out! That fix (['']) will be in the next commit.
I just pushed a commit that should (hopefully) fix OpenBSD support. Can someone please test?
@iMilnb's fix worked for me on OpenBSD 5.2. Here are all the changes I made to the 1.1 release to get it working:
diff -rup gateone.orig/gateone.py gateone/gateone.py
--- gateone.orig/gateone.py Thu Nov 1 18:53:52 2012
+++ gateone/gateone.py Sun Feb 3 18:03:54 2013
@@ -316,6 +316,7 @@ def _(string):
return string.encode('UTF-8')
# Globals
+OPENBSD = os.uname()[0] == 'OpenBSD'
SESSIONS = {} # We store the crux of most session info here
CMD = None # Will be overwritten by options.command
TIMEOUT = timedelta(days=5) # Gets overridden by options.session_timeout
@@ -3062,7 +3063,10 @@ def main():
# First we have to make sure there's at least one pty present
tempfd1, tempfd2 = pty.openpty()
# Now check the owning group (doesn't matter which one so we use 0)
- tty_gid = os.stat('/dev/ptmx').st_gid
+ if OPENBSD:
+ tty_gid = os.stat('/dev/ptm').st_gid
+ else:
+ tty_gid = os.stat('/dev/ptmx').st_gid
# Close our temmporary pty/fds so we're not wasting them
os.close(tempfd1)
os.close(tempfd2)
diff -rup gateone.orig/plugins/ssh/scripts/ssh_connect.py gateone/plugins/ssh/scripts/ssh_connect.py
--- gateone.orig/plugins/ssh/scripts/ssh_connect.py Thu Nov 1 18:53:52 2012
+++ gateone/plugins/ssh/scripts/ssh_connect.py Sat Feb 2 23:37:50 2013
@@ -397,7 +397,7 @@ def openssh_connect(
os.setsid() # This is the key
# Execute then immediately quit so we don't use up any more memory than we
# need.
- os.execvpe(script_path, [], env)
+ os.execvpe(script_path, [''], env)
os._exit(0)
def telnet_connect(user, host, port=23, env=None):
diff -rup gateone.orig/utils.py gateone/utils.py
--- gateone.orig/utils.py Thu Nov 1 18:53:52 2012
+++ gateone/utils.py Sun Feb 3 18:05:14 2013
@@ -40,6 +40,7 @@ from tornado.escape import to_unicode, utf8
# Globals
MACOS = os.uname()[0] == 'Darwin'
+OPENBSD = os.uname()[0] == 'OpenBSD'
# This matches JUST the PIDs from the output of the pstree command
#RE_PSTREE = re.compile(r'\(([0-9]*)\)')
# Matches Gate One's special optional escape sequence (ssh plugin only)
@@ -559,21 +560,26 @@ def kill_dtached_proc(session, term):
except OSError:
pass # Process already died. Not a problem.
-def kill_dtached_proc_macos(session, term):
+def kill_dtached_proc_bsd(session, term):
"""
A Mac OS-specific implementation of `kill_dtached_proc` since Macs don't
have /proc. Seems simpler than :func:`kill_dtached_proc` but actually
having to call a subprocess is less efficient (due to the sophisticated
signal handling required by :func:`shell_command`).
"""
- logging.debug('kill_dtached_proc_macos(%s, %s)' % (session, term))
+ logging.debug('kill_dtached_proc_bsd(%s, %s)' % (session, term))
ps = which('ps')
+ if MACOS:
+ psopts = "-ef"
+ elif OPENBSD:
+ psopts = "-aux"
cmd = (
- "%s -ef | "
+ "%s %s | "
"grep %s/dtach_%s | " # Limit to those matching our session/term combo
"grep -v grep | " # Get rid of grep from the results (if present)
- "awk '{print $2}' " % (ps, session, term) # Just the PID please
+ "awk '{print $2}' " % (ps, psopts, session, term) # Just the PID please
)
+ logging.debug('kill cmd: %s' % (cmd))
exitstatus, output = shell_command(cmd)
for line in output.splitlines():
pid_to_kill = line.strip() # Get rid of trailing newline
@@ -621,7 +627,7 @@ def killall(session_dir):
except OSError:
pass # PID is already dead--great
-def killall_macos(session_dir):
+def killall_bsd(session_dir):
"""
A Mac OS X-specific version of `killall` since Macs don't have /proc.
"""
@@ -629,13 +635,18 @@ def killall_macos(session_dir):
# don't have to enumerate the process table at all.
sessions = os.listdir(session_dir)
for session in sessions:
+ if MACOS:
+ psopts = "-ef"
+ elif OPENBSD:
+ psopts = "-aux"
cmd = (
- "ps -ef | "
+ "ps %s | "
"grep %s | " # Limit to those matching the session
"grep -v grep | " # Get rid of grep from the results (if present)
"awk '{print $2}' | " # Just the PID please
- "xargs kill" % session # Kill em'
+ "xargs kill" % (psopts, session) # Kill em'
)
+ logging.debug(cmd)
exitstatus, output = shell_command(cmd)
def create_plugin_links(static_dir, templates_dir, plugin_dir):
@@ -1176,8 +1187,11 @@ def drop_privileges(uid='nobody', gid='nogroup', supl_
# Misc
_ = get_translation()
if MACOS: # Apply mac-specific stuff
- kill_dtached_proc = kill_dtached_proc_macos
- killall = killall_macos
+ kill_dtached_proc = kill_dtached_proc_bsd
+ killall = killall_bsd
+if OPENBSD: # Apply mac-specific stuff
+ kill_dtached_proc = kill_dtached_proc_bsd
+ killall = killall_bsd
# Used in case bell.ogg can't be found or can't be converted into a data URI
Thanks for posting that diff! I'll be merging those changes in soon (in the middle of some changes at the moment and I'm about to hit the sack =). Expect them to be pushed sometime tomorrow.
I just pushed a commit a little while ago that incorporated all of the changes in the diff listed above. Please pull the latest code and let me know if it works without modification. Thanks!
Just tried the latest and I get the following:
Traceback (most recent call last):
File "gateone.py", line 295, in <module>
from auth import NullAuthHandler, KerberosAuthHandler, GoogleAuthHandler
File "/opt/gateone/auth.py", line 618, in <module>
from authpam import PAMAuthMixin
File "/opt/gateone/authpam.py", line 27, in <module>
import gopam
File "/opt/gateone/gopam.py", line 95, in <module>
PAM_START = LIBPAM.pam_start
File "/usr/local/lib/python2.7/ctypes/__init__.py", line 378, in __getattr__
func = self.__getitem__(name)
File "/usr/local/lib/python2.7/ctypes/__init__.py", line 383, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: Unable to resolve symbol
I haven't dug into it, but I think this is probably caused by PAM not being available on OpenBSD. OpenBSD uses bsd_auth instead of PAM.
I just pushed a commit that should fix the PAM problem. Please pull the latest code and let me know if it works.
Just tried the latest and I get the following:
[I 130217 23:13:19 gateone:2894] Gate One settings are incomplete. A new settings/10server.conf will be generated.
Traceback (most recent call last):
File "gateone.py", line 3308, in <module>
main()
File "gateone.py", line 2933, in main
s.write("// This is Gate One's main settings file.\n")
TypeError: must be unicode, not str
Doh, definitely broken. I'll fix it.
I just pushed a commit that should fix this and several other Python 2/3 compatibility issues. Please grab the latest code and let me know how it goes. Thanks!
I had to change line 3282 in gateone.py to the following to get it to run:
ptm = '/dev/ptm' if os.path.exists('/dev/ptm') else '/dev/ptmx'
After getting the service running the rendering of the terminal is off. It is very tall and narrow:

Also got this error:
[E 130219 23:00:43 gateone:1109] Error/Unknown WebSocket action, terminal:set_terminal: set_terminal() takes exactly 2 arguments (1 given) (/opt/gateone/auth.py line 180)
That ptm thing is definitely a bug. I'll fix it (quick & easy). Can you run gateone.py with '--logging=debug' and paste that output here? Just make sure to remove any lines like this:
[D 130220 10:33:56 gateone:1072] message: u'{"c":"\\u001b[A"}'
[D 130220 10:33:56 app_terminal:1281] char_handler(u'\x1b[A', None)
...because they can reveal things like passwords. Since it failed to load so early in the process you probably don't have to worry about that but having a little warning about it is pertinent.
Here's what I'm looking for: The 'message' line that calls "terminal:set_terminal" (and the surrounding log lines). It is probably sending a bad message like, {"terminal:set_terminal", "null"} or "NaN" which would indicate a problem with the client figuring out what the current terminal number is.
Pull the latest code please... I believe this might have been related to an auth bug I fixed this morning.
Here's what I get with the latest and debug logging:
[D 130220 21:51:56 gateone:1073] message: u'{"terminal:set_terminal":null}'
[E 130220 21:51:56 gateone:1108] Error/Unknown WebSocket action, terminal:set_terminal: set_terminal() takes exactly 2 arguments (1 given) (/opt/gateone/auth.py line 180)
Traceback (most recent call last):
File "gateone.py", line 1098, in on_message
self.actions[key]()
File "/opt/gateone/auth.py", line 180, in wrapped_f
return f(self, *args, **kwargs)
TypeError: set_terminal() takes exactly 2 arguments (1 given)
[D 130220 21:51:56 gateone:1073] message: u'{"go:file_request":"term_colors.css"}'
[D 130220 21:51:56 gateone:1073] message: u'{"terminal:get_terminals":null}'
[D 130220 21:51:56 gateone:1073] message: u'{"terminal:set_terminal":null}'
[E 130220 21:51:56 gateone:1108] Error/Unknown WebSocket action, terminal:set_terminal: set_terminal() takes exactly 2 arguments (1 given) (/opt/gateone/auth.py line 180)
Traceback (most recent call last):
File "gateone.py", line 1098, in on_message
self.actions[key]()
File "/opt/gateone/auth.py", line 180, in wrapped_f
return f(self, *args, **kwargs)
TypeError: set_terminal() takes exactly 2 arguments (1 given)
The page is looking a bit better, but still not quite right:

Can you paste the output from your JS console with the latest code? I added a check to the setTerminal() function that may offer clues as to what is going on.