summaryrefslogtreecommitdiffstats
path: root/sdcard
diff options
context:
space:
mode:
authorRichard Uhler2017-09-14 09:49:19 -0500
committerAndreas Gampe2017-09-22 11:03:18 -0500
commitf09f965f9fe2c19a8b93d457a6a75a026be757b2 (patch)
treeb3a95694a1d9ca798ed581cf068d3ef2bdb32e0d /sdcard
parent7178e29c22ea448a5118397cc31160f9f097291a (diff)
downloadplatform-system-core-f09f965f9fe2c19a8b93d457a6a75a026be757b2.tar.gz
platform-system-core-f09f965f9fe2c19a8b93d457a6a75a026be757b2.tar.xz
platform-system-core-f09f965f9fe2c19a8b93d457a6a75a026be757b2.zip
Revert "Add derive_gid flag for mounting sdcardfs"
This reverts commit 8ca02bbeb54bed3057414d12624da5a02fa4d3be. Causes boot loop on bullhead. (cherry picked from commit 28dbcaa23bde48fba22c9b7874f659de2630148c) Bug: 63245673 Bug: 65660058 Test: m Merged-In: Ife5f83ebf56fb956e5015d2797b5b47a515ec171 Change-Id: Ife5f83ebf56fb956e5015d2797b5b47a515ec171
Diffstat (limited to 'sdcard')
-rw-r--r--sdcard/sdcard.cpp60
1 files changed, 20 insertions, 40 deletions
diff --git a/sdcard/sdcard.cpp b/sdcard/sdcard.cpp
index 77d5a91f1..343a90356 100644
--- a/sdcard/sdcard.cpp
+++ b/sdcard/sdcard.cpp
@@ -319,31 +319,17 @@ static void run(const char* source_path, const char* label, uid_t uid,
319 LOG(FATAL) << "terminated prematurely"; 319 LOG(FATAL) << "terminated prematurely";
320} 320}
321 321
322static bool sdcardfs_setup(const std::string& source_path, const std::string& dest_path, 322static bool sdcardfs_setup(const std::string& source_path, const std::string& dest_path, uid_t fsuid,
323 uid_t fsuid, gid_t fsgid, bool multi_user, userid_t userid, gid_t gid, 323 gid_t fsgid, bool multi_user, userid_t userid, gid_t gid, mode_t mask) {
324 mode_t mask, bool derive_gid) { 324 std::string opts = android::base::StringPrintf("fsuid=%d,fsgid=%d,%smask=%d,userid=%d,gid=%d",
325 std::string opts = android::base::StringPrintf( 325 fsuid, fsgid, multi_user?"multiuser,":"", mask, userid, gid);
326 "fsuid=%d,fsgid=%d,%s%smask=%d,userid=%d,gid=%d", fsuid, fsgid,
327 multi_user ? "multiuser," : "", derive_gid ? "derive_gid," : "", mask, userid, gid);
328 326
329 if (mount(source_path.c_str(), dest_path.c_str(), "sdcardfs", 327 if (mount(source_path.c_str(), dest_path.c_str(), "sdcardfs",
330 MS_NOSUID | MS_NODEV | MS_NOEXEC | MS_NOATIME, opts.c_str()) == -1) { 328 MS_NOSUID | MS_NODEV | MS_NOEXEC | MS_NOATIME, opts.c_str()) == -1) {
331 if (derive_gid) { 329 PLOG(ERROR) << "failed to mount sdcardfs filesystem";
332 PLOG(ERROR) << "trying to mount sdcardfs filesystem without derive_gid"; 330 return false;
333 /* Maybe this isn't supported on this kernel. Try without. */
334 opts = android::base::StringPrintf("fsuid=%d,fsgid=%d,%smask=%d,userid=%d,gid=%d",
335 fsuid, fsgid, multi_user ? "multiuser," : "", mask,
336 userid, gid);
337 if (mount(source_path.c_str(), dest_path.c_str(), "sdcardfs",
338 MS_NOSUID | MS_NODEV | MS_NOEXEC | MS_NOATIME, opts.c_str()) == -1) {
339 PLOG(ERROR) << "failed to mount sdcardfs filesystem";
340 return false;
341 }
342 } else {
343 PLOG(ERROR) << "failed to mount sdcardfs filesystem";
344 return false;
345 }
346 } 331 }
332
347 return true; 333 return true;
348} 334}
349 335
@@ -369,8 +355,7 @@ static bool sdcardfs_setup_bind_remount(const std::string& source_path, const st
369} 355}
370 356
371static void run_sdcardfs(const std::string& source_path, const std::string& label, uid_t uid, 357static void run_sdcardfs(const std::string& source_path, const std::string& label, uid_t uid,
372 gid_t gid, userid_t userid, bool multi_user, bool full_write, 358 gid_t gid, userid_t userid, bool multi_user, bool full_write) {
373 bool derive_gid) {
374 std::string dest_path_default = "/mnt/runtime/default/" + label; 359 std::string dest_path_default = "/mnt/runtime/default/" + label;
375 std::string dest_path_read = "/mnt/runtime/read/" + label; 360 std::string dest_path_read = "/mnt/runtime/read/" + label;
376 std::string dest_path_write = "/mnt/runtime/write/" + label; 361 std::string dest_path_write = "/mnt/runtime/write/" + label;
@@ -380,10 +365,10 @@ static void run_sdcardfs(const std::string& source_path, const std::string& labe
380 // Multi-user storage is fully isolated per user, so "other" 365 // Multi-user storage is fully isolated per user, so "other"
381 // permissions are completely masked off. 366 // permissions are completely masked off.
382 if (!sdcardfs_setup(source_path, dest_path_default, uid, gid, multi_user, userid, 367 if (!sdcardfs_setup(source_path, dest_path_default, uid, gid, multi_user, userid,
383 AID_SDCARD_RW, 0006, derive_gid) || 368 AID_SDCARD_RW, 0006)
384 !sdcardfs_setup_bind_remount(dest_path_default, dest_path_read, AID_EVERYBODY, 0027) || 369 || !sdcardfs_setup_bind_remount(dest_path_default, dest_path_read, AID_EVERYBODY, 0027)
385 !sdcardfs_setup_bind_remount(dest_path_default, dest_path_write, AID_EVERYBODY, 370 || !sdcardfs_setup_bind_remount(dest_path_default, dest_path_write,
386 full_write ? 0007 : 0027)) { 371 AID_EVERYBODY, full_write ? 0007 : 0027)) {
387 LOG(FATAL) << "failed to sdcardfs_setup"; 372 LOG(FATAL) << "failed to sdcardfs_setup";
388 } 373 }
389 } else { 374 } else {
@@ -391,11 +376,11 @@ static void run_sdcardfs(const std::string& source_path, const std::string& labe
391 // the Android directories are masked off to a single user 376 // the Android directories are masked off to a single user
392 // deep inside attr_from_stat(). 377 // deep inside attr_from_stat().
393 if (!sdcardfs_setup(source_path, dest_path_default, uid, gid, multi_user, userid, 378 if (!sdcardfs_setup(source_path, dest_path_default, uid, gid, multi_user, userid,
394 AID_SDCARD_RW, 0006, derive_gid) || 379 AID_SDCARD_RW, 0006)
395 !sdcardfs_setup_bind_remount(dest_path_default, dest_path_read, AID_EVERYBODY, 380 || !sdcardfs_setup_bind_remount(dest_path_default, dest_path_read,
396 full_write ? 0027 : 0022) || 381 AID_EVERYBODY, full_write ? 0027 : 0022)
397 !sdcardfs_setup_bind_remount(dest_path_default, dest_path_write, AID_EVERYBODY, 382 || !sdcardfs_setup_bind_remount(dest_path_default, dest_path_write,
398 full_write ? 0007 : 0022)) { 383 AID_EVERYBODY, full_write ? 0007 : 0022)) {
399 LOG(FATAL) << "failed to sdcardfs_setup"; 384 LOG(FATAL) << "failed to sdcardfs_setup";
400 } 385 }
401 } 386 }
@@ -452,8 +437,7 @@ static int usage() {
452 << " -g: specify GID to run as" 437 << " -g: specify GID to run as"
453 << " -U: specify user ID that owns device" 438 << " -U: specify user ID that owns device"
454 << " -m: source_path is multi-user" 439 << " -m: source_path is multi-user"
455 << " -w: runtime write mount has full write access" 440 << " -w: runtime write mount has full write access";
456 << " -P preserve owners on the lower file system";
457 return 1; 441 return 1;
458} 442}
459 443
@@ -465,13 +449,12 @@ int main(int argc, char **argv) {
465 userid_t userid = 0; 449 userid_t userid = 0;
466 bool multi_user = false; 450 bool multi_user = false;
467 bool full_write = false; 451 bool full_write = false;
468 bool derive_gid = false;
469 int i; 452 int i;
470 struct rlimit rlim; 453 struct rlimit rlim;
471 int fs_version; 454 int fs_version;
472 455
473 int opt; 456 int opt;
474 while ((opt = getopt(argc, argv, "u:g:U:mwG")) != -1) { 457 while ((opt = getopt(argc, argv, "u:g:U:mw")) != -1) {
475 switch (opt) { 458 switch (opt) {
476 case 'u': 459 case 'u':
477 uid = strtoul(optarg, NULL, 10); 460 uid = strtoul(optarg, NULL, 10);
@@ -488,9 +471,6 @@ int main(int argc, char **argv) {
488 case 'w': 471 case 'w':
489 full_write = true; 472 full_write = true;
490 break; 473 break;
491 case 'G':
492 derive_gid = true;
493 break;
494 case '?': 474 case '?':
495 default: 475 default:
496 return usage(); 476 return usage();
@@ -534,7 +514,7 @@ int main(int argc, char **argv) {
534 } 514 }
535 515
536 if (should_use_sdcardfs()) { 516 if (should_use_sdcardfs()) {
537 run_sdcardfs(source_path, label, uid, gid, userid, multi_user, full_write, derive_gid); 517 run_sdcardfs(source_path, label, uid, gid, userid, multi_user, full_write);
538 } else { 518 } else {
539 run(source_path, label, uid, gid, userid, multi_user, full_write); 519 run(source_path, label, uid, gid, userid, multi_user, full_write);
540 } 520 }