🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
2 messages
2 total messages Started by tomjnsn Tue, 15 Jun 1999 00:00
nnrpd_auth.pl
#38037
Author: tomjnsn
Date: Tue, 15 Jun 1999 00:00
62 lines
2338 bytes
I am trying to get an intranet news server to authenticate against
user's network passwords using PAM, and a perl module Authen_PAM.  I've
gotten it setup correctly so that it requests for a login and password
when trying to access the newsgroups, specifically in Netscape, but it
will accept anything for a login and password, and allow the user access
to the groups.  I don't think it is a problem with the Authen_PAM
module, because I can run the same lines of code I put in nnrpd_auth.pl
as an independent process, successfully refusing an incorrect login or
password.  Any suggestions?

Tom

The following is the code I changed in nnrpd_auth.pl:

sub authenticate {
  my $key;
  foreach $key (keys %attributes) {
  }
  if ($attributes{type} eq "connect") {
    my (@results) = checkhost();
    return @results;
  } elsif ($attributes{type} eq "authenticate") {
    return checkuser();
  } elsif ($attributes{type} eq "disconnect") {
  }
  return 502;
}

sub checkuser {
  my $user = $attributes{'username'};

  pam_start("passwd", $user, \&pam_conv_func, $pamh);
  $retval = pam_set_item($pamh,PAM_TTY,$DISPLAY);
  $retval = pam_authenticate($pamh, 0);
  if ($retval) {
	pam_end($pamh);
	return ($authcodes{'allowed'}, 1, 1, $defaultgroups);
  } else {
	pam_end($pamh);
	return ($authcodes{'denied'}, undef, undef, undef);
  }
}

sub pam_conv_func {
	my @res;
	while (@_ ) {
		my $msg_type = shift;
		my $msg = shift;

		push @res, 0;
		push @res, $attributes{'password'};
	}
	push @res, PAM_SUCCESS;
	return @res;
}



Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.

Re: nnrpd_auth.pl
#38064
Author: tomjnsn
Date: Tue, 15 Jun 1999 00:00
36 lines
1559 bytes
Whoops! I wasn't paying attention, I had a couple of lines wrong in
checkuser().  checkuser() should read as follows:

 sub checkuser {
   my $user = $attributes{'username'};

   pam_start("login", $user, \&pam_conv_func, $pamh);
              ^^^^^--(was passwd)


   $retval = pam_set_item($pamh,PAM_TTY,$DISPLAY);
   $retval = pam_authenticate($pamh, 0);
   if ($retval == PAM_SUCCESS) {
               ^^^^^^^^^^^^^^--(wasn't verifying against PAM_SUCCESS
which is = 0)


 	pam_end($pamh);
 	return ($authcodes{'allowed'}, 1, 1, $defaultgroups);
   } else {
 	pam_end($pamh);
 	return ($authcodes{'denied'}, undef, undef, undef);
   }
 }


In article <7k5pjb$o5q$1@nnrp1.deja.com>,
  tomjnsn@my-deja.com wrote:
<snip>



Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.

Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads