OK I'm
almost there, I think...
Here is my test role:
- Code: Select all
role root sAN
subject / rvka
/ rwcdmlxi
As root, I can do "gradm -n root" and I get to the role successfully.
Here is the chunk of code I have for my pam function (I'm linking against all the gradm *.o files so there are no unresolved symbols)
- Code: Select all
special_role_uid = 0;
tailor_to_kernel();
main_stack = &include_stack;
memset(main_stack, 0, sizeof(struct include_entry));
main_stack->sp = -1;
pam_syslog(pamh, LOG_WARNING, "initting variables");
init_variables();
err = mlock(&entry, sizeof (entry));
if (err && !getuid())
pam_syslog(pamh, LOG_WARNING, "Warning: Unable to lock password "
"into physical memory.");
memset(&entry, 0, sizeof (struct gr_pw_entry));
strncpy((char *)entry.rolename, username, GR_SPROLE_LEN);
entry.rolename[GR_SPROLE_LEN - 1] = '\0';
entry.mode = GRADM_SPROLE;
check_acl_status(entry.mode);
grarg = conv_user_to_kernel(&entry);
pam_syslog (pamh, LOG_WARNING, "transmitting to kernel");
my_transmit_to_kernel(pamh, grarg);
pam_syslog(pamh, LOG_WARNING, "grsec role access allowed for '%s'",
username);
The my_transmit_to_kernel function is a copy of transmit_to_kernel, but errors are sent via pam_syslog instead of fprintf (since things die in this function)
Here is the pam config to login via sshd:
- Code: Select all
auth optional pam_grsec.so
auth required pam_unix2.so
Also sshd does have the ability to auth to the kernel (afaik):
- Code: Select all
subject /usr/sbin/sshd
/etc/ld.so.cache r
/etc/ld.so.preload r
/etc/protocols r
/dev/urandom r
/lib rx
/usr/lib rx
/dev/grsec w
/dev/log rwx
+CAP_IPC_LOCK
+CAP_NET_ADMIN
But when I login, I get this:
- Code: Select all
Nov 8 00:51:18 localhost sshd[3608]: pam_grsec(sshd:auth): Attempting to auth to the role 'root'
Nov 8 00:51:18 localhost sshd[3608]: pam_grsec(sshd:auth): initting variables
Nov 8 00:51:18 localhost sshd[3608]: pam_grsec(sshd:auth): transmitting to kernel
Nov 8 00:51:18 localhost sshd[3608]: pam_grsec(sshd:auth): Invalid password.
The "Invalid password." is coming out of the my_transmit_to_kernel function ...
Any ideas? As far as I can tell, I got all the functions that are ran in gradm into this module and running in the right order ....