all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH backup v3 1/2] http_client: store tickets in the user's config directory
@ 2025-04-16 12:56 Maximiliano Sandoval
  2025-04-16 12:56 ` [pbs-devel] [PATCH backup v3 2/2] http_client: add warning when we fail to place a config file Maximiliano Sandoval
  2025-04-18 12:46 ` [pbs-devel] [PATCH backup v3 1/2] http_client: store tickets in the user's config directory Thomas Lamprecht
  0 siblings, 2 replies; 6+ messages in thread
From: Maximiliano Sandoval @ 2025-04-16 12:56 UTC (permalink / raw)
  To: pbs-devel

The environment variable XDG_RUNTIME_DIR is only set if the user is
logged into a seat. If, for example, the backup client was run with
`sudo` then the ticket would not be a stored.

By storing the ticket in the user's configuration directory, it can be
reused later if the user logs out.

Since the tickets are only valid for a limited time, it is not a problem
if this file is not automatically cleaned.

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 pbs-client/src/http_client.rs | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/pbs-client/src/http_client.rs b/pbs-client/src/http_client.rs
index c95def07b..4f525f2ec 100644
--- a/pbs-client/src/http_client.rs
+++ b/pbs-client/src/http_client.rs
@@ -218,8 +218,8 @@ pub struct HttpClient {
 pub fn delete_ticket_info(prefix: &str, server: &str, username: &Userid) -> Result<(), Error> {
     let base = BaseDirectories::with_prefix(prefix)?;
 
-    // usually /run/user/<uid>/...
-    let path = base.place_runtime_file("tickets")?;
+    // usually ~/.config/<prefix>/tickets
+    let path = base.place_config_file("tickets")?;
 
     let mode = nix::sys::stat::Mode::from_bits_truncate(0o0600);
 
@@ -307,8 +307,8 @@ fn store_ticket_info(
 ) -> Result<(), Error> {
     let base = BaseDirectories::with_prefix(prefix)?;
 
-    // usually /run/user/<uid>/...
-    let path = base.place_runtime_file("tickets")?;
+    // usually ~/.config/<prefix>/tickets
+    let path = base.place_config_file("tickets")?;
 
     let mode = nix::sys::stat::Mode::from_bits_truncate(0o0600);
 
@@ -347,8 +347,8 @@ fn store_ticket_info(
 fn load_ticket_info(prefix: &str, server: &str, userid: &Userid) -> Option<(String, String)> {
     let base = BaseDirectories::with_prefix(prefix).ok()?;
 
-    // usually /run/user/<uid>/...
-    let path = base.place_runtime_file("tickets").ok()?;
+    // usually ~/.config/<prefix>/tickets
+    let path = base.place_config_file("tickets").ok()?;
     let data = file_get_json(path, None).ok()?;
     let now = proxmox_time::epoch_i64();
     let ticket_lifetime = proxmox_auth_api::TICKET_LIFETIME - 60;
-- 
2.39.5



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-04-18 13:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-16 12:56 [pbs-devel] [PATCH backup v3 1/2] http_client: store tickets in the user's config directory Maximiliano Sandoval
2025-04-16 12:56 ` [pbs-devel] [PATCH backup v3 2/2] http_client: add warning when we fail to place a config file Maximiliano Sandoval
2025-04-18 12:46 ` [pbs-devel] [PATCH backup v3 1/2] http_client: store tickets in the user's config directory Thomas Lamprecht
2025-04-18 12:47   ` Maximiliano Sandoval
2025-04-18 13:14     ` Thomas Lamprecht
2025-04-18 13:20       ` Maximiliano Sandoval

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.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal