Skip to content

Commit 2a786b0

Browse files
committed
cvd checks user is in cvdnetwork and kvm groups
cvd can't access/setup the cvd directory (/var/tmp/cvd) if the user is not a meber of the cvdnetwork group. If the user is not a member of kvm it won't be able to launch devices. Bug: b/444230097
1 parent 6dc5ac0 commit 2a786b0

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

base/cvd/cuttlefish/host/commands/cvd/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ cf_cc_binary(
3636
"//cuttlefish/common/libs/utils:subprocess",
3737
"//cuttlefish/host/commands/cvd/utils",
3838
"//cuttlefish/host/commands/cvd/version",
39+
"//cuttlefish/host/libs/vm_manager",
3940
"//libbase",
4041
"//libsparse",
4142
"@fmt",

base/cvd/cuttlefish/host/commands/cvd/main.cc

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
#include <iostream>
2424
#include <string>
2525
#include <unordered_map>
26-
#include <utility>
2726
#include <vector>
2827

28+
#include <fmt/format.h>
2929
#include <android-base/file.h>
3030
#include <android-base/logging.h>
3131
#include <android-base/scopeguard.h>
@@ -39,6 +39,7 @@
3939
#include "cuttlefish/host/commands/cvd/cvd.h"
4040
#include "cuttlefish/host/commands/cvd/utils/common.h"
4141
#include "cuttlefish/host/commands/cvd/version/version.h"
42+
#include "cuttlefish/host/libs/vm_manager/host_configuration.h"
4243
// TODO(315772518) Re-enable once metrics send is reenabled
4344
// #include "cuttlefish/host/commands/cvd/metrics/cvd_metrics_api.h"
4445

@@ -190,6 +191,22 @@ std::string ColoredUrl(const std::string& url) {
190191
return output;
191192
}
192193

194+
bool ValidateHostConfiguration() {
195+
// Validate the host before attempting to access directories.
196+
std::vector<std::string> config_commands;
197+
bool valid = vm_manager::ValidateHostConfiguration(&config_commands);
198+
if (!valid) {
199+
std::cerr << "Validation of host configuration failed." << std::endl;
200+
std::cerr << "Execute the following commands:" << std::endl;
201+
for (const auto& cmd : config_commands) {
202+
std::cerr << " " << cmd << std::endl;
203+
}
204+
std::cerr << "You may need to logout for the changes to take effect"
205+
<< std::endl;
206+
}
207+
return valid;
208+
}
209+
193210
} // namespace
194211
} // namespace cuttlefish
195212

@@ -202,6 +219,9 @@ int main(int argc, char** argv, char** envp) {
202219
// set verbosity for this process
203220
cuttlefish::SetMinimumVerbosity(verbosity);
204221

222+
if (!cuttlefish::ValidateHostConfiguration()) {
223+
return -1;
224+
}
205225
auto result = cuttlefish::CvdMain(argc, argv, envp);
206226
if (result.ok()) {
207227
return 0;

0 commit comments

Comments
 (0)