[BACK]Return to sendbug.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / sendbug

Diff for /src/usr.bin/sendbug/sendbug.c between version 1.35 and 1.36

version 1.35, 2007/04/06 01:32:39 version 1.36, 2007/04/06 03:24:08
Line 29 
Line 29 
   
 #define _PATH_DMESG "/var/run/dmesg.boot"  #define _PATH_DMESG "/var/run/dmesg.boot"
   
   void    dmesg(FILE *);
 int     editit(char *);  int     editit(char *);
 void    init(void);  void    init(void);
 int     prompt(void);  int     prompt(void);
Line 133 
Line 134 
                 }                  }
         } else {          } else {
                 template(fp);                  template(fp);
                 if (!Dflag) {                  if (!Dflag)
                         char buf[BUFSIZ];                          dmesg(fp);
                         size_t len;  
                         FILE *dfp;  
   
                         dfp = fopen(_PATH_DMESG, "r");  
                         if (dfp == NULL) {  
                                 warn("can't read dmesg");  
                         } else {  
                                 fputs("\n"  
                                     "<dmesg is attached.>\n"  
                                     "<Feel free to delete or use the -D"  
                                     " flag if it contains sensitive "  
                                     "information.>\n", fp);  
                                 while (!feof(dfp)) {  
                                         len = fread(buf, 1, sizeof buf, dfp);  
                                         if (len == 0)  
                                                 break;  
                                         if (fwrite(buf, 1, len, fp) != len)  
                                                 break;  
                                 }  
                                 fclose(dfp);  
                         }  
                 }  
         }          }
   
         if (fflush(fp) == EOF || fstat(fd, &sb) == -1 || fclose(fp) == EOF)          if (fflush(fp) == EOF || fstat(fd, &sb) == -1 || fclose(fp) == EOF)
Line 192 
Line 171 
         ret = 0;          ret = 0;
 quit:  quit:
         return (ret);          return (ret);
   }
   
   void
   dmesg(FILE *fp)
   {
           char buf[BUFSIZ];
           FILE *dfp;
           off_t offset = -1;
   
           dfp = fopen(_PATH_DMESG, "r");
           if (dfp == NULL) {
                   warn("can't read dmesg");
                   return;
           }
   
           fputs("\n"
               "<dmesg is attached.>\n"
               "<Feel free to delete or use the -D flag if it contains "
               "sensitive information.>\n", fp);
           /* Find last line starting with "OpenBSD". */
           for (;;) {
                   off_t o;
   
                   o = ftello(dfp);
                   if (fgets(buf, sizeof(buf), dfp) == NULL)
                           break;
                   if (!strncmp("OpenBSD ", buf, sizeof("OpenBSD ") - 1))
                           offset = o;
           }
           if (offset != -1) {
                   size_t len;
   
                   clearerr(dfp);
                   fseeko(dfp, offset, SEEK_SET);
                   while (offset != -1 && !feof(dfp)) {
                           len = fread(buf, 1, sizeof buf, dfp);
                           if (len == 0)
                                   break;
                           if (fwrite(buf, 1, len, fp) != len)
                                   break;
                   }
           }
           fclose(dfp);
 }  }
   
 int  int

Legend:
Removed from v.1.35  
changed lines
  Added in v.1.36