Commit c9903fd
committed
Attempt to continue working without namespacing if apparmor denies user namespaces.
If apparmor is configured to deny unprivileged user namespaces, the
unshare(CLONE_NEWUSER) call will still work, it just won't have any
privileges (like CAP_SYS_ADMIN) that we need. This will manifest itself
in the deny_setgroups() function when we try to open /proc/pid/setgroups
for write.
When the unshare() call itself fails, we try to continue on without
namespacing enabled. This allows at least for diminished functionality
where .tup/mnt paths are visibile to subprocesses. However, when the
deny_setgroups() function fails, tup was just quitting outright. It
would be better if we could continue in the diminished capacity as if
the unshare() call itself failed.
Unfortunately, since unshare() isn't failing, we're already in a new
namespace by the time we know that it doesn't have the capabilities we
need. Therefore we need to close out the child master_fork process and
create a new one in the original namespace. This is the reason for the
funkiness of writing out a special restart token ("2").
To prevent these error messages from showing up in the first place, one
could set TUP_NO_NAMESPACING=1 in the environment to force tup to run
without trying namespacing in the first place. Another option is to
update the apparmor configuration for tup. For example, Ubuntu comes
with a default tup configuration in /etc/apparmor.d/tup that contains:
---
abi <abi/4.0>,
include <tunables/global>
profile tup /usr/bin/tup flags=(unconfined) {
userns,
# Site-specific additions and overrides. See local/README for details.
include if exists <local/tup>
}
---
The path (here, /usr/bin/tup) needs to match the path of the actual tup
binary. So if building tup from source, these paths won't match. You
could add another profile in the same file or create a new apparmor
profile like so:
---
profile localtup /path/to/local/tup/tup flags=(unconfined) {
userns,
# Site-specific additions and overrides. See local/README for details.
include if exists <local/tup>
}
---
Fixes #502.1 parent 1091529 commit c9903fd
2 files changed
+65
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
105 | | - | |
| 104 | + | |
106 | 105 | | |
107 | 106 | | |
108 | 107 | | |
109 | 108 | | |
110 | | - | |
| 109 | + | |
111 | 110 | | |
112 | 111 | | |
113 | 112 | | |
| |||
139 | 138 | | |
140 | 139 | | |
141 | 140 | | |
| 141 | + | |
142 | 142 | | |
143 | 143 | | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
144 | 150 | | |
145 | 151 | | |
146 | 152 | | |
| |||
176 | 182 | | |
177 | 183 | | |
178 | 184 | | |
179 | | - | |
| 185 | + | |
| 186 | + | |
180 | 187 | | |
181 | 188 | | |
182 | | - | |
183 | | - | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
184 | 206 | | |
185 | 207 | | |
186 | 208 | | |
| |||
202 | 224 | | |
203 | 225 | | |
204 | 226 | | |
| 227 | + | |
205 | 228 | | |
206 | 229 | | |
207 | 230 | | |
| |||
213 | 236 | | |
214 | 237 | | |
215 | 238 | | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
216 | 251 | | |
217 | 252 | | |
218 | 253 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
205 | | - | |
206 | | - | |
| 205 | + | |
207 | 206 | | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
208 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
209 | 231 | | |
210 | | - | |
211 | 232 | | |
212 | 233 | | |
213 | 234 | | |
| |||
0 commit comments