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

sesman: auth session before fork #694

Closed
wants to merge 1 commit into from

Conversation

jsorg71
Copy link
Contributor

@jsorg71 jsorg71 commented Mar 14, 2017

So, the home directory can be created by "pam_mkhomedir".

@proski
Copy link
Contributor

proski commented Mar 14, 2017

+1

@metalefty
Copy link
Member

The change looks good. But I want you to include "why" in commit message for future source code reading. "Why" is always more important than "What". In this change, to create home directory, right? It's OK to do force push in unmerged PRs.

@ksteinb
Copy link

ksteinb commented Mar 15, 2017

Correct session management is necessary for more things than just to create homedirectory. Here some reasons:

-> Create Homedirectory on demand
-> Correctly setup umask (pam_umask)
-> Correct setup of selinux contexrt
-> Handling of limits (pam_limits)

and so on .....

@proski
Copy link
Contributor

proski commented Mar 15, 2017

I'm a big fan of good comments in the code, however...

The reader of the code would not see that auth_start_session was called elsewhere. So a comment in the code would not be very useful. We cannot annotate every line of code with an explanation why it's there and not elsewhere.

Those who want to dig deeper should be able to find the commit and it's comment. That would provide information about the change and the reason behind it.

Of course, if somebody can come with a useful comment about the auth_start_session that is not duplicating the code, I'll be glad to see it. But the lack of a comment should not be a blocker.

@metalefty
Copy link
Member

I think most of correct session management procedures can be done in PAM.
For example, suggested in #688. This fixes things done in PAM wasn't working.

Of course I don't intend to block merging this PR. We can add comments whenever later.

@ksteinb
Copy link

ksteinb commented Mar 15, 2017

#688 describes the correct setup of the pam configuration, but that doesn't help as long as auth_start_session is called in the wrong place.

So just write as comment something like:

"Calling auth_start_session in the correct place, otherwise pam session management fails"

@jsorg71
Copy link
Contributor Author

jsorg71 commented Mar 15, 2017

Does it also fix the issue if auth_start_session is moved above wait_for_xserver?
I'd rather do that.
There is not matching auth_start_session / auth_stop_session now.

@jsorg71
Copy link
Contributor Author

jsorg71 commented Mar 15, 2017

After looking closer, I think it's right now. auth_start_session and auth_stop_session are called in same process now.

Before this PR

session_start_fork()
g_fork()
    child - g_fork()
        child auth_start_session(), g_fork()
            child - g_exec(window manager)
        parent - g_waitpid(), auth_stop_session(), g_exit()
    parent - g_fork()
        child - g_exec(X11 backend)
    parent - sesman svc(wait for window manager to exit, then kill X11 backend)
parent - exit session_start_fork()

After this PR

session_start_fork()
g_fork()
    child - auth_start_session(), g_fork()
        child g_fork()
            child - g_exec(window manager)
        parent - g_waitpid(), auth_stop_session(), g_exit()
    parent - g_fork()
        child - g_exec(X11 backend)
    parent - sesman svc(wait for window manager to exit, then kill X11 backend)
parent - exit session_start_fork()

@rolnas
Copy link

rolnas commented Mar 16, 2017

This patch don't work with pam_krb5 on Debian 8.
I moved auth_start_session higher to the same process as auth_userpass.
That works, but some auth_end closes session too early (but retain_after_close=true on pam_krb5 solves temporary).
I'm attaching patch and log files from successful session (pam_krb5 with debug=true).
auth_start_session2.txt
auth_start_session2_log.txt

@moobyfr
Copy link
Contributor

moobyfr commented Mar 16, 2017

@rolnas can you add your pam.d/common-* files to understand the problem ?
I'm using pam_krb5 or pam_ldap with xrdp since several years without problem.

@ksteinb
Copy link

ksteinb commented Mar 16, 2017 via email

@jsorg71
Copy link
Contributor Author

jsorg71 commented Mar 17, 2017

I create #696 that can replace this PR. Hopefully it works for everyone.

@setharnold
Copy link

Use CVE-2017-6967.
Thanks

@jsorg71 jsorg71 closed this Mar 22, 2017
@mrkz
Copy link

mrkz commented Mar 24, 2017

Hello, I would like to confirm if PR #704 and #697 are the fix to this CVE issue?
Thanks!

@jsorg71
Copy link
Contributor Author

jsorg71 commented Mar 24, 2017

It's just #704 for the fix. Can someone else confirm it;s fixed?

@moobyfr
Copy link
Contributor

moobyfr commented Mar 26, 2017

I confirm it. I thing the pam process is now ok: before, if pam_krb5 was used, the environement variable set by the module was't available in the user session an the file created by the module was owned by root. Now the variable is set and file owned by user.

@tfischer77 tfischer77 mentioned this pull request Jun 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants