Skip to content
This repository was archived by the owner on Jan 12, 2025. It is now read-only.

Commit 2ed0641

Browse files
author
Andrea Righi
committed
virtme-ng-init: fix build error with older versions of rustc
In older versions of rustc (such as 1.66.1) we can trigger the following build error: error[E0308]: mismatched types --> src/main.rs:632:20 | 632 | ("su", vec![&user, "-c", USER_SCRIPT]) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | expected slice, found array `[&str; 3]` | arguments to this function are incorrect | = note: expected struct `Box<[&String], _>` found struct `Box<[&str; 3], std::alloc::Global>` This happens becausee we are using a mixture of &String and &str types with the vec! macro. To prevent this make sure that the types match, by explicitly converting user to &str when creating the vector. Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
1 parent dcefa64 commit 2ed0641

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ fn run_user_script(uid: u32) {
629629
// Determine if we need to switch to a different user, or if we can run the script as root.
630630
let user = env::var("virtme_user").unwrap_or_else(|_| String::new());
631631
let (cmd, args) = if !user.is_empty() {
632-
("su", vec![&user, "-c", USER_SCRIPT])
632+
("su", vec![user.as_str(), "-c", USER_SCRIPT])
633633
} else {
634634
("/bin/sh", vec![USER_SCRIPT])
635635
};

0 commit comments

Comments
 (0)