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

Side by Side Diff: service.cc

Issue 6598009: Deprecating tracked_directories as a Vault parameter (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/cryptohome.git@master
Patch Set: Created 9 years, 10 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
« service.h ('K') | « service.h ('k') | vault_keyset.proto » ('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) 2009 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium OS 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 "service.h" 5 #include "service.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 9
10 #include <base/file_util.h> 10 #include <base/file_util.h>
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 } 326 }
327 327
328 gboolean Service::IsMounted(gboolean *OUT_is_mounted, GError **error) { 328 gboolean Service::IsMounted(gboolean *OUT_is_mounted, GError **error) {
329 *OUT_is_mounted = mount_->IsCryptohomeMounted(); 329 *OUT_is_mounted = mount_->IsCryptohomeMounted();
330 return TRUE; 330 return TRUE;
331 } 331 }
332 332
333 gboolean Service::Mount(gchar *userid, 333 gboolean Service::Mount(gchar *userid,
334 gchar *key, 334 gchar *key,
335 gboolean create_if_missing, 335 gboolean create_if_missing,
336 gboolean replace_tracked_subdirectories, 336 gboolean deprecated_replace_tracked_subdirectories,
337 gchar** tracked_subdirectories, 337 gchar** deprecated_tracked_subdirectories,
338 gint *OUT_error_code, 338 gint *OUT_error_code,
339 gboolean *OUT_result, 339 gboolean *OUT_result,
340 GError **error) { 340 GError **error) {
341 UsernamePasskey credentials(userid, SecureBlob(key, strlen(key))); 341 UsernamePasskey credentials(userid, SecureBlob(key, strlen(key)));
342 342
343 if (mount_->IsCryptohomeMounted()) { 343 if (mount_->IsCryptohomeMounted()) {
344 if (mount_->IsCryptohomeMountedForUser(credentials)) { 344 if (mount_->IsCryptohomeMountedForUser(credentials)) {
345 LOG(INFO) << "Cryptohome already mounted for this user"; 345 LOG(INFO) << "Cryptohome already mounted for this user";
346 *OUT_error_code = Mount::MOUNT_ERROR_NONE; 346 *OUT_error_code = Mount::MOUNT_ERROR_NONE;
347 *OUT_result = TRUE; 347 *OUT_result = TRUE;
348 return TRUE; 348 return TRUE;
349 } else { 349 } else {
350 if (!mount_->UnmountCryptohome()) { 350 if (!mount_->UnmountCryptohome()) {
351 LOG(ERROR) << "Could not unmount cryptohome from previous user"; 351 LOG(ERROR) << "Could not unmount cryptohome from previous user";
352 *OUT_error_code = Mount::MOUNT_ERROR_MOUNT_POINT_BUSY; 352 *OUT_error_code = Mount::MOUNT_ERROR_MOUNT_POINT_BUSY;
353 *OUT_result = FALSE; 353 *OUT_result = FALSE;
354 return TRUE; 354 return TRUE;
355 } 355 }
356 } 356 }
357 } 357 }
358 358
359 MountTaskResult result; 359 MountTaskResult result;
360 base::WaitableEvent event(true, false); 360 base::WaitableEvent event(true, false);
361 Mount::MountArgs mount_args; 361 Mount::MountArgs mount_args;
362 mount_args.create_if_missing = create_if_missing; 362 mount_args.create_if_missing = create_if_missing;
363 mount_args.replace_tracked_subdirectories = replace_tracked_subdirectories;
364 if (tracked_subdirectories) {
365 mount_args.AssignSubdirsNullTerminatedList(
366 const_cast<const char**>(tracked_subdirectories));
367 }
368 MountTaskMount* mount_task = new MountTaskMount(NULL, 363 MountTaskMount* mount_task = new MountTaskMount(NULL,
369 mount_, 364 mount_,
370 credentials, 365 credentials,
371 mount_args); 366 mount_args);
372 mount_task->set_result(&result); 367 mount_task->set_result(&result);
373 mount_task->set_complete_event(&event); 368 mount_task->set_complete_event(&event);
374 mount_thread_.message_loop()->PostTask(FROM_HERE, mount_task); 369 mount_thread_.message_loop()->PostTask(FROM_HERE, mount_task);
375 event.Wait(); 370 event.Wait();
376 *OUT_error_code = result.return_code(); 371 *OUT_error_code = result.return_code();
377 *OUT_result = result.return_status(); 372 *OUT_result = result.return_status();
378 return TRUE; 373 return TRUE;
379 } 374 }
380 375
381 gboolean Service::AsyncMount(gchar *userid, 376 gboolean Service::AsyncMount(gchar *userid,
382 gchar *key, 377 gchar *key,
383 gboolean create_if_missing, 378 gboolean create_if_missing,
384 gboolean replace_tracked_subdirectories, 379 gboolean deprecated_replace_tracked_subdirectories,
385 gchar** tracked_subdirectories, 380 gchar** deprecated_tracked_subdirectories,
386 gint *OUT_async_id, 381 gint *OUT_async_id,
387 GError **error) { 382 GError **error) {
388 UsernamePasskey credentials(userid, SecureBlob(key, strlen(key))); 383 UsernamePasskey credentials(userid, SecureBlob(key, strlen(key)));
389 384
390 if (mount_->IsCryptohomeMounted()) { 385 if (mount_->IsCryptohomeMounted()) {
391 if (mount_->IsCryptohomeMountedForUser(credentials)) { 386 if (mount_->IsCryptohomeMountedForUser(credentials)) {
392 LOG(INFO) << "Cryptohome already mounted for this user"; 387 LOG(INFO) << "Cryptohome already mounted for this user";
393 MountTaskNop* mount_task = new MountTaskNop(this); 388 MountTaskNop* mount_task = new MountTaskNop(this);
394 mount_task->result()->set_return_code(Mount::MOUNT_ERROR_NONE); 389 mount_task->result()->set_return_code(Mount::MOUNT_ERROR_NONE);
395 mount_task->result()->set_return_status(true); 390 mount_task->result()->set_return_status(true);
396 *OUT_async_id = mount_task->sequence_id(); 391 *OUT_async_id = mount_task->sequence_id();
397 mount_thread_.message_loop()->PostTask(FROM_HERE, mount_task); 392 mount_thread_.message_loop()->PostTask(FROM_HERE, mount_task);
398 return TRUE; 393 return TRUE;
399 } else { 394 } else {
400 if (!mount_->UnmountCryptohome()) { 395 if (!mount_->UnmountCryptohome()) {
401 LOG(ERROR) << "Could not unmount cryptohome from previous user"; 396 LOG(ERROR) << "Could not unmount cryptohome from previous user";
402 MountTaskNop* mount_task = new MountTaskNop(this); 397 MountTaskNop* mount_task = new MountTaskNop(this);
403 mount_task->result()->set_return_code( 398 mount_task->result()->set_return_code(
404 Mount::MOUNT_ERROR_MOUNT_POINT_BUSY); 399 Mount::MOUNT_ERROR_MOUNT_POINT_BUSY);
405 mount_task->result()->set_return_status(false); 400 mount_task->result()->set_return_status(false);
406 *OUT_async_id = mount_task->sequence_id(); 401 *OUT_async_id = mount_task->sequence_id();
407 mount_thread_.message_loop()->PostTask(FROM_HERE, mount_task); 402 mount_thread_.message_loop()->PostTask(FROM_HERE, mount_task);
408 return TRUE; 403 return TRUE;
409 } 404 }
410 } 405 }
411 } 406 }
412 407
413 Mount::MountArgs mount_args; 408 Mount::MountArgs mount_args;
414 mount_args.create_if_missing = create_if_missing; 409 mount_args.create_if_missing = create_if_missing;
415 mount_args.replace_tracked_subdirectories = replace_tracked_subdirectories;
416 if (tracked_subdirectories) {
417 mount_args.AssignSubdirsNullTerminatedList(
418 const_cast<const char**>(tracked_subdirectories));
419 }
420 MountTaskMount* mount_task = new MountTaskMount(this, 410 MountTaskMount* mount_task = new MountTaskMount(this,
421 mount_, 411 mount_,
422 credentials, 412 credentials,
423 mount_args); 413 mount_args);
424 *OUT_async_id = mount_task->sequence_id(); 414 *OUT_async_id = mount_task->sequence_id();
425 mount_thread_.message_loop()->PostTask(FROM_HERE, mount_task); 415 mount_thread_.message_loop()->PostTask(FROM_HERE, mount_task);
426 return TRUE; 416 return TRUE;
427 } 417 }
428 418
429 gboolean Service::MountGuest(gint *OUT_error_code, 419 gboolean Service::MountGuest(gint *OUT_error_code,
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 (tpm_status.CanDecrypt ? "1" : "0"), 625 (tpm_status.CanDecrypt ? "1" : "0"),
636 (tpm_status.ThisInstanceHasContext ? "1" : "0"), 626 (tpm_status.ThisInstanceHasContext ? "1" : "0"),
637 (tpm_status.ThisInstanceHasKeyHandle ? "1" : "0"), 627 (tpm_status.ThisInstanceHasKeyHandle ? "1" : "0"),
638 tpm_status.LastTpmError, 628 tpm_status.LastTpmError,
639 user_data.c_str(), 629 user_data.c_str(),
640 (mount_->IsCryptohomeMounted() ? "1" : "0")); 630 (mount_->IsCryptohomeMounted() ? "1" : "0"));
641 return TRUE; 631 return TRUE;
642 } 632 }
643 633
644 } // namespace cryptohome 634 } // namespace cryptohome
OLDNEW
« service.h ('K') | « service.h ('k') | vault_keyset.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698