Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set custom rsub-port via logged in user #48

Closed
wants to merge 1 commit into from

Conversation

hertell
Copy link

@hertell hertell commented Apr 5, 2016

When using rsub in multiuser-environmets. setting a custom port via
environment-variables won’t work if you use sudo. This patch let’s you
set a .rsub config-file in your homedir witht the following content:

port=52697

the .rsub-file can be eg. distributed by puppet for making things
easier.

The same port should then be set in your .ssh/config file as:
Host *
RemoteForward 52697 127.0.0.1:52698

When using rsub in multiuser-environmets. setting a custom port via
environment-variables won’t work if you use sudo. This patch let’s you
set a .rsub config-file in your homedir witht the following content:

port=52697

the .rsub-file can be eg. distributed by puppet for making things
easier.

The same port should then be set in your .ssh/config file as:
Host *
RemoteForward 52697 127.0.0.1:52698
@aurora
Copy link
Owner

aurora commented Apr 5, 2016

Is it important, that the config-file is named .rsub? Because rmate already supports loading of settings from config file, see: https://github.com/aurora/rmate#default-parameter-configuration

Also your code is not portable: there is no getent on Mac OS X, is it a Linux-specific command?

@aurora
Copy link
Owner

aurora commented Apr 8, 2016

I close this PR, because config files are already supported.

@aurora aurora closed this Apr 8, 2016
@hertell
Copy link
Author

hertell commented Apr 8, 2016

Hi,
Yes, for the config-file part it's ok to close. The other logic to figure out the originally logged in user is still something that would be good to have. Doing a sudo when editing the file will loose the config-file for the particular user.. Unfortunately i did not figure out what i could use instead of getent in OSX.

@aurora
Copy link
Owner

aurora commented Apr 8, 2016

Ah, i think i misunderstood the issue ... however i still cannot merge the patch, we need a more generic way to do this. I'll have a look if i can come up with some other solution.

@aurora aurora reopened this Apr 8, 2016
@aurora
Copy link
Owner

aurora commented Apr 14, 2016

@hertell I think i have a portable solution for this, i've just pushed the change. Would be happy if you can try it and provide feedback for it. I am using $SUDO_USER which should always be set by sudo and fall back to $LOGNAME, which is POSIX conform. Neither solution will work however if you specify a user for sudo -u ... that cannot access the config-file due to missing permissions, but i think this case should be very rare ...

@hertell
Copy link
Author

hertell commented Apr 14, 2016

This works great :-) Normally i edit config-files etc as root, so the need to be someone else is more or less zero. Thanks! :-)

@aurora
Copy link
Owner

aurora commented Apr 14, 2016

@hertell Fine! I never ran into this issue myself, but i think it's a very useful addition, so: thanks very much for filing this issue.

@aurora aurora closed this Apr 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants