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

Side by Side Diff: chrome/browser/shell_integration_linux.cc

Issue 100253002: Don't HANDLE_EINTR(close). Either IGNORE_EINTR(close) or just close. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years 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 | « chrome/browser/process_singleton_mac.cc ('k') | chrome/common/multi_process_lock_linux.cc » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/shell_integration_linux.h" 5 #include "chrome/browser/shell_integration_linux.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <glib.h> 8 #include <glib.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <sys/stat.h> 10 #include <sys/stat.h>
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 return false; 140 return false;
141 141
142 int desktop_fd = open(desktop_path.value().c_str(), O_RDONLY | O_DIRECTORY); 142 int desktop_fd = open(desktop_path.value().c_str(), O_RDONLY | O_DIRECTORY);
143 if (desktop_fd < 0) 143 if (desktop_fd < 0)
144 return false; 144 return false;
145 145
146 int fd = openat(desktop_fd, shortcut_filename.value().c_str(), 146 int fd = openat(desktop_fd, shortcut_filename.value().c_str(),
147 O_CREAT | O_EXCL | O_WRONLY, 147 O_CREAT | O_EXCL | O_WRONLY,
148 S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); 148 S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
149 if (fd < 0) { 149 if (fd < 0) {
150 if (HANDLE_EINTR(close(desktop_fd)) < 0) 150 if (IGNORE_EINTR(close(desktop_fd)) < 0)
151 PLOG(ERROR) << "close"; 151 PLOG(ERROR) << "close";
152 return false; 152 return false;
153 } 153 }
154 154
155 ssize_t bytes_written = file_util::WriteFileDescriptor(fd, contents.data(), 155 ssize_t bytes_written = file_util::WriteFileDescriptor(fd, contents.data(),
156 contents.length()); 156 contents.length());
157 if (HANDLE_EINTR(close(fd)) < 0) 157 if (IGNORE_EINTR(close(fd)) < 0)
158 PLOG(ERROR) << "close"; 158 PLOG(ERROR) << "close";
159 159
160 if (bytes_written != static_cast<ssize_t>(contents.length())) { 160 if (bytes_written != static_cast<ssize_t>(contents.length())) {
161 // Delete the file. No shortuct is better than corrupted one. Use unlinkat 161 // Delete the file. No shortuct is better than corrupted one. Use unlinkat
162 // to make sure we're deleting the file in the directory we think we are. 162 // to make sure we're deleting the file in the directory we think we are.
163 // Even if an attacker manager to put something other at 163 // Even if an attacker manager to put something other at
164 // |shortcut_filename| we'll just undo his action. 164 // |shortcut_filename| we'll just undo his action.
165 unlinkat(desktop_fd, shortcut_filename.value().c_str(), 0); 165 unlinkat(desktop_fd, shortcut_filename.value().c_str(), 0);
166 } 166 }
167 167
168 if (HANDLE_EINTR(close(desktop_fd)) < 0) 168 if (IGNORE_EINTR(close(desktop_fd)) < 0)
169 PLOG(ERROR) << "close"; 169 PLOG(ERROR) << "close";
170 170
171 return true; 171 return true;
172 } 172 }
173 173
174 void DeleteShortcutOnDesktop(const base::FilePath& shortcut_filename) { 174 void DeleteShortcutOnDesktop(const base::FilePath& shortcut_filename) {
175 base::FilePath desktop_path; 175 base::FilePath desktop_path;
176 if (PathService::Get(base::DIR_USER_DESKTOP, &desktop_path)) 176 if (PathService::Get(base::DIR_USER_DESKTOP, &desktop_path))
177 base::DeleteFile(desktop_path.Append(shortcut_filename), false); 177 base::DeleteFile(desktop_path.Append(shortcut_filename), false);
178 } 178 }
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 for (std::vector<base::FilePath>::const_iterator it = 953 for (std::vector<base::FilePath>::const_iterator it =
954 shortcut_filenames_app_menu.begin(); 954 shortcut_filenames_app_menu.begin();
955 it != shortcut_filenames_app_menu.end(); ++it) { 955 it != shortcut_filenames_app_menu.end(); ++it) {
956 DeleteShortcutInApplicationsMenu(*it, 956 DeleteShortcutInApplicationsMenu(*it,
957 base::FilePath(kDirectoryFilename)); 957 base::FilePath(kDirectoryFilename));
958 } 958 }
959 } 959 }
960 } 960 }
961 961
962 } // namespace ShellIntegrationLinux 962 } // namespace ShellIntegrationLinux
OLDNEW
« no previous file with comments | « chrome/browser/process_singleton_mac.cc ('k') | chrome/common/multi_process_lock_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698