On Mar 17, 2006, at 7:33 PM, Jeffrey Altman wrote:
One other place that the credential cache and the AFS token get out of sync is when trying to renew the TGT. Renewal of the TGT and AFS token is a whole subject on its own, but suffice it to say that running "kinit -R" will renew the TGT, but remove the AFS service ticket, while the AFS token remains unchanged.
(Remember, I'm just a developer who happens to work at Apple; I don't speak for Apple.) It turns out I was working this week on something similar, a PAM module for aklog. This is still highly experimental, but I have modified aklog to be more reentrant and embeddible, by converting all the global variables into fields of a structure. I have add an additional routine that allocates such a structure, which is then passed to the aklog() routine. So now, the main() routine of the aklog program calls alloc_aklog_globals() to get a block of memory, and passes that to the aklog() routine with the arguments. The PAM modules does the same thing. There are some differences that are taken care of with a macro definition, like the fact that argv[0] is the name of the aklog program, but is the first real argument from the PAM modules. Also, the aklog program exits on error; the PAM modules does a longjmp back to the aklog() routine to do an error return (because there is no exit, there might be some memory leaks or other cleanup that will need to be done). Creating a loadable PAM module did present some problem. The LWP code uses assembly language (process.s for ppc and process.i386.s for x86), but that code references a global variable in way that would require a writable text segment. So I added the usual assembly goop to move the relocation info to a data segment. (I had tried to replace LWP with the pthread code, but was running into a bunch of undefined symbol problems, so I fell back to LWP. I did notice four places that allocate pthread mutexes but don't initialize with PTHREAD_MUTEX_INITIALIZER as per POSIX, and would have made a difference on Mac OS X, since when uninitialized, it would reside in common segment, which is not allowed for a bundle. Initializing it moves it into a data segment.) So I finally created the PAM module, which only does session open and close. The open calls aklog to create the token. The close does the equivalent of unlog, but I then commented that out, since I can imagine being logging into the GUI, when an ssh session comes in, renews the AFS token and then removes it on logout, leaving the GUI without a token. Some mechanism for the last-one-out removing the token is needed. So fine, I have a PAM module, but so what? Well, I also wrote a loginwindow "LoginHook", that is called loginwindow_pam_helper. It gets run when loginwindow finishes authenticating (presuming /etc/authorization is set up to do Kerberos authentication). It then does the usual PAM stuff to open a session and I set up the PAM config file to call my pam_aklog module. In loginwindow_pam_helper, I use a kqueue to monitor when loginwindow terminates (usually when the user logs out, or if loginwindow dies) and then close the session. Well, this actually all works! I log in, and my AFS tokens are there. I can even set up a .xlog file and get tokens for multiple cells. Now I'm not saying this is the best approach. My thinking was that a PAM module would be useful for other Unix platforms as well, but doesn't really fit in so nicely in Mac OS X. The KFM might be a little cleaner, though Mac OS X specific. But it might be possible to get loginwindow to do PAM directly, so my loginwindow_pam_helper wouldn't be needed anymore, and then the PAM module might fit in better (of course, I'm not on the loginwindow team, so I can't say they will make this change). Mac OS X also has it's own way of doing things, like the Authorization Services framework. Now I'm a Unix guy, so the Authorization Services framework is new to me. But it might also be feasible to put in aklog as a plug-in. Then loginwindow could get to aklog through Authorization Services, and since there is already a pam_securityserver.so module that calls into the Authorization Services framework, things like ssh might also be able to get to aklog. Again this is Mac OS specific, but could be the cleanest way for both Mac OS X applications and command-line programs to get aklog access. And since aklog is embeddable, we could build the aklog program, the aklog PAM module, the aklog Authorization plug-in and possibly even the KFM KLL plug-in, all using the same base code. Anyways, Derrick, let me know if I can be of help with the KFM KLL plug-in (which is something else I don't know much about). -------------------------------------------------------------------------- Edward Moy Apple |
- [OpenAFS-devel] aklog on MacOS X was Re: Servic... Jeffrey Altman
- Re: [OpenAFS-devel] aklog on MacOS X was R... emoy
- Re: [OpenAFS-devel] aklog on MacOS X w... Luke Howard
- Re: [OpenAFS-devel] aklog on MacOS X w... Alexandra Ellwood
- Re: [OpenAFS-devel] aklog on MacOS... Henry B. Hotz
- Re: [OpenAFS-devel] aklog on M... Russ Allbery
- Re: [OpenAFS-devel] aklog... Ken Hornstein
- Re: [OpenAFS-devel] a... Russ Allbery
- Re: [OpenAFS-deve... Ken Hornstein (Contractor)
- Re: [OpenAFS-devel] aklog on M... Jeffrey Altman
- Re: [OpenAFS-devel] aklog... David Botsch
- Re: [OpenAFS-devel] a... Franco Milicchio
