Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Use the ssh man page as a starting point for sshd_config' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Use the ssh man page as a starting point for sshd_config
Authored by: CarlRJ on Feb 20, '08 10:37:45AM

So, first off, either the call to popen should have "/usr/bin/" prepended to each of the command names (man, col, expand, sed), or whatever python magic necessary should be done to prepend /usr/bin to the path to ensure that the script actually runs the expected programs (I have a front-end to man in my ~/bin directory which got run instead of /usr/bin/man).

Second (after working around the above problem)... the output doesn't make a lot of sense to me. I end up with parts of the man page copied into the output file (second command line arg) as comments, but the interesting part (all the tweaks I've made to sshd_config) all go to stdout (apparently from the "print line" at the end of the "edit man page to insert option values" section). Surely you wanted to interpolate those into the output file...?

For what it's worth, this is running on a Tiger system.



[ Reply to This | # ]
Use the ssh man page as a starting point for sshd_config
Authored by: cva on Feb 20, '08 05:57:56PM

I had the same problem. Then I realized that for some reason all of the \'s were missing.

Here's the diff FWIW:

cva:~ $ diff sshd_config_py.txt sshd_config.py
50c50
< pat = r'^(# [A-Z]+[a-z][a-zA-Z]*)s{2,}(S.*)$'
---
> pat = r'^(# [A-Z]+[a-z][a-zA-Z]*)\s{2,}(\S.*)$'
73c73
< pat = r'^(#)?([A-Z][a-z][a-zA-Z]+)s+(.*)$'
---
> pat = r'^(#)?([A-Z][a-z][a-zA-Z]+)\s+(.*)$'
82c82
< new[index] = '# %s %sn' % (option, value)
---
> new[index] = '# %s %s\n' % (option, value)
84c84
< new[index] += 'n%s %snn' % (option, value)
---
> new[index] += '\n%s %s\n\n' % (option, value)



[ Reply to This | # ]
Use the ssh man page as a starting point for sshd_config
Authored by: cva on Feb 20, '08 06:01:45PM

oops, looks like I missed a couple. Here's the real diff ;)

cva:~ $ diff sshd_config_py.txt sshd_config.py
50c50
< pat = r'^(# [A-Z]+[a-z][a-zA-Z]*)s{2,}(S.*)$'
---
> pat = r'^(# [A-Z]+[a-z][a-zA-Z]*)\s{2,}(\S.*)$'
57,58c57,58
< new.append("%sn" % option)
< new.append("# %sn" % text)
---
> new.append("%s\n" % option)
> new.append("# %s\n" % text)
73c73
< pat = r'^(#)?([A-Z][a-z][a-zA-Z]+)s+(.*)$'
---
> pat = r'^(#)?([A-Z][a-z][a-zA-Z]+)\s+(.*)$'
82c82
< new[index] = '# %s %sn' % (option, value)
---
> new[index] = '# %s %s\n' % (option, value)
84c84
< new[index] += 'n%s %snn' % (option, value)
---
> new[index] += '\n%s %s\n\n' % (option, value)



[ Reply to This | # ]