OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "update_engine/install_action.h" | 5 #include "update_engine/install_action.h" |
6 #include <errno.h> | 6 #include <errno.h> |
| 7 #include <string> |
7 #include <vector> | 8 #include <vector> |
8 #include <gflags/gflags.h> | 9 #include <gflags/gflags.h> |
9 #include "update_engine/filesystem_iterator.h" | 10 #include "update_engine/filesystem_iterator.h" |
10 #include "update_engine/gzip.h" | 11 #include "update_engine/gzip.h" |
11 #include "update_engine/subprocess.h" | 12 #include "update_engine/subprocess.h" |
12 #include "update_engine/utils.h" | 13 #include "update_engine/utils.h" |
13 | 14 |
14 DEFINE_string(mount_install_path, "", | 15 DEFINE_string(mount_install_path, "", |
15 "If set, the path to use when mounting the " | 16 "If set, the path to use when mounting the " |
16 "destination device during install"); | 17 "destination device during install"); |
17 | 18 |
| 19 using std::string; |
18 using std::vector; | 20 using std::vector; |
19 | 21 |
20 namespace chromeos_update_engine { | 22 namespace chromeos_update_engine { |
21 | 23 |
22 namespace { | 24 namespace { |
23 const string kBspatchPath = "/usr/bin/bspatch"; | 25 const string kBspatchPath = "/usr/bin/bspatch"; |
24 } | 26 } |
25 | 27 |
26 void InstallAction::PerformAction() { | 28 void InstallAction::PerformAction() { |
27 ScopedActionCompleter completer(processor_, this); | 29 ScopedActionCompleter completer(processor_, this); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 S_ISSOCK(file.mode())) { | 119 S_ISSOCK(file.mode())) { |
118 InstallFileSpecialFile(mountpoint, file, path, parser, exists); | 120 InstallFileSpecialFile(mountpoint, file, path, parser, exists); |
119 } else if (S_ISREG(file.mode())) { | 121 } else if (S_ISREG(file.mode())) { |
120 InstallFileRegularFile(mountpoint, file, path, parser, exists); | 122 InstallFileRegularFile(mountpoint, file, path, parser, exists); |
121 } else { | 123 } else { |
122 // unknown mode type | 124 // unknown mode type |
123 TEST_AND_RETURN_FALSE(false); | 125 TEST_AND_RETURN_FALSE(false); |
124 } | 126 } |
125 | 127 |
126 // chmod/chown new file | 128 // chmod/chown new file |
| 129 TEST_AND_RETURN_FALSE(file.has_uid() && file.has_gid()); |
| 130 TEST_AND_RETURN_FALSE_ERRNO(lchown((mountpoint + path).c_str(), |
| 131 file.uid(), file.gid()) == 0); |
127 if (!S_ISLNK(file.mode())) | 132 if (!S_ISLNK(file.mode())) |
128 TEST_AND_RETURN_FALSE_ERRNO(chmod((mountpoint + path).c_str(), file.mode()) | 133 TEST_AND_RETURN_FALSE_ERRNO(chmod((mountpoint + path).c_str(), file.mode()) |
129 == 0); | 134 == 0); |
130 TEST_AND_RETURN_FALSE(file.has_uid() && file.has_gid()); | |
131 TEST_AND_RETURN_FALSE_ERRNO(lchown((mountpoint + path).c_str(), | |
132 file.uid(), file.gid()) == 0); | |
133 return true; | 135 return true; |
134 } | 136 } |
135 | 137 |
136 bool InstallAction::InstallFileRegularFile( | 138 bool InstallAction::InstallFileRegularFile( |
137 const std::string& mountpoint, | 139 const std::string& mountpoint, |
138 const DeltaArchiveManifest_File& file, | 140 const DeltaArchiveManifest_File& file, |
139 const std::string& path, | 141 const std::string& path, |
140 const DeltaDiffParser& parser, | 142 const DeltaDiffParser& parser, |
141 const bool exists) const { | 143 const bool exists) const { |
142 if (!file.has_data_format()) | 144 if (!file.has_data_format()) |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 symlink_data = decompressed_symlink_data; | 251 symlink_data = decompressed_symlink_data; |
250 } | 252 } |
251 symlink_data.push_back('\0'); | 253 symlink_data.push_back('\0'); |
252 TEST_AND_RETURN_FALSE_ERRNO(symlink(&symlink_data[0], | 254 TEST_AND_RETURN_FALSE_ERRNO(symlink(&symlink_data[0], |
253 (mountpoint + path).c_str()) == 0); | 255 (mountpoint + path).c_str()) == 0); |
254 return true; | 256 return true; |
255 } | 257 } |
256 | 258 |
257 | 259 |
258 } // namespace chromeos_update_engine | 260 } // namespace chromeos_update_engine |
OLD | NEW |