From: Hannes Laimer <h.laimer@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 09/15] pbs-manager: add 'send-command' command
Date: Thu, 19 Aug 2021 13:03:37 +0200 [thread overview]
Message-ID: <20210819110343.8708-10-h.laimer@proxmox.com> (raw)
In-Reply-To: <20210819110343.8708-1-h.laimer@proxmox.com>
Relays a command to the superuser commandSocket, this is necessary
because the path to the socket is prefixed with a '\0' and can therefore
not really be addressed from outside the rust code.
---
src/bin/proxmox-backup-manager.rs | 41 +++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/src/bin/proxmox-backup-manager.rs b/src/bin/proxmox-backup-manager.rs
index 93d6de57..a07f69f1 100644
--- a/src/bin/proxmox-backup-manager.rs
+++ b/src/bin/proxmox-backup-manager.rs
@@ -197,6 +197,43 @@ async fn task_stop(param: Value) -> Result<Value, Error> {
Ok(Value::Null)
}
+#[api(
+ input: {
+ properties: {
+ command: {
+ description: "The command.",
+ type: String,
+ },
+ args: {
+ description: "The argument string.",
+ optional: true,
+ type: String,
+ }
+ }
+ }
+)]
+/// Send command to control socket.
+async fn send_command(param: Value) -> Result<Value, Error> {
+ let command_str = required_string_param(¶m, "command")?;
+ let args = match required_string_param(¶m, "args") {
+ Ok(args) => args,
+ Err(_) => "",
+ };
+
+ let api_pid = proxmox_backup::server::read_pid(pbs_buildcfg::PROXMOX_BACKUP_API_PID_FN)?;
+ let sock = proxmox_backup::server::ctrl_sock_from_pid(api_pid);
+ proxmox_backup::server::send_raw_command(
+ sock,
+ &format!(
+ "{{\"command\":\"{}\",\"args\":\"{}\"}}\n",
+ command_str, args
+ ),
+ )
+ .await?;
+
+ Ok(Value::Null)
+}
+
fn task_mgmt_cli() -> CommandLineInterface {
let task_log_cmd_def = CliCommand::new(&API_METHOD_TASK_LOG)
@@ -392,6 +429,10 @@ fn main() {
.insert("report",
CliCommand::new(&API_METHOD_REPORT)
)
+ .insert(
+ "send-command",
+ CliCommand::new(&API_METHOD_SEND_COMMAND).arg_param(&["command"]),
+ )
.insert("versions",
CliCommand::new(&API_METHOD_GET_VERSIONS)
);
--
2.30.2
next prev parent reply other threads:[~2021-08-19 11:04 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-19 11:03 [pbs-devel] [PATCH proxmox-backup 00/15] (partially)close #3156: Add support for removable datastores Hannes Laimer
2021-08-19 11:03 ` [pbs-devel] [PATCH proxmox-backup 01/15] tools: add disks utility functions Hannes Laimer
2021-08-19 11:03 ` [pbs-devel] [PATCH proxmox-backup 02/15] config: add uuid+mountpoint to DataStoreConfig Hannes Laimer
2021-08-19 11:03 ` [pbs-devel] [PATCH proxmox-backup 03/15] api2: add support for removable datastore creation Hannes Laimer
2021-08-19 11:03 ` [pbs-devel] [PATCH proxmox-backup 04/15] backup: add check_if_available function to ds Hannes Laimer
2021-08-19 11:03 ` [pbs-devel] [PATCH proxmox-backup 05/15] api2: add 'is_available' to DataStoreConfig Hannes Laimer
2021-08-19 11:03 ` [pbs-devel] [PATCH proxmox-backup 06/15] api2: add 'removable' to DataStoreListItem Hannes Laimer
2021-08-19 11:03 ` [pbs-devel] [PATCH proxmox-backup 07/15] api2: add (un)mount endpoint for removable ds's Hannes Laimer
2021-08-19 11:03 ` [pbs-devel] [PATCH proxmox-backup 08/15] pbs: add mount-removable command to commandSocket Hannes Laimer
2021-08-19 11:03 ` Hannes Laimer [this message]
2021-08-19 11:03 ` [pbs-devel] [PATCH proxmox-backup 10/15] debian: add udev rule for removable datastores Hannes Laimer
2021-08-19 11:03 ` [pbs-devel] [PATCH proxmox-backup 11/15] ui: show usb icon for removable datastore in list Hannes Laimer
2021-08-19 11:03 ` [pbs-devel] [PATCH proxmox-backup 12/15] ui: add 'removable' checkbox in datastore creation Hannes Laimer
2021-08-19 11:03 ` [pbs-devel] [PATCH proxmox-backup 13/15] ui: display row as disabled in ds statistics Hannes Laimer
2021-08-19 11:03 ` [pbs-devel] [PATCH proxmox-backup 14/15] ui: show backing device UUID in option tab Hannes Laimer
2021-08-19 11:03 ` [pbs-devel] [PATCH proxmox-backup 15/15] ui: add (un)mount button to summary Hannes Laimer
2021-08-27 8:03 ` [pbs-devel] [PATCH proxmox-backup 00/15] (partially)close #3156: Add support for removable datastores Lorenz Stechauner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210819110343.8708-10-h.laimer@proxmox.com \
--to=h.laimer@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.