├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── kbfsd.5 └── kbfsd.in /.gitignore: -------------------------------------------------------------------------------- 1 | kbfsd 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | SPDX-License-Identifier: BSD-2-Clause 2 | 3 | Copyright (c) 2018-2019 Mateusz Piotrowski <0mp@FreeBSD.org> 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 2. Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: BSD-2-Clause 2 | # 3 | # Copyright 2018-2021 Mateusz Piotrowski <0mp@FreeBSD.org> 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are met: 7 | # 8 | # 1. Redistributions of source code must retain the above copyright notice, 9 | # this list of conditions and the following disclaimer. 10 | # 11 | # 2. Redistributions in binary form must reproduce the above copyright notice, 12 | # this list of conditions and the following disclaimer in the documentation 13 | # and/or other materials provided with the distribution. 14 | # 15 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | # POSSIBILITY OF SUCH DAMAGE. 26 | 27 | DESTDIR?= # none 28 | PREFIX?= /usr/local 29 | LOCALBASE?= ${PREFIX} 30 | ETCDIR?= ${DESTDIR}${PREFIX}/etc 31 | RCDIR?= ${ETCDIR}/rc.d 32 | MANDIR?= ${DESTDIR}${PREFIX}/man 33 | MAN5DIR?= ${MANDIR}/man5 34 | 35 | .PHONY: all 36 | all: kbfsd 37 | 38 | kbfsd: kbfsd.in 39 | sed -e 's|%%LOCALBASE%%|${LOCALBASE}|g' \ 40 | kbfsd.in > kbfsd 41 | 42 | .PHONY: install 43 | install: kbfsd 44 | mkdir -p ${RCDIR} 45 | install -m 0755 kbfsd ${RCDIR}/kbfsd 46 | mkdir -p ${MAN5DIR} 47 | install -m 0555 kbfsd.5 ${MAN5DIR}/kbfsd.5 48 | 49 | .PHONY: clean 50 | clean: 51 | rm -f -- kbfsd 52 | 53 | .PHONY: regenerate-readme 54 | regenerate-readme: 55 | mandoc -Tmarkdown kbfsd.5 | awk 'NR > 2 {print}' | sed '$d;x' | sed '$d;x' > README.md 56 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # NAME 4 | 5 | **kbfsd** - service daemon for the Keybase filesystem (KBFS) 6 | 7 | # SYNOPSIS 8 | 9 | Required 10 | rc.conf(5) 11 | variables: 12 | 13 | kbfsd_enable="YES" 14 | kbfsd_user="beastie" 15 | 16 | Optional 17 | rc.conf(5) 18 | variables: 19 | 20 | kbfsd_keybase_username="${kbfsd_user}" 21 | kbfsd_mountpoint="/keybase" 22 | 23 | # DESCRIPTION 24 | 25 | **kbfsd** 26 | is an 27 | rc(8) 28 | daemon for the Keybase filesystem (KBFS). 29 | Its aim is to ease the process of using KBFS on 30 | FreeBSD. 31 | It takes care of the configuration the Keybase user would have to do manually 32 | otherwise. 33 | 34 | **kbfsd** 35 | does not start automatically even when 36 | *kbfsd\_enable* 37 | is set to 38 | '`YES`' 39 | in 40 | rc.conf(5). 41 | See the 42 | *CAVEATS* 43 | section for more details. 44 | 45 | **kbfsd** 46 | has to configure some bits of the system in order to mount KBFS as 47 | *kbfsd_user*. 48 | *kbfsd_mountpoint* 49 | is created and 50 | the 51 | sysctl(8) 52 | tunable 53 | *vfs.usermount* 54 | is set to 55 | "1" 56 | so that 57 | *kbfsd_user* 58 | could mount 59 | *kbfsd_mountpoint*. 60 | Then 61 | *kbfsd_user* 62 | is added to the 63 | "operator" 64 | group to be able to use the 65 | */dev/fuse* 66 | device. 67 | Finally, 68 | **kbfsd** 69 | attempts to spin off the Keybase server and create required socket files. 70 | Note that this step requires 71 | *kbfsd_user* 72 | to be able to log in as 73 | *kbfsd_keybase_username*. 74 | This should be possible once 75 | *kbfsd_user* 76 | registers a device with 77 | '`keybase device add`'. 78 | 79 | **kbfsd** 80 | may be controlled with the following 81 | rc.conf(5) 82 | variables: 83 | 84 | *kbfsd_enable* 85 | 86 | (*bool*, default: '`NO`') 87 | Enable 88 | **kbfsd**. 89 | 90 | *kbfsd_keybase_username* 91 | 92 | (*str*, default: *kbfsd_user*) 93 | The username used to log into Keybase. 94 | 95 | *kbfsd_mountpoint* 96 | 97 | (*str*, default: '`/keybase`') 98 | The directory where KBFS should be mounted. 99 | 100 | *kbfsd_user* 101 | 102 | (*str*, no defaults) 103 | The login name of a user, who should own 104 | *kbfsd_mountpoint*. 105 | It cannot be empty. 106 | 107 | # INSTALLATION 108 | 109 | The easiest way is to just install the 110 | **kbfsd** 111 | package via 112 | pkg(8) 113 | on 114 | FreeBSD: 115 | 116 | pkg install kbfsd 117 | 118 | **kbfsd** 119 | can be installed manually with the following command: 120 | 121 | make all 122 | make install 123 | 124 | # FILES 125 | 126 | */home/*${*kbfsd_user*}*/.config/keybase/kbfsd.*${*kbfsd_user*}*.pid* 127 | 128 | PID file. 129 | 130 | # EXIT STATUS 131 | 132 | The 133 | **kbfsd** 134 | daemon 135 | exits 0 on success, and >0 if an error occurs. 136 | 137 | # SEE ALSO 138 | 139 | rc.conf(5), 140 | mount(8), 141 | rc(8) 142 | 143 | # AUTHORS 144 | 145 | The 146 | **kbfsd** 147 | daemon and its manual page were written by 148 | Mateusz Piotrowski <[0mp@FreeBSD.org](mailto:0mp@FreeBSD.org)>. 149 | 150 | # CAVEATS 151 | 152 | **kbfsd** 153 | is 154 | *not* 155 | started automatically together with other daemons during boot because it uses 156 | the 157 | '`nostart`' 158 | KEYWORD 159 | (see rc(8) for details). 160 | The reason is that in order to reliably mount KBFS the user has to establish 161 | a session with the Keybase server first. 162 | This is done by calling: 163 | '`keybase login username`' 164 | (where 165 | *username* 166 | is the same as 167 | *kbfsd_keybase_username*) 168 | . 169 | Unfortunately, this command happens to block the booting process from time to 170 | time, which is unacceptable. 171 | 172 | # BUGS 173 | 174 | **kbfsd** 175 | seems to kill 176 | **kbfsfuse** 177 | too rapidly for 178 | **kbfsfuse** 179 | to properly unmount. 180 | As a workaround, 181 | **kbfsd** 182 | calls 183 | umount(8) 184 | on the mount point in the 185 | *poststop* 186 | phase 187 | (see rc.subr(8)). 188 | 189 | Currently, 190 | **kbfsd** 191 | uses 192 | *kbfsd_env* 193 | internally to set the 194 | `HOME` 195 | environmental variable to the home directory of 196 | *kbfsd_user*. 197 | It is recommended to read the service file before setting 198 | *kbfsd_env* 199 | in 200 | rc.conf(5). 201 | 202 | On some 203 | FreeBSD 204 | versions older than 13.0 the name of 205 | fusefs(5) 206 | might be 207 | "fuse" 208 | instead of 209 | "fusefs". 210 | As a result, 211 | **kbfsd** 212 | might fail to start. 213 | A potential workaronud is to set 214 | *required_modules* 215 | to an empty string in 216 | */usr/local/etc/rc.conf.d/kbfsd* 217 | and then loading the FUSE kernel module differently 218 | (e.g., via 219 | *kld_list* 220 | in 221 | rc.conf(5)) 222 | . 223 | -------------------------------------------------------------------------------- /kbfsd.5: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" SPDX-License-Identifier: BSD-2-Clause 3 | .\" 4 | .\" Copyright (c) 2018-2021 Mateusz Piotrowski <0mp@FreeBSD.org> 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that the following conditions are met: 8 | .\" 9 | .\" 1. Redistributions of source code must retain the above copyright notice, 10 | .\" this list of conditions and the following disclaimer. 11 | .\" 12 | .\" 2. Redistributions in binary form must reproduce the above copyright 13 | .\" notice, this list of conditions and the following disclaimer in the 14 | .\" documentation and/or other materials provided with the distribution. 15 | .\" 16 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | .\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 | .\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | .\" POSSIBILITY OF SUCH DAMAGE. 27 | .Dd July 22, 2021 28 | .Dt KBFSD 5 29 | .Os 30 | .Sh NAME 31 | .Nm kbfsd 32 | .Nd service daemon for the Keybase filesystem (KBFS) 33 | .Sh SYNOPSIS 34 | Required 35 | .Xr rc.conf 5 36 | variables: 37 | .Bd -literal -offset indent 38 | kbfsd_enable="YES" 39 | kbfsd_user="beastie" 40 | .Ed 41 | .Pp 42 | Optional 43 | .Xr rc.conf 5 44 | variables: 45 | .Bd -literal -offset indent 46 | kbfsd_keybase_username="${kbfsd_user}" 47 | kbfsd_mountpoint="/keybase" 48 | .Ed 49 | .Sh DESCRIPTION 50 | .Nm 51 | is an 52 | .Xr rc 8 53 | daemon for the Keybase filesystem (KBFS). 54 | Its aim is to ease the process of using KBFS on 55 | .Fx . 56 | It takes care of the configuration the Keybase user would have to do manually 57 | otherwise. 58 | .Pp 59 | .Nm 60 | does not start automatically even when 61 | .Va kbfsd_enable 62 | is set to 63 | .Ql YES 64 | in 65 | .Xr rc.conf 5 . 66 | See the 67 | .Sx CAVEATS 68 | section for more details. 69 | .Pp 70 | .Nm 71 | has to configure some bits of the system in order to mount KBFS as 72 | .Va kbfsd_user . 73 | .Va kbfsd_mountpoint 74 | is created and 75 | the 76 | .Xr sysctl 8 77 | tunable 78 | .Va vfs.usermount 79 | is set to 80 | .Dq 1 81 | so that 82 | .Va kbfsd_user 83 | could mount 84 | .Va kbfsd_mountpoint . 85 | Then 86 | .Va kbfsd_user 87 | is added to the 88 | .Dq operator 89 | group to be able to use the 90 | .Pa /dev/fuse 91 | device. 92 | Finally, 93 | .Nm 94 | attempts to spin off the Keybase server and create required socket files. 95 | Note that this step requires 96 | .Va kbfsd_user 97 | to be able to log in as 98 | .Va kbfsd_keybase_username . 99 | This should be possible once 100 | .Va kbfsd_user 101 | registers a device with 102 | .Ql keybase device add . 103 | .Pp 104 | .Nm 105 | may be controlled with the following 106 | .Xr rc.conf 5 107 | variables: 108 | .Bl -tag -width kbfsd_keybase_username 109 | .It Va kbfsd_enable 110 | .Pq Vt bool , No default: Ql NO 111 | Enable 112 | .Nm . 113 | .It Va kbfsd_keybase_username 114 | .Pq Vt str , No default: Va kbfsd_user 115 | The username used to log into Keybase. 116 | .It Va kbfsd_mountpoint 117 | .Pq Vt str , No default: Ql /keybase 118 | The directory where KBFS should be mounted. 119 | .It Va kbfsd_user 120 | .Pq Vt str , No no defaults 121 | The login name of a user, who should own 122 | .Va kbfsd_mountpoint . 123 | It cannot be empty. 124 | .El 125 | .Sh INSTALLATION 126 | The easiest way is to just install the 127 | .Nm 128 | package via 129 | .Xr pkg 8 130 | on 131 | .Fx : 132 | .Bd -literal -offset indent 133 | pkg install kbfsd 134 | .Ed 135 | .Pp 136 | .Nm 137 | can be installed manually with the following command: 138 | .Bd -literal -offset indent 139 | make all 140 | make install 141 | .Ed 142 | .Sh FILES 143 | .Bl -tag -width "/home/${kbfsd_user}/.config/keybase/kbfsd.${kbfsd_user}.pid" -compact 144 | .Sm off 145 | .It Pa /home/ No ${ Ar kbfsd_user No } Pa /.config/keybase/kbfsd\&. No ${ Ar kbfsd_user No } Pa ".pid" 146 | .Sm on 147 | PID file. 148 | .El 149 | .Sh EXIT STATUS 150 | The 151 | .Nm 152 | daemon 153 | exits 0 on success, and >0 if an error occurs. 154 | .Sh SEE ALSO 155 | .Xr rc.conf 5 , 156 | .Xr mount 8 , 157 | .Xr rc 8 158 | .Sh AUTHORS 159 | The 160 | .Nm 161 | daemon and its manual page were written by 162 | .An Mateusz Piotrowski Aq Mt 0mp@FreeBSD.org . 163 | .Sh CAVEATS 164 | .Nm 165 | is 166 | .Em not 167 | started automatically together with other daemons during boot because it uses 168 | the 169 | .Ql nostart 170 | KEYWORD 171 | .Pq see Xr rc 8 for details . 172 | The reason is that in order to reliably mount KBFS the user has to establish 173 | a session with the Keybase server first. 174 | This is done by calling: 175 | .Ql keybase login username 176 | .Po where 177 | .Ar username 178 | is the same as 179 | .Ar kbfsd_keybase_username 180 | .Pc . 181 | Unfortunately, this command happens to block the booting process from time to 182 | time, which is unacceptable. 183 | .Sh BUGS 184 | .Nm 185 | seems to kill 186 | .Nm kbfsfuse 187 | too rapidly for 188 | .Nm kbfsfuse 189 | to properly unmount. 190 | As a workaround, 191 | .Nm 192 | calls 193 | .Xr umount 8 194 | on the mount point in the 195 | .Em poststop 196 | phase 197 | .Pq see Xr rc.subr 8 . 198 | .Pp 199 | Currently, 200 | .Nm 201 | uses 202 | .Va kbfsd_env 203 | internally to set the 204 | .Ev HOME 205 | environmental variable to the home directory of 206 | .Va kbfsd_user . 207 | It is recommended to read the service file before setting 208 | .Va kbfsd_env 209 | in 210 | .Xr rc.conf 5 . 211 | .Pp 212 | On some 213 | .Fx 214 | versions older than 13.0 the name of 215 | .Xr fusefs 5 216 | might be 217 | .Dq fuse 218 | instead of 219 | .Dq fusefs . 220 | As a result, 221 | .Nm 222 | might fail to start. 223 | A potential workaronud is to set 224 | .Va required_modules 225 | to an empty string in 226 | .Pa /usr/local/etc/rc.conf.d/kbfsd 227 | and then loading the FUSE kernel module differently 228 | .Po e.g., via 229 | .Va kld_list 230 | in 231 | .Xr rc.conf 5 232 | .Pc . 233 | -------------------------------------------------------------------------------- /kbfsd.in: -------------------------------------------------------------------------------- 1 | #! /bin/sh - 2 | # 3 | # SPDX-License-Identifier: BSD-2-Clause 4 | # 5 | # Copyright (c) 2018-2021 Mateusz Piotrowski <0mp@FreeBSD.org> 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions are met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright notice, 11 | # this list of conditions and the following disclaimer. 12 | # 2. Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | # POSSIBILITY OF SUCH DAMAGE. 27 | 28 | # PROVIDE: kbfsd 29 | # REQUIRE: DAEMON LOGIN NETWORKING 30 | # KEYWORD: nostart 31 | 32 | . /etc/rc.subr 33 | 34 | name='kbfsd' 35 | rcvar='kbfsd_enable' 36 | 37 | load_rc_config "${name}" 38 | 39 | # Default settings. 40 | : "${kbfsd_enable:=no}" 41 | : "${kbfsd_mountpoint:=/keybase}" 42 | : "${kbfsd_user:?kbfsd_user cannot be empty.}" 43 | # It has to be done manually because the su(1) mechanism present in rc.subr(8) 44 | # uses the "-m" flag, which causes kbfsfuse to look for files in root's 45 | # directories instead of the directories of ${kbfsd_user}. 46 | : "${kbfsd_env:="HOME=/home/${kbfsd_user}"}" 47 | : "${kbfsd_keybase_username:="${kbfsd_user}"}" 48 | 49 | # This location is a popular one for other Keybase-related files. 50 | pidfile="/home/${kbfsd_user}/.config/keybase/kbfsd.${kbfsd_user}.pid" 51 | 52 | # The "procname" variable has to be set because we use daemon(8) here and the 53 | # process name does not match the "command" variable. 54 | procname='%%LOCALBASE%%/bin/kbfsfuse' 55 | command='/usr/sbin/daemon' 56 | command_args="-p ${pidfile} %%LOCALBASE%%/bin/kbfsfuse -log-to-file ${kbfsd_mountpoint}" 57 | 58 | start_precmd="kbfsd_prestart" 59 | stop_postcmd="kbfsd_poststop" 60 | 61 | required_modules='fusefs' 62 | 63 | kbfsd_prestart() 64 | { 65 | # Make sure that the username is valid. 66 | if pw showuser -n "${kbfsd_user}" > /dev/null 2>&1 67 | then :; else 68 | err "${?}" "kbfsd_user is set to '${kbfsd_user}' which is not a valid user." 69 | fi 70 | 71 | # Attempt to unmount in case there are some leftovers after 72 | # previous kbfsfuse. 73 | umount "${kbfsd_mountpoint}" > /dev/null 2>&1 74 | # Create the mountpoint for the filesystem. 75 | if mkdir -p -- "${kbfsd_mountpoint}" 76 | then :; else 77 | err "${?}" "Cannot create the '${kbfsd_mountpoint}' directory.'" 78 | fi 79 | if chown "${kbfsd_user}" "${kbfsd_mountpoint}" 80 | then :; else 81 | err "${?}" "Cannot set ${kbfsd_user} as the owner of ${kbfsd_mountpoint}." 82 | fi 83 | 84 | # Make it possible to mount filesystems as a normal user. 85 | if sysctl vfs.usermount=1 > /dev/null 2>&1 86 | then :; else 87 | err "${?}" "Cannot set vfs.usermount to 1." 88 | fi 89 | 90 | # Add the specified user account to the opearator group so that it 91 | # could use the /dev/fuse device. 92 | if pw groupmod operator -m "${kbfsd_user}" 93 | then :; else 94 | err "${?}" "Cannot add ${kbfsd_user} to the operator group." 95 | fi 96 | 97 | if %%LOCALBASE%%/bin/jq --exit-status \ 98 | ".current_user == \"${kbfsd_keybase_username}\"" \ 99 | "/home/${kbfsd_user}/.config/keybase/config.json" | 100 | grep true >/dev/null 101 | then :; else 102 | err 78 "\"${kbfsd_keybase_username}\" is not logged into Keybase." 103 | fi 104 | 105 | 106 | # The Keybase client has to be initiated so that 107 | # "/home/${kbfsd_user}/.config/keybase/keybased.sock" is present. 108 | su -l "${kbfsd_user}" -c "%%LOCALBASE%%/bin/keybase login ${kbfsd_keybase_username}" > /dev/null 2>&1 109 | 110 | local _keybased_sock="/home/${kbfsd_user}/.config/keybase/keybased.sock" 111 | if [ ! -S "${_keybased_sock}" ]; then 112 | err 78 "Missing the \"${_keybased_sock}\" file." 113 | fi 114 | 115 | return 0 116 | } 117 | 118 | kbfsd_poststop() 119 | { 120 | # Attempt to unmount in case there are some leftovers after terminating 121 | # kbfsfuse too rapidly. 122 | umount "${kbfsd_mountpoint}" > /dev/null 2>&1 123 | } 124 | 125 | run_rc_command "$1" 126 | 127 | # vim: filetype=sh softtabstop=8 shiftwidth=8 tabstop=8 noexpandtab 128 | --------------------------------------------------------------------------------