This commit is contained in:
@@ -82,7 +82,7 @@ func (s *Service) execCommand(name string, args ...string) (string, error) {
|
|||||||
if err != nil && useSudo {
|
if err != nil && useSudo {
|
||||||
// Log that sudo failed
|
// Log that sudo failed
|
||||||
log.Printf("sudo command failed, trying direct execution: %s %v (error: %v, stderr: %s)", name, args, err, stderr.String())
|
log.Printf("sudo command failed, trying direct execution: %s %v (error: %v, stderr: %s)", name, args, err, stderr.String())
|
||||||
|
|
||||||
// If sudo failed, try running the command directly
|
// If sudo failed, try running the command directly
|
||||||
// (user might already have permissions or be root)
|
// (user might already have permissions or be root)
|
||||||
directCmd := exec.Command(name, args...)
|
directCmd := exec.Command(name, args...)
|
||||||
@@ -90,7 +90,8 @@ func (s *Service) execCommand(name string, args ...string) (string, error) {
|
|||||||
directCmd.Stdout = &directStdout
|
directCmd.Stdout = &directStdout
|
||||||
directCmd.Stderr = &directStderr
|
directCmd.Stderr = &directStderr
|
||||||
|
|
||||||
if directErr := directCmd.Run(); directErr == nil {
|
directErr := directCmd.Run()
|
||||||
|
if directErr == nil {
|
||||||
// Direct execution succeeded, return that result
|
// Direct execution succeeded, return that result
|
||||||
log.Printf("direct command execution succeeded (without sudo)")
|
log.Printf("direct command execution succeeded (without sudo)")
|
||||||
return strings.TrimSpace(directStdout.String()), nil
|
return strings.TrimSpace(directStdout.String()), nil
|
||||||
@@ -231,7 +232,7 @@ func (s *Service) CreatePool(name string, vdevs []string, options map[string]str
|
|||||||
}
|
}
|
||||||
|
|
||||||
args = append(args, name)
|
args = append(args, name)
|
||||||
|
|
||||||
// Normalize vdev paths - ensure they start with /dev/ if they don't already
|
// Normalize vdev paths - ensure they start with /dev/ if they don't already
|
||||||
normalizedVdevs := make([]string, 0, len(vdevs))
|
normalizedVdevs := make([]string, 0, len(vdevs))
|
||||||
for _, vdev := range vdevs {
|
for _, vdev := range vdevs {
|
||||||
@@ -245,11 +246,11 @@ func (s *Service) CreatePool(name string, vdevs []string, options map[string]str
|
|||||||
}
|
}
|
||||||
normalizedVdevs = append(normalizedVdevs, vdev)
|
normalizedVdevs = append(normalizedVdevs, vdev)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(normalizedVdevs) == 0 {
|
if len(normalizedVdevs) == 0 {
|
||||||
return fmt.Errorf("no valid vdevs provided after normalization")
|
return fmt.Errorf("no valid vdevs provided after normalization")
|
||||||
}
|
}
|
||||||
|
|
||||||
args = append(args, normalizedVdevs...)
|
args = append(args, normalizedVdevs...)
|
||||||
|
|
||||||
// Log the command we're about to run for debugging
|
// Log the command we're about to run for debugging
|
||||||
|
|||||||
Reference in New Issue
Block a user