all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] gnu: Use a directory owned by ntpd user for drift file.
@ 2016-09-07 19:52 John Darrington
  2016-09-07 20:36 ` Ludovic Courtès
  2016-09-08  6:57 ` Vincent Legoll
  0 siblings, 2 replies; 6+ messages in thread
From: John Darrington @ 2016-09-07 19:52 UTC (permalink / raw)
  To: guix-devel; +Cc: John Darrington

Fixes bug #24366




* gnu/services/networking.scm (ntp-shepherd-service): Create new
directory at startup.
---
 gnu/services/networking.scm | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index 71f49a0..f983961 100644
--- a/gnu/services/networking.scm
+++ b/gnu/services/networking.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2016 John Darrington <jmd@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -272,7 +273,7 @@ Protocol (DHCP) client, on all the non-loopback network interfaces."
      (let ()
        ;; TODO: Add authentication support.
        (define config
-         (string-append "driftfile /var/run/ntp.drift\n"
+         (string-append "driftfile /var/run/ntpd/ntp.drift\n"
                         (string-join (map (cut string-append "server " <>)
                                           servers)
                                      "\n")
@@ -307,13 +308,28 @@ restrict -6 ::1\n"))
          (home-directory "/var/empty")
          (shell #~(string-append #$shadow "/sbin/nologin")))))
 
+
+(define (ntp-service-activation config)
+  "Return the activation gexp for config"
+  #~(begin
+      (use-modules (guix build utils))
+
+      (define %user
+        (getpw "ntpd"))
+
+      (let ((directory "/var/run/ntpd"))
+          (mkdir-p directory)
+          (chown directory (passwd:uid %user) (passwd:gid %user)))))
+
 (define ntp-service-type
   (service-type (name 'ntp)
                 (extensions
                  (list (service-extension shepherd-root-service-type
                                           ntp-shepherd-service)
                        (service-extension account-service-type
-                                          (const %ntp-accounts))))))
+                                          (const %ntp-accounts))
+                       (service-extension activation-service-type
+                                          ntp-service-activation)))))
 
 (define* (ntp-service #:key (ntp ntp)
                       (servers %ntp-servers))
-- 
2.1.4

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

* Re: [PATCH] gnu: Use a directory owned by ntpd user for drift file.
  2016-09-07 19:52 [PATCH] gnu: Use a directory owned by ntpd user for drift file John Darrington
@ 2016-09-07 20:36 ` Ludovic Courtès
  2016-09-08  6:57 ` Vincent Legoll
  1 sibling, 0 replies; 6+ messages in thread
From: Ludovic Courtès @ 2016-09-07 20:36 UTC (permalink / raw)
  To: John Darrington; +Cc: guix-devel

John Darrington <jmd@gnu.org> skribis:

> Fixes bug #24366

Rather:

  Fixes <http://bugs.gnu.org/24366>.

(See ‘git log’ for examples.)

>
>
>
> * gnu/services/networking.scm (ntp-shepherd-service): Create new
> directory at startup.

Please mention the new variables and changes.

> +(define (ntp-service-activation config)
> +  "Return the activation gexp for config"
                                     ^^^^^^^
Capitalize the variable name and add a period.

> +  #~(begin
> +      (use-modules (guix build utils))

Please wrap the gexp in:

  (with-imported-modules '((guix build utils))
    #~(…))

> +      (let ((directory "/var/run/ntpd"))
> +          (mkdir-p directory)
            ^^
Indentation.

OK with these changes.

Thanks for fixing this bug!

Ludo’.

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

* Re: [PATCH] gnu: Use a directory owned by ntpd user for drift file.
  2016-09-07 19:52 [PATCH] gnu: Use a directory owned by ntpd user for drift file John Darrington
  2016-09-07 20:36 ` Ludovic Courtès
@ 2016-09-08  6:57 ` Vincent Legoll
  2016-09-08 16:03   ` John Darrington
  2016-09-09  9:30   ` Ludovic Courtès
  1 sibling, 2 replies; 6+ messages in thread
From: Vincent Legoll @ 2016-09-08  6:57 UTC (permalink / raw)
  To: John Darrington; +Cc: guix-devel

Hello,

> +(define (ntp-service-activation config)
> +  "Return the activation gexp for config"
> +  #~(begin
> +      (use-modules (guix build utils))
> +
> +      (define %user
> +        (getpw "ntpd"))
> +
> +      (let ((directory "/var/run/ntpd"))
> +          (mkdir-p directory)
> +          (chown directory (passwd:uid %user) (passwd:gid %user)))))
> +

Excuse my scheme-newbie questions, but

- why did you use %user (I thought %s were for kind of global vars) ?
- why did you use define and not put it in the let just below ? Idon't see
it being used elsewhere...

-- 
Vincent Legoll

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

* Re: [PATCH] gnu: Use a directory owned by ntpd user for drift file.
  2016-09-08  6:57 ` Vincent Legoll
@ 2016-09-08 16:03   ` John Darrington
  2016-09-08 16:51     ` Vincent Legoll
  2016-09-09  9:30   ` Ludovic Courtès
  1 sibling, 1 reply; 6+ messages in thread
From: John Darrington @ 2016-09-08 16:03 UTC (permalink / raw)
  To: Vincent Legoll; +Cc: guix-devel, John Darrington

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

On Thu, Sep 08, 2016 at 08:57:57AM +0200, Vincent Legoll wrote:
     Hello,
     
     > +(define (ntp-service-activation config)
     > +  "Return the activation gexp for config"
     > +  #~(begin
     > +      (use-modules (guix build utils))
     > +
     > +      (define %user
     > +        (getpw "ntpd"))
     > +
     > +      (let ((directory "/var/run/ntpd"))
     > +          (mkdir-p directory)
     > +          (chown directory (passwd:uid %user) (passwd:gid %user)))))
     > +
     
     - why did you use %user (I thought %s were for kind of global vars) ?
     - why did you use define and not put it in the let just below ? Idon't see
     it being used elsewhere...
     

I think you need to look a little harder, because the answer to both your
(very valid) questions is : I copied it from other, existing examples.

J'

-- 
Avoid eavesdropping.  Send strong encrypted email.
PGP Public key ID: 1024D/2DE827B3 
fingerprint = 8797 A26D 0854 2EAB 0285  A290 8A67 719C 2DE8 27B3
See http://sks-keyservers.net or any PGP keyserver for public key.


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

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

* Re: [PATCH] gnu: Use a directory owned by ntpd user for drift file.
  2016-09-08 16:03   ` John Darrington
@ 2016-09-08 16:51     ` Vincent Legoll
  0 siblings, 0 replies; 6+ messages in thread
From: Vincent Legoll @ 2016-09-08 16:51 UTC (permalink / raw)
  To: John Darrington; +Cc: guix-devel, John Darrington

> I think you need to look a little harder, because the answer to both your
> (very valid) questions is : I copied it from other, existing examples.

Ah, couldn't have seen it, I only read the patch, not the entire file...

You copied it from : tor-hidden-service-activation ?

So, can an old-schemer tell me if the questions make sense, or is
it equivalent ?

-- 
Vincent Legoll

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

* Re: [PATCH] gnu: Use a directory owned by ntpd user for drift file.
  2016-09-08  6:57 ` Vincent Legoll
  2016-09-08 16:03   ` John Darrington
@ 2016-09-09  9:30   ` Ludovic Courtès
  1 sibling, 0 replies; 6+ messages in thread
From: Ludovic Courtès @ 2016-09-09  9:30 UTC (permalink / raw)
  To: Vincent Legoll; +Cc: guix-devel, John Darrington

Hi,

Vincent Legoll <vincent.legoll@gmail.com> skribis:

>> +(define (ntp-service-activation config)
>> +  "Return the activation gexp for config"
>> +  #~(begin
>> +      (use-modules (guix build utils))
>> +
>> +      (define %user
>> +        (getpw "ntpd"))
>> +
>> +      (let ((directory "/var/run/ntpd"))
>> +          (mkdir-p directory)
>> +          (chown directory (passwd:uid %user) (passwd:gid %user)))))
>> +
>
> Excuse my scheme-newbie questions, but
>
> - why did you use %user (I thought %s were for kind of global vars) ?

In the context of this gexp it’s a global variable.

> - why did you use define and not put it in the let just below ? Idon't see
> it being used elsewhere...

Both styles are OK, though putting it in the ‘let’ would have made it
more concise, indeed.  :-)

Ludo’.

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

end of thread, other threads:[~2016-09-09  9:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-07 19:52 [PATCH] gnu: Use a directory owned by ntpd user for drift file John Darrington
2016-09-07 20:36 ` Ludovic Courtès
2016-09-08  6:57 ` Vincent Legoll
2016-09-08 16:03   ` John Darrington
2016-09-08 16:51     ` Vincent Legoll
2016-09-09  9:30   ` Ludovic Courtès

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.