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

Use pam_env to properly setup system-wide env #2692

Closed
wants to merge 3 commits into from

Conversation

kirelagin
Copy link
Member

This is the proper fix of #2688.

@edolstra
Copy link
Member

Seems good to me. Maybe environment.systemVariables should be called environment.sessionVariables (since they're bound to PAM sessions, and environment.variables is also system-wide).

@@ -58,9 +58,6 @@ in
# Don't edit this file. Set the NixOS option ‘security.sudo.configFile’ instead.

# Environment variables to keep for root and %wheel.
Defaults:root,%wheel env_keep+=LOCALE_ARCHIVE
Defaults:root,%wheel env_keep+=NIX_CONF_DIR
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm - where did NIX_CONF_DIR go? Shouldn't that be a systemVariable as well then?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are systemVariables now, obviously.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see what you are asking about.
NIX_CONF_DIR is an envVar, and all the envVars are systemVariables now.

@wmertens
Copy link
Contributor

I like it, and the name environment.sessionVariables as well. Will this not break things when switching to this configuration? I think maybe people will have to log out to have sudo behave the same?

👍

@kirelagin
Copy link
Member Author

I chose the name systemVariables exactly because they are now more “system” then they used to be. Previously they were set by shells rc and preserved in sudoers (which is basically a hacky workaround).
Now they are initialised earlier, so we get them both in shells and in shell-less (that is, system) things. So, again, they are “system” because they are used almost always, even when there is no user involved.

My guess is that those variables are also available now in services, so we don't have to pass them explicitly, even though I was too lazy to test this.

@kirelagin
Copy link
Member Author

BTW, I was going to rename environment.variables to environment.shellVariables, but something stopped me. Can't remember now what exactly.

@kirelagin
Copy link
Member Author

Ok, I've checked systemd docs and it looks like that it won't open a PAM session for a service unless explicitly asked to do so (via PAMName).

@vcunat
Copy link
Member

vcunat commented Jun 10, 2014

Merged, thanks!

@vcunat vcunat closed this Jun 10, 2014
@kirelagin kirelagin deleted the pam_env branch June 10, 2014 10:00
vcunat added a commit that referenced this pull request Jun 10, 2014
@vcunat
Copy link
Member

vcunat commented Jun 10, 2014

Picked into release, too.

@kirelagin
Copy link
Member Author

Not sure picking into release was a good idea. As mentioned in the comments, this requires a relogin.

@vcunat
Copy link
Member

vcunat commented Jun 10, 2014

I don't see why requiring relogin should be a problem for release. We e.g. push kernel updates there, and they even need a reboot :-)

@kirelagin
Copy link
Member Author

Right, that's not a critical issue, but still there is a difference.
After you upgrade the kernel your system keeps working as it was until you restart.
In this case your system kinda breaks until you relogin. Well, not really breaks, but strange things might start happening when you run sudo until you relogin because of those three variables that I removed from sudoers.

vcunat added a commit to vcunat/nixpkgs that referenced this pull request Jun 10, 2014
@vcunat
Copy link
Member

vcunat commented Jun 10, 2014

Yes, it's unfortunate that such things happen... e.g. when running xfce4session the session is killed on typical nixos-rebuild switch (whenever dbus gets restarted IIRC); or trying to resume into the updated system after suspend-to-disk will also fail (at least when kernel changed).

I don't know how to approach such updates, where you may need some restarting action.

edolstra added a commit that referenced this pull request Jun 10, 2014
@edolstra
Copy link
Member

I've reverted this in release-14.04, because IMHO this kind of global behaviour change is not a good idea there. At least not until it has had a lot of soak time in master.

@edolstra
Copy link
Member

Urgh, I screwed up, reverted it in master instead. Branches are hard...

edolstra added a commit that referenced this pull request Jun 10, 2014
edolstra added a commit that referenced this pull request Jun 10, 2014
@vcunat
Copy link
Member

vcunat commented Jun 10, 2014

Heh, OK.

@vcunat
Copy link
Member

vcunat commented Jun 10, 2014

It's just the thing that I did see people complaining about the channel checkout error right after installation (I ran into that one as well), which is unfixed in our default ISOs now. It could be worked-around by merging #2688 into release instead.

@kirelagin
Copy link
Member Author

Merging #2688 is never a good idea. It can be worked around by adding the relevant variable to sudoers as I suggested in #2688. This might be indeed a good idea to fix the installation ISO right away.

vcunat added a commit that referenced this pull request Jun 15, 2014
so all users get this variable, thanks to work from #2692.
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.

None yet

4 participants