[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [leafnode-list] fetch "report" option and fetch GUI



------=_NextPart_000_000D_01BEA7D2.90904FA0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Mark Brown <broonie@xxxxxxxxxxxxxxx> wrote:

>On Sat, May 01, 1999 at 10:48:51AM +0800, Mark Harrison wrote:
>> I've got the authinfo patche untangled now, and will post soon.
>> It implements the protocol, but currently allows any
>> name/password combination.
>
>Any progress on this?  I'd like to have a play with it.  The obvious
>thing to do to make it actually do authentication is to use PAM,
>avoiding having to implement the authentication itself within Leafnode.


Sorry for the delay, things were a bit out of sort around here
the last couple of weeks.

Attached is a patch file for nntpd.c.  The framework for authinfo
seems to work mostly, it's just lacking the real authorization code.
The basic modifications are:

    - add doauthinfo() to handle authinfo command.  This follows the
      layout of the other do... commands.  It is finished except for
      the actual code that does the authorization.  Look for the
      "do the real authentication here" comment.

    - in the command processor, added call to isauthorized() in
      appropriate places.  This function returns true if
      the previously supplied name/password pair was authorized.

        } else if (!strcasecmp(cmd, "mode") && isauthorized()) {

To do:

    - add real authentication.  It would be nice to add a switch
      where the "if (1)" is, and allow the authorization type
      to be set in the configuration file.

    - add a "use authorization" option to the configuration file.

    - document.

Let me know if you start something on this, so we can keep in
synch.

Mark.

---------------------------------------------------------------------
Mark Harrison                       "Open the floppy disk door, Hal."
AsiaInfo Computer Networks          http://usai.asiainfo.com:8080/
Beijing, China / Santa Clara, CA    markh@xxxxxxxxxxxxxxxxx



------=_NextPart_000_000D_01BEA7D2.90904FA0
Content-Type: application/octet-stream;
	name="Diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="Diff"

*** ../leafnode-1.9.2/nntpd.c	Fri Apr 30 11:44:05 1999
--- nntpd.c	Fri Apr 30 16:03:20 1999
***************
*** 68,73 ****
--- 68,74 ----
  void doxhdr(char *);
  void doxover(const char *);
  void dolistgroup( const char * );
+ void doauthinfo( const char * );
  void markinterest( void );
 =20
  struct newsgroup * group;	/* current group, initially none */
***************
*** 82,87 ****
--- 83,117 ----
  int debug =3D 0;
  int verbose =3D 0;		/* verbose doesn't count here */
 =20
+ /* authorization information */
+ #define USE_AUTH 0
+ #ifndef USE_AUTH
+ #define USE_AUTH 1
+ #endif
+ char myuser[MAXLINELENGTH];
+ char mypass[MAXLINELENGTH];
+ int authflag =3D 0;
+=20
+=20
+ int isauthorized(void);
+ #if USE_AUTH
+ int isauthorized()
+ {
+     if (!authflag) {
+         printf( "480 Authentication required for command\r\n" );
+         if ( debugmode )
+             syslog( LOG_DEBUG, ">480 Authentication required for =
command" );
+         return 0;
+     } else
+         return 1;
+ }
+ #else
+ int isauthorized()
+ {
+     return 1;
+ }
+ #endif
+=20
  void rereadactive(void) {
      struct stat st;
 =20
***************
*** 147,199 ****
  	    return;
  	}
  	rereadactive();
! 	if (!strcasecmp(cmd, "article")) {
  	    doarticle(arg, 3);
! 	} else if (!strcasecmp(cmd, "head")) {
  	    doarticle(arg, 2);
! 	} else if (!strcasecmp(cmd, "body")) {
  	    doarticle(arg, 1);
! 	} else if (!strcasecmp(cmd, "stat")) {
  	    doarticle(arg, 0);
  	} else if (!strcasecmp(cmd, "help")) {
  	    dohelp();
! 	} else if (!strcasecmp(cmd, "ihave")) {
  	    if ( debugmode )
  		syslog( LOG_DEBUG, ">500 IHAVE is for big news servers" );
  	    printf("500 IHAVE is for big news servers\r\n");
! 	} else if (!strcasecmp(cmd, "last")) {
  	    domove(-1);
! 	} else if (!strcasecmp(cmd, "next")) {
  	    domove(1);
! 	} else if (!strcasecmp(cmd, "list")) {
  	    dolist(arg);
! 	} else if (!strcasecmp(cmd, "mode")) {
  	    if ( debugmode )
  		syslog( LOG_DEBUG, ">200 Leafnode %s, pleased to meet you!",
  			version);
  	    printf("200 Leafnode %s, pleased to meet you!\r\n", version);
! 	} else if (!strcasecmp(cmd, "newgroups")) {
  	    donewgroups(arg);
! 	} else if (!strcasecmp(cmd, "newnews")) {
  	    if ( debugmode )
  		syslog( LOG_DEBUG,
  			">500 NEWNEWS is meaningless for this server" );
  	    printf( "500 NEWNEWS is meaningless for this server\r\n" );
! 	} else if (!strcasecmp(cmd, "post")) {
  	    dopost();
! 	} else if (!strcasecmp(cmd, "slave")) {
  	    if ( debugmode )
  		syslog( LOG_DEBUG, ">202 Cool - I always wanted a slave" );
  	    printf("202 Cool - I always wanted a slave\r\n");
! 	} else if (!strcasecmp(cmd, "xhdr")) {
  	    doxhdr(arg);
! 	} else if (!strcasecmp(cmd, "xover")) {
  	    doxover(arg);
! 	} else if (!strcasecmp(cmd, "over")) {
  	    doxover(arg);
! 	} else if (!strcasecmp(cmd, "listgroup")) {
  	    dolistgroup(arg);
! 	} else if (!strcasecmp(cmd, "group")) {
  	    dogroup(arg);
  	} else {
  	    if ( debugmode )
--- 177,231 ----
  	    return;
  	}
  	rereadactive();
! 	if (!strcasecmp(cmd, "article") && isauthorized()) {
  	    doarticle(arg, 3);
! 	} else if (!strcasecmp(cmd, "head") && isauthorized()) {
  	    doarticle(arg, 2);
! 	} else if (!strcasecmp(cmd, "body") && isauthorized()) {
  	    doarticle(arg, 1);
! 	} else if (!strcasecmp(cmd, "stat") && isauthorized()) {
  	    doarticle(arg, 0);
  	} else if (!strcasecmp(cmd, "help")) {
  	    dohelp();
! 	} else if (!strcasecmp(cmd, "ihave") && isauthorized()) {
  	    if ( debugmode )
  		syslog( LOG_DEBUG, ">500 IHAVE is for big news servers" );
  	    printf("500 IHAVE is for big news servers\r\n");
! 	} else if (!strcasecmp(cmd, "last") && isauthorized()) {
  	    domove(-1);
! 	} else if (!strcasecmp(cmd, "next && isauthorized()")) {
  	    domove(1);
! 	} else if (!strcasecmp(cmd, "list && isauthorized()")) {
  	    dolist(arg);
! 	} else if (!strcasecmp(cmd, "mode") && isauthorized()) {
  	    if ( debugmode )
  		syslog( LOG_DEBUG, ">200 Leafnode %s, pleased to meet you!",
  			version);
  	    printf("200 Leafnode %s, pleased to meet you!\r\n", version);
! 	} else if (!strcasecmp(cmd, "newgroups") && isauthorized()) {
  	    donewgroups(arg);
! 	} else if (!strcasecmp(cmd, "newnews") && isauthorized()) {
  	    if ( debugmode )
  		syslog( LOG_DEBUG,
  			">500 NEWNEWS is meaningless for this server" );
  	    printf( "500 NEWNEWS is meaningless for this server\r\n" );
! 	} else if (!strcasecmp(cmd, "post") && isauthorized()) {
  	    dopost();
! 	} else if (!strcasecmp(cmd, "slave") && isauthorized()) {
  	    if ( debugmode )
  		syslog( LOG_DEBUG, ">202 Cool - I always wanted a slave" );
  	    printf("202 Cool - I always wanted a slave\r\n");
! 	} else if (!strcasecmp(cmd, "xhdr") && isauthorized()) {
  	    doxhdr(arg);
! 	} else if (!strcasecmp(cmd, "xover") && isauthorized()) {
  	    doxover(arg);
! 	} else if (!strcasecmp(cmd, "over") && isauthorized()) {
  	    doxover(arg);
! 	} else if (!strcasecmp(cmd, "listgroup") && isauthorized()) {
  	    dolistgroup(arg);
! 	} else if (!strcasecmp(cmd, "authinfo")) {
! 	    doauthinfo(arg);
! 	} else if (!strcasecmp(cmd, "group") && isauthorized()) {
  	    dogroup(arg);
  	} else {
  	    if ( debugmode )
***************
*** 1281,1286 ****
--- 1313,1361 ----
      printf( ".\r\n" );
  }
 =20
+ void doauthinfo( const char * arg ) {
+     char cmd[MAXLINELENGTH];
+     char parm[MAXLINELENGTH];
+=20
+     if ( arg && strlen(arg) ) {
+         *cmd =3D *parm =3D 0;
+         sscanf(arg,"%s %s", cmd, parm);
+ 	if (!strcasecmp(cmd, "user")) {
+             strcpy(myuser, parm);
+             printf( "381 PASS required\r\n" );
+ 	    if ( debugmode )
+                 syslog( LOG_DEBUG, ">381 PASS required" );
+ 	} else if (!strcasecmp(cmd, "pass")) {
+             if (*myuser =3D=3D 0) {
+                 printf( "482 USER required\r\n" );
+ 	        if ( debugmode )
+                     syslog( LOG_DEBUG, ">482 USER required" );
+             } else {
+                 /* do the real authentication here */
+                 if (1) { /* GOOD */
+                     authflag =3D 1;
+                     printf( "281 Ok\r\n" );
+ 	            if ( debugmode )
+                         syslog( LOG_DEBUG, ">281 Ok" );
+                 } else {
+                     printf( "502 Authentication error\r\n" );
+ 	            if ( debugmode )
+                         syslog( LOG_DEBUG, ">502 Authentication error" =
);
+                     exit(1);
+                 }
+             }
+         } else {
+ 	    printf( "500 bad authinfo param\r\n" );
+ 	    if ( debugmode )
+ 	        syslog( LOG_DEBUG, ">500 bad authinfo param" );
+         }
+     } else {
+ 	printf( "500 bad authinfo param\r\n" );
+ 	if ( debugmode )
+ 	    syslog( LOG_DEBUG, ">500 bad authinfo param" );
+     }
+ }
+=20
 =20
 =20
  int main( int argc, char ** argv ) {
***************
*** 1302,1307 ****
--- 1377,1383 ----
  		 he && he->h_name ? he->h_name : inet_ntoa(sa.sin_addr),
  		 63 );
      }
+=20
      if ( strncasecmp( fqdn, "localhost", 9 ) =3D=3D 0 )
  	whoami();
 =20

------=_NextPart_000_000D_01BEA7D2.90904FA0--

-- 
leafnode-list@xxxxxxxxxxxxxxxxxxxxxxxxxxxx -- mailing list for leafnode
To unsubscribe, send mail with "unsubscribe" in the subject to the list