all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#49601] [PATCH] services: transmission: Create downloads directory.
@ 2021-07-17  0:28 Morgan.J.Smith
  2021-07-17 11:52 ` Simon South
  0 siblings, 1 reply; 5+ messages in thread
From: Morgan.J.Smith @ 2021-07-17  0:28 UTC (permalink / raw)
  To: 49601; +Cc: Morgan Smith

From: Morgan Smith <Morgan.J.Smith@outlook.com>

* gnu/services/file-sharing.scm (transmission-daemon-activation): Create
downloads directory.

This fixes a bug where transmission doesn't have permission to create it's
download directory. This bug occurs when download-dir is configured to a
location where the transmission user doesn't have permission to create a directory.
---
 gnu/services/file-sharing.scm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gnu/services/file-sharing.scm b/gnu/services/file-sharing.scm
index 72cd6478d6..143fd3ed75 100644
--- a/gnu/services/file-sharing.scm
+++ b/gnu/services/file-sharing.scm
@@ -746,6 +746,7 @@ produces a Transmission settings file (@file{settings.json}) matching CONFIG."
 (define (transmission-daemon-activation config)
   "Return the Transmission Daemon activation GEXP for CONFIG."
   (let ((config-dir %transmission-daemon-configuration-directory)
+        (download-dir (transmission-daemon-configuration-download-dir config))
         (incomplete-dir-enabled
          (transmission-daemon-configuration-incomplete-dir-enabled? config))
         (incomplete-dir
@@ -769,7 +770,8 @@ produces a Transmission settings file (@file{settings.json}) matching CONFIG."
             (for-each (lambda (directory-specification)
                         (apply mkdir-p/perms directory-specification))
                       '(#$@(append
-                            `((,config-dir #o750))
+                            `((,config-dir #o750)
+                              (,download-dir #o755))
                             (if incomplete-dir-enabled
                                 `((,incomplete-dir #o750))
                                 '())
-- 
2.32.0





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

* [bug#49601] [PATCH] services: transmission: Create downloads directory.
  2021-07-17  0:28 [bug#49601] [PATCH] services: transmission: Create downloads directory Morgan.J.Smith
@ 2021-07-17 11:52 ` Simon South
  2021-07-17 17:47   ` Simon South
  2021-07-19 12:13   ` Efraim Flashner
  0 siblings, 2 replies; 5+ messages in thread
From: Simon South @ 2021-07-17 11:52 UTC (permalink / raw)
  To: Morgan.J.Smith; +Cc: 49601

Morgan.J.Smith@outlook.com writes:
> This fixes a bug where transmission doesn't have permission to create
> it's download directory. This bug occurs when download-dir is
> configured to a location where the transmission user doesn't have
> permission to create a directory.

Morgan,

I recall originally having the service activation create the downloads
directory, as your change makes it do, but then removing this as there
was some common case where it made service activation fail.
Unfortunately, I've forgotten what that was.

Let me see if I can duplicate that and if so, perhaps we can find a
solution that will handle both cases. At any rate:

> +                              (,download-dir #o755))

The folder permissions should be #o750, not #o755. The reasoning here is
that it ought to be possible to place limits on who can see and access
files being shared by other users.

-- 
Simon South
simon@simonsouth.net




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

* [bug#49601] [PATCH] services: transmission: Create downloads directory.
  2021-07-17 11:52 ` Simon South
@ 2021-07-17 17:47   ` Simon South
  2021-07-19 12:13   ` Efraim Flashner
  1 sibling, 0 replies; 5+ messages in thread
From: Simon South @ 2021-07-17 17:47 UTC (permalink / raw)
  To: Morgan.J.Smith; +Cc: 49601

Simon South <simon@simonsouth.net> writes:
> Let me see if I can duplicate that...

I haven't been able to duplicate whatever issue it was I saw originally.
Likely it had to do with the download directory being placed on a
separate volume and thus matching a mount point already declared in the
operating-system declaration.  Probably the system test should be
expanded to check this kind of configuration works but a quick test on
my end shows that at least for existing setups, it is not a problem.

Morgan, just a few pieces of feedback then:

> This fixes a bug where transmission doesn't have permission to create
> it's download directory. This bug occurs when download-dir is

"it's" should be "its" (no apostrophe) here, the possessive form.

> +                              (,download-dir #o755))

Again, the permissions here should be "#o750".

Finally, I recommend updating the system test (in
gnu/tests/file-sharing.scm) to verify the download directory is created
correctly, now that this functionality has been added.  I've included a
patch below that does this for you.  To verify this works, apply the
patch and run the test suite with

    make check-system TESTS="transmission-daemon"

The Guix manual has more information[0].

Otherwise, looks good to me.  Thanks for submitting this patch.

[0] https://guix.gnu.org/en/manual/en/html_node/Running-the-Test-Suite.html

-- 
Simon South
simon@simonsouth.net


diff --git a/gnu/tests/file-sharing.scm b/gnu/tests/file-sharing.scm
index 9a8ee6a593..d27a206c4f 100644
--- a/gnu/tests/file-sharing.scm
+++ b/gnu/tests/file-sharing.scm
@@ -34,6 +34,8 @@
 (define %transmission-daemon-group "transmission")
 
 (define %transmission-daemon-config-dir "/var/lib/transmission-daemon")
+(define %transmission-daemon-download-dir
+  (string-append %transmission-daemon-config-dir "/downloads"))
 (define %transmission-daemon-watch-dir
   (string-append %transmission-daemon-config-dir "/watch"))
 (define %transmission-daemon-incomplete-dir
@@ -110,8 +112,9 @@
                 #t)
              marionette))
 
-          ;; Make sure Transmission Daemon's configuration directory has been
-          ;; created with the correct ownership and permissions.
+          ;; Make sure Transmission Daemon's configuration and download
+          ;; directories have been created with the correct ownership and
+          ;; permissions.
           (test-assert "configuration directory exists"
             (marionette-eval
              '(eq? (stat:type (stat #$%transmission-daemon-config-dir))
@@ -132,6 +135,26 @@
                     #o750)
              marionette))
 
+          (test-assert "download directory exists"
+            (marionette-eval
+             '(eq? (stat:type (stat #$%transmission-daemon-download-dir))
+                   'directory)
+             marionette))
+          (test-assert "download directory has correct ownership"
+            (marionette-eval
+             '(let ((download-dir (stat #$%transmission-daemon-download-dir))
+                    (transmission-user (getpwnam #$%transmission-daemon-user)))
+                (and (eqv? (stat:uid download-dir)
+                           (passwd:uid transmission-user))
+                     (eqv? (stat:gid download-dir)
+                           (passwd:gid transmission-user))))
+             marionette))
+          (test-assert "download directory has expected permissions"
+            (marionette-eval
+             '(eqv? (stat:perms (stat #$%transmission-daemon-download-dir))
+                    #o750)
+             marionette))
+
           ;; Make sure the incomplete-downloads and watch directories have been
           ;; created with the correct ownership and permissions.
           (test-assert "incomplete-downloads directory exists"




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

* [bug#49601] [PATCH] services: transmission: Create downloads directory.
  2021-07-17 11:52 ` Simon South
  2021-07-17 17:47   ` Simon South
@ 2021-07-19 12:13   ` Efraim Flashner
  2021-07-21 13:14     ` Simon South
  1 sibling, 1 reply; 5+ messages in thread
From: Efraim Flashner @ 2021-07-19 12:13 UTC (permalink / raw)
  To: Simon South; +Cc: Morgan.J.Smith, 49601

[-- Attachment #1: Type: text/plain, Size: 1669 bytes --]

On Sat, Jul 17, 2021 at 07:52:21AM -0400, Simon South wrote:
> Morgan.J.Smith@outlook.com writes:
> > This fixes a bug where transmission doesn't have permission to create
> > it's download directory. This bug occurs when download-dir is
> > configured to a location where the transmission user doesn't have
> > permission to create a directory.
> 
> Morgan,
> 
> I recall originally having the service activation create the downloads
> directory, as your change makes it do, but then removing this as there
> was some common case where it made service activation fail.
> Unfortunately, I've forgotten what that was.
> 
> Let me see if I can duplicate that and if so, perhaps we can find a
> solution that will handle both cases. At any rate:
> 
> > +                              (,download-dir #o755))
> 
> The folder permissions should be #o750, not #o755. The reasoning here is
> that it ought to be possible to place limits on who can see and access
> files being shared by other users.
> 

It's possible it was mkdir vs mkdir-p

(ins)scheme@(guile-user)> (mkdir "tmp")
(ins)scheme@(guile-user)> (mkdir "tmp")
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
In procedure mkdir: File exists

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
(ins)scheme@(guile-user) [1]> ,q
(ins)scheme@(guile-user)> (use-modules (guix build utils))
(ins)scheme@(guile-user)> (mkdir-p "tmp")
$1 = #t


-- 
Efraim Flashner   <efraim@flashner.co.il>   אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* [bug#49601] [PATCH] services: transmission: Create downloads directory.
  2021-07-19 12:13   ` Efraim Flashner
@ 2021-07-21 13:14     ` Simon South
  0 siblings, 0 replies; 5+ messages in thread
From: Simon South @ 2021-07-21 13:14 UTC (permalink / raw)
  To: Efraim Flashner; +Cc: Morgan.J.Smith, 49601

Efraim Flashner <efraim@flashner.co.il> writes:
> It's possible it was mkdir vs mkdir-p

Yes, or perhaps I hadn't yet added the code that sets the ownership and
permissions on the directory.

Morgan, I hope you'll submit a revised patch so others can review.

-- 
Simon South
simon@simonsouth.net




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

end of thread, other threads:[~2021-07-21 13:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-17  0:28 [bug#49601] [PATCH] services: transmission: Create downloads directory Morgan.J.Smith
2021-07-17 11:52 ` Simon South
2021-07-17 17:47   ` Simon South
2021-07-19 12:13   ` Efraim Flashner
2021-07-21 13:14     ` Simon South

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

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.