Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mostlikelee committed Dec 5, 2024
1 parent 20ca2aa commit 69dba04
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 60 deletions.
3 changes: 0 additions & 3 deletions orbit/pkg/dialog/dialog.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,4 @@ type ProgressOptions struct {

// Text sets the text of the dialog.
Text string

// Value sets the percentage of the progress bar (0-100).
Value int
}
10 changes: 1 addition & 9 deletions orbit/pkg/execuser/execuser.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
package execuser

import (
"context"
"io"
"time"
)
Expand Down Expand Up @@ -32,6 +31,7 @@ func WithArg(name, value string) Option {
}
}

// WithTimeout sets the timeout for the application. Currently only supported on Linux.
func WithTimeout(duration time.Duration) Option {
return func(a *eopts) {
a.timeout = duration
Expand Down Expand Up @@ -70,11 +70,3 @@ func RunWithStdin(path string, opts ...Option) (io.WriteCloser, error) {
}
return runWithStdin(path, o)
}

func RunWithContext(ctx context.Context, path string, opts ...Option) error {
var o eopts
for _, fn := range opts {
fn(&o)
}
return runWithContext(ctx, path, o)
}
5 changes: 0 additions & 5 deletions orbit/pkg/execuser/execuser_darwin.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package execuser

import (
"context"
"errors"
"fmt"
"io"
Expand Down Expand Up @@ -59,7 +58,3 @@ func runWithOutput(path string, opts eopts) (output []byte, exitCode int, err er
func runWithStdin(path string, opts eopts) (io.WriteCloser, error) {
return nil, errors.New("not implemented")
}

func runWithContext(ctx context.Context, path string, opts eopts) error {
return errors.New("not implemented")
}
36 changes: 0 additions & 36 deletions orbit/pkg/execuser/execuser_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package execuser
import (
"bufio"
"bytes"
"context"
"errors"
"fmt"
"io"
Expand Down Expand Up @@ -50,41 +49,6 @@ func run(path string, opts eopts) (lastLogs string, err error) {
return "", nil
}

// run uses sudo to run the given path as login user.
func runWithContext(ctx context.Context, path string, opts eopts) error {
args, err := getUserAndDisplayArgs(path, opts)
if err != nil {
return fmt.Errorf("get args: %w", err)
}

args = append(args, path)

if len(opts.args) > 0 {
for _, arg := range opts.args {
args = append(args, arg[0], arg[1])
}
}

cmd := exec.CommandContext(ctx, "sudo", args...)
cmd.Stderr = os.Stderr
cmd.Stdout = os.Stdout
log.Printf("cmd=%s", cmd.String())

if err := cmd.Start(); err != nil {
return fmt.Errorf("open path %q: %w", path, err)
}

// Wait for the process to finish.
if err := cmd.Wait(); err != nil {
if exitErr, ok := err.(*exec.ExitError); ok {
return fmt.Errorf("%q exited with code %d: %w", path, exitErr.ExitCode(), err)
}
return fmt.Errorf("%q error: %w", path, err)
}

return nil
}

// run uses sudo to run the given path as login user and waits for the process to finish.
func runWithOutput(path string, opts eopts) (output []byte, exitCode int, err error) {
args, err := getUserAndDisplayArgs(path, opts)
Expand Down
5 changes: 0 additions & 5 deletions orbit/pkg/execuser/execuser_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package execuser
// To view what was modified/added, you can use the execuser_windows_diff.sh script.

import (
"context"
"errors"
"fmt"
"io"
Expand Down Expand Up @@ -127,10 +126,6 @@ func runWithStdin(path string, opts eopts) (io.WriteCloser, error) {
return nil, errors.New("not implemented")
}

func runWithContext(ctx context.Context, path string, opts eopts) error {
return errors.New("not implemented")
}

// getCurrentUserSessionId will attempt to resolve
// the session ID of the user currently active on
// the system.
Expand Down
4 changes: 2 additions & 2 deletions tools/luks/luks/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func main() {
prompt := zenity.New()

// Prompt existing passphrase from the user.
currentPassphrase, err := prompt.ShowEntry(context.Background(), dialog.EntryOptions{
currentPassphrase, err := prompt.ShowEntry(dialog.EntryOptions{
Title: "Enter Existing LUKS Passphrase",
Text: "Enter your existing LUKS passphrase:",
HideText: true,
Expand All @@ -49,7 +49,7 @@ func main() {

if err := device.AddKey(context.Background(), devicePath, userKey, escrowKey); err != nil {
if errors.Is(err, encryption.ErrEncryptionKeyRejected) {
currentPassphrase, err = prompt.ShowEntry(context.Background(), dialog.EntryOptions{
currentPassphrase, err = prompt.ShowEntry(dialog.EntryOptions{
Title: "Enter Existing LUKS Passphrase",
Text: "Bad password. Enter your existing LUKS passphrase:",
HideText: true,
Expand Down

0 comments on commit 69dba04

Please sign in to comment.