]> arthur.barton.de Git - netatalk.git/blobdiff - etc/papd/queries.c
pap: Allow login using gecos name too, fix most obvious buffers overrun... from
[netatalk.git] / etc / papd / queries.c
index ba0e8ca1096d8058c231ceca0ac18efb0d32ba23..ab1d745e37a88364d59b2edf563bb014030d6cad 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: queries.c,v 1.8 2001-07-31 19:50:14 srittau Exp $
+ * $Id: queries.c,v 1.17 2003-05-14 15:13:50 didg Exp $
  *
  * Copyright (c) 1990,1994 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -12,7 +12,7 @@
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <sys/syslog.h>
+#include <atalk/logger.h>
 #include <sys/param.h>
 #include <sys/time.h>
 #include <sys/types.h>
@@ -145,13 +145,13 @@ int cq_k4login( in, out )
 
     if (( rc = krb_rd_req( &tkt, "LaserWriter", printer->p_name,
            0, &ad, "" )) != RD_AP_OK ) {
-       syslog( LOG_ERR, "cq_k4login: %s", krb_err_txt[ rc ] );
+       LOG(log_error, logtype_papd, "cq_k4login: %s", krb_err_txt[ rc ] );
        append( out, LoginFailed, strlen( LoginFailed ));
        compop();
        CONSUME( in, linelength + crlflength );
        return( CH_DONE );
     }
-    syslog( LOG_INFO, "cq_k4login: %s.%s@%s", ad.pname, ad.pinst,
+    LOG(log_info, logtype_papd, "cq_k4login: %s.%s@%s", ad.pname, ad.pinst,
            ad.prealm );
     lp_person( ad.pname );
     lp_host( ad.prealm );
@@ -183,7 +183,7 @@ int cq_uameth( in, out )
        if ( comgetflags() == 0 ) {     /* start */
            if (( printer->p_flags & P_KRB ) == 0 ) {   /* no kerberos */
                if ( comswitch( queries, cq_default ) < 0 ) {
-                   syslog( LOG_ERR, "cq_uameth: can't find default!" );
+                   LOG(log_error, logtype_papd, "cq_uameth: can't find default!" );
                    exit( 1 );
                }
                return( CH_DONE );
@@ -255,7 +255,7 @@ int gq_balance( out )
  * Handler for RBISpoolerID
  */
 
-static const char *spoolerid = "(PAPD Spooler) 2.1 (2.1.4 pre-release)\n";
+static const char *spoolerid = "(PAPD Spooler) 1.0 (" VERSION ")\n";
 
 int gq_rbispoolerid( out )
     struct papfile     *out;
@@ -302,6 +302,7 @@ struct genquery {
 #endif /* notdef */
     { "RBISpoolerID",  gq_rbispoolerid },
     { "RBIUAMListQuery", gq_rbiuamlist },
+    { "ADOIsBinaryOK?", gq_true },
     { "UMICHListQueue", gq_true },
     { "UMICHDeleteJob", gq_true },
     { NULL },
@@ -357,7 +358,7 @@ int cq_query( in, out )
            if ( gq->gq_name == NULL || gq->gq_handler == NULL ||
                    (gq->gq_handler)( out ) < 0 ) {
                if ( comswitch( queries, cq_default ) < 0 ) {
-                   syslog( LOG_ERR, "cq_feature: can't find default!" );
+                   LOG(log_error, logtype_papd, "cq_feature: can't find default!" );
                    exit( 1 );
                }
                return( CH_DONE );
@@ -503,7 +504,7 @@ int cq_feature( in, out )
 
            if (( pfe = ppd_feature( p, stop - p )) == NULL ) {
                if ( comswitch( queries, cq_default ) < 0 ) {
-                   syslog( LOG_ERR, "cq_feature: can't find default!" );
+                   LOG(log_error, logtype_papd, "cq_feature: can't find default!" );
                    exit( 1 );
                }
                return( CH_DONE );
@@ -548,7 +549,7 @@ int cq_printer( in, out )
 
            if (( pdpsver = ppd_feature( psver, strlen( psver ))) == NULL ) {
                if ( comswitch( queries, cq_default ) < 0 ) {
-                   syslog( LOG_ERR, "cq_printer: can't find default!" );
+                   LOG(log_error, logtype_papd, "cq_printer: can't find default!" );
                    exit( 1 );
                }
                return( CH_DONE );
@@ -560,9 +561,9 @@ int cq_printer( in, out )
                }
            }
            if ( *p == '\0' ) {
-               syslog( LOG_ERR, "cq_printer: can't parse PSVersion!" );
+               LOG(log_error, logtype_papd, "cq_printer: can't parse PSVersion!" );
                if ( comswitch( queries, cq_default ) < 0 ) {
-                   syslog( LOG_ERR, "cq_printer: can't find default!" );
+                   LOG(log_error, logtype_papd, "cq_printer: can't find default!" );
                    exit( 1 );
                }
                return( CH_DONE );
@@ -570,7 +571,7 @@ int cq_printer( in, out )
 
            if (( pdprod = ppd_feature( prod, strlen( prod ))) == NULL ) {
                if ( comswitch( queries, cq_default ) < 0 ) {
-                   syslog( LOG_ERR, "cq_printer: can't find default!" );
+                   LOG(log_error, logtype_papd, "cq_printer: can't find default!" );
                    exit( 1 );
                }
                return( CH_DONE );
@@ -658,7 +659,7 @@ int cq_listq( in, out )
     }
 
     if ( lp_queue( out )) {
-       syslog( LOG_ERR, "cq_listq: lp_queue failed" );
+       LOG(log_error, logtype_papd, "cq_listq: lp_queue failed" );
     }
 
     compop();
@@ -676,7 +677,7 @@ static const char *rbiloginok = "0\r";
 static const char *rbiloginbad = "-1\r";
 static const char *rbiloginerrstr = "%%[Error: SecurityError; \
 SecurityViolation: Unknown user, incorrect password or log on is \
-disabled ]%%\r%%Flushing: rest of job (to end-of-file) will be \
+disabled ]%%\r%%[Flushing: rest of job (to end-of-file) will be \
 ignored ]%%\r";
 
 int cq_rbilogin( in, out )
@@ -684,7 +685,7 @@ int cq_rbilogin( in, out )
 {
     char               *start, *stop, *p, *begin;
     int                        linelength, crlflength;
-    char               username[9] = "\0";
+    char               username[UAM_USERNAMELEN + 1] = "\0";
     struct papd_comment        *comment = compeek();
     char               uamtype[20] = "\0";
 
@@ -711,12 +712,14 @@ int cq_rbilogin( in, out )
 
            if ((papd_uam = auth_uamfind(UAM_SERVER_PRINTAUTH,
                                uamtype, strlen(uamtype))) == NULL) {
-               syslog(LOG_INFO, "Could not find uam: %s", uamtype);
+               LOG(log_info, logtype_papd, "Could not find uam: %s", uamtype);
                append(out, rbiloginbad, strlen(rbiloginbad));
                append(out, rbiloginerrstr, strlen(rbiloginerrstr));
            } else {
                 if ( (papd_uam->u.uam_printer(p,stop,username,out)) == 0 ) {
                     lp_person( username );
+                   append(out, rbiloginok, strlen( rbiloginok ));
+                   LOG(log_info, logtype_papd, "RBILogin: Logged in '%s'", username);
                 } else {
                     append(out, rbiloginbad, strlen( rbiloginbad));
                     append(out, rbiloginerrstr, strlen(rbiloginerrstr));