Skip to content

Commit 4b66399

Browse files
committed
remove ssh accounts
1 parent 9757f6f commit 4b66399

File tree

3 files changed

+19
-44
lines changed

3 files changed

+19
-44
lines changed

internal/cmd/root.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"os"
77
"os/exec"
88
"path/filepath"
9-
"strconv"
109
"strings"
1110

1211
"github.com/abiosoft/ishell/v2"
@@ -206,12 +205,6 @@ func NewCmdRoot() *cobra.Command {
206205
return nil
207206
}
208207

209-
if env, ok := os.LookupEnv("SMALLWEB_DISABLE_CUSTOM_COMMANDS"); ok {
210-
if disableCustomCommands, _ := strconv.ParseBool(env); disableCustomCommands {
211-
return fmt.Errorf("unknown command \"%s\" for \"smallweb\"", args[0])
212-
}
213-
}
214-
215208
for _, pluginDir := range []string{
216209
filepath.Join(k.String("dir"), ".smallweb", "commands"),
217210
filepath.Join(xdg.ConfigHome, "smallweb", "commands"),

internal/cmd/up.go

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,6 @@ func NewCmdUp() *cobra.Command {
306306
authorizedKeys := []string{authorizedKey}
307307
authorizedKeys = append(authorizedKeys, k.Strings("authorizedKeys")...)
308308

309-
if ctx.User() != "_" {
310-
authorizedKeys = append(authorizedKeys, k.Strings(fmt.Sprintf("apps.%s.authorizedKeys", ctx.User()))...)
311-
}
312-
313309
for _, authorizedKey := range authorizedKeys {
314310
if authorizedKey == "*" {
315311
return true
@@ -331,37 +327,28 @@ func NewCmdUp() *cobra.Command {
331327
wish.WithMiddleware(
332328
func(next ssh.Handler) ssh.Handler {
333329
return func(sess ssh.Session) {
334-
var cmd *exec.Cmd
335-
if sess.User() != "_" {
336-
a, err := app.LoadApp(sess.User(), k.String("dir"), k.String("domain"))
337-
if err != nil {
338-
fmt.Fprintf(sess, "failed to load app: %v\n", err)
339-
sess.Exit(1)
340-
return
341-
}
330+
args := sess.Command()
331+
if len(args) == 0 {
332+
fmt.Fprintf(sess, "no app provided\n")
333+
sess.Exit(1)
334+
return
335+
}
342336

343-
wk := worker.NewWorker(a, nil)
344-
c, err := wk.Command(sess.Context(), sess.Command())
345-
if err != nil {
346-
fmt.Fprintf(sess, "failed to get command: %v\n", err)
347-
sess.Exit(1)
348-
return
349-
}
337+
appname, args := args[0], args[1:]
350338

351-
cmd = c
352-
} else {
353-
execPath, err := os.Executable()
354-
if err != nil {
355-
fmt.Fprintf(sess.Stderr(), "failed to get executable path: %v\n", err)
356-
sess.Exit(1)
357-
return
358-
}
339+
a, err := app.LoadApp(appname, k.String("dir"), k.String("domain"))
340+
if err != nil {
341+
fmt.Fprintf(sess, "failed to load app: %v\n", err)
342+
sess.Exit(1)
343+
return
344+
}
359345

360-
cmd = exec.Command(execPath, "--dir", k.String("dir"), "--domain", k.String("domain"))
361-
cmd.Args = append(cmd.Args, sess.Command()...)
362-
cmd.Env = os.Environ()
363-
cmd.Env = append(cmd.Env, "SMALLWEB_DISABLE_CUSTOM_COMMANDS=true")
364-
cmd.Env = append(cmd.Env, "SMALLWEB_DISABLED_COMMANDS=up,config,init,doctor,completion")
346+
wk := worker.NewWorker(a, nil)
347+
cmd, err := wk.Command(sess.Context(), args)
348+
if err != nil {
349+
fmt.Fprintf(sess, "failed to get command: %v\n", err)
350+
sess.Exit(1)
351+
return
365352
}
366353

367354
ptyReq, winCh, isPty := sess.Pty()

internal/sftp/sftp.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ func SubsystemHandler(dir string, logger *slog.Logger) ssh.SubsystemHandler {
3333
}
3434
}()
3535

36-
if session.User() != "_" {
37-
wish.Errorln(session, "sftp subsystem is only available for the _ user")
38-
return
39-
}
40-
4136
root, err := os.OpenRoot(dir)
4237
if err != nil {
4338
if logger != nil {

0 commit comments

Comments
 (0)