blob: 4cd53af1c4ea486571d0cbb8ac70c6603d819e14 [file] [log] [blame] [view]
Davide Pesaventoe541d1b2022-08-17 15:10:32 -04001# Starting NFD on macOS
Alexander Afanasyevc6e61422014-05-07 00:32:25 -07002
Davide Pesaventoe541d1b2022-08-17 15:10:32 -04003macOS provides a standard way to start system daemons, monitor their health, and restart
4them when they die.
Alexander Afanasyevc6e61422014-05-07 00:32:25 -07005
Davide Pesaventoe541d1b2022-08-17 15:10:32 -04006## Initial setup
Alexander Afanasyevc6e61422014-05-07 00:32:25 -07007
Davide Pesaventoe541d1b2022-08-17 15:10:32 -04008Edit `net.named-data.nfd.plist` as needed, adjusting the paths for the `nfd` binary,
9configuration, and log files.
Alexander Afanasyevc6e61422014-05-07 00:32:25 -070010
Alexander Afanasyevf08a7372015-02-09 21:28:19 -080011 # Copy launchd.plist for NFD
Alexander Afanasyevc6e61422014-05-07 00:32:25 -070012 sudo cp net.named-data.nfd.plist /Library/LaunchDaemons/
13 sudo chown root /Library/LaunchDaemons/net.named-data.nfd.plist
14
Alexander Afanasyevc6e61422014-05-07 00:32:25 -070015### Assumptions in the default scripts
16
Alexander Afanasyevf08a7372015-02-09 21:28:19 -080017* `nfd` is installed into `/usr/local/bin`
Alexander Afanasyevc6e61422014-05-07 00:32:25 -070018* Configuration file is `/usr/local/etc/ndn/nfd.conf`
19* `nfd` will be run as root
Alexander Afanasyevc6e61422014-05-07 00:32:25 -070020* Log files will be written to `/usr/local/var/log/ndn` folder, which is owned by user `ndn`
21
22### Creating users
23
24If `ndn` user does not exists, it needs to be manually created (procedure copied from
25[macports script](https://trac.macports.org/browser/trunk/base/src/port1.0/portutil.tcl)).
26Update uid/gid if 6363 is already used.
27
28 # Create user `ndn`
29 sudo dscl . -create /Users/ndn UniqueID 6363
30
31 # These are implicitly added on Mac OSX Lion. AuthenticationAuthority
32 # causes the user to be visible in the Users & Groups Preference Pane,
33 # and the others are just noise, so delete them.
34 # https://trac.macports.org/ticket/30168
35 sudo dscl . -delete /Users/ndn AuthenticationAuthority
36 sudo dscl . -delete /Users/ndn PasswordPolicyOptions
37 sudo dscl . -delete /Users/ndn dsAttrTypeNative:KerberosKeys
38 sudo dscl . -delete /Users/ndn dsAttrTypeNative:ShadowHashData
39
40 sudo dscl . -create /Users/ndn RealName "NDN User"
41 sudo dscl . -create /Users/ndn Password "{*}"
42 sudo dscl . -create /Users/ndn PrimaryGroupID 6363
43 sudo dscl . -create /Users/ndn NFSHomeDirectory /var/empty
44 sudo dscl . -create /Users/ndn UserShell /usr/bin/false
45
46 # Create group `ndn`
47 sudo dscl . -create /Groupsndn Password "{*}"
48 sudo dscl . -create /Groups/ndn RealName "NDN User"
49 sudo dscl . -create /Groups/ndn PrimaryGroupID 6363
50
51### Creating folders
52
53Folder `/usr/local/var/log/ndn` should be created and assigned proper user and group:
54
55 sudo mkdir -p /usr/local/var/log/ndn
56 sudo chown -R ndn:ndn /usr/local/var/log/ndn
57
Alexander Afanasyevf08a7372015-02-09 21:28:19 -080058`HOME` directory for `nfd` should be created and configured with correct library's config file
59and contain proper NDN security credentials for signing Data packets. This is necessary since
Davide Pesaventoe541d1b2022-08-17 15:10:32 -040060the default private key storage on macOS (`tpm-osxkeychain`) does not support non-interactive
61access, and file-based private key storage needs to be used:
Alexander Afanasyevc6e61422014-05-07 00:32:25 -070062
Alexander Afanasyevf08a7372015-02-09 21:28:19 -080063 # Create HOME and generate self-signed NDN certificate for nfd
64 sudo -s -- ' \
65 mkdir -p /usr/local/var/lib/ndn/nfd/.ndn; \
66 export HOME=/usr/local/var/lib/ndn/nfd; \
67 echo tpm=tpm-file > /usr/local/var/lib/ndn/nfd/.ndn/client.conf; \
Davide Pesaventod69070e2021-06-04 18:50:52 -040068 ndnsec key-gen /localhost/daemons/nfd | ndnsec cert-install -; \
Alexander Afanasyevf08a7372015-02-09 21:28:19 -080069 '
Alexander Afanasyevc6e61422014-05-07 00:32:25 -070070
71### Configuring NFD's security
72
Alexander Afanasyevf08a7372015-02-09 21:28:19 -080073NFD sample configuration allows anybody to create faces, add nexthops to FIB, and set strategy
74choice for namespaces. While such settings could be a good start, it is generally not a good
75idea to run NFD in this mode.
Alexander Afanasyevc6e61422014-05-07 00:32:25 -070076
Alexander Afanasyev37a05f62014-05-09 18:55:21 -070077While thorough discussion about security configuration of NFD is outside the scope of this
78document, at least the following change should be done to nfd.conf in authorize section:
Alexander Afanasyevc6e61422014-05-07 00:32:25 -070079
80 authorizations
81 {
82 authorize
83 {
Alexander Afanasyevf08a7372015-02-09 21:28:19 -080084 certfile certs/localhost_daemons_nfd.ndncert
Alexander Afanasyevc6e61422014-05-07 00:32:25 -070085 privileges
86 {
87 faces
88 fib
89 strategy-choice
90 }
91 }
92
93 authorize
94 {
95 certfile any
96 privileges
97 {
98 faces
99 strategy-choice
100 }
101 }
102 }
103
104While this configuration still allows management of faces and updating strategy choice by
Alexander Afanasyevf08a7372015-02-09 21:28:19 -0800105anybody, only NFD's RIB Manager (i.e., NFD itself) is allowed to manage FIB.
Alexander Afanasyevc6e61422014-05-07 00:32:25 -0700106
Alexander Afanasyevf08a7372015-02-09 21:28:19 -0800107As the final step to make this configuration work, NFD's self-signed certificate needs to
108be exported into `localhost_daemons_nfd.ndncert` file:
Alexander Afanasyevc6e61422014-05-07 00:32:25 -0700109
Alexander Afanasyevf08a7372015-02-09 21:28:19 -0800110 sudo -s -- '\
111 mkdir -p /usr/local/etc/ndn/certs || true; \
112 export HOME=/usr/local/var/lib/ndn/nfd; \
Davide Pesaventod69070e2021-06-04 18:50:52 -0400113 ndnsec cert-dump -i /localhost/daemons/nfd > \
Alexander Afanasyevf08a7372015-02-09 21:28:19 -0800114 /usr/local/etc/ndn/certs/localhost_daemons_nfd.ndncert; \
115 '
Alexander Afanasyevc6e61422014-05-07 00:32:25 -0700116
Davide Pesaventoe541d1b2022-08-17 15:10:32 -0400117## Enable auto-start
Alexander Afanasyevc6e61422014-05-07 00:32:25 -0700118
119 sudo launchctl load -w /Library/LaunchDaemons/net.named-data.nfd.plist
Alexander Afanasyevc6e61422014-05-07 00:32:25 -0700120
Davide Pesaventoe541d1b2022-08-17 15:10:32 -0400121## Disable auto-start
Alexander Afanasyevc6e61422014-05-07 00:32:25 -0700122
123 sudo launchctl unload -w /Library/LaunchDaemons/net.named-data.nfd.plist