Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(688)

Side by Side Diff: client/mac/sender/crash_report_sender.m

Issue 87013: Make breakpad compile against 10.5 SDK (Closed) Base URL: http://google-breakpad.googlecode.com/svn/trunk/src/
Patch Set: '' Created 11 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « client/mac/sender/crash_report_sender.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006, Google Inc. 1 // Copyright (c) 2006, Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
(...skipping 21 matching lines...) Expand all
32 #import <unistd.h> 32 #import <unistd.h>
33 33
34 #import <Cocoa/Cocoa.h> 34 #import <Cocoa/Cocoa.h>
35 #import <SystemConfiguration/SystemConfiguration.h> 35 #import <SystemConfiguration/SystemConfiguration.h>
36 36
37 #import "common/mac/HTTPMultipartUpload.h" 37 #import "common/mac/HTTPMultipartUpload.h"
38 38
39 #import "crash_report_sender.h" 39 #import "crash_report_sender.h"
40 #import "common/mac/GTMLogger.h" 40 #import "common/mac/GTMLogger.h"
41 41
42 #if VERBOSE
43 bool gDebugLog = true;
44 #else
45 bool gDebugLog = false;
46 #endif
47
42 #define kLastSubmission @"LastSubmission" 48 #define kLastSubmission @"LastSubmission"
43 const int kMinidumpFileLengthLimit = 800000; 49 const int kMinidumpFileLengthLimit = 800000;
44 50
45 #define kApplePrefsSyncExcludeAllKey @"com.apple.PreferenceSync.ExcludeAllSyncKe ys" 51 #define kApplePrefsSyncExcludeAllKey @"com.apple.PreferenceSync.ExcludeAllSyncKe ys"
46 52
47 @interface Reporter(PrivateMethods) 53 @interface Reporter(PrivateMethods)
48 + (uid_t)consoleUID; 54 + (uid_t)consoleUID;
49 55
50 - (id)initWithConfigurationFD:(int)fd; 56 - (id)initWithConfigurationFD:(int)fd;
51 57
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 - (void)dealloc { 696 - (void)dealloc {
691 [parameters_ release]; 697 [parameters_ release];
692 [minidumpContents_ release]; 698 [minidumpContents_ release];
693 [logFileData_ release]; 699 [logFileData_ release];
694 [super dealloc]; 700 [super dealloc];
695 } 701 }
696 @end 702 @end
697 703
698 //============================================================================= 704 //=============================================================================
699 int main(int argc, const char *argv[]) { 705 int main(int argc, const char *argv[]) {
706 DEBUGLOG(stderr, "Reporter Launched, argc=%d\n", argc);
700 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 707 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
701 // The expectation is that there will be one argument which is the path 708 // The expectation is that there will be one argument which is the path
702 // to the configuration file 709 // to the configuration file
703 if (argc != 2) { 710 if (argc != 2) {
704 exit(1); 711 exit(1);
705 } 712 }
706 713
707 // Open the file before (potentially) switching to console user 714 // Open the file before (potentially) switching to console user
708 int configFile = open(argv[1], O_RDONLY, 0600); 715 int configFile = open(argv[1], O_RDONLY, 0600);
709 716
717 if (configFile == -1) {
718 DEBUGLOG(stderr,
719 "Couldn't open config file %s - %s\n",
720 argv[1],
721 strerror(errno));
722 }
723
710 // we want to avoid a build-up of old config files even if they 724 // we want to avoid a build-up of old config files even if they
711 // have been incorrectly written by the framework 725 // have been incorrectly written by the framework
712 unlink(argv[1]); 726 unlink(argv[1]);
713 727
714 if (configFile == -1) { 728 if (configFile == -1) {
729 DEBUGLOG(stderr,
730 "Couldn't unlink config file %s - %s\n",
731 argv[1],
732 strerror(errno));
715 exit(1); 733 exit(1);
716 } 734 }
717 735
718 Reporter *reporter = [[Reporter alloc] initWithConfigurationFD:configFile]; 736 Reporter *reporter = [[Reporter alloc] initWithConfigurationFD:configFile];
719 737
720 // Gather the configuration data 738 // Gather the configuration data
721 if (![reporter readConfigurationData]) { 739 if (![reporter readConfigurationData]) {
740 DEBUGLOG(stderr, "reporter readConfigurationData failed\n");
722 exit(1); 741 exit(1);
723 } 742 }
724 743
725 // Read the minidump into memory before we (potentially) switch from the 744 // Read the minidump into memory before we (potentially) switch from the
726 // root user 745 // root user
727 [reporter readMinidumpData]; 746 [reporter readMinidumpData];
728 747
729 [reporter readLogFileData]; 748 [reporter readLogFileData];
730 749
731 // only submit a report if we have not recently crashed in the past 750 // only submit a report if we have not recently crashed in the past
732 BOOL shouldSubmitReport = [reporter shouldSubmitReport]; 751 BOOL shouldSubmitReport = [reporter shouldSubmitReport];
733 BOOL okayToSend = NO; 752 BOOL okayToSend = NO;
734 753
735 // ask user if we should send 754 // ask user if we should send
736 if (shouldSubmitReport) { 755 if (shouldSubmitReport) {
737 okayToSend = [reporter askUserPermissionToSend:shouldSubmitReport]; 756 okayToSend = [reporter askUserPermissionToSend:shouldSubmitReport];
738 } 757 }
739 758
740 // If we're running as root, switch over to nobody 759 // If we're running as root, switch over to nobody
741 if (getuid() == 0 || geteuid() == 0) { 760 if (getuid() == 0 || geteuid() == 0) {
742 struct passwd *pw = getpwnam("nobody"); 761 struct passwd *pw = getpwnam("nobody");
743 762
744 // If we can't get a non-root uid, don't send the report 763 // If we can't get a non-root uid, don't send the report
745 if (!pw) 764 if (!pw) {
765 DEBUGLOG(stderr, "!pw - %s\n", strerror(errno));
746 exit(0); 766 exit(0);
767 }
747 768
748 if (setgid(pw->pw_gid) == -1) 769 if (setgid(pw->pw_gid) == -1) {
770 DEBUGLOG(stderr, "setgid(pw->pw_gid) == -1 - %s\n", strerror(errno));
749 exit(0); 771 exit(0);
772 }
750 773
751 if (setuid(pw->pw_uid) == -1) 774 if (setuid(pw->pw_uid) == -1) {
775 DEBUGLOG(stderr, "setuid(pw->pw_uid) == -1 - %s\n", strerror(errno));
752 exit(0); 776 exit(0);
777 }
778 }
779 else {
780 DEBUGLOG(stderr, "getuid() !=0 || geteuid() != 0 \n");
753 } 781 }
754 782
755 if (okayToSend && shouldSubmitReport) { 783 if (okayToSend && shouldSubmitReport) {
784 DEBUGLOG(stderr, "Sending Report\n");
756 [reporter report]; 785 [reporter report];
786 DEBUGLOG(stderr, "Report Sent!\n");
787 } else {
788 DEBUGLOG(stderr, "Not sending crash report okayToSend=%d, "\
789 "shouldSubmitReport=%d\n", okayToSend, shouldSubmitReport);
757 } 790 }
758 791
759 // Cleanup 792 // Cleanup
760 [reporter release]; 793 [reporter release];
761 [pool release]; 794 [pool release];
762 795
796 DEBUGLOG(stderr, "Exiting with no errors\n");
763 return 0; 797 return 0;
764 } 798 }
OLDNEW
« no previous file with comments | « client/mac/sender/crash_report_sender.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698