aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Cox <me@jasoncarloscox.com>2024-02-22 20:25:20 -0500
committerRobin Jarry <robin@jarry.cc>2024-04-13 21:46:44 +0200
commit480637d9ed8cf979f4be377cb37fdd14b60ceef3 (patch)
treeb4a42644e0e3b1b2718c4f9f4a638828b61bfc94
parentf4cf6ca5c13fce8fe1f84f37cdafe62c1d2d8b0c (diff)
downloadaerc-480637d9ed8cf979f4be377cb37fdd14b60ceef3.tar.gz
aerc-480637d9ed8cf979f4be377cb37fdd14b60ceef3.zip
ipc: disable IPC completely when disable-ipc=true
Truly disable IPC when disable-ipc is set to true in aerc.conf. Don't run commands over IPC and don't start an IPC server. Being able to disable IPC in the config is useful because it allows making aerc open mailto links in a new instance without modifying the aerc.desktop file. There are of course potential security benefits as well. Changelog-changed: The `disable-ipc` option in `aerc.conf` completely disables IPC. Signed-off-by: Jason Cox <me@jasoncarloscox.com> Acked-by: Robin Jarry <robin@jarry.cc>
-rw-r--r--config/aerc.conf7
-rw-r--r--doc/aerc-config.5.scd4
-rw-r--r--doc/aerc.1.scd10
-rw-r--r--lib/ipc/receive.go4
-rw-r--r--main.go20
5 files changed, 26 insertions, 19 deletions
diff --git a/config/aerc.conf b/config/aerc.conf
index a6f287a1..70f07949 100644
--- a/config/aerc.conf
+++ b/config/aerc.conf
@@ -38,6 +38,13 @@
# Default: info
#log-level=info
+# Disable IPC entirely. Don't run commands (including mailto:... and mbox:...)
+# in an existing aerc instance, and don't start an IPC server to allow
+# subsequent aerc instances to run commands in the current one.
+#
+# Default: false
+#disable-ipc=false
+
# Set the $TERM environment variable used for the embedded terminal.
#
# Default: xterm-256color
diff --git a/doc/aerc-config.5.scd b/doc/aerc-config.5.scd
index ded49a14..fae2abc2 100644
--- a/doc/aerc-config.5.scd
+++ b/doc/aerc-config.5.scd
@@ -64,7 +64,9 @@ These options are configured in the *[general]* section of _aerc.conf_.
Default: _info_
*disable-ipc* = _true_|_false_
- Disable the execution of commands over IPC.
+ Disable IPC entirely. Don't run commands (including _mailto:..._ and
+ _mbox..._) in an existing aerc instance and don't start an IPC server to
+ allow subsequent aerc instances to run commands in the current one.
Default: _false_
diff --git a/doc/aerc.1.scd b/doc/aerc.1.scd
index 5511e79e..402be59a 100644
--- a/doc/aerc.1.scd
+++ b/doc/aerc.1.scd
@@ -46,7 +46,7 @@ from your terminal.
Open the composer with the address(es) in the To field. These
addresses must not be percent encoded.
- If aerc is already running (and *--no-ipc* is not passed), the composer is
+ If aerc is already running (and IPC is not disabled), the composer is
started in that instance; otherwise a new instance is started with the
composer.
@@ -84,14 +84,14 @@ from your terminal.
directly on aerc's command line. This latter form can be helpful for
commands that don't interpret quotes in their arguments.
- If aerc is already running (and *--no-ipc* is not passed), the command is
- run in that instance; otherwise a new instance is started with the command.
+ If aerc is already running (and IPC is not disabled), the command is run in
+ that instance; otherwise a new instance is started with the command.
*mbox:*_<file>_
Open the specified mbox file as a virtual temporary account.
- If aerc is already running (and *--no-ipc* is not passed), the file is
- opened in that instance; otherwise a new instance is started with the file.
+ If aerc is already running (and IPC is not disabled), the file is opened in
+ that instance; otherwise a new instance is started with the file.
# RUNTIME COMMANDS
diff --git a/lib/ipc/receive.go b/lib/ipc/receive.go
index ff837d0f..bba365b6 100644
--- a/lib/ipc/receive.go
+++ b/lib/ipc/receive.go
@@ -9,7 +9,6 @@ import (
"sync/atomic"
"time"
- "git.sr.ht/~rjarry/aerc/config"
"git.sr.ht/~rjarry/aerc/lib/log"
"git.sr.ht/~rjarry/aerc/lib/xdg"
)
@@ -97,9 +96,6 @@ func (as *AercServer) Serve() {
}
func (as *AercServer) handleMessage(req *Request) *Response {
- if config.General.DisableIPC {
- return &Response{Error: "command rejected: IPC is disabled"}
- }
err := as.handler.Command(req.Arguments)
if err != nil {
return &Response{Error: err.Error()}
diff --git a/main.go b/main.go
index 9558382b..b7437fbd 100644
--- a/main.go
+++ b/main.go
@@ -162,7 +162,16 @@ func main() {
die("%s", err)
}
- if len(opts.Command) > 0 && !opts.NoIPC {
+ err = config.LoadConfigFromFile(
+ nil, opts.Accounts, opts.ConfAerc, opts.ConfBinds, opts.ConfAccounts,
+ )
+ if err != nil {
+ die("%s", err)
+ }
+
+ noIPC := opts.NoIPC || config.General.DisableIPC
+
+ if len(opts.Command) > 0 && !noIPC {
response, err := ipc.ConnectAndExec(opts.Command)
if err == nil {
if response.Error != "" {
@@ -173,13 +182,6 @@ func main() {
// continue with setting up a new aerc instance and retry after init
}
- err = config.LoadConfigFromFile(
- nil, opts.Accounts, opts.ConfAerc, opts.ConfBinds, opts.ConfAccounts,
- )
- if err != nil {
- die("%s", err)
- }
-
log.Infof("Starting up version %s", log.BuildInfo)
deferLoop := make(chan struct{})
@@ -205,7 +207,7 @@ func main() {
startup, startupDone := context.WithCancel(context.Background())
- if !opts.NoIPC {
+ if !noIPC {
as, err := ipc.StartServer(app.IPCHandler(), startup)
if err != nil {
log.Warnf("Failed to start Unix server: %v", err)