]> arthur.barton.de Git - netatalk.git/commitdiff
merge papd changes from HEAD
authordidg <didg>
Tue, 3 Feb 2009 08:25:00 +0000 (08:25 +0000)
committerdidg <didg>
Tue, 3 Feb 2009 08:25:00 +0000 (08:25 +0000)
etc/afpd/afp_config.c
etc/afpd/volume.c
etc/papd/auth.c
etc/papd/file.c
etc/papd/headers.c
etc/papd/lp.c
etc/papd/lp.h
etc/papd/magics.c
etc/papd/main.c
etc/papd/ppd.c
etc/papd/queries.c

index a289edb2ee5d1ccb601ebfcd0b42f0e166b2bf94..3b9d98b26c9c56d1e38a3e585481cb17d63f7743 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: afp_config.c,v 1.22.6.9.2.3 2005-09-27 10:40:40 didg Exp $
+ * $Id: afp_config.c,v 1.22.6.9.2.4 2009-02-03 08:25:00 didg Exp $
  *
  * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
  * All Rights Reserved.  See COPYRIGHT.
@@ -534,6 +534,7 @@ AFPConfig *configinit(struct afp_options *cmdline)
 {
     FILE *fp;
     char buf[LINESIZE + 1], *p, have_option = 0;
+    size_t len;
     struct afp_options options;
     AFPConfig *config=NULL, *first = NULL; 
 
@@ -549,9 +550,16 @@ AFPConfig *configinit(struct afp_options *cmdline)
     LOG(log_debug, logtype_afpd, "Loading ConfigFile"); 
 
     /* scan in the configuration file */
+    len = 0;
     while (!feof(fp)) {
-        if (!fgets(buf, sizeof(buf), fp) || buf[0] == '#')
+       if (!fgets(&buf[len], LINESIZE - len, fp) || buf[len] == '#')
             continue;
+       len = strlen(buf);
+       if ( len >= 2 && buf[len-2] == '\\' ) {
+           len -= 2;
+           continue;
+       } else
+           len = 0;
 
         /* a little pre-processing to get rid of spaces and end-of-lines */
         p = buf;
index fca4bb9835bb0be192f23154ab4771155996e31a..f2ae4cb248b9c8132c701fa4e00fa87f2f1dab30 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: volume.c,v 1.51.2.7.2.33.2.22 2009-02-01 07:00:12 didg Exp $
+ * $Id: volume.c,v 1.51.2.7.2.33.2.23 2009-02-03 08:25:00 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -746,6 +746,11 @@ FILE       *fp;
     p = buf;
     while ((EOF != ( c = getc( fp )) ) && ( size > 1 )) {
         if ( c == '\n' || c == '\r' ) {
+            if (p != buf && *(p -1) == '\\') {
+                p--;
+                size++;
+                continue;
+            }
             *p++ = '\n';
             break;
         } else {
index 47ee94bbdb63deda610edf94828a5a9d9dfb07f3..8e8226f0eafcc73943b429d4aed339acee4c8946 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: auth.c,v 1.6.8.2.2.2 2005-03-11 15:36:59 didg Exp $
+ * $Id: auth.c,v 1.6.8.2.2.3 2009-02-03 08:25:00 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -99,7 +99,7 @@ int auth_load(const char *path, const char *list)
   char name[MAXPATHLEN + 1], buf[MAXPATHLEN + 1], *p; 
   struct uam_mod *mod;
   struct stat st;
-  int len;
+  size_t len;
   
   if (!path || !list || (len = strlen(path)) > sizeof(name) - 2)
     return -1;
index 62e3c033eb35515fa2f8a010dcc18e535efdfd51..1517c0c380c1b2ba46c363473b6a2e1331957103 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: file.c,v 1.9 2002-01-04 04:45:47 sibaz Exp $
+ * $Id: file.c,v 1.9.12.1 2009-02-03 08:25:00 didg Exp $
  *
  * Copyright (c) 1990,1994 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -17,6 +17,8 @@
 
 #include "file.h"
 
+/* 
+*/
 int markline( pf, start, linelength, crlflength )
     char               **start;
     int                        *linelength, *crlflength;
@@ -53,6 +55,12 @@ int markline( pf, start, linelength, crlflength )
     (p[*crlflength]=='\r' || p[*crlflength]=='\n')) {
        (*crlflength)++;
     }
+    
+    if (!*crlflength) {
+        /* line is way too long, something fishy is going on, give up */
+        LOG(log_error, logtype_papd, "markline: no crlf in comment, give up" );
+        return( -2 );
+    }
 
     /* success, return 1 */
     return( 1 );
index 9b87f3c3cc4b9d606cb3678438a5a0d499adc9fc..029bbd74a45f7858770b34380bbeecaa9ab8f2c2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: headers.c,v 1.9.10.1.2.3 2008-08-14 19:58:27 didg Exp $
+ * $Id: headers.c,v 1.9.10.1.2.4 2009-02-03 08:25:00 didg Exp $
  *
  * Copyright (c) 1990,1994 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -92,6 +92,9 @@ int ch_for( in, out )
 
     case -1 :
         return( CH_MORE );
+
+    case -2 :
+        return( CH_ERROR );
     }
 
     cmt = get_text(start, linelength);
@@ -121,6 +124,9 @@ int ch_title( in, out )
 
     case -1 :
        return( CH_MORE );
+
+    case -2 :
+        return( CH_ERROR );
     }
 
 #ifdef DEBUG
@@ -165,6 +171,9 @@ int ch_creator( in, out )
 
     case -1 :
        return( CH_MORE );
+
+    case -2 :
+        return( CH_ERROR );
     }
 
     cmt = get_text(start, linelength);
@@ -200,6 +209,9 @@ int ch_endcomm( in, out )
 
     case -1 :
        return( CH_MORE );
+
+    case -2 :
+        return( CH_ERROR );
     }
 
     in->pf_state |= PF_TRANSLATE;
@@ -226,6 +238,9 @@ int ch_starttranslate(in,out)
 
     case -1 :
         return( CH_MORE );
+
+    case -2 :
+        return( CH_ERROR );
     }
 
     in->pf_state |= PF_TRANSLATE;
@@ -251,6 +266,9 @@ int ch_endtranslate(in,out)
 
     case -1 :
         return( CH_MORE );
+
+    case -2 :
+        return( CH_ERROR );
     }
 
     lp_write( in, start, linelength + crlflength );
@@ -276,6 +294,9 @@ int ch_translateone(in,out)
 
     case -1 :
         return( CH_MORE );
+
+    case -2 :
+        return( CH_ERROR );
     }
 
     in->pf_state |= PF_TRANSLATE;
index 613993faac6764c300ac47efbf6985a53b86338d..f5428f7ac733f767dea9d4389d421195599ae198 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: lp.c,v 1.14.8.4.2.6 2009-01-21 02:33:55 didg Exp $
+ * $Id: lp.c,v 1.14.8.4.2.7 2009-02-03 08:25:00 didg Exp $
  *
  * Copyright (c) 1990,1994 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -375,7 +375,7 @@ void lp_for ( lpfor )
 }
 
 
-int lp_init( out, sat )
+static int lp_init( out, sat )
     struct papfile     *out;
     struct sockaddr_at *sat;
 {
@@ -566,25 +566,29 @@ int lp_open( out, sat )
     }
 
     if ( lp.lp_flags & LP_PIPE ) {
+        char *pipe_cmd;
 
        /* go right to program */
        if (lp.lp_person != NULL) {
            if((pwent = getpwnam(lp.lp_person)) != NULL) {
                if(setreuid(pwent->pw_uid, pwent->pw_uid) != 0) {
-                   LOG(log_info, logtype_papd, "setreuid error: %s", strerror(errno));
+                   LOG(log_error, logtype_papd, "setreuid error: %s", strerror(errno));
+                   exit(1);
                }
            } else {
-               LOG(log_info, logtype_papd, "Error getting username (%s)", lp.lp_person);
+               LOG(log_error, logtype_papd, "Error getting username (%s)", lp.lp_person);
+                exit(1);
            }
        }
 
        lp_setup_comments(CH_UNIX);
-       if (( lp.lp_stream = popen( pipexlate(printer->p_printer), "w" )) == NULL ) {
+       pipe_cmd = pipexlate(printer->p_printer);
+       if (( lp.lp_stream = popen(pipe_cmd, "w" )) == NULL ) {
            LOG(log_error, logtype_papd, "lp_open popen %s: %s", printer->p_printer, strerror(errno) );
            spoolerror( out, NULL );
            return( -1 );
        }
-        LOG(log_debug, logtype_papd, "lp_open: opened %s",  pipexlate(printer->p_printer) );
+        LOG(log_debug, logtype_papd, "lp_open: opened %s",  pipe_cmd );
     } else {
        sprintf( name, "df%c%03d%s", lp.lp_letter++, lp.lp_seq, hostname );
 
index d63314172d2720ac81b9138030fce10aef20f8c0..a450be8b80e039ac380df4e5668bc1eebc77a9b4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: lp.h,v 1.3.14.1 2004-06-09 01:25:53 bfernhomberg Exp $
+ * $Id: lp.h,v 1.3.14.1.2.1 2009-02-03 08:25:00 didg Exp $
  */
 
 #ifndef PAPD_LP_H
@@ -18,8 +18,6 @@ void lp_origin __P(( int ));
 int lp_rmjob __P(( int ));
 int lp_queue __P(( struct papfile * ));
 
-/* initialize printing interface */
-int lp_init __P(( struct papfile *, struct sockaddr_at * ));
 /* cancel current job */
 int lp_cancel __P(( void ));
 /* print current job */
index c1c96f0f9eaf6765b89b1ae76e1b518180c64747..6ab61ac2063decc90419db05856eb81a9652aabf 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: magics.c,v 1.11.6.2.2.2 2005-09-27 10:40:41 didg Exp $
+ * $Id: magics.c,v 1.11.6.2.2.3 2009-02-03 08:25:00 didg Exp $
  *
  * Copyright (c) 1990,1994 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
 
 static int state=0;
 
+static void parser_error(outfile)
+    struct papfile     *outfile;
+{
+                spoolerror( outfile, "Comments error, Ignoring job." );
+               outfile->pf_state |= PF_EOF;
+               lp_close();
+}
+
 int ps( infile, outfile, sat )
     struct papfile     *infile, *outfile;
     struct sockaddr_at *sat;
@@ -49,6 +57,10 @@ int ps( infile, outfile, sat )
            case CH_MORE :
                return( CH_MORE );
 
+           case CH_ERROR :
+               parser_error(outfile);
+               return( 0 );
+
            default :
                return( CH_ERROR );
            }
@@ -60,6 +72,10 @@ int ps( infile, outfile, sat )
                lp_close();
                return( 0 );
 
+           case -2:
+               parser_error(outfile);
+               return( 0 );
+
            case -1 :
                return( 0 );
            }
@@ -105,6 +121,9 @@ int cm_psquery( in, out, sat )
 
        case -1 :
            return( CH_MORE );
+
+        case -2 :
+            return( CH_ERROR );
        }
 
        if ( in->pf_state & PF_BOT ) {
@@ -138,6 +157,9 @@ int cm_psadobe( in, out, sat )
 
        case -1 :
            return( CH_MORE );
+
+        case -2 :
+            return( CH_ERROR );
        }
        if ( in->pf_state & PF_BOT ) {
            in->pf_state &= ~PF_BOT;
@@ -177,6 +199,9 @@ int cm_psswitch( in, out, sat )
 
     case -1 :
        return( CH_MORE );
+
+    case -2 :
+        return( CH_ERROR );
     }
 
     stop = start + linelength;
@@ -191,7 +216,7 @@ int cm_psswitch( in, out, sat )
        }
     }
 
-    if ( stop - p >= strlen( Query ) &&
+    if ( (size_t)(stop - p) >= strlen( Query ) &&
            strncmp( p, Query, strlen( Query )) == 0 ) {
        if ( comswitch( magics, cm_psquery ) < 0 ) {
            LOG(log_error, logtype_papd, "cm_psswitch: can't find psquery!" );
index 6aabc126a118354f82f78169d88d680c4059923c..f803170cd80472a8559f585abfa0e08297416dae 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: main.c,v 1.18.6.2.2.6 2009-01-21 04:07:05 didg Exp $
+ * $Id: main.c,v 1.18.6.2.2.7 2009-02-03 08:25:00 didg Exp $
  *
  * Copyright (c) 1990,1995 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -489,6 +489,11 @@ int main( ac, av )
                            LOG(log_error, logtype_papd, "sigaction: %s", strerror(errno) );
                            exit( 1 );
                        }
+                       
+                       if ( sigaction( SIGCHLD, &sv, 0 ) < 0 ) {
+                           LOG(log_error, logtype_papd, "sigaction: %s", strerror(errno) );
+                           exit( 1 );
+                        }
 
                        for ( pr = printers; pr; pr = pr->p_next ) {
                            atp_close( pr->p_atp );
index b10d46d4cbfb309061b9a03b4cc2fb9831ba20d7..ed62e95e048434972ce258411d5bd3430d3e3fea 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: ppd.c,v 1.9.8.1.2.6 2009-01-21 04:07:05 didg Exp $
+ * $Id: ppd.c,v 1.9.8.1.2.7 2009-02-03 08:25:00 didg Exp $
  *
  * Copyright (c) 1995 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -289,6 +289,9 @@ struct ppd_feature *ppd_feature( feature, len )
     }
 #endif /* SHOWPPD */
 
+    if (len > sizeof(ppd_feature_main) -1)
+        return( NULL );
+        
     for ( end = feature + len, p = feature, q = ppd_feature_main;
            (p <= end) && (*p != '\n') && (*p != '\r'); p++, q++ ) {
        *q = *p;
index 69ed8ad6d97b89a248bc8d5ba6a1a1401f35d051..e642f38aa4de83a184268381629a68bc62e04e08 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: queries.c,v 1.16.2.1.2.1.2.1 2005-02-06 10:16:02 didg Exp $
+ * $Id: queries.c,v 1.16.2.1.2.1.2.2 2009-02-03 08:25:00 didg Exp $
  *
  * Copyright (c) 1990,1994 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -71,6 +71,9 @@ int cq_default( in, out )
 
        case -1 :
            return( CH_MORE );
+
+        case -2 :
+            return( CH_ERROR );
        }
 
        stop = start+linelength;
@@ -91,9 +94,11 @@ int cq_default( in, out )
                        break;
                    }
                }
-               p++;
-               while ( *p == ' ' ) {
+               if (p < stop) {
                    p++;
+                   while ( *p == ' ' ) {
+                       p++;
+                    }
                }
 
                append( out, p, stop - p + crlflength );
@@ -130,6 +135,9 @@ int cq_k4login( in, out )
 
     case -1 :
        return( CH_MORE );
+
+    case -2 :
+        return( CH_ERROR );
     }
 
     p = start + strlen( comment->c_begin );
@@ -139,6 +147,7 @@ int cq_k4login( in, out )
 
     bzero( &tkt, sizeof( tkt ));
     stop = start+linelength;
+    /* FIXME */
     for ( i = 0, t = tkt.dat; p < stop; p += 2, t++, i++ ) {
        *t = ( h2b( (unsigned char)*p ) << 4 ) +
                h2b( (unsigned char)*( p + 1 ));
@@ -180,6 +189,9 @@ int cq_uameth( in, out )
 
        case -1 :
            return( CH_MORE );
+
+        case -2 :
+            return( CH_ERROR );
        }
 
        if ( comgetflags() == 0 ) {     /* start */
@@ -326,6 +338,9 @@ int cq_query( in, out )
 
        case -1 :
            return( CH_MORE );
+
+        case -2 :
+            return( CH_ERROR );
        }
 
        stop = start+linelength;
@@ -339,7 +354,7 @@ int cq_query( in, out )
                }
            }
 
-           for ( p++; p < stop; p++ ) {
+           if (p < stop) for ( p++; p < stop; p++ ) {
                if ( *p != ' ' && *p != '\t' ) {
                    break;
                }
@@ -352,7 +367,7 @@ int cq_query( in, out )
            }
 
            for ( gq = genqueries; gq->gq_name; gq++ ) {
-               if (( strlen( gq->gq_name ) == q - p ) &&
+               if (( strlen( gq->gq_name ) == (size_t)(q - p) ) &&
                        ( strncmp( gq->gq_name, p, q - p ) == 0 )) {
                    break;
                }
@@ -386,14 +401,16 @@ void cq_font_answer( start, stop, out )
 
     p = start;
     while ( p < stop ) {
+        unsigned int count = 0;
        while (( *p == ' ' || *p == '\t' ) && p < stop ) {
            p++;
        }
 
        q = buf;
        while ( *p != ' ' && *p != '\t' &&
-               *p != '\n' && *p != '\r' && p < stop ) {
+               *p != '\n' && *p != '\r' && p < stop && count < sizeof(buf)) {
            *q++ = *p++;
+           count++;
        }
 
        if ( q != buf ) {
@@ -428,6 +445,9 @@ int cq_font( in, out )
 
        case -1 :
            return( CH_MORE );
+
+        case -2 :
+            return( CH_ERROR );
        }
 
        stop = start + linelength;
@@ -440,7 +460,8 @@ int cq_font( in, out )
                    break;
                }
            }
-           p++;
+           if (p < stop)
+               p++;
 
            cq_font_answer( p, stop, out );
        } else {
@@ -453,7 +474,8 @@ int cq_font( in, out )
                        break;
                    }
                }
-               p++;
+               if (p < stop)
+                   p++;
 
                cq_font_answer( p, stop, out );
            } else {
@@ -486,6 +508,9 @@ int cq_feature( in, out )
 
        case -1 :
            return( CH_MORE );
+
+        case -2 :
+            return( CH_ERROR );
        }
 
        stop = start + linelength;
@@ -499,7 +524,8 @@ int cq_feature( in, out )
                    break;
                }
            }
-           p++;
+           if (p < stop)
+               p++;
            while ( *p == ' ' ) {
                p++;
            }
@@ -544,6 +570,9 @@ int cq_printer( in, out )
 
        case -1 :
            return( CH_MORE );
+
+        case -2 :
+            return( CH_ERROR );
        }
 
        if ( comgetflags() == 0 ) {
@@ -620,6 +649,9 @@ int cq_rmjob( in, out )
 
     case -1 :
        return( CH_MORE );
+
+    case -2 :
+        return( CH_ERROR );
     }
 
     stop = start + linelength;
@@ -660,6 +692,9 @@ int cq_listq( in, out )
 
     case -1 :
        return( CH_MORE );
+
+    case -2 :
+        return( CH_ERROR );
     }
 
     if ( lp_queue( out )) {
@@ -692,7 +727,7 @@ int cq_rbilogin( in, out )
     int                        linelength, crlflength;
     char               username[UAM_USERNAMELEN + 1] = "\0";
     struct papd_comment        *comment = compeek();
-    char               uamtype[20] = "\0";
+    char               uamtype[20];
 
     for (;;) {
         switch ( markline( in, &start, &linelength, &crlflength )) {
@@ -701,6 +736,9 @@ int cq_rbilogin( in, out )
 
         case -1 :
             return( CH_MORE );
+
+        case -2 :
+            return( CH_ERROR );
         }
 
        stop = start + linelength;
@@ -709,13 +747,16 @@ int cq_rbilogin( in, out )
            begin = start + strlen(comment->c_begin);
            p = begin;
 
-           while (*p != ' ') {
+           while (*p != ' ' && p < stop) {
                p++;
            }
 
-           strncat(uamtype, begin, p - begin);
+           memset(uamtype, 0, sizeof(uamtype));
+           if ((size_t)(p -begin) <= sizeof(uamtype) -1) {
+               strncpy(uamtype, begin, p - begin);
+            }
 
-           if ((papd_uam = auth_uamfind(UAM_SERVER_PRINTAUTH,
+           if ( !*uamtype || (papd_uam = auth_uamfind(UAM_SERVER_PRINTAUTH,
                                uamtype, strlen(uamtype))) == NULL) {
                LOG(log_info, logtype_papd, "Could not find uam: %s", uamtype);
                append(out, rbiloginbad, strlen(rbiloginbad));