Merge lp:~logan/ubuntu/quantal/nfs-utils/debian-merge into lp:ubuntu/quantal/nfs-utils
- Quantal (12.10)
- debian-merge
- Merge into quantal
Proposed by
Logan Rosen
Status: | Merged |
---|---|
Merged at revision: | 59 |
Proposed branch: | lp:~logan/ubuntu/quantal/nfs-utils/debian-merge |
Merge into: | lp:ubuntu/quantal/nfs-utils |
Diff against target: |
4328 lines (+58/-3989) 29 files modified
.pc/.quilt_patches (+1/-0) .pc/.quilt_series (+1/-0) .pc/01-sm-notify-in-sbin.patch/utils/statd/statd.c (+0/-493) .pc/02-524255-manpages.patch/utils/exportfs/nfsd.man (+0/-206) .pc/02-524255-manpages.patch/utils/nfsd/nfsd.man (+0/-105) .pc/03-handle-mtab-symlink.patch/utils/mount/fstab.c (+0/-649) .pc/03-handle-mtab-symlink.patch/utils/mount/fstab.h (+0/-31) .pc/03-handle-mtab-symlink.patch/utils/mount/mount.c (+0/-550) .pc/11-532048-reduce-verbosity.patch/utils/gssd/gss_util.c (+0/-341) .pc/11-532048-reduce-verbosity.patch/utils/gssd/gssd_proc.c (+0/-1241) .pc/16-mount.nfs.man-update-distinction-between-fstype.patch/utils/mount/mount.nfs.man (+0/-86) .pc/17-multiarch-kerberos-paths.patch/aclocal/kerberos5.m4 (+0/-115) .pc/18-osd_login-sbindir.patch/utils/osd_login/Makefile.am (+0/-12) .pc/19-iscsiadm-path.patch/utils/osd_login/osd_login (+0/-118) .pc/applied-patches (+0/-8) aclocal/kerberos5.m4 (+0/-2) debian/changelog (+27/-0) debian/nfs-kernel-server.init (+7/-1) utils/exportfs/nfsd.man (+0/-1) utils/gssd/gss_util.c (+1/-1) utils/gssd/gssd_proc.c (+3/-3) utils/mount/fstab.c (+1/-1) utils/mount/fstab.h (+0/-1) utils/mount/mount.c (+0/-7) utils/mount/mount.nfs.man (+4/-8) utils/nfsd/nfsd.man (+0/-1) utils/osd_login/Makefile.am (+8/-5) utils/osd_login/osd_login (+4/-2) utils/statd/statd.c (+1/-1) |
To merge this branch: | bzr merge lp:~logan/ubuntu/quantal/nfs-utils/debian-merge |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Luke Yelavich (community) | Approve | ||
Ubuntu branches | Pending | ||
Review via email: mp+118261@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added file '.pc/.quilt_patches' | |||
2 | --- .pc/.quilt_patches 1970-01-01 00:00:00 +0000 | |||
3 | +++ .pc/.quilt_patches 2012-08-05 05:01:18 +0000 | |||
4 | @@ -0,0 +1,1 @@ | |||
5 | 1 | debian/patches | ||
6 | 0 | 2 | ||
7 | === added file '.pc/.quilt_series' | |||
8 | --- .pc/.quilt_series 1970-01-01 00:00:00 +0000 | |||
9 | +++ .pc/.quilt_series 2012-08-05 05:01:18 +0000 | |||
10 | @@ -0,0 +1,1 @@ | |||
11 | 1 | series | ||
12 | 0 | 2 | ||
13 | === removed directory '.pc/01-sm-notify-in-sbin.patch' | |||
14 | === removed directory '.pc/01-sm-notify-in-sbin.patch/utils' | |||
15 | === removed directory '.pc/01-sm-notify-in-sbin.patch/utils/statd' | |||
16 | === removed file '.pc/01-sm-notify-in-sbin.patch/utils/statd/statd.c' | |||
17 | --- .pc/01-sm-notify-in-sbin.patch/utils/statd/statd.c 2010-04-06 16:11:22 +0000 | |||
18 | +++ .pc/01-sm-notify-in-sbin.patch/utils/statd/statd.c 1970-01-01 00:00:00 +0000 | |||
19 | @@ -1,493 +0,0 @@ | |||
20 | 1 | /* | ||
21 | 2 | * Copyright (C) 1995, 1997-1999 Jeffrey A. Uphoff | ||
22 | 3 | * Modified by Olaf Kirch, Oct. 1996. | ||
23 | 4 | * Modified by H.J. Lu, 1998. | ||
24 | 5 | * Modified by L. Hohberger of Mission Critical Linux, 2000. | ||
25 | 6 | * | ||
26 | 7 | * NSM for Linux. | ||
27 | 8 | */ | ||
28 | 9 | |||
29 | 10 | #ifdef HAVE_CONFIG_H | ||
30 | 11 | #include <config.h> | ||
31 | 12 | #endif | ||
32 | 13 | |||
33 | 14 | #include <sys/stat.h> | ||
34 | 15 | #include <limits.h> | ||
35 | 16 | #include <signal.h> | ||
36 | 17 | #include <unistd.h> | ||
37 | 18 | #include <fcntl.h> | ||
38 | 19 | #include <errno.h> | ||
39 | 20 | #include <string.h> | ||
40 | 21 | #include <getopt.h> | ||
41 | 22 | #include <rpc/rpc.h> | ||
42 | 23 | #include <rpc/pmap_clnt.h> | ||
43 | 24 | #include <rpcmisc.h> | ||
44 | 25 | #include <sys/resource.h> | ||
45 | 26 | #include <sys/wait.h> | ||
46 | 27 | #include <grp.h> | ||
47 | 28 | |||
48 | 29 | #include "statd.h" | ||
49 | 30 | #include "nfslib.h" | ||
50 | 31 | #include "nsm.h" | ||
51 | 32 | |||
52 | 33 | /* Socket operations */ | ||
53 | 34 | #include <sys/types.h> | ||
54 | 35 | #include <sys/socket.h> | ||
55 | 36 | |||
56 | 37 | int run_mode = 0; /* foreground logging mode */ | ||
57 | 38 | |||
58 | 39 | /* LH - I had these local to main, but it seemed silly to have | ||
59 | 40 | * two copies of each - one in main(), one static in log.c... | ||
60 | 41 | * It also eliminates the 256-char static in log.c */ | ||
61 | 42 | static char *name_p = NULL; | ||
62 | 43 | |||
63 | 44 | /* PRC: a high-availability callout program can be specified with -H | ||
64 | 45 | * When this is done, the program will receive callouts whenever clients | ||
65 | 46 | * are added or deleted to the notify list */ | ||
66 | 47 | char *ha_callout_prog = NULL; | ||
67 | 48 | |||
68 | 49 | static struct option longopts[] = | ||
69 | 50 | { | ||
70 | 51 | { "foreground", 0, 0, 'F' }, | ||
71 | 52 | { "no-syslog", 0, 0, 'd' }, | ||
72 | 53 | { "help", 0, 0, 'h' }, | ||
73 | 54 | { "version", 0, 0, 'v' }, | ||
74 | 55 | { "outgoing-port", 1, 0, 'o' }, | ||
75 | 56 | { "port", 1, 0, 'p' }, | ||
76 | 57 | { "name", 1, 0, 'n' }, | ||
77 | 58 | { "state-directory-path", 1, 0, 'P' }, | ||
78 | 59 | { "notify-mode", 0, 0, 'N' }, | ||
79 | 60 | { "ha-callout", 1, 0, 'H' }, | ||
80 | 61 | { "no-notify", 0, 0, 'L' }, | ||
81 | 62 | { NULL, 0, 0, 0 } | ||
82 | 63 | }; | ||
83 | 64 | |||
84 | 65 | extern void sm_prog_1 (struct svc_req *, register SVCXPRT *); | ||
85 | 66 | |||
86 | 67 | #ifdef SIMULATIONS | ||
87 | 68 | extern void simulator (int, char **); | ||
88 | 69 | #endif | ||
89 | 70 | |||
90 | 71 | |||
91 | 72 | #ifdef HAVE_TCP_WRAPPER | ||
92 | 73 | #include "tcpwrapper.h" | ||
93 | 74 | |||
94 | 75 | static void | ||
95 | 76 | sm_prog_1_wrapper (struct svc_req *rqstp, register SVCXPRT *transp) | ||
96 | 77 | { | ||
97 | 78 | /* remote host authorization check */ | ||
98 | 79 | if (!check_default("statd", nfs_getrpccaller(transp), SM_PROG)) { | ||
99 | 80 | svcerr_auth (transp, AUTH_FAILED); | ||
100 | 81 | return; | ||
101 | 82 | } | ||
102 | 83 | |||
103 | 84 | sm_prog_1 (rqstp, transp); | ||
104 | 85 | } | ||
105 | 86 | |||
106 | 87 | #define sm_prog_1 sm_prog_1_wrapper | ||
107 | 88 | #endif | ||
108 | 89 | |||
109 | 90 | static void | ||
110 | 91 | statd_unregister(void) { | ||
111 | 92 | nfs_svc_unregister(SM_PROG, SM_VERS); | ||
112 | 93 | } | ||
113 | 94 | |||
114 | 95 | /* | ||
115 | 96 | * Signal handler. | ||
116 | 97 | */ | ||
117 | 98 | static void | ||
118 | 99 | killer (int sig) | ||
119 | 100 | { | ||
120 | 101 | statd_unregister (); | ||
121 | 102 | xlog_err ("Caught signal %d, un-registering and exiting", sig); | ||
122 | 103 | } | ||
123 | 104 | |||
124 | 105 | static void | ||
125 | 106 | sigusr (int sig) | ||
126 | 107 | { | ||
127 | 108 | extern void my_svc_exit (void); | ||
128 | 109 | xlog(D_GENERAL, "Caught signal %d, re-notifying (state %d)", sig, | ||
129 | 110 | MY_STATE); | ||
130 | 111 | my_svc_exit(); | ||
131 | 112 | } | ||
132 | 113 | |||
133 | 114 | /* | ||
134 | 115 | * Startup information. | ||
135 | 116 | */ | ||
136 | 117 | static void log_modes(void) | ||
137 | 118 | { | ||
138 | 119 | char buf[128]; /* watch stack size... */ | ||
139 | 120 | |||
140 | 121 | /* No flags = no message */ | ||
141 | 122 | if (!run_mode) return; | ||
142 | 123 | |||
143 | 124 | memset(buf,0,128); | ||
144 | 125 | sprintf(buf,"Flags: "); | ||
145 | 126 | if (run_mode & MODE_NODAEMON) | ||
146 | 127 | strcat(buf,"No-Daemon "); | ||
147 | 128 | if (run_mode & MODE_LOG_STDERR) | ||
148 | 129 | strcat(buf,"Log-STDERR "); | ||
149 | 130 | #ifdef HAVE_LIBTIRPC | ||
150 | 131 | strcat(buf, "TI-RPC "); | ||
151 | 132 | #endif | ||
152 | 133 | |||
153 | 134 | xlog_warn(buf); | ||
154 | 135 | } | ||
155 | 136 | |||
156 | 137 | /* | ||
157 | 138 | * Since we do more than standard statd stuff, we might need to | ||
158 | 139 | * help the occasional admin. | ||
159 | 140 | */ | ||
160 | 141 | static void | ||
161 | 142 | usage(void) | ||
162 | 143 | { | ||
163 | 144 | fprintf(stderr,"usage: %s [options]\n", name_p); | ||
164 | 145 | fprintf(stderr," -h, -?, --help Print this help screen.\n"); | ||
165 | 146 | fprintf(stderr," -F, --foreground Foreground (no-daemon mode)\n"); | ||
166 | 147 | fprintf(stderr," -d, --no-syslog Verbose logging to stderr. Foreground mode only.\n"); | ||
167 | 148 | fprintf(stderr," -p, --port Port to listen on\n"); | ||
168 | 149 | fprintf(stderr," -o, --outgoing-port Port for outgoing connections\n"); | ||
169 | 150 | fprintf(stderr," -V, -v, --version Display version information and exit.\n"); | ||
170 | 151 | fprintf(stderr," -n, --name Specify a local hostname.\n"); | ||
171 | 152 | fprintf(stderr," -P State directory path.\n"); | ||
172 | 153 | fprintf(stderr," -N Run in notify only mode.\n"); | ||
173 | 154 | fprintf(stderr," -L, --no-notify Do not perform any notification.\n"); | ||
174 | 155 | fprintf(stderr," -H Specify a high-availability callout program.\n"); | ||
175 | 156 | } | ||
176 | 157 | |||
177 | 158 | static const char *pidfile = "/var/run/rpc.statd.pid"; | ||
178 | 159 | |||
179 | 160 | int pidfd = -1; | ||
180 | 161 | static void create_pidfile(void) | ||
181 | 162 | { | ||
182 | 163 | FILE *fp; | ||
183 | 164 | |||
184 | 165 | unlink(pidfile); | ||
185 | 166 | fp = fopen(pidfile, "w"); | ||
186 | 167 | if (!fp) | ||
187 | 168 | xlog_err("Opening %s failed: %m\n", pidfile); | ||
188 | 169 | fprintf(fp, "%d\n", getpid()); | ||
189 | 170 | pidfd = dup(fileno(fp)); | ||
190 | 171 | if (fclose(fp) < 0) { | ||
191 | 172 | xlog_warn("Flushing pid file failed: errno %d (%m)\n", | ||
192 | 173 | errno); | ||
193 | 174 | } | ||
194 | 175 | } | ||
195 | 176 | |||
196 | 177 | static void truncate_pidfile(void) | ||
197 | 178 | { | ||
198 | 179 | if (pidfd >= 0) { | ||
199 | 180 | if (ftruncate(pidfd, 0) < 0) { | ||
200 | 181 | xlog_warn("truncating pid file failed: errno %d (%m)\n", | ||
201 | 182 | errno); | ||
202 | 183 | } | ||
203 | 184 | } | ||
204 | 185 | } | ||
205 | 186 | |||
206 | 187 | static void run_sm_notify(int outport) | ||
207 | 188 | { | ||
208 | 189 | char op[20]; | ||
209 | 190 | char *av[6]; | ||
210 | 191 | int ac = 0; | ||
211 | 192 | |||
212 | 193 | av[ac++] = "/usr/sbin/sm-notify"; | ||
213 | 194 | if (run_mode & MODE_NODAEMON) | ||
214 | 195 | av[ac++] = "-d"; | ||
215 | 196 | if (outport) { | ||
216 | 197 | sprintf(op, "-p%d", outport); | ||
217 | 198 | av[ac++] = op; | ||
218 | 199 | } | ||
219 | 200 | if (run_mode & STATIC_HOSTNAME) { | ||
220 | 201 | av[ac++] = "-v"; | ||
221 | 202 | av[ac++] = MY_NAME; | ||
222 | 203 | } | ||
223 | 204 | av[ac] = NULL; | ||
224 | 205 | execv(av[0], av); | ||
225 | 206 | fprintf(stderr, "%s: failed to run %s\n", name_p, av[0]); | ||
226 | 207 | exit(2); | ||
227 | 208 | |||
228 | 209 | } | ||
229 | 210 | /* | ||
230 | 211 | * Entry routine/main loop. | ||
231 | 212 | */ | ||
232 | 213 | int main (int argc, char **argv) | ||
233 | 214 | { | ||
234 | 215 | extern char *optarg; | ||
235 | 216 | int pid; | ||
236 | 217 | int arg; | ||
237 | 218 | int port = 0, out_port = 0; | ||
238 | 219 | struct rlimit rlim; | ||
239 | 220 | |||
240 | 221 | int pipefds[2] = { -1, -1}; | ||
241 | 222 | char status; | ||
242 | 223 | |||
243 | 224 | /* Default: daemon mode, no other options */ | ||
244 | 225 | run_mode = 0; | ||
245 | 226 | xlog_stderr(0); | ||
246 | 227 | xlog_syslog(1); | ||
247 | 228 | |||
248 | 229 | /* Set the basename */ | ||
249 | 230 | if ((name_p = strrchr(argv[0],'/')) != NULL) { | ||
250 | 231 | name_p ++; | ||
251 | 232 | } else { | ||
252 | 233 | name_p = argv[0]; | ||
253 | 234 | } | ||
254 | 235 | |||
255 | 236 | /* Set hostname */ | ||
256 | 237 | MY_NAME = NULL; | ||
257 | 238 | |||
258 | 239 | /* Process command line switches */ | ||
259 | 240 | while ((arg = getopt_long(argc, argv, "h?vVFNH:dn:p:o:P:L", longopts, NULL)) != EOF) { | ||
260 | 241 | switch (arg) { | ||
261 | 242 | case 'V': /* Version */ | ||
262 | 243 | case 'v': | ||
263 | 244 | printf("%s version " VERSION "\n",name_p); | ||
264 | 245 | exit(0); | ||
265 | 246 | case 'F': /* Foreground/nodaemon mode */ | ||
266 | 247 | run_mode |= MODE_NODAEMON; | ||
267 | 248 | break; | ||
268 | 249 | case 'N': | ||
269 | 250 | run_mode |= MODE_NOTIFY_ONLY; | ||
270 | 251 | break; | ||
271 | 252 | case 'L': /* Listen only */ | ||
272 | 253 | run_mode |= MODE_NO_NOTIFY; | ||
273 | 254 | break; | ||
274 | 255 | case 'd': /* No daemon only - log to stderr */ | ||
275 | 256 | run_mode |= MODE_LOG_STDERR; | ||
276 | 257 | break; | ||
277 | 258 | case 'o': | ||
278 | 259 | out_port = atoi(optarg); | ||
279 | 260 | if (out_port < 1 || out_port > 65535) { | ||
280 | 261 | fprintf(stderr, "%s: bad port number: %s\n", | ||
281 | 262 | argv[0], optarg); | ||
282 | 263 | usage(); | ||
283 | 264 | exit(1); | ||
284 | 265 | } | ||
285 | 266 | break; | ||
286 | 267 | case 'p': | ||
287 | 268 | port = atoi(optarg); | ||
288 | 269 | if (port < 1 || port > 65535) { | ||
289 | 270 | fprintf(stderr, "%s: bad port number: %s\n", | ||
290 | 271 | argv[0], optarg); | ||
291 | 272 | usage(); | ||
292 | 273 | exit(1); | ||
293 | 274 | } | ||
294 | 275 | break; | ||
295 | 276 | case 'n': /* Specify local hostname */ | ||
296 | 277 | run_mode |= STATIC_HOSTNAME; | ||
297 | 278 | MY_NAME = xstrdup(optarg); | ||
298 | 279 | break; | ||
299 | 280 | case 'P': | ||
300 | 281 | if (!nsm_setup_pathnames(argv[0], optarg)) | ||
301 | 282 | exit(1); | ||
302 | 283 | break; | ||
303 | 284 | case 'H': /* PRC: specify the ha-callout program */ | ||
304 | 285 | if ((ha_callout_prog = xstrdup(optarg)) == NULL) { | ||
305 | 286 | fprintf(stderr, "%s: xstrdup(%s) failed!\n", | ||
306 | 287 | argv[0], optarg); | ||
307 | 288 | exit(1); | ||
308 | 289 | } | ||
309 | 290 | break; | ||
310 | 291 | case '?': /* heeeeeelllllllpppp? heh */ | ||
311 | 292 | case 'h': | ||
312 | 293 | usage(); | ||
313 | 294 | exit (0); | ||
314 | 295 | default: /* oh dear ... heh */ | ||
315 | 296 | usage(); | ||
316 | 297 | exit(-1); | ||
317 | 298 | } | ||
318 | 299 | } | ||
319 | 300 | |||
320 | 301 | if (port == out_port && port != 0) { | ||
321 | 302 | fprintf(stderr, "Listening and outgoing ports cannot be the same!\n"); | ||
322 | 303 | exit(-1); | ||
323 | 304 | } | ||
324 | 305 | |||
325 | 306 | if (run_mode & MODE_NOTIFY_ONLY) { | ||
326 | 307 | fprintf(stderr, "%s: -N deprecated, consider using /usr/sbin/sm-notify directly\n", | ||
327 | 308 | name_p); | ||
328 | 309 | run_sm_notify(out_port); | ||
329 | 310 | } | ||
330 | 311 | |||
331 | 312 | if (!(run_mode & MODE_NODAEMON)) { | ||
332 | 313 | run_mode &= ~MODE_LOG_STDERR; /* Never log to console in | ||
333 | 314 | daemon mode. */ | ||
334 | 315 | } | ||
335 | 316 | |||
336 | 317 | if (getrlimit (RLIMIT_NOFILE, &rlim) != 0) | ||
337 | 318 | fprintf(stderr, "%s: getrlimit (RLIMIT_NOFILE) failed: %s\n", | ||
338 | 319 | argv [0], strerror(errno)); | ||
339 | 320 | else { | ||
340 | 321 | /* glibc sunrpc code dies if getdtablesize > FD_SETSIZE */ | ||
341 | 322 | if (rlim.rlim_cur > FD_SETSIZE) { | ||
342 | 323 | rlim.rlim_cur = FD_SETSIZE; | ||
343 | 324 | |||
344 | 325 | if (setrlimit (RLIMIT_NOFILE, &rlim) != 0) { | ||
345 | 326 | fprintf(stderr, "%s: setrlimit (RLIMIT_NOFILE) failed: %s\n", | ||
346 | 327 | argv [0], strerror(errno)); | ||
347 | 328 | } | ||
348 | 329 | } | ||
349 | 330 | } | ||
350 | 331 | |||
351 | 332 | #ifdef SIMULATIONS | ||
352 | 333 | if (argc > 1) | ||
353 | 334 | /* LH - I _really_ need to update simulator... */ | ||
354 | 335 | simulator (--argc, ++argv); /* simulator() does exit() */ | ||
355 | 336 | #endif | ||
356 | 337 | |||
357 | 338 | if (!(run_mode & MODE_NODAEMON)) { | ||
358 | 339 | int tempfd; | ||
359 | 340 | |||
360 | 341 | if (pipe(pipefds)<0) { | ||
361 | 342 | perror("statd: unable to create pipe"); | ||
362 | 343 | exit(1); | ||
363 | 344 | } | ||
364 | 345 | if ((pid = fork ()) < 0) { | ||
365 | 346 | perror ("statd: Could not fork"); | ||
366 | 347 | exit (1); | ||
367 | 348 | } else if (pid != 0) { | ||
368 | 349 | /* Parent. | ||
369 | 350 | * Wait for status from child. | ||
370 | 351 | */ | ||
371 | 352 | close(pipefds[1]); | ||
372 | 353 | if (read(pipefds[0], &status, 1) != 1) | ||
373 | 354 | exit(1); | ||
374 | 355 | exit (0); | ||
375 | 356 | } | ||
376 | 357 | /* Child. */ | ||
377 | 358 | close(pipefds[0]); | ||
378 | 359 | setsid (); | ||
379 | 360 | |||
380 | 361 | while (pipefds[1] <= 2) { | ||
381 | 362 | pipefds[1] = dup(pipefds[1]); | ||
382 | 363 | if (pipefds[1]<0) { | ||
383 | 364 | perror("statd: dup"); | ||
384 | 365 | exit(1); | ||
385 | 366 | } | ||
386 | 367 | } | ||
387 | 368 | tempfd = open("/dev/null", O_RDWR); | ||
388 | 369 | dup2(tempfd, 0); | ||
389 | 370 | dup2(tempfd, 1); | ||
390 | 371 | dup2(tempfd, 2); | ||
391 | 372 | dup2(pipefds[1], 3); | ||
392 | 373 | pipefds[1] = 3; | ||
393 | 374 | closeall(4); | ||
394 | 375 | } | ||
395 | 376 | |||
396 | 377 | /* Child. */ | ||
397 | 378 | |||
398 | 379 | if (run_mode & MODE_LOG_STDERR) { | ||
399 | 380 | xlog_syslog(0); | ||
400 | 381 | xlog_stderr(1); | ||
401 | 382 | xlog_config(D_ALL, 1); | ||
402 | 383 | } | ||
403 | 384 | xlog_open(name_p); | ||
404 | 385 | xlog(L_NOTICE, "Version " VERSION " starting"); | ||
405 | 386 | |||
406 | 387 | log_modes(); | ||
407 | 388 | |||
408 | 389 | signal (SIGHUP, killer); | ||
409 | 390 | signal (SIGINT, killer); | ||
410 | 391 | signal (SIGTERM, killer); | ||
411 | 392 | /* PRC: trap SIGUSR1 to re-read notify list from disk */ | ||
412 | 393 | signal(SIGUSR1, sigusr); | ||
413 | 394 | /* WARNING: the following works on Linux and SysV, but not BSD! */ | ||
414 | 395 | signal(SIGCHLD, SIG_IGN); | ||
415 | 396 | /* | ||
416 | 397 | * Ignore SIGPIPE to avoid statd dying when peers close their | ||
417 | 398 | * TCP connection while we're trying to reply to them. | ||
418 | 399 | */ | ||
419 | 400 | signal(SIGPIPE, SIG_IGN); | ||
420 | 401 | |||
421 | 402 | create_pidfile(); | ||
422 | 403 | atexit(truncate_pidfile); | ||
423 | 404 | |||
424 | 405 | if (! (run_mode & MODE_NO_NOTIFY)) | ||
425 | 406 | switch (pid = fork()) { | ||
426 | 407 | case 0: | ||
427 | 408 | run_sm_notify(out_port); | ||
428 | 409 | break; | ||
429 | 410 | case -1: | ||
430 | 411 | break; | ||
431 | 412 | default: | ||
432 | 413 | waitpid(pid, NULL, 0); | ||
433 | 414 | } | ||
434 | 415 | |||
435 | 416 | /* Make sure we have a privilege port for calling into the kernel */ | ||
436 | 417 | if (statd_get_socket() < 0) | ||
437 | 418 | exit(1); | ||
438 | 419 | |||
439 | 420 | /* If sm-notify didn't take all the state files, load | ||
440 | 421 | * state information into our notify-list so we can | ||
441 | 422 | * pass on any SM_NOTIFY that arrives | ||
442 | 423 | */ | ||
443 | 424 | load_state(); | ||
444 | 425 | |||
445 | 426 | MY_STATE = nsm_get_state(0); | ||
446 | 427 | if (MY_STATE == 0) | ||
447 | 428 | exit(1); | ||
448 | 429 | xlog(D_GENERAL, "Local NSM state number: %d", MY_STATE); | ||
449 | 430 | nsm_update_kernel_state(MY_STATE); | ||
450 | 431 | |||
451 | 432 | /* | ||
452 | 433 | * ORDER | ||
453 | 434 | * Clear old listeners while still root, to override any | ||
454 | 435 | * permission checking done by rpcbind. | ||
455 | 436 | */ | ||
456 | 437 | statd_unregister(); | ||
457 | 438 | |||
458 | 439 | /* | ||
459 | 440 | * ORDER | ||
460 | 441 | */ | ||
461 | 442 | if (!nsm_drop_privileges(pidfd)) | ||
462 | 443 | exit(1); | ||
463 | 444 | |||
464 | 445 | /* | ||
465 | 446 | * ORDER | ||
466 | 447 | * Create RPC listeners after dropping privileges. This permits | ||
467 | 448 | * statd to unregister its own listeners when it exits. | ||
468 | 449 | */ | ||
469 | 450 | if (nfs_svc_create("statd", SM_PROG, SM_VERS, sm_prog_1, port) == 0) { | ||
470 | 451 | xlog(L_ERROR, "failed to create RPC listeners, exiting"); | ||
471 | 452 | exit(1); | ||
472 | 453 | } | ||
473 | 454 | atexit(statd_unregister); | ||
474 | 455 | |||
475 | 456 | /* If we got this far, we have successfully started, so notify parent */ | ||
476 | 457 | if (pipefds[1] > 0) { | ||
477 | 458 | status = 0; | ||
478 | 459 | if (write(pipefds[1], &status, 1) != 1) { | ||
479 | 460 | xlog_warn("writing to parent pipe failed: errno %d (%s)\n", | ||
480 | 461 | errno, strerror(errno)); | ||
481 | 462 | } | ||
482 | 463 | close(pipefds[1]); | ||
483 | 464 | pipefds[1] = -1; | ||
484 | 465 | } | ||
485 | 466 | |||
486 | 467 | for (;;) { | ||
487 | 468 | /* | ||
488 | 469 | * Handle incoming requests: SM_NOTIFY socket requests, as | ||
489 | 470 | * well as callbacks from lockd. | ||
490 | 471 | */ | ||
491 | 472 | my_svc_run(); /* I rolled my own, Olaf made it better... */ | ||
492 | 473 | |||
493 | 474 | /* Only get here when simulating a crash so we should probably | ||
494 | 475 | * start sm-notify running again. As we have already dropped | ||
495 | 476 | * privileges, this might not work, but I don't think | ||
496 | 477 | * responding to SM_SIMU_CRASH is an important use cases to | ||
497 | 478 | * get perfect. | ||
498 | 479 | */ | ||
499 | 480 | if (! (run_mode & MODE_NO_NOTIFY)) | ||
500 | 481 | switch (pid = fork()) { | ||
501 | 482 | case 0: | ||
502 | 483 | run_sm_notify(out_port); | ||
503 | 484 | break; | ||
504 | 485 | case -1: | ||
505 | 486 | break; | ||
506 | 487 | default: | ||
507 | 488 | waitpid(pid, NULL, 0); | ||
508 | 489 | } | ||
509 | 490 | |||
510 | 491 | } | ||
511 | 492 | return 0; | ||
512 | 493 | } | ||
513 | 494 | 0 | ||
514 | === removed directory '.pc/02-524255-manpages.patch' | |||
515 | === removed directory '.pc/02-524255-manpages.patch/utils' | |||
516 | === removed directory '.pc/02-524255-manpages.patch/utils/exportfs' | |||
517 | === removed file '.pc/02-524255-manpages.patch/utils/exportfs/nfsd.man' | |||
518 | --- .pc/02-524255-manpages.patch/utils/exportfs/nfsd.man 2012-05-25 20:41:58 +0000 | |||
519 | +++ .pc/02-524255-manpages.patch/utils/exportfs/nfsd.man 1970-01-01 00:00:00 +0000 | |||
520 | @@ -1,206 +0,0 @@ | |||
521 | 1 | .\" | ||
522 | 2 | .\" nfsd(7) - The nfsd filesystem | ||
523 | 3 | .\" | ||
524 | 4 | .\" Copyright (C) 2003 Neil Brown <neilb@cse.unsw.edu.au> | ||
525 | 5 | .\" Licensed for public use under the terms of the FSF | ||
526 | 6 | .\" General Public License (GPL) version 2. | ||
527 | 7 | .TH nfsd 7 "3 July 2003" | ||
528 | 8 | .SH NAME | ||
529 | 9 | nfsd \- special filesystem for controlling Linux NFS server | ||
530 | 10 | .SH SYNPOSIS | ||
531 | 11 | .B "mount -t nfsd nfsd /proc/fs/nfsd" | ||
532 | 12 | .SH DESCRIPTION | ||
533 | 13 | The | ||
534 | 14 | .B nfsd | ||
535 | 15 | filesystem is a special filesystem which provides access to the Linux | ||
536 | 16 | NFS server. The filesystem consists of a single directory which | ||
537 | 17 | contains a number of files. These files are actually gateways into | ||
538 | 18 | the NFS server. Writing to them can affect the server. Reading from | ||
539 | 19 | them can provide information about the server. | ||
540 | 20 | .P | ||
541 | 21 | This file system is only available in Linux 2.6 and later series | ||
542 | 22 | kernels (and in the later parts of the 2.5 development series leading | ||
543 | 23 | up to 2.6). This man page does not apply to 2.4 and earlier. | ||
544 | 24 | .P | ||
545 | 25 | As well as this filesystem, there are a collection of files in the | ||
546 | 26 | .B procfs | ||
547 | 27 | filesystem (normally mounted at | ||
548 | 28 | .BR /proc ) | ||
549 | 29 | which are used to control the NFS server. | ||
550 | 30 | This manual page describes all of these files. | ||
551 | 31 | .P | ||
552 | 32 | The | ||
553 | 33 | .I exportfs | ||
554 | 34 | and | ||
555 | 35 | .I mountd | ||
556 | 36 | programs (part of the nfs-utils package) expect to find this | ||
557 | 37 | filesystem mounted at | ||
558 | 38 | .B /proc/fs/nfsd | ||
559 | 39 | or | ||
560 | 40 | .BR /proc/fs/nfs . | ||
561 | 41 | If it is not mounted, they will fall-back on 2.4 style functionality. | ||
562 | 42 | This involves accessing the NFS server via a systemcall. This | ||
563 | 43 | systemcall is scheduled to be removed after the 2.6 kernel series. | ||
564 | 44 | .SH DETAILS | ||
565 | 45 | The three files in the | ||
566 | 46 | .B nfsd | ||
567 | 47 | filesystem are: | ||
568 | 48 | .TP | ||
569 | 49 | .B exports | ||
570 | 50 | This file contains a list of filesystems that are currently exported | ||
571 | 51 | and clients that each filesystem is exported to, together with a list | ||
572 | 52 | of export options for that client/filesystem pair. This is similar | ||
573 | 53 | to the | ||
574 | 54 | .B /proc/fs/nfs/exports | ||
575 | 55 | file in 2.4. | ||
576 | 56 | One difference is that a client doesn't necessarily correspond to just | ||
577 | 57 | one host. It can respond to a large collection of hosts that are | ||
578 | 58 | being treated identically. | ||
579 | 59 | |||
580 | 60 | Each line of the file contains a path name, a client name, and a | ||
581 | 61 | number of options in parentheses. Any space, tab, newline or | ||
582 | 62 | back-slash character in the path name or client name will be replaced | ||
583 | 63 | by a backslash followed by the octal ASCII code for that character. | ||
584 | 64 | |||
585 | 65 | .TP | ||
586 | 66 | .B threads | ||
587 | 67 | This file represents the number of | ||
588 | 68 | .B nfsd | ||
589 | 69 | thread currently running. Reading it will show the number of | ||
590 | 70 | threads. Writing an ASCII decimal number will cause the number of | ||
591 | 71 | threads to be changed (increased or decreased as necessary) to achieve | ||
592 | 72 | that number. | ||
593 | 73 | |||
594 | 74 | .TP | ||
595 | 75 | .B filehandle | ||
596 | 76 | This is a somewhat unusual file in that what is read from it depends | ||
597 | 77 | on what was just written to it. It provides a transactional interface | ||
598 | 78 | where a program can open the file, write a request, and read a | ||
599 | 79 | response. If two separate programs open, write, and read at the same | ||
600 | 80 | time, their requests will not be mixed up. | ||
601 | 81 | |||
602 | 82 | The request written to | ||
603 | 83 | .B filehandle | ||
604 | 84 | should be a client name, a path name, and a number of bytes. This | ||
605 | 85 | should be followed by a newline, with white-space separating the | ||
606 | 86 | fields, and octal quoting of special characters. | ||
607 | 87 | |||
608 | 88 | On writing this, the program will be able to read back a filehandle | ||
609 | 89 | for that path as exported to the given client. The filehandle's length | ||
610 | 90 | will be at most the number of bytes given. | ||
611 | 91 | |||
612 | 92 | The filehandle will be represented in hex with a leading '\ex'. | ||
613 | 93 | .PP | ||
614 | 94 | The directory | ||
615 | 95 | .B /proc/net/rpc | ||
616 | 96 | in the | ||
617 | 97 | .B procfs | ||
618 | 98 | filesystem contains a number of files and directories. | ||
619 | 99 | The files contain statistics that can be display using the | ||
620 | 100 | .I nfsstat | ||
621 | 101 | program. | ||
622 | 102 | The directories contain information about various caches that the NFS | ||
623 | 103 | server maintains to keep track of access permissions that different | ||
624 | 104 | clients have for different filesystems. | ||
625 | 105 | The caches are: | ||
626 | 106 | |||
627 | 107 | .TP | ||
628 | 108 | .B auth.domain | ||
629 | 109 | This cache maps the name of a client (or domain) to an internal data | ||
630 | 110 | structure. The only access that is possible is to flush the cache. | ||
631 | 111 | |||
632 | 112 | .TP | ||
633 | 113 | .B auth.unix.ip | ||
634 | 114 | This cache contains a mapping from IP address to the name of the | ||
635 | 115 | authentication domain that the ipaddress should be treated as part of. | ||
636 | 116 | |||
637 | 117 | .TP | ||
638 | 118 | .B nfsd.export | ||
639 | 119 | This cache contains a mapping from directory and domain to export | ||
640 | 120 | options. | ||
641 | 121 | |||
642 | 122 | .TP | ||
643 | 123 | .B nfsd.fh | ||
644 | 124 | This cache contains a mapping from domain and a filesystem identifier | ||
645 | 125 | to a directory. The filesystem identifier is stored in the | ||
646 | 126 | filehandles and consists of a number indicating the type of identifier | ||
647 | 127 | and a number of hex bytes indicating the content of the identifier. | ||
648 | 128 | |||
649 | 129 | .PP | ||
650 | 130 | Each directory representing a cache can hold from 1 to 3 files. They | ||
651 | 131 | are: | ||
652 | 132 | .TP | ||
653 | 133 | .B flush | ||
654 | 134 | When a number of seconds since epoch (1 Jan 1970) is written to this | ||
655 | 135 | file, all entries in the cache that were last updated before that file | ||
656 | 136 | become invalidated and will be flushed out. Writing 1 will flush | ||
657 | 137 | everything. This is the only file that will always be present. | ||
658 | 138 | |||
659 | 139 | .TP | ||
660 | 140 | .B content | ||
661 | 141 | This file, if present, contains a textual representation of ever entry | ||
662 | 142 | in the cache, one per line. If an entry is still in the cache | ||
663 | 143 | (because it is actively being used) but has expired or is otherwise | ||
664 | 144 | invalid, it will be presented as a comment (with a leading hash | ||
665 | 145 | character). | ||
666 | 146 | |||
667 | 147 | .TP | ||
668 | 148 | .B channel | ||
669 | 149 | This file, if present, acts a channel for request from the kernel-based | ||
670 | 150 | nfs server to be passed to a user-space program for handling. | ||
671 | 151 | |||
672 | 152 | When the kernel needs some information which isn't in the cache, it | ||
673 | 153 | makes a line appear in the | ||
674 | 154 | .B channel | ||
675 | 155 | file giving the key for the information. A user-space program should | ||
676 | 156 | read this, find the answer, and write a line containing the key, an | ||
677 | 157 | expiry time, and the content. | ||
678 | 158 | For example the kernel might make | ||
679 | 159 | .ti +5 | ||
680 | 160 | nfsd 127.0.0.1 | ||
681 | 161 | .br | ||
682 | 162 | appear in the | ||
683 | 163 | .B auth.unix.ip/content | ||
684 | 164 | file. The user-space program might then write | ||
685 | 165 | .ti +5 | ||
686 | 166 | nfsd 127.0.0.1 1057206953 localhost | ||
687 | 167 | .br | ||
688 | 168 | to indicate that 127.0.0.1 should map to localhost, at least for now. | ||
689 | 169 | |||
690 | 170 | If the program uses select(2) or poll(2) to discover if it can read | ||
691 | 171 | from the | ||
692 | 172 | .B channel | ||
693 | 173 | then it will never see and end-of-file but when all requests have been | ||
694 | 174 | answered, it will block until another request appears. | ||
695 | 175 | |||
696 | 176 | .PP | ||
697 | 177 | In the | ||
698 | 178 | .B /proc | ||
699 | 179 | filesystem there are 4 files that can be used to enabled extra tracing | ||
700 | 180 | of nfsd and related code. They are: | ||
701 | 181 | .in +5 | ||
702 | 182 | .B /proc/sys/sunrpc/nfs_debug | ||
703 | 183 | .br | ||
704 | 184 | .B /proc/sys/sunrpc/nfsd_debug | ||
705 | 185 | .br | ||
706 | 186 | .B /proc/sys/sunrpc/nlm_debug | ||
707 | 187 | .br | ||
708 | 188 | .B /proc/sys/sunrpc/rpc_debug | ||
709 | 189 | .br | ||
710 | 190 | .in -5 | ||
711 | 191 | They control tracing for the NFS client, the NFS server, the Network | ||
712 | 192 | Lock Manager (lockd) and the underlying RPC layer respectively. | ||
713 | 193 | Decimal numbers can be read from or written to these files. Each | ||
714 | 194 | number represents a bit-pattern where bits that are set cause certain | ||
715 | 195 | classes of tracing to be enabled. Consult the kernel header files to | ||
716 | 196 | find out what number correspond to what tracing. | ||
717 | 197 | |||
718 | 198 | .SH SEE ALSO | ||
719 | 199 | .BR rpc.nfsd (8), | ||
720 | 200 | .BR exports (5), | ||
721 | 201 | .BR nfsstat (8), | ||
722 | 202 | .BR mountd (8) | ||
723 | 203 | .BR exportfs (8). | ||
724 | 204 | |||
725 | 205 | .SH AUTHOR | ||
726 | 206 | NeilBrown | ||
727 | 207 | 0 | ||
728 | === removed directory '.pc/02-524255-manpages.patch/utils/nfsd' | |||
729 | === removed file '.pc/02-524255-manpages.patch/utils/nfsd/nfsd.man' | |||
730 | --- .pc/02-524255-manpages.patch/utils/nfsd/nfsd.man 2012-05-25 20:41:58 +0000 | |||
731 | +++ .pc/02-524255-manpages.patch/utils/nfsd/nfsd.man 1970-01-01 00:00:00 +0000 | |||
732 | @@ -1,105 +0,0 @@ | |||
733 | 1 | .\" | ||
734 | 2 | .\" nfsd(8) | ||
735 | 3 | .\" | ||
736 | 4 | .\" Copyright (C) 1999 Olaf Kirch <okir@monad.swb.de> | ||
737 | 5 | .TH rpc.nfsd 8 "7 Aug 2006" | ||
738 | 6 | .SH NAME | ||
739 | 7 | rpc.nfsd \- NFS server process | ||
740 | 8 | .SH SYNOPSIS | ||
741 | 9 | .BI "/usr/sbin/rpc.nfsd [" options "]" " "nproc | ||
742 | 10 | .SH DESCRIPTION | ||
743 | 11 | The | ||
744 | 12 | .B rpc.nfsd | ||
745 | 13 | program implements the user level part of the NFS service. The | ||
746 | 14 | main functionality is handled by the | ||
747 | 15 | .B nfsd | ||
748 | 16 | kernel module. The user space program merely specifies what sort of sockets | ||
749 | 17 | the kernel service should listen on, what NFS versions it should support, and | ||
750 | 18 | how many kernel threads it should use. | ||
751 | 19 | .P | ||
752 | 20 | The | ||
753 | 21 | .B rpc.mountd | ||
754 | 22 | server provides an ancillary service needed to satisfy mount requests | ||
755 | 23 | by NFS clients. | ||
756 | 24 | .SH OPTIONS | ||
757 | 25 | .TP | ||
758 | 26 | .B \-d " or " \-\-debug | ||
759 | 27 | enable logging of debugging messages | ||
760 | 28 | .TP | ||
761 | 29 | .B \-H " or " \-\-host hostname | ||
762 | 30 | specify a particular hostname (or address) that NFS requests will | ||
763 | 31 | be accepted on. By default, | ||
764 | 32 | .B rpc.nfsd | ||
765 | 33 | will accept NFS requests on all known network addresses. | ||
766 | 34 | Note that | ||
767 | 35 | .B lockd | ||
768 | 36 | (which performs file locking services for NFS) may still accept | ||
769 | 37 | request on all known network addresses. This may change in future | ||
770 | 38 | releases of the Linux Kernel. | ||
771 | 39 | .TP | ||
772 | 40 | .B \-p " or " \-\-port port | ||
773 | 41 | specify a different port to listen on for NFS requests. By default, | ||
774 | 42 | .B rpc.nfsd | ||
775 | 43 | will listen on port 2049. | ||
776 | 44 | .TP | ||
777 | 45 | .B \-N " or " \-\-no-nfs-version vers | ||
778 | 46 | This option can be used to request that | ||
779 | 47 | .B rpc.nfsd | ||
780 | 48 | does not offer certain versions of NFS. The current version of | ||
781 | 49 | .B rpc.nfsd | ||
782 | 50 | can support both NFS version 2,3 and the newer version 4. | ||
783 | 51 | .TP | ||
784 | 52 | .B \-s " or " \-\-syslog | ||
785 | 53 | By default, | ||
786 | 54 | .B rpc.nfsd | ||
787 | 55 | logs error messages (and debug messages, if enabled) to stderr. This option makes | ||
788 | 56 | .B rpc.nfsd | ||
789 | 57 | log these messages to syslog instead. Note that errors encountered during | ||
790 | 58 | option processing will still be logged to stderr regardless of this option. | ||
791 | 59 | .TP | ||
792 | 60 | .B \-T " or " \-\-no-tcp | ||
793 | 61 | Disable | ||
794 | 62 | .B rpc.nfsd | ||
795 | 63 | from accepting TCP connections from clients. | ||
796 | 64 | .TP | ||
797 | 65 | .B \-U " or " \-\-no-udp | ||
798 | 66 | Disable | ||
799 | 67 | .B rpc.nfsd | ||
800 | 68 | from accepting UDP connections from clients. | ||
801 | 69 | .TP | ||
802 | 70 | .I nproc | ||
803 | 71 | specify the number of NFS server threads. By default, just one | ||
804 | 72 | thread is started. However, for optimum performance several threads | ||
805 | 73 | should be used. The actual figure depends on the number of and the work | ||
806 | 74 | load created by the NFS clients, but a useful starting point is | ||
807 | 75 | 8 threads. Effects of modifying that number can be checked using | ||
808 | 76 | the | ||
809 | 77 | .BR nfsstat (8) | ||
810 | 78 | program. | ||
811 | 79 | .P | ||
812 | 80 | Note that if the NFS server is already running, then the options for | ||
813 | 81 | specifying host, port, and protocol will be ignored. The number of | ||
814 | 82 | processes given will be the only option considered, and the number of | ||
815 | 83 | active | ||
816 | 84 | .B nfsd | ||
817 | 85 | processes will be increased or decreased to match this number. | ||
818 | 86 | In particular | ||
819 | 87 | .B rpc.nfsd 0 | ||
820 | 88 | will stop all threads and thus close any open connections. | ||
821 | 89 | |||
822 | 90 | .SH NOTES | ||
823 | 91 | If the program is built with TI-RPC support, it will enable any protocol and | ||
824 | 92 | address family combinations that are marked visible in the | ||
825 | 93 | .B netconfig | ||
826 | 94 | database. | ||
827 | 95 | |||
828 | 96 | .SH SEE ALSO | ||
829 | 97 | .BR rpc.mountd (8), | ||
830 | 98 | .BR exports (5), | ||
831 | 99 | .BR exportfs (8), | ||
832 | 100 | .BR rpc.rquotad (8), | ||
833 | 101 | .BR nfsstat (8), | ||
834 | 102 | .BR netconfig(5). | ||
835 | 103 | .SH AUTHOR | ||
836 | 104 | Olaf Kirch, Bill Hawes, H. J. Lu, G. Allan Morris III, | ||
837 | 105 | and a host of others. | ||
838 | 106 | 0 | ||
839 | === removed directory '.pc/03-handle-mtab-symlink.patch' | |||
840 | === removed directory '.pc/03-handle-mtab-symlink.patch/utils' | |||
841 | === removed directory '.pc/03-handle-mtab-symlink.patch/utils/mount' | |||
842 | === removed file '.pc/03-handle-mtab-symlink.patch/utils/mount/fstab.c' | |||
843 | --- .pc/03-handle-mtab-symlink.patch/utils/mount/fstab.c 2011-10-02 18:29:53 +0000 | |||
844 | +++ .pc/03-handle-mtab-symlink.patch/utils/mount/fstab.c 1970-01-01 00:00:00 +0000 | |||
845 | @@ -1,649 +0,0 @@ | |||
846 | 1 | /* 1999-02-22 Arkadiusz Miskiewicz <misiek@pld.ORG.PL> | ||
847 | 2 | * - added Native Language Support | ||
848 | 3 | * Sun Mar 21 1999 - Arnaldo Carvalho de Melo <acme@conectiva.com.br> | ||
849 | 4 | * - fixed strerr(errno) in gettext calls | ||
850 | 5 | * | ||
851 | 6 | * 2006-06-08 Amit Gud <agud@redhat.com> | ||
852 | 7 | * - Moved code to nfs-utils/support/nfs from util-linux/mount. | ||
853 | 8 | */ | ||
854 | 9 | |||
855 | 10 | #include <errno.h> | ||
856 | 11 | #include <stdio.h> | ||
857 | 12 | #include <fcntl.h> | ||
858 | 13 | #include <unistd.h> | ||
859 | 14 | #include <string.h> | ||
860 | 15 | #include <sys/stat.h> | ||
861 | 16 | #include <mntent.h> | ||
862 | 17 | |||
863 | 18 | #include "fstab.h" | ||
864 | 19 | #include "xcommon.h" | ||
865 | 20 | #include "nfs_mntent.h" | ||
866 | 21 | #include "nfs_paths.h" | ||
867 | 22 | #include "nls.h" | ||
868 | 23 | |||
869 | 24 | #define LOCK_TIMEOUT 10 | ||
870 | 25 | #define streq(s, t) (strcmp ((s), (t)) == 0) | ||
871 | 26 | #define PROC_MOUNTS "/proc/mounts" | ||
872 | 27 | |||
873 | 28 | extern char *progname; | ||
874 | 29 | extern int verbose; | ||
875 | 30 | |||
876 | 31 | /* Information about mtab. ------------------------------------*/ | ||
877 | 32 | static int have_mtab_info = 0; | ||
878 | 33 | static int var_mtab_does_not_exist = 0; | ||
879 | 34 | static int var_mtab_is_a_symlink = 0; | ||
880 | 35 | |||
881 | 36 | static void | ||
882 | 37 | get_mtab_info(void) { | ||
883 | 38 | struct stat mtab_stat; | ||
884 | 39 | |||
885 | 40 | if (!have_mtab_info) { | ||
886 | 41 | if (lstat(MOUNTED, &mtab_stat)) | ||
887 | 42 | var_mtab_does_not_exist = 1; | ||
888 | 43 | else if (S_ISLNK(mtab_stat.st_mode)) | ||
889 | 44 | var_mtab_is_a_symlink = 1; | ||
890 | 45 | have_mtab_info = 1; | ||
891 | 46 | } | ||
892 | 47 | } | ||
893 | 48 | |||
894 | 49 | void | ||
895 | 50 | reset_mtab_info(void) { | ||
896 | 51 | have_mtab_info = 0; | ||
897 | 52 | } | ||
898 | 53 | |||
899 | 54 | int | ||
900 | 55 | mtab_does_not_exist(void) { | ||
901 | 56 | get_mtab_info(); | ||
902 | 57 | return var_mtab_does_not_exist; | ||
903 | 58 | } | ||
904 | 59 | |||
905 | 60 | static int | ||
906 | 61 | mtab_is_a_symlink(void) { | ||
907 | 62 | get_mtab_info(); | ||
908 | 63 | return var_mtab_is_a_symlink; | ||
909 | 64 | } | ||
910 | 65 | |||
911 | 66 | int | ||
912 | 67 | mtab_is_writable() { | ||
913 | 68 | int fd; | ||
914 | 69 | |||
915 | 70 | /* Should we write to /etc/mtab upon an update? | ||
916 | 71 | Probably not if it is a symlink to /proc/mounts, since that | ||
917 | 72 | would create a file /proc/mounts in case the proc filesystem | ||
918 | 73 | is not mounted. */ | ||
919 | 74 | if (mtab_is_a_symlink()) | ||
920 | 75 | return 0; | ||
921 | 76 | |||
922 | 77 | fd = open(MOUNTED, O_RDWR | O_CREAT, 0644); | ||
923 | 78 | if (fd >= 0) { | ||
924 | 79 | close(fd); | ||
925 | 80 | return 1; | ||
926 | 81 | } else | ||
927 | 82 | return 0; | ||
928 | 83 | } | ||
929 | 84 | |||
930 | 85 | /* Contents of mtab and fstab ---------------------------------*/ | ||
931 | 86 | |||
932 | 87 | struct mntentchn mounttable; | ||
933 | 88 | static int got_mtab = 0; | ||
934 | 89 | struct mntentchn procmounts; | ||
935 | 90 | static int got_procmounts = 0; | ||
936 | 91 | struct mntentchn fstab; | ||
937 | 92 | static int got_fstab = 0; | ||
938 | 93 | |||
939 | 94 | static void read_mounttable(void); | ||
940 | 95 | static void read_procmounts(void); | ||
941 | 96 | static void read_fstab(void); | ||
942 | 97 | |||
943 | 98 | static struct mntentchn * | ||
944 | 99 | mtab_head(void) | ||
945 | 100 | { | ||
946 | 101 | if (!got_mtab) | ||
947 | 102 | read_mounttable(); | ||
948 | 103 | return &mounttable; | ||
949 | 104 | } | ||
950 | 105 | |||
951 | 106 | static struct mntentchn * | ||
952 | 107 | procmounts_head(void) | ||
953 | 108 | { | ||
954 | 109 | if (!got_procmounts) | ||
955 | 110 | read_procmounts(); | ||
956 | 111 | return &procmounts; | ||
957 | 112 | } | ||
958 | 113 | |||
959 | 114 | static struct mntentchn * | ||
960 | 115 | fstab_head(void) | ||
961 | 116 | { | ||
962 | 117 | if (!got_fstab) | ||
963 | 118 | read_fstab(); | ||
964 | 119 | return &fstab; | ||
965 | 120 | } | ||
966 | 121 | |||
967 | 122 | #if 0 | ||
968 | 123 | static void | ||
969 | 124 | my_free(const void *s) { | ||
970 | 125 | if (s) | ||
971 | 126 | free((void *) s); | ||
972 | 127 | } | ||
973 | 128 | |||
974 | 129 | static void | ||
975 | 130 | discard_mntentchn(struct mntentchn *mc0) { | ||
976 | 131 | struct mntentchn *mc, *mc1; | ||
977 | 132 | |||
978 | 133 | for (mc = mc0->nxt; mc && mc != mc0; mc = mc1) { | ||
979 | 134 | mc1 = mc->nxt; | ||
980 | 135 | my_free(mc->m.mnt_fsname); | ||
981 | 136 | my_free(mc->m.mnt_dir); | ||
982 | 137 | my_free(mc->m.mnt_type); | ||
983 | 138 | my_free(mc->m.mnt_opts); | ||
984 | 139 | free(mc); | ||
985 | 140 | } | ||
986 | 141 | } | ||
987 | 142 | #endif | ||
988 | 143 | |||
989 | 144 | static void | ||
990 | 145 | read_mntentchn(mntFILE *mfp, const char *fnam, struct mntentchn *mc0) { | ||
991 | 146 | struct mntentchn *mc = mc0; | ||
992 | 147 | struct mntent *mnt; | ||
993 | 148 | |||
994 | 149 | while ((mnt = nfs_getmntent(mfp)) != NULL) { | ||
995 | 150 | if (!streq(mnt->mnt_type, MNTTYPE_IGNORE)) { | ||
996 | 151 | mc->nxt = (struct mntentchn *) xmalloc(sizeof(*mc)); | ||
997 | 152 | mc->nxt->prev = mc; | ||
998 | 153 | mc = mc->nxt; | ||
999 | 154 | mc->m = *mnt; | ||
1000 | 155 | mc->nxt = mc0; | ||
1001 | 156 | } | ||
1002 | 157 | } | ||
1003 | 158 | mc0->prev = mc; | ||
1004 | 159 | if (ferror(mfp->mntent_fp)) { | ||
1005 | 160 | int errsv = errno; | ||
1006 | 161 | nfs_error(_("warning: error reading %s: %s"), | ||
1007 | 162 | fnam, strerror (errsv)); | ||
1008 | 163 | mc0->nxt = mc0->prev = NULL; | ||
1009 | 164 | } | ||
1010 | 165 | nfs_endmntent(mfp); | ||
1011 | 166 | } | ||
1012 | 167 | |||
1013 | 168 | /* | ||
1014 | 169 | * Read /etc/mtab. If that fails, try /proc/mounts. | ||
1015 | 170 | * This produces a linked list. The list head mounttable is a dummy. | ||
1016 | 171 | * Return 0 on success. | ||
1017 | 172 | */ | ||
1018 | 173 | static void | ||
1019 | 174 | read_mounttable() { | ||
1020 | 175 | mntFILE *mfp; | ||
1021 | 176 | const char *fnam; | ||
1022 | 177 | struct mntentchn *mc = &mounttable; | ||
1023 | 178 | |||
1024 | 179 | got_mtab = 1; | ||
1025 | 180 | mc->nxt = mc->prev = NULL; | ||
1026 | 181 | |||
1027 | 182 | fnam = MOUNTED; | ||
1028 | 183 | mfp = nfs_setmntent (fnam, "r"); | ||
1029 | 184 | if (mfp == NULL || mfp->mntent_fp == NULL) { | ||
1030 | 185 | int errsv = errno; | ||
1031 | 186 | fnam = PROC_MOUNTS; | ||
1032 | 187 | mfp = nfs_setmntent (fnam, "r"); | ||
1033 | 188 | if (mfp == NULL || mfp->mntent_fp == NULL) { | ||
1034 | 189 | nfs_error(_("warning: can't open %s: %s"), | ||
1035 | 190 | MOUNTED, strerror (errsv)); | ||
1036 | 191 | return; | ||
1037 | 192 | } | ||
1038 | 193 | if (verbose) | ||
1039 | 194 | printf(_("%s: could not open %s; using %s instead\n"), | ||
1040 | 195 | progname, MOUNTED, PROC_MOUNTS); | ||
1041 | 196 | } | ||
1042 | 197 | read_mntentchn(mfp, fnam, mc); | ||
1043 | 198 | } | ||
1044 | 199 | |||
1045 | 200 | /* | ||
1046 | 201 | * Read /proc/mounts. | ||
1047 | 202 | * This produces a linked list. The list head procmounts is a dummy. | ||
1048 | 203 | * Return 0 on success. | ||
1049 | 204 | */ | ||
1050 | 205 | static void | ||
1051 | 206 | read_procmounts() { | ||
1052 | 207 | mntFILE *mfp; | ||
1053 | 208 | const char *fnam; | ||
1054 | 209 | struct mntentchn *mc = &procmounts; | ||
1055 | 210 | |||
1056 | 211 | got_procmounts = 1; | ||
1057 | 212 | mc->nxt = mc->prev = NULL; | ||
1058 | 213 | |||
1059 | 214 | fnam = PROC_MOUNTS; | ||
1060 | 215 | mfp = nfs_setmntent(fnam, "r"); | ||
1061 | 216 | if (mfp == NULL || mfp->mntent_fp == NULL) { | ||
1062 | 217 | nfs_error(_("warning: can't open %s: %s"), | ||
1063 | 218 | PROC_MOUNTS, strerror (errno)); | ||
1064 | 219 | return; | ||
1065 | 220 | } | ||
1066 | 221 | read_mntentchn(mfp, fnam, mc); | ||
1067 | 222 | } | ||
1068 | 223 | |||
1069 | 224 | static void | ||
1070 | 225 | read_fstab() | ||
1071 | 226 | { | ||
1072 | 227 | mntFILE *mfp = NULL; | ||
1073 | 228 | const char *fnam; | ||
1074 | 229 | struct mntentchn *mc = &fstab; | ||
1075 | 230 | |||
1076 | 231 | got_fstab = 1; | ||
1077 | 232 | mc->nxt = mc->prev = NULL; | ||
1078 | 233 | |||
1079 | 234 | fnam = _PATH_FSTAB; | ||
1080 | 235 | mfp = nfs_setmntent (fnam, "r"); | ||
1081 | 236 | if (mfp == NULL || mfp->mntent_fp == NULL) { | ||
1082 | 237 | int errsv = errno; | ||
1083 | 238 | nfs_error(_("warning: can't open %s: %s"), | ||
1084 | 239 | _PATH_FSTAB, strerror (errsv)); | ||
1085 | 240 | return; | ||
1086 | 241 | } | ||
1087 | 242 | read_mntentchn(mfp, fnam, mc); | ||
1088 | 243 | } | ||
1089 | 244 | |||
1090 | 245 | /* | ||
1091 | 246 | * Given the directory name NAME, and the place MCPREV we found it last time, | ||
1092 | 247 | * try to find more occurrences. | ||
1093 | 248 | */ | ||
1094 | 249 | struct mntentchn * | ||
1095 | 250 | getmntdirbackward (const char *name, struct mntentchn *mcprev) { | ||
1096 | 251 | struct mntentchn *mc, *mc0; | ||
1097 | 252 | |||
1098 | 253 | mc0 = mtab_head(); | ||
1099 | 254 | if (!mcprev) | ||
1100 | 255 | mcprev = mc0; | ||
1101 | 256 | for (mc = mcprev->prev; mc && mc != mc0; mc = mc->prev) | ||
1102 | 257 | if (streq(mc->m.mnt_dir, name)) | ||
1103 | 258 | return mc; | ||
1104 | 259 | return NULL; | ||
1105 | 260 | } | ||
1106 | 261 | |||
1107 | 262 | /* | ||
1108 | 263 | * Given the directory name NAME, and the place MCPREV we found it last time, | ||
1109 | 264 | * try to find more occurrences. | ||
1110 | 265 | */ | ||
1111 | 266 | struct mntentchn * | ||
1112 | 267 | getprocmntdirbackward (const char *name, struct mntentchn *mcprev) { | ||
1113 | 268 | struct mntentchn *mc, *mc0; | ||
1114 | 269 | |||
1115 | 270 | mc0 = procmounts_head(); | ||
1116 | 271 | if (!mcprev) | ||
1117 | 272 | mcprev = mc0; | ||
1118 | 273 | for (mc = mcprev->prev; mc && mc != mc0; mc = mc->prev) | ||
1119 | 274 | if (streq(mc->m.mnt_dir, name)) | ||
1120 | 275 | return mc; | ||
1121 | 276 | return NULL; | ||
1122 | 277 | } | ||
1123 | 278 | |||
1124 | 279 | /* | ||
1125 | 280 | * Given the device name NAME, and the place MCPREV we found it last time, | ||
1126 | 281 | * try to find more occurrences. | ||
1127 | 282 | */ | ||
1128 | 283 | struct mntentchn * | ||
1129 | 284 | getmntdevbackward (const char *name, struct mntentchn *mcprev) { | ||
1130 | 285 | struct mntentchn *mc, *mc0; | ||
1131 | 286 | |||
1132 | 287 | mc0 = mtab_head(); | ||
1133 | 288 | if (!mcprev) | ||
1134 | 289 | mcprev = mc0; | ||
1135 | 290 | for (mc = mcprev->prev; mc && mc != mc0; mc = mc->prev) | ||
1136 | 291 | if (streq(mc->m.mnt_fsname, name)) | ||
1137 | 292 | return mc; | ||
1138 | 293 | return NULL; | ||
1139 | 294 | } | ||
1140 | 295 | |||
1141 | 296 | /* Find the dir FILE in fstab. */ | ||
1142 | 297 | struct mntentchn * | ||
1143 | 298 | getfsfile (const char *file) | ||
1144 | 299 | { | ||
1145 | 300 | struct mntentchn *mc, *mc0; | ||
1146 | 301 | |||
1147 | 302 | mc0 = fstab_head(); | ||
1148 | 303 | for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt) | ||
1149 | 304 | if (streq(mc->m.mnt_dir, file)) | ||
1150 | 305 | return mc; | ||
1151 | 306 | return NULL; | ||
1152 | 307 | } | ||
1153 | 308 | |||
1154 | 309 | /* Find the device SPEC in fstab. */ | ||
1155 | 310 | struct mntentchn * | ||
1156 | 311 | getfsspec (const char *spec) | ||
1157 | 312 | { | ||
1158 | 313 | struct mntentchn *mc, *mc0; | ||
1159 | 314 | |||
1160 | 315 | mc0 = fstab_head(); | ||
1161 | 316 | for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt) | ||
1162 | 317 | if (streq(mc->m.mnt_fsname, spec)) | ||
1163 | 318 | return mc; | ||
1164 | 319 | return NULL; | ||
1165 | 320 | } | ||
1166 | 321 | |||
1167 | 322 | /* Updating mtab ----------------------------------------------*/ | ||
1168 | 323 | |||
1169 | 324 | /* Flag for already existing lock file. */ | ||
1170 | 325 | static int we_created_lockfile = 0; | ||
1171 | 326 | static int lockfile_fd = -1; | ||
1172 | 327 | |||
1173 | 328 | /* Flag to indicate that signals have been set up. */ | ||
1174 | 329 | static int signals_have_been_setup = 0; | ||
1175 | 330 | |||
1176 | 331 | /* Ensure that the lock is released if we are interrupted. */ | ||
1177 | 332 | extern char *strsignal(int sig); /* not always in <string.h> */ | ||
1178 | 333 | |||
1179 | 334 | static void | ||
1180 | 335 | handler (int sig) { | ||
1181 | 336 | die(EX_USER, "%s", strsignal(sig)); | ||
1182 | 337 | } | ||
1183 | 338 | |||
1184 | 339 | static void | ||
1185 | 340 | setlkw_timeout (__attribute__((unused)) int sig) { | ||
1186 | 341 | /* nothing, fcntl will fail anyway */ | ||
1187 | 342 | } | ||
1188 | 343 | |||
1189 | 344 | /* Remove lock file. */ | ||
1190 | 345 | void | ||
1191 | 346 | unlock_mtab (void) { | ||
1192 | 347 | if (we_created_lockfile) { | ||
1193 | 348 | close(lockfile_fd); | ||
1194 | 349 | lockfile_fd = -1; | ||
1195 | 350 | unlink (MOUNTED_LOCK); | ||
1196 | 351 | we_created_lockfile = 0; | ||
1197 | 352 | } | ||
1198 | 353 | } | ||
1199 | 354 | |||
1200 | 355 | /* Create the lock file. | ||
1201 | 356 | The lock file will be removed if we catch a signal or when we exit. */ | ||
1202 | 357 | /* The old code here used flock on a lock file /etc/mtab~ and deleted | ||
1203 | 358 | this lock file afterwards. However, as rgooch remarks, that has a | ||
1204 | 359 | race: a second mount may be waiting on the lock and proceed as | ||
1205 | 360 | soon as the lock file is deleted by the first mount, and immediately | ||
1206 | 361 | afterwards a third mount comes, creates a new /etc/mtab~, applies | ||
1207 | 362 | flock to that, and also proceeds, so that the second and third mount | ||
1208 | 363 | now both are scribbling in /etc/mtab. | ||
1209 | 364 | The new code uses a link() instead of a creat(), where we proceed | ||
1210 | 365 | only if it was us that created the lock, and hence we always have | ||
1211 | 366 | to delete the lock afterwards. Now the use of flock() is in principle | ||
1212 | 367 | superfluous, but avoids an arbitrary sleep(). */ | ||
1213 | 368 | |||
1214 | 369 | /* Where does the link point to? Obvious choices are mtab and mtab~~. | ||
1215 | 370 | HJLu points out that the latter leads to races. Right now we use | ||
1216 | 371 | mtab~.<pid> instead. Use 20 as upper bound for the length of %d. */ | ||
1217 | 372 | #define MOUNTLOCK_LINKTARGET MOUNTED_LOCK "%d" | ||
1218 | 373 | #define MOUNTLOCK_LINKTARGET_LTH (sizeof(MOUNTED_LOCK)+20) | ||
1219 | 374 | |||
1220 | 375 | void | ||
1221 | 376 | lock_mtab (void) { | ||
1222 | 377 | int tries = 100000, i; | ||
1223 | 378 | char linktargetfile[MOUNTLOCK_LINKTARGET_LTH]; | ||
1224 | 379 | |||
1225 | 380 | at_die = unlock_mtab; | ||
1226 | 381 | |||
1227 | 382 | if (!signals_have_been_setup) { | ||
1228 | 383 | int sig = 0; | ||
1229 | 384 | struct sigaction sa; | ||
1230 | 385 | |||
1231 | 386 | sa.sa_flags = 0; | ||
1232 | 387 | sigfillset (&sa.sa_mask); | ||
1233 | 388 | |||
1234 | 389 | while (sigismember (&sa.sa_mask, ++sig) != -1) { | ||
1235 | 390 | switch(sig) { | ||
1236 | 391 | case SIGCHLD: | ||
1237 | 392 | case SIGKILL: | ||
1238 | 393 | case SIGCONT: | ||
1239 | 394 | case SIGSTOP: | ||
1240 | 395 | /* The cannot be caught, or should not, | ||
1241 | 396 | * so don't even try. | ||
1242 | 397 | */ | ||
1243 | 398 | continue; | ||
1244 | 399 | case SIGALRM: | ||
1245 | 400 | sa.sa_handler = setlkw_timeout; | ||
1246 | 401 | break; | ||
1247 | 402 | case SIGHUP: | ||
1248 | 403 | case SIGINT: | ||
1249 | 404 | case SIGQUIT: | ||
1250 | 405 | case SIGWINCH: | ||
1251 | 406 | case SIGTSTP: | ||
1252 | 407 | case SIGTTIN: | ||
1253 | 408 | case SIGTTOU: | ||
1254 | 409 | case SIGPIPE: | ||
1255 | 410 | case SIGXFSZ: | ||
1256 | 411 | case SIGXCPU: | ||
1257 | 412 | /* non-priv user can cause these to be | ||
1258 | 413 | * generated, so ignore them. | ||
1259 | 414 | */ | ||
1260 | 415 | sa.sa_handler = SIG_IGN; | ||
1261 | 416 | break; | ||
1262 | 417 | default: | ||
1263 | 418 | /* The rest should not be possible, so just | ||
1264 | 419 | * print a message and unlock mtab. | ||
1265 | 420 | */ | ||
1266 | 421 | sa.sa_handler = handler; | ||
1267 | 422 | } | ||
1268 | 423 | sigaction (sig, &sa, (struct sigaction *) 0); | ||
1269 | 424 | } | ||
1270 | 425 | signals_have_been_setup = 1; | ||
1271 | 426 | } | ||
1272 | 427 | |||
1273 | 428 | sprintf(linktargetfile, MOUNTLOCK_LINKTARGET, getpid ()); | ||
1274 | 429 | |||
1275 | 430 | i = open (linktargetfile, O_WRONLY|O_CREAT, 0); | ||
1276 | 431 | if (i < 0) { | ||
1277 | 432 | int errsv = errno; | ||
1278 | 433 | /* linktargetfile does not exist (as a file) | ||
1279 | 434 | and we cannot create it. Read-only filesystem? | ||
1280 | 435 | Too many files open in the system? | ||
1281 | 436 | Filesystem full? */ | ||
1282 | 437 | die (EX_FILEIO, _("can't create lock file %s: %s " | ||
1283 | 438 | "(use -n flag to override)"), | ||
1284 | 439 | linktargetfile, strerror (errsv)); | ||
1285 | 440 | } | ||
1286 | 441 | close(i); | ||
1287 | 442 | |||
1288 | 443 | /* Repeat until it was us who made the link */ | ||
1289 | 444 | while (!we_created_lockfile) { | ||
1290 | 445 | struct flock flock; | ||
1291 | 446 | int j; | ||
1292 | 447 | |||
1293 | 448 | j = link(linktargetfile, MOUNTED_LOCK); | ||
1294 | 449 | |||
1295 | 450 | { | ||
1296 | 451 | int errsv = errno; | ||
1297 | 452 | |||
1298 | 453 | if (j == 0) | ||
1299 | 454 | we_created_lockfile = 1; | ||
1300 | 455 | |||
1301 | 456 | if (j < 0 && errsv != EEXIST) { | ||
1302 | 457 | (void) unlink(linktargetfile); | ||
1303 | 458 | die (EX_FILEIO, _("can't link lock file %s: %s " | ||
1304 | 459 | "(use -n flag to override)"), | ||
1305 | 460 | MOUNTED_LOCK, strerror (errsv)); | ||
1306 | 461 | } | ||
1307 | 462 | } | ||
1308 | 463 | |||
1309 | 464 | lockfile_fd = open (MOUNTED_LOCK, O_WRONLY); | ||
1310 | 465 | |||
1311 | 466 | if (lockfile_fd < 0) { | ||
1312 | 467 | int errsv = errno; | ||
1313 | 468 | /* Strange... Maybe the file was just deleted? */ | ||
1314 | 469 | if (errno == ENOENT && tries-- > 0) { | ||
1315 | 470 | if (tries % 200 == 0) | ||
1316 | 471 | usleep(30); | ||
1317 | 472 | continue; | ||
1318 | 473 | } | ||
1319 | 474 | (void) unlink(linktargetfile); | ||
1320 | 475 | die (EX_FILEIO, _("can't open lock file %s: %s " | ||
1321 | 476 | "(use -n flag to override)"), | ||
1322 | 477 | MOUNTED_LOCK, strerror (errsv)); | ||
1323 | 478 | } | ||
1324 | 479 | |||
1325 | 480 | flock.l_type = F_WRLCK; | ||
1326 | 481 | flock.l_whence = SEEK_SET; | ||
1327 | 482 | flock.l_start = 0; | ||
1328 | 483 | flock.l_len = 0; | ||
1329 | 484 | |||
1330 | 485 | if (j == 0) { | ||
1331 | 486 | /* We made the link. Now claim the lock. */ | ||
1332 | 487 | if (fcntl (lockfile_fd, F_SETLK, &flock) == -1) { | ||
1333 | 488 | if (verbose) { | ||
1334 | 489 | int errsv = errno; | ||
1335 | 490 | nfs_error(_("%s: Can't lock lock file " | ||
1336 | 491 | "%s: %s"), progname, | ||
1337 | 492 | MOUNTED_LOCK, | ||
1338 | 493 | strerror (errsv)); | ||
1339 | 494 | } | ||
1340 | 495 | /* proceed anyway */ | ||
1341 | 496 | } | ||
1342 | 497 | (void) unlink(linktargetfile); | ||
1343 | 498 | } else { | ||
1344 | 499 | static int retries = 0; | ||
1345 | 500 | |||
1346 | 501 | /* Someone else made the link. Wait. */ | ||
1347 | 502 | alarm(LOCK_TIMEOUT); | ||
1348 | 503 | if (fcntl (lockfile_fd, F_SETLKW, &flock) == -1) { | ||
1349 | 504 | int errsv = errno; | ||
1350 | 505 | (void) unlink(linktargetfile); | ||
1351 | 506 | die (EX_FILEIO, _("can't lock lock file %s: %s"), | ||
1352 | 507 | MOUNTED_LOCK, (errno == EINTR) ? | ||
1353 | 508 | _("timed out") : strerror (errsv)); | ||
1354 | 509 | } | ||
1355 | 510 | alarm(0); | ||
1356 | 511 | /* Limit the number of iterations - maybe there | ||
1357 | 512 | still is some old /etc/mtab~ */ | ||
1358 | 513 | ++retries; | ||
1359 | 514 | if (retries % 200 == 0) | ||
1360 | 515 | usleep(30); | ||
1361 | 516 | if (retries > 100000) { | ||
1362 | 517 | (void) unlink(linktargetfile); | ||
1363 | 518 | close(lockfile_fd); | ||
1364 | 519 | die (EX_FILEIO, _("Cannot create link %s\n" | ||
1365 | 520 | "Perhaps there is a stale lock file?\n"), | ||
1366 | 521 | MOUNTED_LOCK); | ||
1367 | 522 | } | ||
1368 | 523 | close(lockfile_fd); | ||
1369 | 524 | } | ||
1370 | 525 | } | ||
1371 | 526 | } | ||
1372 | 527 | |||
1373 | 528 | /* | ||
1374 | 529 | * Update the mtab. | ||
1375 | 530 | * Used by umount with null INSTEAD: remove the last DIR entry. | ||
1376 | 531 | * Used by mount upon a remount: update option part, | ||
1377 | 532 | * and complain if a wrong device or type was given. | ||
1378 | 533 | * [Note that often a remount will be a rw remount of / | ||
1379 | 534 | * where there was no entry before, and we'll have to believe | ||
1380 | 535 | * the values given in INSTEAD.] | ||
1381 | 536 | */ | ||
1382 | 537 | |||
1383 | 538 | void | ||
1384 | 539 | update_mtab (const char *dir, struct mntent *instead) | ||
1385 | 540 | { | ||
1386 | 541 | mntFILE *mfp, *mftmp; | ||
1387 | 542 | const char *fnam = MOUNTED; | ||
1388 | 543 | struct mntentchn mtabhead; /* dummy */ | ||
1389 | 544 | struct mntentchn *mc, *mc0, *absent = NULL; | ||
1390 | 545 | |||
1391 | 546 | if (mtab_does_not_exist() || !mtab_is_writable()) | ||
1392 | 547 | return; | ||
1393 | 548 | |||
1394 | 549 | lock_mtab(); | ||
1395 | 550 | |||
1396 | 551 | /* having locked mtab, read it again */ | ||
1397 | 552 | mc0 = mc = &mtabhead; | ||
1398 | 553 | mc->nxt = mc->prev = NULL; | ||
1399 | 554 | |||
1400 | 555 | mfp = nfs_setmntent(fnam, "r"); | ||
1401 | 556 | if (mfp == NULL || mfp->mntent_fp == NULL) { | ||
1402 | 557 | int errsv = errno; | ||
1403 | 558 | nfs_error (_("cannot open %s (%s) - mtab not updated"), | ||
1404 | 559 | fnam, strerror (errsv)); | ||
1405 | 560 | goto leave; | ||
1406 | 561 | } | ||
1407 | 562 | |||
1408 | 563 | read_mntentchn(mfp, fnam, mc); | ||
1409 | 564 | |||
1410 | 565 | /* find last occurrence of dir */ | ||
1411 | 566 | for (mc = mc0->prev; mc && mc != mc0; mc = mc->prev) | ||
1412 | 567 | if (streq(mc->m.mnt_dir, dir)) | ||
1413 | 568 | break; | ||
1414 | 569 | if (mc && mc != mc0) { | ||
1415 | 570 | if (instead == NULL) { | ||
1416 | 571 | /* An umount - remove entry */ | ||
1417 | 572 | if (mc && mc != mc0) { | ||
1418 | 573 | mc->prev->nxt = mc->nxt; | ||
1419 | 574 | mc->nxt->prev = mc->prev; | ||
1420 | 575 | free(mc); | ||
1421 | 576 | } | ||
1422 | 577 | } else { | ||
1423 | 578 | /* A remount */ | ||
1424 | 579 | mc->m.mnt_opts = instead->mnt_opts; | ||
1425 | 580 | } | ||
1426 | 581 | } else if (instead) { | ||
1427 | 582 | /* not found, add a new entry */ | ||
1428 | 583 | absent = xmalloc(sizeof(*absent)); | ||
1429 | 584 | absent->m = *instead; | ||
1430 | 585 | absent->nxt = mc0; | ||
1431 | 586 | absent->prev = mc0->prev; | ||
1432 | 587 | mc0->prev = absent; | ||
1433 | 588 | if (mc0->nxt == NULL) | ||
1434 | 589 | mc0->nxt = absent; | ||
1435 | 590 | } | ||
1436 | 591 | |||
1437 | 592 | /* write chain to mtemp */ | ||
1438 | 593 | mftmp = nfs_setmntent (MOUNTED_TEMP, "w"); | ||
1439 | 594 | if (mftmp == NULL || mftmp->mntent_fp == NULL) { | ||
1440 | 595 | int errsv = errno; | ||
1441 | 596 | nfs_error (_("cannot open %s (%s) - mtab not updated"), | ||
1442 | 597 | MOUNTED_TEMP, strerror (errsv)); | ||
1443 | 598 | goto leave; | ||
1444 | 599 | } | ||
1445 | 600 | |||
1446 | 601 | for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt) { | ||
1447 | 602 | if (nfs_addmntent(mftmp, &(mc->m)) == 1) { | ||
1448 | 603 | int errsv = errno; | ||
1449 | 604 | die (EX_FILEIO, _("error writing %s: %s"), | ||
1450 | 605 | MOUNTED_TEMP, strerror (errsv)); | ||
1451 | 606 | } | ||
1452 | 607 | } | ||
1453 | 608 | |||
1454 | 609 | #if 0 | ||
1455 | 610 | /* the chain might have strings copied from 'instead', | ||
1456 | 611 | * so we cannot safely free it. | ||
1457 | 612 | * And there is no need anyway because we are going to exit | ||
1458 | 613 | * shortly. So just don't call discard_mntentchn.... | ||
1459 | 614 | */ | ||
1460 | 615 | discard_mntentchn(mc0); | ||
1461 | 616 | #endif | ||
1462 | 617 | if (fchmod (fileno (mftmp->mntent_fp), | ||
1463 | 618 | S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) < 0) { | ||
1464 | 619 | int errsv = errno; | ||
1465 | 620 | nfs_error(_("%s: error changing mode of %s: %s"), | ||
1466 | 621 | progname, MOUNTED_TEMP, strerror (errsv)); | ||
1467 | 622 | } | ||
1468 | 623 | nfs_endmntent (mftmp); | ||
1469 | 624 | |||
1470 | 625 | { /* | ||
1471 | 626 | * If mount is setuid and some non-root user mounts sth, | ||
1472 | 627 | * then mtab.tmp might get the group of this user. Copy uid/gid | ||
1473 | 628 | * from the present mtab before renaming. | ||
1474 | 629 | */ | ||
1475 | 630 | struct stat sbuf; | ||
1476 | 631 | if (stat (MOUNTED, &sbuf) == 0) { | ||
1477 | 632 | if (chown (MOUNTED_TEMP, sbuf.st_uid, sbuf.st_gid) < 0) { | ||
1478 | 633 | nfs_error(_("%s: error changing owner of %s: %s"), | ||
1479 | 634 | progname, MOUNTED_TEMP, strerror (errno)); | ||
1480 | 635 | } | ||
1481 | 636 | } | ||
1482 | 637 | } | ||
1483 | 638 | |||
1484 | 639 | /* rename mtemp to mtab */ | ||
1485 | 640 | if (rename (MOUNTED_TEMP, MOUNTED) < 0) { | ||
1486 | 641 | int errsv = errno; | ||
1487 | 642 | nfs_error(_("%s: can't rename %s to %s: %s\n"), | ||
1488 | 643 | progname, MOUNTED_TEMP, MOUNTED, | ||
1489 | 644 | strerror(errsv)); | ||
1490 | 645 | } | ||
1491 | 646 | |||
1492 | 647 | leave: | ||
1493 | 648 | unlock_mtab(); | ||
1494 | 649 | } | ||
1495 | 650 | 0 | ||
1496 | === removed file '.pc/03-handle-mtab-symlink.patch/utils/mount/fstab.h' | |||
1497 | --- .pc/03-handle-mtab-symlink.patch/utils/mount/fstab.h 2011-10-02 18:29:53 +0000 | |||
1498 | +++ .pc/03-handle-mtab-symlink.patch/utils/mount/fstab.h 1970-01-01 00:00:00 +0000 | |||
1499 | @@ -1,31 +0,0 @@ | |||
1500 | 1 | #ifndef _NFS_UTILS_MOUNT_FSTAB_H | ||
1501 | 2 | #define _NFS_UTILS_MOUNT_FSTAB_H | ||
1502 | 3 | |||
1503 | 4 | #include "nfs_mntent.h" | ||
1504 | 5 | |||
1505 | 6 | #ifndef _PATH_FSTAB | ||
1506 | 7 | #define _PATH_FSTAB "/etc/fstab" | ||
1507 | 8 | #endif | ||
1508 | 9 | |||
1509 | 10 | int mtab_is_writable(void); | ||
1510 | 11 | int mtab_does_not_exist(void); | ||
1511 | 12 | void reset_mtab_info(void); | ||
1512 | 13 | |||
1513 | 14 | struct mntentchn { | ||
1514 | 15 | struct mntentchn *nxt, *prev; | ||
1515 | 16 | struct mntent m; | ||
1516 | 17 | }; | ||
1517 | 18 | |||
1518 | 19 | struct mntentchn *getmntoptfile (const char *file); | ||
1519 | 20 | struct mntentchn *getmntdirbackward (const char *dir, struct mntentchn *mc); | ||
1520 | 21 | struct mntentchn *getprocmntdirbackward (const char *name, struct mntentchn *mc); | ||
1521 | 22 | struct mntentchn *getmntdevbackward (const char *dev, struct mntentchn *mc); | ||
1522 | 23 | |||
1523 | 24 | struct mntentchn *getfsfile (const char *file); | ||
1524 | 25 | struct mntentchn *getfsspec (const char *spec); | ||
1525 | 26 | |||
1526 | 27 | void lock_mtab (void); | ||
1527 | 28 | void unlock_mtab (void); | ||
1528 | 29 | void update_mtab (const char *special, struct mntent *with); | ||
1529 | 30 | |||
1530 | 31 | #endif /* _NFS_UTILS_MOUNT_FSTAB_H */ | ||
1531 | 32 | 0 | ||
1532 | === removed file '.pc/03-handle-mtab-symlink.patch/utils/mount/mount.c' | |||
1533 | --- .pc/03-handle-mtab-symlink.patch/utils/mount/mount.c 2011-07-09 16:28:32 +0000 | |||
1534 | +++ .pc/03-handle-mtab-symlink.patch/utils/mount/mount.c 1970-01-01 00:00:00 +0000 | |||
1535 | @@ -1,550 +0,0 @@ | |||
1536 | 1 | /* | ||
1537 | 2 | * mount.c -- Linux NFS mount | ||
1538 | 3 | * | ||
1539 | 4 | * Copyright (C) 2006 Amit Gud <agud@redhat.com> | ||
1540 | 5 | * | ||
1541 | 6 | * - Basic code and wrapper around mount and umount code of NFS. | ||
1542 | 7 | * Based on util-linux/mount/mount.c. | ||
1543 | 8 | * | ||
1544 | 9 | * This program is free software; you can redistribute it and/or modify | ||
1545 | 10 | * it under the terms of the GNU General Public License as published by | ||
1546 | 11 | * the Free Software Foundation; either version 2, or (at your option) | ||
1547 | 12 | * any later version. | ||
1548 | 13 | * | ||
1549 | 14 | * This program is distributed in the hope that it will be useful, | ||
1550 | 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1551 | 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1552 | 17 | * GNU General Public License for more details. | ||
1553 | 18 | * | ||
1554 | 19 | */ | ||
1555 | 20 | |||
1556 | 21 | #ifdef HAVE_CONFIG_H | ||
1557 | 22 | #include <config.h> | ||
1558 | 23 | #endif | ||
1559 | 24 | |||
1560 | 25 | #include <unistd.h> | ||
1561 | 26 | #include <sys/types.h> | ||
1562 | 27 | #include <sys/stat.h> | ||
1563 | 28 | #include <stdio.h> | ||
1564 | 29 | #include <string.h> | ||
1565 | 30 | #include <errno.h> | ||
1566 | 31 | #include <fcntl.h> | ||
1567 | 32 | #include <sys/mount.h> | ||
1568 | 33 | #include <getopt.h> | ||
1569 | 34 | #include <mntent.h> | ||
1570 | 35 | #include <pwd.h> | ||
1571 | 36 | |||
1572 | 37 | #include "fstab.h" | ||
1573 | 38 | #include "xcommon.h" | ||
1574 | 39 | #include "nls.h" | ||
1575 | 40 | #include "mount_constants.h" | ||
1576 | 41 | #include "mount_config.h" | ||
1577 | 42 | #include "nfs_paths.h" | ||
1578 | 43 | #include "nfs_mntent.h" | ||
1579 | 44 | |||
1580 | 45 | #include "nfs_mount.h" | ||
1581 | 46 | #include "nfs4_mount.h" | ||
1582 | 47 | #include "mount.h" | ||
1583 | 48 | #include "error.h" | ||
1584 | 49 | #include "stropts.h" | ||
1585 | 50 | #include "utils.h" | ||
1586 | 51 | |||
1587 | 52 | char *progname; | ||
1588 | 53 | int nfs_mount_data_version; | ||
1589 | 54 | int nomtab; | ||
1590 | 55 | int verbose; | ||
1591 | 56 | int sloppy; | ||
1592 | 57 | int string; | ||
1593 | 58 | |||
1594 | 59 | #define FOREGROUND (0) | ||
1595 | 60 | #define BACKGROUND (1) | ||
1596 | 61 | |||
1597 | 62 | static struct option longopts[] = { | ||
1598 | 63 | { "fake", 0, 0, 'f' }, | ||
1599 | 64 | { "help", 0, 0, 'h' }, | ||
1600 | 65 | { "no-mtab", 0, 0, 'n' }, | ||
1601 | 66 | { "read-only", 0, 0, 'r' }, | ||
1602 | 67 | { "ro", 0, 0, 'r' }, | ||
1603 | 68 | { "verbose", 0, 0, 'v' }, | ||
1604 | 69 | { "version", 0, 0, 'V' }, | ||
1605 | 70 | { "read-write", 0, 0, 'w' }, | ||
1606 | 71 | { "rw", 0, 0, 'w' }, | ||
1607 | 72 | { "options", 1, 0, 'o' }, | ||
1608 | 73 | { NULL, 0, 0, 0 } | ||
1609 | 74 | }; | ||
1610 | 75 | |||
1611 | 76 | /* | ||
1612 | 77 | * Map from -o and fstab option strings to the flag argument to mount(2). | ||
1613 | 78 | */ | ||
1614 | 79 | struct opt_map { | ||
1615 | 80 | const char *opt; /* option name */ | ||
1616 | 81 | int skip; /* skip in mtab option string */ | ||
1617 | 82 | int inv; /* true if flag value should be inverted */ | ||
1618 | 83 | int mask; /* flag mask value */ | ||
1619 | 84 | }; | ||
1620 | 85 | |||
1621 | 86 | static const struct opt_map opt_map[] = { | ||
1622 | 87 | { "defaults", 0, 0, 0 }, /* default options */ | ||
1623 | 88 | { "ro", 1, 0, MS_RDONLY }, /* read-only */ | ||
1624 | 89 | { "rw", 1, 1, MS_RDONLY }, /* read-write */ | ||
1625 | 90 | { "exec", 0, 1, MS_NOEXEC }, /* permit execution of binaries */ | ||
1626 | 91 | { "noexec", 0, 0, MS_NOEXEC }, /* don't execute binaries */ | ||
1627 | 92 | { "suid", 0, 1, MS_NOSUID }, /* honor suid executables */ | ||
1628 | 93 | { "nosuid", 0, 0, MS_NOSUID }, /* don't honor suid executables */ | ||
1629 | 94 | { "dev", 0, 1, MS_NODEV }, /* interpret device files */ | ||
1630 | 95 | { "nodev", 0, 0, MS_NODEV }, /* don't interpret devices */ | ||
1631 | 96 | { "sync", 0, 0, MS_SYNCHRONOUS}, /* synchronous I/O */ | ||
1632 | 97 | { "async", 0, 1, MS_SYNCHRONOUS}, /* asynchronous I/O */ | ||
1633 | 98 | { "dirsync", 0, 0, MS_DIRSYNC}, /* synchronous directory modifications */ | ||
1634 | 99 | { "remount", 0, 0, MS_REMOUNT}, /* Alter flags of mounted FS */ | ||
1635 | 100 | { "bind", 0, 0, MS_BIND }, /* Remount part of tree elsewhere */ | ||
1636 | 101 | { "rbind", 0, 0, MS_BIND|MS_REC }, /* Idem, plus mounted subtrees */ | ||
1637 | 102 | { "auto", 0, 0, MS_DUMMY }, /* Can be mounted using -a */ | ||
1638 | 103 | { "noauto", 0, 0, MS_DUMMY }, /* Can only be mounted explicitly */ | ||
1639 | 104 | { "users", 1, 0, MS_USERS }, /* Allow ordinary user to mount */ | ||
1640 | 105 | { "nousers", 0, 1, MS_DUMMY }, /* Forbid ordinary user to mount */ | ||
1641 | 106 | { "user", 1, 0, MS_USER }, /* Allow ordinary user to mount */ | ||
1642 | 107 | { "nouser", 0, 1, MS_DUMMY }, /* Forbid ordinary user to mount */ | ||
1643 | 108 | { "owner", 0, 0, MS_DUMMY }, /* Let the owner of the device mount */ | ||
1644 | 109 | { "noowner", 0, 0, MS_DUMMY }, /* Device owner has no special privs */ | ||
1645 | 110 | { "group", 0, 0, MS_DUMMY }, /* Let the group of the device mount */ | ||
1646 | 111 | { "nogroup", 0, 0, MS_DUMMY }, /* Device group has no special privs */ | ||
1647 | 112 | { "_netdev", 0, 0, MS_DUMMY}, /* Device requires network */ | ||
1648 | 113 | { "comment", 0, 0, MS_DUMMY}, /* fstab comment only (kudzu,_netdev)*/ | ||
1649 | 114 | |||
1650 | 115 | /* add new options here */ | ||
1651 | 116 | #ifdef MS_NOSUB | ||
1652 | 117 | { "sub", 0, 1, MS_NOSUB }, /* allow submounts */ | ||
1653 | 118 | { "nosub", 0, 0, MS_NOSUB }, /* don't allow submounts */ | ||
1654 | 119 | #endif | ||
1655 | 120 | #ifdef MS_SILENT | ||
1656 | 121 | { "quiet", 0, 0, MS_SILENT }, /* be quiet */ | ||
1657 | 122 | { "loud", 0, 1, MS_SILENT }, /* print out messages. */ | ||
1658 | 123 | #endif | ||
1659 | 124 | #ifdef MS_MANDLOCK | ||
1660 | 125 | { "mand", 0, 0, MS_MANDLOCK }, /* Allow mandatory locks on this FS */ | ||
1661 | 126 | { "nomand", 0, 1, MS_MANDLOCK }, /* Forbid mandatory locks on this FS */ | ||
1662 | 127 | #endif | ||
1663 | 128 | { "loop", 1, 0, MS_DUMMY }, /* use a loop device */ | ||
1664 | 129 | #ifdef MS_NOATIME | ||
1665 | 130 | { "atime", 0, 1, MS_NOATIME }, /* Update access time */ | ||
1666 | 131 | { "noatime", 0, 0, MS_NOATIME }, /* Do not update access time */ | ||
1667 | 132 | #endif | ||
1668 | 133 | #ifdef MS_NODIRATIME | ||
1669 | 134 | { "diratime", 0, 1, MS_NODIRATIME }, /* Update dir access times */ | ||
1670 | 135 | { "nodiratime", 0, 0, MS_NODIRATIME },/* Do not update dir access times */ | ||
1671 | 136 | #endif | ||
1672 | 137 | #ifdef MS_RELATIME | ||
1673 | 138 | { "relatime", 0, 0, MS_RELATIME }, /* Update access times relative to | ||
1674 | 139 | mtime/ctime */ | ||
1675 | 140 | { "norelatime", 0, 1, MS_RELATIME }, /* Update access time without regard | ||
1676 | 141 | to mtime/ctime */ | ||
1677 | 142 | #endif | ||
1678 | 143 | { "noquota", 0, 0, MS_DUMMY }, /* Don't enforce quota */ | ||
1679 | 144 | { "quota", 0, 0, MS_DUMMY }, /* Enforce user quota */ | ||
1680 | 145 | { "usrquota", 0, 0, MS_DUMMY }, /* Enforce user quota */ | ||
1681 | 146 | { "grpquota", 0, 0, MS_DUMMY }, /* Enforce group quota */ | ||
1682 | 147 | { NULL, 0, 0, 0 } | ||
1683 | 148 | }; | ||
1684 | 149 | |||
1685 | 150 | static void parse_opts(const char *options, int *flags, char **extra_opts); | ||
1686 | 151 | |||
1687 | 152 | /* | ||
1688 | 153 | * Build a canonical mount option string for /etc/mtab. | ||
1689 | 154 | */ | ||
1690 | 155 | static char *fix_opts_string(int flags, const char *extra_opts) | ||
1691 | 156 | { | ||
1692 | 157 | const struct opt_map *om; | ||
1693 | 158 | char *new_opts; | ||
1694 | 159 | |||
1695 | 160 | new_opts = xstrdup((flags & MS_RDONLY) ? "ro" : "rw"); | ||
1696 | 161 | if (flags & MS_USER) { | ||
1697 | 162 | /* record who mounted this so they can unmount */ | ||
1698 | 163 | struct passwd *pw = getpwuid(getuid()); | ||
1699 | 164 | if(pw) | ||
1700 | 165 | new_opts = xstrconcat3(new_opts, ",user=", pw->pw_name); | ||
1701 | 166 | } | ||
1702 | 167 | if (flags & MS_USERS) | ||
1703 | 168 | new_opts = xstrconcat3(new_opts, ",users", ""); | ||
1704 | 169 | |||
1705 | 170 | for (om = opt_map; om->opt != NULL; om++) { | ||
1706 | 171 | if (om->skip) | ||
1707 | 172 | continue; | ||
1708 | 173 | if (om->inv || !om->mask || (flags & om->mask) != om->mask) | ||
1709 | 174 | continue; | ||
1710 | 175 | new_opts = xstrconcat3(new_opts, ",", om->opt); | ||
1711 | 176 | flags &= ~om->mask; | ||
1712 | 177 | } | ||
1713 | 178 | if (extra_opts && *extra_opts) { | ||
1714 | 179 | new_opts = xstrconcat3(new_opts, ",", extra_opts); | ||
1715 | 180 | } | ||
1716 | 181 | return new_opts; | ||
1717 | 182 | } | ||
1718 | 183 | |||
1719 | 184 | static void | ||
1720 | 185 | init_mntent(struct mntent *mnt, char *fsname, char *dir, char *type, | ||
1721 | 186 | int flags, char *opts) | ||
1722 | 187 | { | ||
1723 | 188 | mnt->mnt_fsname = fsname; | ||
1724 | 189 | mnt->mnt_dir = dir; | ||
1725 | 190 | mnt->mnt_type = type; | ||
1726 | 191 | mnt->mnt_opts = fix_opts_string(flags & ~MS_NOMTAB, opts); | ||
1727 | 192 | |||
1728 | 193 | /* these are always zero for NFS */ | ||
1729 | 194 | mnt->mnt_freq = 0; | ||
1730 | 195 | mnt->mnt_passno = 0; | ||
1731 | 196 | } | ||
1732 | 197 | |||
1733 | 198 | /* Create mtab with a root entry. */ | ||
1734 | 199 | static void | ||
1735 | 200 | create_mtab (void) { | ||
1736 | 201 | struct mntentchn *fstab; | ||
1737 | 202 | struct mntent mnt; | ||
1738 | 203 | int flags; | ||
1739 | 204 | mntFILE *mfp; | ||
1740 | 205 | |||
1741 | 206 | lock_mtab(); | ||
1742 | 207 | |||
1743 | 208 | mfp = nfs_setmntent (MOUNTED, "a+"); | ||
1744 | 209 | if (mfp == NULL || mfp->mntent_fp == NULL) { | ||
1745 | 210 | int errsv = errno; | ||
1746 | 211 | die (EX_FILEIO, _("mount: can't open %s for writing: %s"), | ||
1747 | 212 | MOUNTED, strerror (errsv)); | ||
1748 | 213 | } | ||
1749 | 214 | |||
1750 | 215 | /* Find the root entry by looking it up in fstab */ | ||
1751 | 216 | if ((fstab = getfsfile ("/")) || (fstab = getfsfile ("root"))) { | ||
1752 | 217 | char *extra_opts; | ||
1753 | 218 | parse_opts (fstab->m.mnt_opts, &flags, &extra_opts); | ||
1754 | 219 | init_mntent(&mnt, xstrdup(fstab->m.mnt_fsname), "/", | ||
1755 | 220 | fstab->m.mnt_type, flags, extra_opts); | ||
1756 | 221 | free(extra_opts); | ||
1757 | 222 | |||
1758 | 223 | if (nfs_addmntent (mfp, &mnt) == 1) { | ||
1759 | 224 | int errsv = errno; | ||
1760 | 225 | die (EX_FILEIO, _("mount: error writing %s: %s"), | ||
1761 | 226 | _PATH_MOUNTED, strerror (errsv)); | ||
1762 | 227 | } | ||
1763 | 228 | } | ||
1764 | 229 | if (fchmod (fileno (mfp->mntent_fp), 0644) < 0) | ||
1765 | 230 | if (errno != EROFS) { | ||
1766 | 231 | int errsv = errno; | ||
1767 | 232 | die (EX_FILEIO, | ||
1768 | 233 | _("mount: error changing mode of %s: %s"), | ||
1769 | 234 | _PATH_MOUNTED, strerror (errsv)); | ||
1770 | 235 | } | ||
1771 | 236 | nfs_endmntent (mfp); | ||
1772 | 237 | |||
1773 | 238 | unlock_mtab(); | ||
1774 | 239 | |||
1775 | 240 | reset_mtab_info(); | ||
1776 | 241 | } | ||
1777 | 242 | |||
1778 | 243 | static int add_mtab(char *spec, char *mount_point, char *fstype, | ||
1779 | 244 | int flags, char *opts) | ||
1780 | 245 | { | ||
1781 | 246 | struct mntent ment; | ||
1782 | 247 | int result = EX_SUCCESS; | ||
1783 | 248 | |||
1784 | 249 | init_mntent(&ment, spec, mount_point, fstype, flags, opts); | ||
1785 | 250 | |||
1786 | 251 | if (!nomtab && mtab_does_not_exist()) { | ||
1787 | 252 | if (verbose > 1) | ||
1788 | 253 | printf(_("mount: no %s found - creating it..\n"), | ||
1789 | 254 | MOUNTED); | ||
1790 | 255 | create_mtab (); | ||
1791 | 256 | } | ||
1792 | 257 | |||
1793 | 258 | if (!nomtab && mtab_is_writable()) { | ||
1794 | 259 | if (flags & MS_REMOUNT) | ||
1795 | 260 | update_mtab(ment.mnt_dir, &ment); | ||
1796 | 261 | else { | ||
1797 | 262 | mntFILE *mtab; | ||
1798 | 263 | |||
1799 | 264 | lock_mtab(); | ||
1800 | 265 | mtab = nfs_setmntent(MOUNTED, "a+"); | ||
1801 | 266 | if (mtab == NULL || mtab->mntent_fp == NULL) { | ||
1802 | 267 | nfs_error(_("Can't open mtab: %s"), | ||
1803 | 268 | strerror(errno)); | ||
1804 | 269 | result = EX_FILEIO; | ||
1805 | 270 | } else { | ||
1806 | 271 | if (nfs_addmntent(mtab, &ment) == 1) { | ||
1807 | 272 | nfs_error(_("Can't write mount entry to mtab: %s"), | ||
1808 | 273 | strerror(errno)); | ||
1809 | 274 | result = EX_FILEIO; | ||
1810 | 275 | } | ||
1811 | 276 | } | ||
1812 | 277 | nfs_endmntent(mtab); | ||
1813 | 278 | unlock_mtab(); | ||
1814 | 279 | } | ||
1815 | 280 | } | ||
1816 | 281 | |||
1817 | 282 | free(ment.mnt_opts); | ||
1818 | 283 | |||
1819 | 284 | return result; | ||
1820 | 285 | } | ||
1821 | 286 | |||
1822 | 287 | static void parse_opt(const char *opt, int *mask, char *extra_opts, size_t len) | ||
1823 | 288 | { | ||
1824 | 289 | const struct opt_map *om; | ||
1825 | 290 | |||
1826 | 291 | for (om = opt_map; om->opt != NULL; om++) { | ||
1827 | 292 | if (!strcmp (opt, om->opt)) { | ||
1828 | 293 | if (om->inv) | ||
1829 | 294 | *mask &= ~om->mask; | ||
1830 | 295 | else | ||
1831 | 296 | *mask |= om->mask; | ||
1832 | 297 | return; | ||
1833 | 298 | } | ||
1834 | 299 | } | ||
1835 | 300 | |||
1836 | 301 | len -= strlen(extra_opts); | ||
1837 | 302 | |||
1838 | 303 | if (*extra_opts && --len > 0) | ||
1839 | 304 | strcat(extra_opts, ","); | ||
1840 | 305 | |||
1841 | 306 | if ((len -= strlen(opt)) > 0) | ||
1842 | 307 | strcat(extra_opts, opt); | ||
1843 | 308 | } | ||
1844 | 309 | |||
1845 | 310 | /* | ||
1846 | 311 | * Convert the provided mount command-line options into the 4th & | ||
1847 | 312 | * 5th arguments to mount(2). Output parameter "@flags" gets the | ||
1848 | 313 | * standard options (indicated by MS_ bits), and output parameter | ||
1849 | 314 | * "@extra_opts" gets all the filesystem-specific options. | ||
1850 | 315 | */ | ||
1851 | 316 | static void parse_opts(const char *options, int *flags, char **extra_opts) | ||
1852 | 317 | { | ||
1853 | 318 | if (options != NULL) { | ||
1854 | 319 | char *opts = xstrdup(options); | ||
1855 | 320 | char *opt, *p; | ||
1856 | 321 | size_t len = strlen(opts) + 1; /* include room for a null */ | ||
1857 | 322 | int open_quote = 0; | ||
1858 | 323 | |||
1859 | 324 | *extra_opts = xmalloc(len); | ||
1860 | 325 | **extra_opts = '\0'; | ||
1861 | 326 | |||
1862 | 327 | for (p = opts, opt = NULL; p && *p; p++) { | ||
1863 | 328 | if (!opt) | ||
1864 | 329 | opt = p; /* begin of the option item */ | ||
1865 | 330 | if (*p == '"') | ||
1866 | 331 | open_quote ^= 1; /* reverse the status */ | ||
1867 | 332 | if (open_quote) | ||
1868 | 333 | continue; /* still in a quoted block */ | ||
1869 | 334 | if (*p == ',') | ||
1870 | 335 | *p = '\0'; /* terminate the option item */ | ||
1871 | 336 | |||
1872 | 337 | /* end of option item or last item */ | ||
1873 | 338 | if (*p == '\0' || *(p + 1) == '\0') { | ||
1874 | 339 | parse_opt(opt, flags, *extra_opts, len); | ||
1875 | 340 | opt = NULL; | ||
1876 | 341 | } | ||
1877 | 342 | } | ||
1878 | 343 | free(opts); | ||
1879 | 344 | } | ||
1880 | 345 | } | ||
1881 | 346 | |||
1882 | 347 | static int try_mount(char *spec, char *mount_point, int flags, | ||
1883 | 348 | char *fs_type, char **extra_opts, char *mount_opts, | ||
1884 | 349 | int fake, int bg) | ||
1885 | 350 | { | ||
1886 | 351 | int ret; | ||
1887 | 352 | |||
1888 | 353 | if (string) | ||
1889 | 354 | ret = nfsmount_string(spec, mount_point, fs_type, flags, | ||
1890 | 355 | extra_opts, fake, bg); | ||
1891 | 356 | else { | ||
1892 | 357 | if (strcmp(fs_type, "nfs4") == 0) | ||
1893 | 358 | ret = nfs4mount(spec, mount_point, flags, | ||
1894 | 359 | extra_opts, fake, bg); | ||
1895 | 360 | else | ||
1896 | 361 | ret = nfsmount(spec, mount_point, flags, | ||
1897 | 362 | extra_opts, fake, bg); | ||
1898 | 363 | } | ||
1899 | 364 | |||
1900 | 365 | if (ret) | ||
1901 | 366 | return ret; | ||
1902 | 367 | |||
1903 | 368 | if (!fake) | ||
1904 | 369 | print_one(spec, mount_point, fs_type, mount_opts); | ||
1905 | 370 | |||
1906 | 371 | return add_mtab(spec, mount_point, fs_type, flags, *extra_opts); | ||
1907 | 372 | } | ||
1908 | 373 | |||
1909 | 374 | int main(int argc, char *argv[]) | ||
1910 | 375 | { | ||
1911 | 376 | int c, flags = 0, mnt_err = 1, fake = 0; | ||
1912 | 377 | char *spec = NULL, *mount_point = NULL, *fs_type = "nfs"; | ||
1913 | 378 | char *extra_opts = NULL, *mount_opts = NULL; | ||
1914 | 379 | uid_t uid = getuid(); | ||
1915 | 380 | |||
1916 | 381 | progname = basename(argv[0]); | ||
1917 | 382 | |||
1918 | 383 | nfs_mount_data_version = discover_nfs_mount_data_version(&string); | ||
1919 | 384 | |||
1920 | 385 | if(!strncmp(progname, "umount", strlen("umount"))) | ||
1921 | 386 | exit(nfsumount(argc, argv)); | ||
1922 | 387 | |||
1923 | 388 | if ((argc < 3)) { | ||
1924 | 389 | mount_usage(); | ||
1925 | 390 | exit(EX_USAGE); | ||
1926 | 391 | } | ||
1927 | 392 | |||
1928 | 393 | mount_config_init(progname); | ||
1929 | 394 | |||
1930 | 395 | while ((c = getopt_long(argc, argv, "rvVwfno:hs", | ||
1931 | 396 | longopts, NULL)) != -1) { | ||
1932 | 397 | switch (c) { | ||
1933 | 398 | case 'r': | ||
1934 | 399 | flags |= MS_RDONLY; | ||
1935 | 400 | break; | ||
1936 | 401 | case 'v': | ||
1937 | 402 | ++verbose; | ||
1938 | 403 | break; | ||
1939 | 404 | case 'V': | ||
1940 | 405 | printf("%s: ("PACKAGE_STRING")\n", progname); | ||
1941 | 406 | exit(EX_SUCCESS); | ||
1942 | 407 | case 'w': | ||
1943 | 408 | flags &= ~MS_RDONLY; | ||
1944 | 409 | break; | ||
1945 | 410 | case 'f': | ||
1946 | 411 | ++fake; | ||
1947 | 412 | break; | ||
1948 | 413 | case 'n': | ||
1949 | 414 | ++nomtab; | ||
1950 | 415 | break; | ||
1951 | 416 | case 'o': /* specify mount options */ | ||
1952 | 417 | if (mount_opts) | ||
1953 | 418 | mount_opts = xstrconcat3(mount_opts, ",", optarg); | ||
1954 | 419 | else | ||
1955 | 420 | mount_opts = xstrdup(optarg); | ||
1956 | 421 | break; | ||
1957 | 422 | case 's': | ||
1958 | 423 | ++sloppy; | ||
1959 | 424 | break; | ||
1960 | 425 | case 'h': | ||
1961 | 426 | default: | ||
1962 | 427 | mount_usage(); | ||
1963 | 428 | goto out_usage; | ||
1964 | 429 | } | ||
1965 | 430 | } | ||
1966 | 431 | |||
1967 | 432 | /* | ||
1968 | 433 | * Extra non-option words at the end are bogus... | ||
1969 | 434 | */ | ||
1970 | 435 | if (optind != argc - 2) { | ||
1971 | 436 | mount_usage(); | ||
1972 | 437 | goto out_usage; | ||
1973 | 438 | } else { | ||
1974 | 439 | while (optind < argc) { | ||
1975 | 440 | if (!spec) | ||
1976 | 441 | spec = argv[optind]; | ||
1977 | 442 | else | ||
1978 | 443 | mount_point = argv[optind]; | ||
1979 | 444 | optind++; | ||
1980 | 445 | } | ||
1981 | 446 | } | ||
1982 | 447 | |||
1983 | 448 | if (strcmp(progname, "mount.nfs4") == 0) | ||
1984 | 449 | fs_type = "nfs4"; | ||
1985 | 450 | |||
1986 | 451 | /* | ||
1987 | 452 | * If a non-root user is attempting to mount, make sure the | ||
1988 | 453 | * user's requested options match the options specified in | ||
1989 | 454 | * /etc/fstab; otherwise, don't allow the mount. | ||
1990 | 455 | */ | ||
1991 | 456 | if (uid != 0) { | ||
1992 | 457 | struct mntentchn *mc; | ||
1993 | 458 | |||
1994 | 459 | if ((mc = getfsfile(mount_point)) == NULL || | ||
1995 | 460 | strcmp(mc->m.mnt_fsname, spec) != 0 || | ||
1996 | 461 | strcmp(mc->m.mnt_type, fs_type) != 0) { | ||
1997 | 462 | nfs_error(_("%s: permission denied: no match for %s " | ||
1998 | 463 | "found in /etc/fstab"), progname, mount_point); | ||
1999 | 464 | goto out_usage; | ||
2000 | 465 | } | ||
2001 | 466 | |||
2002 | 467 | /* | ||
2003 | 468 | * 'mount' munges the options from fstab before passing them | ||
2004 | 469 | * to us, so it is non-trivial to test that we have the correct | ||
2005 | 470 | * set of options and we don't want to trust what the user | ||
2006 | 471 | * gave us, so just take whatever is in /etc/fstab. | ||
2007 | 472 | */ | ||
2008 | 473 | mount_opts = strdup(mc->m.mnt_opts); | ||
2009 | 474 | } | ||
2010 | 475 | |||
2011 | 476 | mount_point = canonicalize(mount_point); | ||
2012 | 477 | if (!mount_point) { | ||
2013 | 478 | nfs_error(_("%s: no mount point provided"), progname); | ||
2014 | 479 | goto out_usage; | ||
2015 | 480 | } | ||
2016 | 481 | if (mount_point[0] != '/') { | ||
2017 | 482 | nfs_error(_("%s: unrecognized mount point %s"), | ||
2018 | 483 | progname, mount_point); | ||
2019 | 484 | mnt_err = EX_USAGE; | ||
2020 | 485 | goto out; | ||
2021 | 486 | } | ||
2022 | 487 | /* | ||
2023 | 488 | * Concatenate mount options from the configuration file | ||
2024 | 489 | */ | ||
2025 | 490 | mount_opts = mount_config_opts(spec, mount_point, mount_opts); | ||
2026 | 491 | |||
2027 | 492 | parse_opts(mount_opts, &flags, &extra_opts); | ||
2028 | 493 | |||
2029 | 494 | if (uid != 0) { | ||
2030 | 495 | if (!(flags & (MS_USERS|MS_USER))) { | ||
2031 | 496 | nfs_error(_("%s: permission denied"), progname); | ||
2032 | 497 | mnt_err = EX_USAGE; | ||
2033 | 498 | goto out; | ||
2034 | 499 | } | ||
2035 | 500 | |||
2036 | 501 | if (geteuid() != 0) { | ||
2037 | 502 | nfs_error(_("%s: not installed setuid - " | ||
2038 | 503 | "\"user\" NFS mounts not supported."), progname); | ||
2039 | 504 | exit(EX_FAIL); | ||
2040 | 505 | } | ||
2041 | 506 | } | ||
2042 | 507 | |||
2043 | 508 | if (chk_mountpoint(mount_point)) { | ||
2044 | 509 | mnt_err = EX_USAGE; | ||
2045 | 510 | goto out; | ||
2046 | 511 | } | ||
2047 | 512 | |||
2048 | 513 | mnt_err = try_mount(spec, mount_point, flags, fs_type, &extra_opts, | ||
2049 | 514 | mount_opts, fake, FOREGROUND); | ||
2050 | 515 | if (mnt_err == EX_BG) { | ||
2051 | 516 | printf(_("%s: backgrounding \"%s\"\n"), | ||
2052 | 517 | progname, spec); | ||
2053 | 518 | printf(_("%s: mount options: \"%s\"\n"), | ||
2054 | 519 | progname, extra_opts); | ||
2055 | 520 | |||
2056 | 521 | fflush(stdout); | ||
2057 | 522 | |||
2058 | 523 | /* | ||
2059 | 524 | * Parent exits immediately with success. | ||
2060 | 525 | */ | ||
2061 | 526 | if (daemon(0, 0)) { | ||
2062 | 527 | nfs_error(_("%s: failed to start " | ||
2063 | 528 | "background process: %s\n"), | ||
2064 | 529 | progname, strerror(errno)); | ||
2065 | 530 | exit(EX_FAIL); | ||
2066 | 531 | } | ||
2067 | 532 | |||
2068 | 533 | mnt_err = try_mount(spec, mount_point, flags, fs_type, | ||
2069 | 534 | &extra_opts, mount_opts, fake, | ||
2070 | 535 | BACKGROUND); | ||
2071 | 536 | if (verbose && mnt_err) | ||
2072 | 537 | printf(_("%s: giving up \"%s\"\n"), | ||
2073 | 538 | progname, spec); | ||
2074 | 539 | } | ||
2075 | 540 | |||
2076 | 541 | out: | ||
2077 | 542 | free(mount_opts); | ||
2078 | 543 | free(extra_opts); | ||
2079 | 544 | free(mount_point); | ||
2080 | 545 | exit(mnt_err); | ||
2081 | 546 | |||
2082 | 547 | out_usage: | ||
2083 | 548 | free(mount_opts); | ||
2084 | 549 | exit(EX_USAGE); | ||
2085 | 550 | } | ||
2086 | 551 | 0 | ||
2087 | === removed directory '.pc/11-532048-reduce-verbosity.patch' | |||
2088 | === removed directory '.pc/11-532048-reduce-verbosity.patch/utils' | |||
2089 | === removed directory '.pc/11-532048-reduce-verbosity.patch/utils/gssd' | |||
2090 | === removed file '.pc/11-532048-reduce-verbosity.patch/utils/gssd/gss_util.c' | |||
2091 | --- .pc/11-532048-reduce-verbosity.patch/utils/gssd/gss_util.c 2011-07-09 16:28:32 +0000 | |||
2092 | +++ .pc/11-532048-reduce-verbosity.patch/utils/gssd/gss_util.c 1970-01-01 00:00:00 +0000 | |||
2093 | @@ -1,341 +0,0 @@ | |||
2094 | 1 | /* | ||
2095 | 2 | * Adapted in part from MIT Kerberos 5-1.2.1 slave/kprop.c and from | ||
2096 | 3 | * http://docs.sun.com/?p=/doc/816-1331/6m7oo9sms&a=view | ||
2097 | 4 | * | ||
2098 | 5 | * Copyright (c) 2002 The Regents of the University of Michigan. | ||
2099 | 6 | * All rights reserved. | ||
2100 | 7 | * | ||
2101 | 8 | * Andy Adamson <andros@umich.edu> | ||
2102 | 9 | * J. Bruce Fields <bfields@umich.edu> | ||
2103 | 10 | * Marius Aamodt Eriksen <marius@umich.edu> | ||
2104 | 11 | */ | ||
2105 | 12 | |||
2106 | 13 | /* | ||
2107 | 14 | * slave/kprop.c | ||
2108 | 15 | * | ||
2109 | 16 | * Copyright 1990,1991 by the Massachusetts Institute of Technology. | ||
2110 | 17 | * All Rights Reserved. | ||
2111 | 18 | * | ||
2112 | 19 | * Export of this software from the United States of America may | ||
2113 | 20 | * require a specific license from the United States Government. | ||
2114 | 21 | * It is the responsibility of any person or organization contemplating | ||
2115 | 22 | * export to obtain such a license before exporting. | ||
2116 | 23 | * | ||
2117 | 24 | * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and | ||
2118 | 25 | * distribute this software and its documentation for any purpose and | ||
2119 | 26 | * without fee is hereby granted, provided that the above copyright | ||
2120 | 27 | * notice appear in all copies and that both that copyright notice and | ||
2121 | 28 | * this permission notice appear in supporting documentation, and that | ||
2122 | 29 | * the name of M.I.T. not be used in advertising or publicity pertaining | ||
2123 | 30 | * to distribution of the software without specific, written prior | ||
2124 | 31 | * permission. Furthermore if you modify this software you must label | ||
2125 | 32 | * your software as modified software and not distribute it in such a | ||
2126 | 33 | * fashion that it might be confused with the original M.I.T. software. | ||
2127 | 34 | * M.I.T. makes no representations about the suitability of | ||
2128 | 35 | * this software for any purpose. It is provided "as is" without express | ||
2129 | 36 | * or implied warranty. | ||
2130 | 37 | */ | ||
2131 | 38 | |||
2132 | 39 | /* | ||
2133 | 40 | * Copyright 1994 by OpenVision Technologies, Inc. | ||
2134 | 41 | * | ||
2135 | 42 | * Permission to use, copy, modify, distribute, and sell this software | ||
2136 | 43 | * and its documentation for any purpose is hereby granted without fee, | ||
2137 | 44 | * provided that the above copyright notice appears in all copies and | ||
2138 | 45 | * that both that copyright notice and this permission notice appear in | ||
2139 | 46 | * supporting documentation, and that the name of OpenVision not be used | ||
2140 | 47 | * in advertising or publicity pertaining to distribution of the software | ||
2141 | 48 | * without specific, written prior permission. OpenVision makes no | ||
2142 | 49 | * representations about the suitability of this software for any | ||
2143 | 50 | * purpose. It is provided "as is" without express or implied warranty. | ||
2144 | 51 | * | ||
2145 | 52 | * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, | ||
2146 | 53 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO | ||
2147 | 54 | * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR | ||
2148 | 55 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF | ||
2149 | 56 | * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
2150 | 57 | * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
2151 | 58 | * PERFORMANCE OF THIS SOFTWARE. | ||
2152 | 59 | */ | ||
2153 | 60 | |||
2154 | 61 | #ifdef HAVE_CONFIG_H | ||
2155 | 62 | #include <config.h> | ||
2156 | 63 | #endif /* HAVE_CONFIG_H */ | ||
2157 | 64 | |||
2158 | 65 | #include <errno.h> | ||
2159 | 66 | #include <stdio.h> | ||
2160 | 67 | #include <ctype.h> | ||
2161 | 68 | #include <sys/file.h> | ||
2162 | 69 | #include <signal.h> | ||
2163 | 70 | #include <string.h> | ||
2164 | 71 | #include <sys/types.h> | ||
2165 | 72 | #include <sys/time.h> | ||
2166 | 73 | #include <sys/stat.h> | ||
2167 | 74 | #include <sys/socket.h> | ||
2168 | 75 | #include <netinet/in.h> | ||
2169 | 76 | #include <sys/param.h> | ||
2170 | 77 | #include <netdb.h> | ||
2171 | 78 | #include <fcntl.h> | ||
2172 | 79 | #include <gssapi/gssapi.h> | ||
2173 | 80 | #if defined(HAVE_KRB5) && !defined(GSS_C_NT_HOSTBASED_SERVICE) | ||
2174 | 81 | #include <gssapi/gssapi_generic.h> | ||
2175 | 82 | #define GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name | ||
2176 | 83 | #endif | ||
2177 | 84 | #include "gss_util.h" | ||
2178 | 85 | #include "err_util.h" | ||
2179 | 86 | #include "gssd.h" | ||
2180 | 87 | #ifdef HAVE_UNISTD_H | ||
2181 | 88 | #include <unistd.h> | ||
2182 | 89 | #endif | ||
2183 | 90 | #include <stdlib.h> | ||
2184 | 91 | #ifdef HAVE_COM_ERR_H | ||
2185 | 92 | #include <com_err.h> | ||
2186 | 93 | #endif | ||
2187 | 94 | |||
2188 | 95 | /* Global gssd_credentials handle */ | ||
2189 | 96 | gss_cred_id_t gssd_creds; | ||
2190 | 97 | |||
2191 | 98 | gss_OID g_mechOid = GSS_C_NULL_OID;; | ||
2192 | 99 | |||
2193 | 100 | #if 0 | ||
2194 | 101 | static void | ||
2195 | 102 | display_status_1(char *m, u_int32_t code, int type, const gss_OID mech) | ||
2196 | 103 | { | ||
2197 | 104 | u_int32_t maj_stat, min_stat; | ||
2198 | 105 | gss_buffer_desc msg = GSS_C_EMPTY_BUFFER; | ||
2199 | 106 | u_int32_t msg_ctx = 0; | ||
2200 | 107 | char *typestr; | ||
2201 | 108 | |||
2202 | 109 | switch (type) { | ||
2203 | 110 | case GSS_C_GSS_CODE: | ||
2204 | 111 | typestr = "GSS"; | ||
2205 | 112 | break; | ||
2206 | 113 | case GSS_C_MECH_CODE: | ||
2207 | 114 | typestr = "mechanism"; | ||
2208 | 115 | break; | ||
2209 | 116 | default: | ||
2210 | 117 | return; | ||
2211 | 118 | /* NOTREACHED */ | ||
2212 | 119 | } | ||
2213 | 120 | |||
2214 | 121 | for (;;) { | ||
2215 | 122 | maj_stat = gss_display_status(&min_stat, code, | ||
2216 | 123 | type, mech, &msg_ctx, &msg); | ||
2217 | 124 | if (maj_stat != GSS_S_COMPLETE) { | ||
2218 | 125 | printerr(0, "ERROR: in call to " | ||
2219 | 126 | "gss_display_status called from %s\n", m); | ||
2220 | 127 | break; | ||
2221 | 128 | } else { | ||
2222 | 129 | printerr(0, "ERROR: GSS-API: (%s) error in %s(): %s\n", | ||
2223 | 130 | typestr, m, (char *)msg.value); | ||
2224 | 131 | } | ||
2225 | 132 | |||
2226 | 133 | if (msg.length != 0) | ||
2227 | 134 | (void) gss_release_buffer(&min_stat, &msg); | ||
2228 | 135 | |||
2229 | 136 | if (msg_ctx == 0) | ||
2230 | 137 | break; | ||
2231 | 138 | } | ||
2232 | 139 | } | ||
2233 | 140 | #endif | ||
2234 | 141 | static char * | ||
2235 | 142 | gss_display_error(OM_uint32 status) | ||
2236 | 143 | { | ||
2237 | 144 | char *error = NULL; | ||
2238 | 145 | |||
2239 | 146 | switch(status) { | ||
2240 | 147 | case GSS_S_COMPLETE: | ||
2241 | 148 | error = "GSS_S_COMPLETE"; | ||
2242 | 149 | break; | ||
2243 | 150 | case GSS_S_CALL_INACCESSIBLE_READ: | ||
2244 | 151 | error = "GSS_S_CALL_INACCESSIBLE_READ"; | ||
2245 | 152 | break; | ||
2246 | 153 | case GSS_S_CALL_INACCESSIBLE_WRITE: | ||
2247 | 154 | error = "GSS_S_CALL_INACCESSIBLE_WRITE"; | ||
2248 | 155 | break; | ||
2249 | 156 | case GSS_S_CALL_BAD_STRUCTURE: | ||
2250 | 157 | error = "GSS_S_CALL_BAD_STRUCTURE"; | ||
2251 | 158 | break; | ||
2252 | 159 | case GSS_S_BAD_MECH: | ||
2253 | 160 | error = "GSS_S_BAD_MECH"; | ||
2254 | 161 | break; | ||
2255 | 162 | case GSS_S_BAD_NAME: | ||
2256 | 163 | error = "GSS_S_BAD_NAME"; | ||
2257 | 164 | break; | ||
2258 | 165 | case GSS_S_BAD_NAMETYPE: | ||
2259 | 166 | error = "GSS_S_BAD_NAMETYPE"; | ||
2260 | 167 | break; | ||
2261 | 168 | case GSS_S_BAD_BINDINGS: | ||
2262 | 169 | error = "GSS_S_BAD_BINDINGS"; | ||
2263 | 170 | break; | ||
2264 | 171 | case GSS_S_BAD_STATUS: | ||
2265 | 172 | error = "GSS_S_BAD_STATUS"; | ||
2266 | 173 | break; | ||
2267 | 174 | case GSS_S_BAD_SIG: | ||
2268 | 175 | error = "GSS_S_BAD_SIG"; | ||
2269 | 176 | break; | ||
2270 | 177 | case GSS_S_NO_CRED: | ||
2271 | 178 | error = "GSS_S_NO_CRED"; | ||
2272 | 179 | break; | ||
2273 | 180 | case GSS_S_NO_CONTEXT: | ||
2274 | 181 | error = "GSS_S_NO_CONTEXT"; | ||
2275 | 182 | break; | ||
2276 | 183 | case GSS_S_DEFECTIVE_TOKEN: | ||
2277 | 184 | error = "GSS_S_DEFECTIVE_TOKEN"; | ||
2278 | 185 | break; | ||
2279 | 186 | case GSS_S_DEFECTIVE_CREDENTIAL: | ||
2280 | 187 | error = "GSS_S_DEFECTIVE_CREDENTIAL"; | ||
2281 | 188 | break; | ||
2282 | 189 | case GSS_S_CREDENTIALS_EXPIRED: | ||
2283 | 190 | error = "GSS_S_CREDENTIALS_EXPIRED"; | ||
2284 | 191 | break; | ||
2285 | 192 | case GSS_S_CONTEXT_EXPIRED: | ||
2286 | 193 | error = "GSS_S_CONTEXT_EXPIRED"; | ||
2287 | 194 | break; | ||
2288 | 195 | case GSS_S_FAILURE: | ||
2289 | 196 | error = "GSS_S_FAILURE"; | ||
2290 | 197 | break; | ||
2291 | 198 | case GSS_S_BAD_QOP: | ||
2292 | 199 | error = "GSS_S_BAD_QOP"; | ||
2293 | 200 | break; | ||
2294 | 201 | case GSS_S_UNAUTHORIZED: | ||
2295 | 202 | error = "GSS_S_UNAUTHORIZED"; | ||
2296 | 203 | break; | ||
2297 | 204 | case GSS_S_UNAVAILABLE: | ||
2298 | 205 | error = "GSS_S_UNAVAILABLE"; | ||
2299 | 206 | break; | ||
2300 | 207 | case GSS_S_DUPLICATE_ELEMENT: | ||
2301 | 208 | error = "GSS_S_DUPLICATE_ELEMENT"; | ||
2302 | 209 | break; | ||
2303 | 210 | case GSS_S_NAME_NOT_MN: | ||
2304 | 211 | error = "GSS_S_NAME_NOT_MN"; | ||
2305 | 212 | break; | ||
2306 | 213 | default: | ||
2307 | 214 | error = "Not defined"; | ||
2308 | 215 | } | ||
2309 | 216 | return error; | ||
2310 | 217 | } | ||
2311 | 218 | |||
2312 | 219 | static void | ||
2313 | 220 | display_status_2(char *m, u_int32_t major, u_int32_t minor, const gss_OID mech) | ||
2314 | 221 | { | ||
2315 | 222 | u_int32_t maj_stat1, min_stat1; | ||
2316 | 223 | u_int32_t maj_stat2, min_stat2; | ||
2317 | 224 | gss_buffer_desc maj_gss_buf = GSS_C_EMPTY_BUFFER; | ||
2318 | 225 | gss_buffer_desc min_gss_buf = GSS_C_EMPTY_BUFFER; | ||
2319 | 226 | char maj_buf[30], min_buf[30]; | ||
2320 | 227 | char *maj, *min; | ||
2321 | 228 | u_int32_t msg_ctx = 0; | ||
2322 | 229 | int msg_verbosity = 0; | ||
2323 | 230 | |||
2324 | 231 | /* Get major status message */ | ||
2325 | 232 | maj_stat1 = gss_display_status(&min_stat1, major, | ||
2326 | 233 | GSS_C_GSS_CODE, mech, &msg_ctx, &maj_gss_buf); | ||
2327 | 234 | |||
2328 | 235 | if (maj_stat1 != GSS_S_COMPLETE) { | ||
2329 | 236 | snprintf(maj_buf, sizeof(maj_buf), "(0x%08x)", major); | ||
2330 | 237 | maj = &maj_buf[0]; | ||
2331 | 238 | } else { | ||
2332 | 239 | maj = maj_gss_buf.value; | ||
2333 | 240 | } | ||
2334 | 241 | |||
2335 | 242 | /* Get minor status message */ | ||
2336 | 243 | maj_stat2 = gss_display_status(&min_stat2, minor, | ||
2337 | 244 | GSS_C_MECH_CODE, mech, &msg_ctx, &min_gss_buf); | ||
2338 | 245 | |||
2339 | 246 | if (maj_stat2 != GSS_S_COMPLETE) { | ||
2340 | 247 | snprintf(min_buf, sizeof(min_buf), "(0x%08x)", minor); | ||
2341 | 248 | min = &min_buf[0]; | ||
2342 | 249 | } else { | ||
2343 | 250 | min = min_gss_buf.value; | ||
2344 | 251 | } | ||
2345 | 252 | |||
2346 | 253 | if (major == GSS_S_CREDENTIALS_EXPIRED) | ||
2347 | 254 | msg_verbosity = 1; | ||
2348 | 255 | |||
2349 | 256 | printerr(msg_verbosity, "ERROR: GSS-API: error in %s(): %s (%s) - %s\n", | ||
2350 | 257 | m, gss_display_error(major), maj, min); | ||
2351 | 258 | |||
2352 | 259 | if (maj_gss_buf.length != 0) | ||
2353 | 260 | (void) gss_release_buffer(&min_stat1, &maj_gss_buf); | ||
2354 | 261 | if (min_gss_buf.length != 0) | ||
2355 | 262 | (void) gss_release_buffer(&min_stat2, &min_gss_buf); | ||
2356 | 263 | } | ||
2357 | 264 | |||
2358 | 265 | void | ||
2359 | 266 | pgsserr(char *msg, u_int32_t maj_stat, u_int32_t min_stat, const gss_OID mech) | ||
2360 | 267 | { | ||
2361 | 268 | display_status_2(msg, maj_stat, min_stat, mech); | ||
2362 | 269 | } | ||
2363 | 270 | |||
2364 | 271 | int | ||
2365 | 272 | gssd_acquire_cred(char *server_name, const gss_OID oid) | ||
2366 | 273 | { | ||
2367 | 274 | gss_buffer_desc name; | ||
2368 | 275 | gss_name_t target_name; | ||
2369 | 276 | u_int32_t maj_stat, min_stat; | ||
2370 | 277 | u_int32_t ignore_maj_stat, ignore_min_stat; | ||
2371 | 278 | gss_buffer_desc pbuf; | ||
2372 | 279 | |||
2373 | 280 | /* If server_name is NULL, get cred for GSS_C_NO_NAME */ | ||
2374 | 281 | if (server_name == NULL) { | ||
2375 | 282 | target_name = GSS_C_NO_NAME; | ||
2376 | 283 | } else { | ||
2377 | 284 | name.value = (void *)server_name; | ||
2378 | 285 | name.length = strlen(server_name); | ||
2379 | 286 | |||
2380 | 287 | maj_stat = gss_import_name(&min_stat, &name, | ||
2381 | 288 | oid, | ||
2382 | 289 | &target_name); | ||
2383 | 290 | |||
2384 | 291 | if (maj_stat != GSS_S_COMPLETE) { | ||
2385 | 292 | pgsserr("gss_import_name", maj_stat, min_stat, g_mechOid); | ||
2386 | 293 | return (FALSE); | ||
2387 | 294 | } | ||
2388 | 295 | } | ||
2389 | 296 | |||
2390 | 297 | maj_stat = gss_acquire_cred(&min_stat, target_name, GSS_C_INDEFINITE, | ||
2391 | 298 | GSS_C_NO_OID_SET, GSS_C_ACCEPT, | ||
2392 | 299 | &gssd_creds, NULL, NULL); | ||
2393 | 300 | |||
2394 | 301 | if (maj_stat != GSS_S_COMPLETE) { | ||
2395 | 302 | pgsserr("gss_acquire_cred", maj_stat, min_stat, g_mechOid); | ||
2396 | 303 | ignore_maj_stat = gss_display_name(&ignore_min_stat, | ||
2397 | 304 | target_name, &pbuf, NULL); | ||
2398 | 305 | if (ignore_maj_stat == GSS_S_COMPLETE) { | ||
2399 | 306 | printerr(1, "Unable to obtain credentials for '%.*s'\n", | ||
2400 | 307 | pbuf.length, pbuf.value); | ||
2401 | 308 | ignore_maj_stat = gss_release_buffer(&ignore_min_stat, | ||
2402 | 309 | &pbuf); | ||
2403 | 310 | } | ||
2404 | 311 | } | ||
2405 | 312 | |||
2406 | 313 | ignore_maj_stat = gss_release_name(&ignore_min_stat, &target_name); | ||
2407 | 314 | |||
2408 | 315 | return (maj_stat == GSS_S_COMPLETE); | ||
2409 | 316 | } | ||
2410 | 317 | |||
2411 | 318 | int gssd_check_mechs(void) | ||
2412 | 319 | { | ||
2413 | 320 | u_int32_t maj_stat, min_stat; | ||
2414 | 321 | gss_OID_set supported_mechs = GSS_C_NO_OID_SET; | ||
2415 | 322 | int retval = -1; | ||
2416 | 323 | |||
2417 | 324 | maj_stat = gss_indicate_mechs(&min_stat, &supported_mechs); | ||
2418 | 325 | if (maj_stat != GSS_S_COMPLETE) { | ||
2419 | 326 | printerr(0, "Unable to obtain list of supported mechanisms. " | ||
2420 | 327 | "Check that gss library is properly configured.\n"); | ||
2421 | 328 | goto out; | ||
2422 | 329 | } | ||
2423 | 330 | if (supported_mechs == GSS_C_NO_OID_SET || | ||
2424 | 331 | supported_mechs->count == 0) { | ||
2425 | 332 | printerr(0, "Unable to obtain list of supported mechanisms. " | ||
2426 | 333 | "Check that gss library is properly configured.\n"); | ||
2427 | 334 | goto out; | ||
2428 | 335 | } | ||
2429 | 336 | maj_stat = gss_release_oid_set(&min_stat, &supported_mechs); | ||
2430 | 337 | retval = 0; | ||
2431 | 338 | out: | ||
2432 | 339 | return retval; | ||
2433 | 340 | } | ||
2434 | 341 | |||
2435 | 342 | 0 | ||
2436 | === removed file '.pc/11-532048-reduce-verbosity.patch/utils/gssd/gssd_proc.c' | |||
2437 | --- .pc/11-532048-reduce-verbosity.patch/utils/gssd/gssd_proc.c 2012-05-25 20:41:58 +0000 | |||
2438 | +++ .pc/11-532048-reduce-verbosity.patch/utils/gssd/gssd_proc.c 1970-01-01 00:00:00 +0000 | |||
2439 | @@ -1,1241 +0,0 @@ | |||
2440 | 1 | /* | ||
2441 | 2 | gssd_proc.c | ||
2442 | 3 | |||
2443 | 4 | Copyright (c) 2000-2004 The Regents of the University of Michigan. | ||
2444 | 5 | All rights reserved. | ||
2445 | 6 | |||
2446 | 7 | Copyright (c) 2000 Dug Song <dugsong@UMICH.EDU>. | ||
2447 | 8 | Copyright (c) 2001 Andy Adamson <andros@UMICH.EDU>. | ||
2448 | 9 | Copyright (c) 2002 Marius Aamodt Eriksen <marius@UMICH.EDU>. | ||
2449 | 10 | Copyright (c) 2002 Bruce Fields <bfields@UMICH.EDU> | ||
2450 | 11 | Copyright (c) 2004 Kevin Coffman <kwc@umich.edu> | ||
2451 | 12 | All rights reserved, all wrongs reversed. | ||
2452 | 13 | |||
2453 | 14 | Redistribution and use in source and binary forms, with or without | ||
2454 | 15 | modification, are permitted provided that the following conditions | ||
2455 | 16 | are met: | ||
2456 | 17 | |||
2457 | 18 | 1. Redistributions of source code must retain the above copyright | ||
2458 | 19 | notice, this list of conditions and the following disclaimer. | ||
2459 | 20 | 2. Redistributions in binary form must reproduce the above copyright | ||
2460 | 21 | notice, this list of conditions and the following disclaimer in the | ||
2461 | 22 | documentation and/or other materials provided with the distribution. | ||
2462 | 23 | 3. Neither the name of the University nor the names of its | ||
2463 | 24 | contributors may be used to endorse or promote products derived | ||
2464 | 25 | from this software without specific prior written permission. | ||
2465 | 26 | |||
2466 | 27 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
2467 | 28 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
2468 | 29 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
2469 | 30 | DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
2470 | 31 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
2471 | 32 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
2472 | 33 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | ||
2473 | 34 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
2474 | 35 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
2475 | 36 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
2476 | 37 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
2477 | 38 | |||
2478 | 39 | */ | ||
2479 | 40 | |||
2480 | 41 | #ifdef HAVE_CONFIG_H | ||
2481 | 42 | #include <config.h> | ||
2482 | 43 | #endif /* HAVE_CONFIG_H */ | ||
2483 | 44 | |||
2484 | 45 | #ifndef _GNU_SOURCE | ||
2485 | 46 | #define _GNU_SOURCE | ||
2486 | 47 | #endif | ||
2487 | 48 | |||
2488 | 49 | #include <sys/param.h> | ||
2489 | 50 | #include <rpc/rpc.h> | ||
2490 | 51 | #include <sys/stat.h> | ||
2491 | 52 | #include <sys/socket.h> | ||
2492 | 53 | #include <arpa/inet.h> | ||
2493 | 54 | #include <sys/fsuid.h> | ||
2494 | 55 | |||
2495 | 56 | #include <stdio.h> | ||
2496 | 57 | #include <stdlib.h> | ||
2497 | 58 | #include <pwd.h> | ||
2498 | 59 | #include <grp.h> | ||
2499 | 60 | #include <string.h> | ||
2500 | 61 | #include <dirent.h> | ||
2501 | 62 | #include <poll.h> | ||
2502 | 63 | #include <fcntl.h> | ||
2503 | 64 | #include <signal.h> | ||
2504 | 65 | #include <unistd.h> | ||
2505 | 66 | #include <errno.h> | ||
2506 | 67 | #include <gssapi/gssapi.h> | ||
2507 | 68 | #include <netdb.h> | ||
2508 | 69 | |||
2509 | 70 | #include "gssd.h" | ||
2510 | 71 | #include "err_util.h" | ||
2511 | 72 | #include "gss_util.h" | ||
2512 | 73 | #include "krb5_util.h" | ||
2513 | 74 | #include "context.h" | ||
2514 | 75 | #include "nfsrpc.h" | ||
2515 | 76 | #include "nfslib.h" | ||
2516 | 77 | |||
2517 | 78 | /* | ||
2518 | 79 | * pollarray: | ||
2519 | 80 | * array of struct pollfd suitable to pass to poll. initialized to | ||
2520 | 81 | * zero - a zero struct is ignored by poll() because the events mask is 0. | ||
2521 | 82 | * | ||
2522 | 83 | * clnt_list: | ||
2523 | 84 | * linked list of struct clnt_info which associates a clntXXX directory | ||
2524 | 85 | * with an index into pollarray[], and other basic data about that client. | ||
2525 | 86 | * | ||
2526 | 87 | * Directory structure: created by the kernel | ||
2527 | 88 | * {rpc_pipefs}/{dir}/clntXX : one per rpc_clnt struct in the kernel | ||
2528 | 89 | * {rpc_pipefs}/{dir}/clntXX/krb5 : read uid for which kernel wants | ||
2529 | 90 | * a context, write the resulting context | ||
2530 | 91 | * {rpc_pipefs}/{dir}/clntXX/info : stores info such as server name | ||
2531 | 92 | * {rpc_pipefs}/{dir}/clntXX/gssd : pipe for all gss mechanisms using | ||
2532 | 93 | * a text-based string of parameters | ||
2533 | 94 | * | ||
2534 | 95 | * Algorithm: | ||
2535 | 96 | * Poll all {rpc_pipefs}/{dir}/clntXX/YYYY files. When data is ready, | ||
2536 | 97 | * read and process; performs rpcsec_gss context initialization protocol to | ||
2537 | 98 | * get a cred for that user. Writes result to corresponding krb5 file | ||
2538 | 99 | * in a form the kernel code will understand. | ||
2539 | 100 | * In addition, we make sure we are notified whenever anything is | ||
2540 | 101 | * created or destroyed in {rpc_pipefs} or in any of the clntXX directories, | ||
2541 | 102 | * and rescan the whole {rpc_pipefs} when this happens. | ||
2542 | 103 | */ | ||
2543 | 104 | |||
2544 | 105 | struct pollfd * pollarray; | ||
2545 | 106 | |||
2546 | 107 | int pollsize; /* the size of pollaray (in pollfd's) */ | ||
2547 | 108 | |||
2548 | 109 | /* | ||
2549 | 110 | * convert a presentation address string to a sockaddr_storage struct. Returns | ||
2550 | 111 | * true on success or false on failure. | ||
2551 | 112 | * | ||
2552 | 113 | * Note that we do not populate the sin6_scope_id field here for IPv6 addrs. | ||
2553 | 114 | * gssd nececessarily relies on hostname resolution and DNS AAAA records | ||
2554 | 115 | * do not generally contain scope-id's. This means that GSSAPI auth really | ||
2555 | 116 | * can't work with IPv6 link-local addresses. | ||
2556 | 117 | * | ||
2557 | 118 | * We *could* consider changing this if we did something like adopt the | ||
2558 | 119 | * Microsoft "standard" of using the ipv6-literal.net domainname, but it's | ||
2559 | 120 | * not really feasible at present. | ||
2560 | 121 | */ | ||
2561 | 122 | static int | ||
2562 | 123 | addrstr_to_sockaddr(struct sockaddr *sa, const char *node, const char *port) | ||
2563 | 124 | { | ||
2564 | 125 | int rc; | ||
2565 | 126 | struct addrinfo *res; | ||
2566 | 127 | struct addrinfo hints = { .ai_flags = AI_NUMERICHOST | AI_NUMERICSERV }; | ||
2567 | 128 | |||
2568 | 129 | #ifndef IPV6_SUPPORTED | ||
2569 | 130 | hints.ai_family = AF_INET; | ||
2570 | 131 | #endif /* IPV6_SUPPORTED */ | ||
2571 | 132 | |||
2572 | 133 | rc = getaddrinfo(node, port, &hints, &res); | ||
2573 | 134 | if (rc) { | ||
2574 | 135 | printerr(0, "ERROR: unable to convert %s|%s to sockaddr: %s\n", | ||
2575 | 136 | node, port, rc == EAI_SYSTEM ? strerror(errno) : | ||
2576 | 137 | gai_strerror(rc)); | ||
2577 | 138 | return 0; | ||
2578 | 139 | } | ||
2579 | 140 | |||
2580 | 141 | #ifdef IPV6_SUPPORTED | ||
2581 | 142 | /* | ||
2582 | 143 | * getnameinfo ignores the scopeid. If the address turns out to have | ||
2583 | 144 | * a non-zero scopeid, we can't use it -- the resolved host might be | ||
2584 | 145 | * completely different from the one intended. | ||
2585 | 146 | */ | ||
2586 | 147 | if (res->ai_addr->sa_family == AF_INET6) { | ||
2587 | 148 | struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)res->ai_addr; | ||
2588 | 149 | if (sin6->sin6_scope_id) { | ||
2589 | 150 | printerr(0, "ERROR: address %s has non-zero " | ||
2590 | 151 | "sin6_scope_id!\n", node); | ||
2591 | 152 | freeaddrinfo(res); | ||
2592 | 153 | return 0; | ||
2593 | 154 | } | ||
2594 | 155 | } | ||
2595 | 156 | #endif /* IPV6_SUPPORTED */ | ||
2596 | 157 | |||
2597 | 158 | memcpy(sa, res->ai_addr, res->ai_addrlen); | ||
2598 | 159 | freeaddrinfo(res); | ||
2599 | 160 | return 1; | ||
2600 | 161 | } | ||
2601 | 162 | |||
2602 | 163 | /* | ||
2603 | 164 | * convert a sockaddr to a hostname | ||
2604 | 165 | */ | ||
2605 | 166 | static char * | ||
2606 | 167 | sockaddr_to_hostname(const struct sockaddr *sa, const char *addr) | ||
2607 | 168 | { | ||
2608 | 169 | socklen_t addrlen; | ||
2609 | 170 | int err; | ||
2610 | 171 | char *hostname; | ||
2611 | 172 | char hbuf[NI_MAXHOST]; | ||
2612 | 173 | |||
2613 | 174 | switch (sa->sa_family) { | ||
2614 | 175 | case AF_INET: | ||
2615 | 176 | addrlen = sizeof(struct sockaddr_in); | ||
2616 | 177 | break; | ||
2617 | 178 | #ifdef IPV6_SUPPORTED | ||
2618 | 179 | case AF_INET6: | ||
2619 | 180 | addrlen = sizeof(struct sockaddr_in6); | ||
2620 | 181 | break; | ||
2621 | 182 | #endif /* IPV6_SUPPORTED */ | ||
2622 | 183 | default: | ||
2623 | 184 | printerr(0, "ERROR: unrecognized addr family %d\n", | ||
2624 | 185 | sa->sa_family); | ||
2625 | 186 | return NULL; | ||
2626 | 187 | } | ||
2627 | 188 | |||
2628 | 189 | err = getnameinfo(sa, addrlen, hbuf, sizeof(hbuf), NULL, 0, | ||
2629 | 190 | NI_NAMEREQD); | ||
2630 | 191 | if (err) { | ||
2631 | 192 | printerr(0, "ERROR: unable to resolve %s to hostname: %s\n", | ||
2632 | 193 | addr, err == EAI_SYSTEM ? strerror(err) : | ||
2633 | 194 | gai_strerror(err)); | ||
2634 | 195 | return NULL; | ||
2635 | 196 | } | ||
2636 | 197 | |||
2637 | 198 | hostname = strdup(hbuf); | ||
2638 | 199 | |||
2639 | 200 | return hostname; | ||
2640 | 201 | } | ||
2641 | 202 | |||
2642 | 203 | /* XXX buffer problems: */ | ||
2643 | 204 | static int | ||
2644 | 205 | read_service_info(char *info_file_name, char **servicename, char **servername, | ||
2645 | 206 | int *prog, int *vers, char **protocol, | ||
2646 | 207 | struct sockaddr *addr) { | ||
2647 | 208 | #define INFOBUFLEN 256 | ||
2648 | 209 | char buf[INFOBUFLEN + 1]; | ||
2649 | 210 | static char dummy[128]; | ||
2650 | 211 | int nbytes; | ||
2651 | 212 | static char service[128]; | ||
2652 | 213 | static char address[128]; | ||
2653 | 214 | char program[16]; | ||
2654 | 215 | char version[16]; | ||
2655 | 216 | char protoname[16]; | ||
2656 | 217 | char port[128]; | ||
2657 | 218 | char *p; | ||
2658 | 219 | int fd = -1; | ||
2659 | 220 | int numfields; | ||
2660 | 221 | |||
2661 | 222 | *servicename = *servername = *protocol = NULL; | ||
2662 | 223 | |||
2663 | 224 | if ((fd = open(info_file_name, O_RDONLY)) == -1) { | ||
2664 | 225 | printerr(0, "ERROR: can't open %s: %s\n", info_file_name, | ||
2665 | 226 | strerror(errno)); | ||
2666 | 227 | goto fail; | ||
2667 | 228 | } | ||
2668 | 229 | if ((nbytes = read(fd, buf, INFOBUFLEN)) == -1) | ||
2669 | 230 | goto fail; | ||
2670 | 231 | close(fd); | ||
2671 | 232 | buf[nbytes] = '\0'; | ||
2672 | 233 | |||
2673 | 234 | numfields = sscanf(buf,"RPC server: %127s\n" | ||
2674 | 235 | "service: %127s %15s version %15s\n" | ||
2675 | 236 | "address: %127s\n" | ||
2676 | 237 | "protocol: %15s\n", | ||
2677 | 238 | dummy, | ||
2678 | 239 | service, program, version, | ||
2679 | 240 | address, | ||
2680 | 241 | protoname); | ||
2681 | 242 | |||
2682 | 243 | if (numfields == 5) { | ||
2683 | 244 | strcpy(protoname, "tcp"); | ||
2684 | 245 | } else if (numfields != 6) { | ||
2685 | 246 | goto fail; | ||
2686 | 247 | } | ||
2687 | 248 | |||
2688 | 249 | port[0] = '\0'; | ||
2689 | 250 | if ((p = strstr(buf, "port")) != NULL) | ||
2690 | 251 | sscanf(p, "port: %127s\n", port); | ||
2691 | 252 | |||
2692 | 253 | /* check service, program, and version */ | ||
2693 | 254 | if (memcmp(service, "nfs", 3) != 0) | ||
2694 | 255 | return -1; | ||
2695 | 256 | *prog = atoi(program + 1); /* skip open paren */ | ||
2696 | 257 | *vers = atoi(version); | ||
2697 | 258 | |||
2698 | 259 | if (strlen(service) == 3 ) { | ||
2699 | 260 | if ((*prog != 100003) || ((*vers != 2) && (*vers != 3) && | ||
2700 | 261 | (*vers != 4))) | ||
2701 | 262 | goto fail; | ||
2702 | 263 | } else if (memcmp(service, "nfs4_cb", 7) == 0) { | ||
2703 | 264 | if (*vers != 1) | ||
2704 | 265 | goto fail; | ||
2705 | 266 | } | ||
2706 | 267 | |||
2707 | 268 | if (!addrstr_to_sockaddr(addr, address, port)) | ||
2708 | 269 | goto fail; | ||
2709 | 270 | |||
2710 | 271 | *servername = sockaddr_to_hostname(addr, address); | ||
2711 | 272 | if (*servername == NULL) | ||
2712 | 273 | goto fail; | ||
2713 | 274 | |||
2714 | 275 | nbytes = snprintf(buf, INFOBUFLEN, "%s@%s", service, *servername); | ||
2715 | 276 | if (nbytes > INFOBUFLEN) | ||
2716 | 277 | goto fail; | ||
2717 | 278 | |||
2718 | 279 | if (!(*servicename = calloc(strlen(buf) + 1, 1))) | ||
2719 | 280 | goto fail; | ||
2720 | 281 | memcpy(*servicename, buf, strlen(buf)); | ||
2721 | 282 | |||
2722 | 283 | if (!(*protocol = strdup(protoname))) | ||
2723 | 284 | goto fail; | ||
2724 | 285 | return 0; | ||
2725 | 286 | fail: | ||
2726 | 287 | printerr(0, "ERROR: failed to read service info\n"); | ||
2727 | 288 | if (fd != -1) close(fd); | ||
2728 | 289 | free(*servername); | ||
2729 | 290 | free(*servicename); | ||
2730 | 291 | free(*protocol); | ||
2731 | 292 | *servicename = *servername = *protocol = NULL; | ||
2732 | 293 | return -1; | ||
2733 | 294 | } | ||
2734 | 295 | |||
2735 | 296 | static void | ||
2736 | 297 | destroy_client(struct clnt_info *clp) | ||
2737 | 298 | { | ||
2738 | 299 | if (clp->krb5_poll_index != -1) | ||
2739 | 300 | memset(&pollarray[clp->krb5_poll_index], 0, | ||
2740 | 301 | sizeof(struct pollfd)); | ||
2741 | 302 | if (clp->gssd_poll_index != -1) | ||
2742 | 303 | memset(&pollarray[clp->gssd_poll_index], 0, | ||
2743 | 304 | sizeof(struct pollfd)); | ||
2744 | 305 | if (clp->dir_fd != -1) close(clp->dir_fd); | ||
2745 | 306 | if (clp->krb5_fd != -1) close(clp->krb5_fd); | ||
2746 | 307 | if (clp->gssd_fd != -1) close(clp->gssd_fd); | ||
2747 | 308 | free(clp->dirname); | ||
2748 | 309 | free(clp->servicename); | ||
2749 | 310 | free(clp->servername); | ||
2750 | 311 | free(clp->protocol); | ||
2751 | 312 | free(clp); | ||
2752 | 313 | } | ||
2753 | 314 | |||
2754 | 315 | static struct clnt_info * | ||
2755 | 316 | insert_new_clnt(void) | ||
2756 | 317 | { | ||
2757 | 318 | struct clnt_info *clp = NULL; | ||
2758 | 319 | |||
2759 | 320 | if (!(clp = (struct clnt_info *)calloc(1,sizeof(struct clnt_info)))) { | ||
2760 | 321 | printerr(0, "ERROR: can't malloc clnt_info: %s\n", | ||
2761 | 322 | strerror(errno)); | ||
2762 | 323 | goto out; | ||
2763 | 324 | } | ||
2764 | 325 | clp->krb5_poll_index = -1; | ||
2765 | 326 | clp->gssd_poll_index = -1; | ||
2766 | 327 | clp->krb5_fd = -1; | ||
2767 | 328 | clp->gssd_fd = -1; | ||
2768 | 329 | clp->dir_fd = -1; | ||
2769 | 330 | |||
2770 | 331 | TAILQ_INSERT_HEAD(&clnt_list, clp, list); | ||
2771 | 332 | out: | ||
2772 | 333 | return clp; | ||
2773 | 334 | } | ||
2774 | 335 | |||
2775 | 336 | static int | ||
2776 | 337 | process_clnt_dir_files(struct clnt_info * clp) | ||
2777 | 338 | { | ||
2778 | 339 | char name[PATH_MAX]; | ||
2779 | 340 | char gname[PATH_MAX]; | ||
2780 | 341 | char info_file_name[PATH_MAX]; | ||
2781 | 342 | |||
2782 | 343 | if (clp->gssd_fd == -1) { | ||
2783 | 344 | snprintf(gname, sizeof(gname), "%s/gssd", clp->dirname); | ||
2784 | 345 | clp->gssd_fd = open(gname, O_RDWR); | ||
2785 | 346 | } | ||
2786 | 347 | if (clp->gssd_fd == -1) { | ||
2787 | 348 | if (clp->krb5_fd == -1) { | ||
2788 | 349 | snprintf(name, sizeof(name), "%s/krb5", clp->dirname); | ||
2789 | 350 | clp->krb5_fd = open(name, O_RDWR); | ||
2790 | 351 | } | ||
2791 | 352 | |||
2792 | 353 | /* If we opened a gss-specific pipe, let's try opening | ||
2793 | 354 | * the new upcall pipe again. If we succeed, close | ||
2794 | 355 | * gss-specific pipe(s). | ||
2795 | 356 | */ | ||
2796 | 357 | if (clp->krb5_fd != -1) { | ||
2797 | 358 | clp->gssd_fd = open(gname, O_RDWR); | ||
2798 | 359 | if (clp->gssd_fd != -1) { | ||
2799 | 360 | if (clp->krb5_fd != -1) | ||
2800 | 361 | close(clp->krb5_fd); | ||
2801 | 362 | clp->krb5_fd = -1; | ||
2802 | 363 | } | ||
2803 | 364 | } | ||
2804 | 365 | } | ||
2805 | 366 | |||
2806 | 367 | if ((clp->krb5_fd == -1) && (clp->gssd_fd == -1)) | ||
2807 | 368 | return -1; | ||
2808 | 369 | snprintf(info_file_name, sizeof(info_file_name), "%s/info", | ||
2809 | 370 | clp->dirname); | ||
2810 | 371 | if ((clp->servicename == NULL) && | ||
2811 | 372 | read_service_info(info_file_name, &clp->servicename, | ||
2812 | 373 | &clp->servername, &clp->prog, &clp->vers, | ||
2813 | 374 | &clp->protocol, (struct sockaddr *) &clp->addr)) | ||
2814 | 375 | return -1; | ||
2815 | 376 | return 0; | ||
2816 | 377 | } | ||
2817 | 378 | |||
2818 | 379 | static int | ||
2819 | 380 | get_poll_index(int *ind) | ||
2820 | 381 | { | ||
2821 | 382 | int i; | ||
2822 | 383 | |||
2823 | 384 | *ind = -1; | ||
2824 | 385 | for (i=0; i<FD_ALLOC_BLOCK; i++) { | ||
2825 | 386 | if (pollarray[i].events == 0) { | ||
2826 | 387 | *ind = i; | ||
2827 | 388 | break; | ||
2828 | 389 | } | ||
2829 | 390 | } | ||
2830 | 391 | if (*ind == -1) { | ||
2831 | 392 | printerr(0, "ERROR: No pollarray slots open\n"); | ||
2832 | 393 | return -1; | ||
2833 | 394 | } | ||
2834 | 395 | return 0; | ||
2835 | 396 | } | ||
2836 | 397 | |||
2837 | 398 | |||
2838 | 399 | static int | ||
2839 | 400 | insert_clnt_poll(struct clnt_info *clp) | ||
2840 | 401 | { | ||
2841 | 402 | if ((clp->gssd_fd != -1) && (clp->gssd_poll_index == -1)) { | ||
2842 | 403 | if (get_poll_index(&clp->gssd_poll_index)) { | ||
2843 | 404 | printerr(0, "ERROR: Too many gssd clients\n"); | ||
2844 | 405 | return -1; | ||
2845 | 406 | } | ||
2846 | 407 | pollarray[clp->gssd_poll_index].fd = clp->gssd_fd; | ||
2847 | 408 | pollarray[clp->gssd_poll_index].events |= POLLIN; | ||
2848 | 409 | } | ||
2849 | 410 | |||
2850 | 411 | if ((clp->krb5_fd != -1) && (clp->krb5_poll_index == -1)) { | ||
2851 | 412 | if (get_poll_index(&clp->krb5_poll_index)) { | ||
2852 | 413 | printerr(0, "ERROR: Too many krb5 clients\n"); | ||
2853 | 414 | return -1; | ||
2854 | 415 | } | ||
2855 | 416 | pollarray[clp->krb5_poll_index].fd = clp->krb5_fd; | ||
2856 | 417 | pollarray[clp->krb5_poll_index].events |= POLLIN; | ||
2857 | 418 | } | ||
2858 | 419 | |||
2859 | 420 | return 0; | ||
2860 | 421 | } | ||
2861 | 422 | |||
2862 | 423 | static void | ||
2863 | 424 | process_clnt_dir(char *dir, char *pdir) | ||
2864 | 425 | { | ||
2865 | 426 | struct clnt_info * clp; | ||
2866 | 427 | |||
2867 | 428 | if (!(clp = insert_new_clnt())) | ||
2868 | 429 | goto fail_destroy_client; | ||
2869 | 430 | |||
2870 | 431 | /* An extra for the '/', and an extra for the null */ | ||
2871 | 432 | if (!(clp->dirname = calloc(strlen(dir) + strlen(pdir) + 2, 1))) { | ||
2872 | 433 | goto fail_destroy_client; | ||
2873 | 434 | } | ||
2874 | 435 | sprintf(clp->dirname, "%s/%s", pdir, dir); | ||
2875 | 436 | if ((clp->dir_fd = open(clp->dirname, O_RDONLY)) == -1) { | ||
2876 | 437 | printerr(0, "ERROR: can't open %s: %s\n", | ||
2877 | 438 | clp->dirname, strerror(errno)); | ||
2878 | 439 | goto fail_destroy_client; | ||
2879 | 440 | } | ||
2880 | 441 | fcntl(clp->dir_fd, F_SETSIG, DNOTIFY_SIGNAL); | ||
2881 | 442 | fcntl(clp->dir_fd, F_NOTIFY, DN_CREATE | DN_DELETE | DN_MULTISHOT); | ||
2882 | 443 | |||
2883 | 444 | if (process_clnt_dir_files(clp)) | ||
2884 | 445 | goto fail_keep_client; | ||
2885 | 446 | |||
2886 | 447 | if (insert_clnt_poll(clp)) | ||
2887 | 448 | goto fail_destroy_client; | ||
2888 | 449 | |||
2889 | 450 | return; | ||
2890 | 451 | |||
2891 | 452 | fail_destroy_client: | ||
2892 | 453 | if (clp) { | ||
2893 | 454 | TAILQ_REMOVE(&clnt_list, clp, list); | ||
2894 | 455 | destroy_client(clp); | ||
2895 | 456 | } | ||
2896 | 457 | fail_keep_client: | ||
2897 | 458 | /* We couldn't find some subdirectories, but we keep the client | ||
2898 | 459 | * around in case we get a notification on the directory when the | ||
2899 | 460 | * subdirectories are created. */ | ||
2900 | 461 | return; | ||
2901 | 462 | } | ||
2902 | 463 | |||
2903 | 464 | void | ||
2904 | 465 | init_client_list(void) | ||
2905 | 466 | { | ||
2906 | 467 | TAILQ_INIT(&clnt_list); | ||
2907 | 468 | /* Eventually plan to grow/shrink poll array: */ | ||
2908 | 469 | pollsize = FD_ALLOC_BLOCK; | ||
2909 | 470 | pollarray = calloc(pollsize, sizeof(struct pollfd)); | ||
2910 | 471 | } | ||
2911 | 472 | |||
2912 | 473 | /* | ||
2913 | 474 | * This is run after a DNOTIFY signal, and should clear up any | ||
2914 | 475 | * directories that are no longer around, and re-scan any existing | ||
2915 | 476 | * directories, since the DNOTIFY could have been in there. | ||
2916 | 477 | */ | ||
2917 | 478 | static void | ||
2918 | 479 | update_old_clients(struct dirent **namelist, int size, char *pdir) | ||
2919 | 480 | { | ||
2920 | 481 | struct clnt_info *clp; | ||
2921 | 482 | void *saveprev; | ||
2922 | 483 | int i, stillhere; | ||
2923 | 484 | char fname[PATH_MAX]; | ||
2924 | 485 | |||
2925 | 486 | for (clp = clnt_list.tqh_first; clp != NULL; clp = clp->list.tqe_next) { | ||
2926 | 487 | /* only compare entries in the global list that are from the | ||
2927 | 488 | * same pipefs parent directory as "pdir" | ||
2928 | 489 | */ | ||
2929 | 490 | if (strncmp(clp->dirname, pdir, strlen(pdir)) != 0) continue; | ||
2930 | 491 | |||
2931 | 492 | stillhere = 0; | ||
2932 | 493 | for (i=0; i < size; i++) { | ||
2933 | 494 | snprintf(fname, sizeof(fname), "%s/%s", | ||
2934 | 495 | pdir, namelist[i]->d_name); | ||
2935 | 496 | if (strcmp(clp->dirname, fname) == 0) { | ||
2936 | 497 | stillhere = 1; | ||
2937 | 498 | break; | ||
2938 | 499 | } | ||
2939 | 500 | } | ||
2940 | 501 | if (!stillhere) { | ||
2941 | 502 | printerr(2, "destroying client %s\n", clp->dirname); | ||
2942 | 503 | saveprev = clp->list.tqe_prev; | ||
2943 | 504 | TAILQ_REMOVE(&clnt_list, clp, list); | ||
2944 | 505 | destroy_client(clp); | ||
2945 | 506 | clp = saveprev; | ||
2946 | 507 | } | ||
2947 | 508 | } | ||
2948 | 509 | for (clp = clnt_list.tqh_first; clp != NULL; clp = clp->list.tqe_next) { | ||
2949 | 510 | if (!process_clnt_dir_files(clp)) | ||
2950 | 511 | insert_clnt_poll(clp); | ||
2951 | 512 | } | ||
2952 | 513 | } | ||
2953 | 514 | |||
2954 | 515 | /* Search for a client by directory name, return 1 if found, 0 otherwise */ | ||
2955 | 516 | static int | ||
2956 | 517 | find_client(char *dirname, char *pdir) | ||
2957 | 518 | { | ||
2958 | 519 | struct clnt_info *clp; | ||
2959 | 520 | char fname[PATH_MAX]; | ||
2960 | 521 | |||
2961 | 522 | for (clp = clnt_list.tqh_first; clp != NULL; clp = clp->list.tqe_next) { | ||
2962 | 523 | snprintf(fname, sizeof(fname), "%s/%s", pdir, dirname); | ||
2963 | 524 | if (strcmp(clp->dirname, fname) == 0) | ||
2964 | 525 | return 1; | ||
2965 | 526 | } | ||
2966 | 527 | return 0; | ||
2967 | 528 | } | ||
2968 | 529 | |||
2969 | 530 | static int | ||
2970 | 531 | process_pipedir(char *pipe_name) | ||
2971 | 532 | { | ||
2972 | 533 | struct dirent **namelist; | ||
2973 | 534 | int i, j; | ||
2974 | 535 | |||
2975 | 536 | if (chdir(pipe_name) < 0) { | ||
2976 | 537 | printerr(0, "ERROR: can't chdir to %s: %s\n", | ||
2977 | 538 | pipe_name, strerror(errno)); | ||
2978 | 539 | return -1; | ||
2979 | 540 | } | ||
2980 | 541 | |||
2981 | 542 | j = scandir(pipe_name, &namelist, NULL, alphasort); | ||
2982 | 543 | if (j < 0) { | ||
2983 | 544 | printerr(0, "ERROR: can't scandir %s: %s\n", | ||
2984 | 545 | pipe_name, strerror(errno)); | ||
2985 | 546 | return -1; | ||
2986 | 547 | } | ||
2987 | 548 | |||
2988 | 549 | update_old_clients(namelist, j, pipe_name); | ||
2989 | 550 | for (i=0; i < j; i++) { | ||
2990 | 551 | if (i < FD_ALLOC_BLOCK | ||
2991 | 552 | && !strncmp(namelist[i]->d_name, "clnt", 4) | ||
2992 | 553 | && !find_client(namelist[i]->d_name, pipe_name)) | ||
2993 | 554 | process_clnt_dir(namelist[i]->d_name, pipe_name); | ||
2994 | 555 | free(namelist[i]); | ||
2995 | 556 | } | ||
2996 | 557 | |||
2997 | 558 | free(namelist); | ||
2998 | 559 | |||
2999 | 560 | return 0; | ||
3000 | 561 | } | ||
3001 | 562 | |||
3002 | 563 | /* Used to read (and re-read) list of clients, set up poll array. */ | ||
3003 | 564 | int | ||
3004 | 565 | update_client_list(void) | ||
3005 | 566 | { | ||
3006 | 567 | int retval = -1; | ||
3007 | 568 | struct topdirs_info *tdi; | ||
3008 | 569 | |||
3009 | 570 | TAILQ_FOREACH(tdi, &topdirs_list, list) { | ||
3010 | 571 | retval = process_pipedir(tdi->dirname); | ||
3011 | 572 | if (retval) | ||
3012 | 573 | printerr(1, "WARNING: error processing %s\n", | ||
3013 | 574 | tdi->dirname); | ||
3014 | 575 | |||
3015 | 576 | } | ||
3016 | 577 | return retval; | ||
3017 | 578 | } | ||
3018 | 579 | |||
3019 | 580 | /* Encryption types supported by the kernel rpcsec_gss code */ | ||
3020 | 581 | int num_krb5_enctypes = 0; | ||
3021 | 582 | krb5_enctype *krb5_enctypes = NULL; | ||
3022 | 583 | |||
3023 | 584 | /* | ||
3024 | 585 | * Parse the supported encryption type information | ||
3025 | 586 | */ | ||
3026 | 587 | static int | ||
3027 | 588 | parse_enctypes(char *enctypes) | ||
3028 | 589 | { | ||
3029 | 590 | int n = 0; | ||
3030 | 591 | char *curr, *comma; | ||
3031 | 592 | int i; | ||
3032 | 593 | static char *cached_types; | ||
3033 | 594 | |||
3034 | 595 | if (cached_types && strcmp(cached_types, enctypes) == 0) | ||
3035 | 596 | return 0; | ||
3036 | 597 | free(cached_types); | ||
3037 | 598 | |||
3038 | 599 | if (krb5_enctypes != NULL) { | ||
3039 | 600 | free(krb5_enctypes); | ||
3040 | 601 | krb5_enctypes = NULL; | ||
3041 | 602 | num_krb5_enctypes = 0; | ||
3042 | 603 | } | ||
3043 | 604 | |||
3044 | 605 | /* count the number of commas */ | ||
3045 | 606 | for (curr = enctypes; curr && *curr != '\0'; curr = ++comma) { | ||
3046 | 607 | comma = strchr(curr, ','); | ||
3047 | 608 | if (comma != NULL) | ||
3048 | 609 | n++; | ||
3049 | 610 | else | ||
3050 | 611 | break; | ||
3051 | 612 | } | ||
3052 | 613 | /* If no more commas and we're not at the end, there's one more value */ | ||
3053 | 614 | if (*curr != '\0') | ||
3054 | 615 | n++; | ||
3055 | 616 | |||
3056 | 617 | /* Empty string, return an error */ | ||
3057 | 618 | if (n == 0) | ||
3058 | 619 | return ENOENT; | ||
3059 | 620 | |||
3060 | 621 | /* Allocate space for enctypes array */ | ||
3061 | 622 | if ((krb5_enctypes = (int *) calloc(n, sizeof(int))) == NULL) { | ||
3062 | 623 | return ENOMEM; | ||
3063 | 624 | } | ||
3064 | 625 | |||
3065 | 626 | /* Now parse each value into the array */ | ||
3066 | 627 | for (curr = enctypes, i = 0; curr && *curr != '\0'; curr = ++comma) { | ||
3067 | 628 | krb5_enctypes[i++] = atoi(curr); | ||
3068 | 629 | comma = strchr(curr, ','); | ||
3069 | 630 | if (comma == NULL) | ||
3070 | 631 | break; | ||
3071 | 632 | } | ||
3072 | 633 | |||
3073 | 634 | num_krb5_enctypes = n; | ||
3074 | 635 | if ((cached_types = malloc(strlen(enctypes)+1))) | ||
3075 | 636 | strcpy(cached_types, enctypes); | ||
3076 | 637 | |||
3077 | 638 | return 0; | ||
3078 | 639 | } | ||
3079 | 640 | |||
3080 | 641 | static int | ||
3081 | 642 | do_downcall(int k5_fd, uid_t uid, struct authgss_private_data *pd, | ||
3082 | 643 | gss_buffer_desc *context_token) | ||
3083 | 644 | { | ||
3084 | 645 | char *buf = NULL, *p = NULL, *end = NULL; | ||
3085 | 646 | unsigned int timeout = context_timeout; | ||
3086 | 647 | unsigned int buf_size = 0; | ||
3087 | 648 | |||
3088 | 649 | printerr(1, "doing downcall\n"); | ||
3089 | 650 | buf_size = sizeof(uid) + sizeof(timeout) + sizeof(pd->pd_seq_win) + | ||
3090 | 651 | sizeof(pd->pd_ctx_hndl.length) + pd->pd_ctx_hndl.length + | ||
3091 | 652 | sizeof(context_token->length) + context_token->length; | ||
3092 | 653 | p = buf = malloc(buf_size); | ||
3093 | 654 | end = buf + buf_size; | ||
3094 | 655 | |||
3095 | 656 | if (WRITE_BYTES(&p, end, uid)) goto out_err; | ||
3096 | 657 | if (WRITE_BYTES(&p, end, timeout)) goto out_err; | ||
3097 | 658 | if (WRITE_BYTES(&p, end, pd->pd_seq_win)) goto out_err; | ||
3098 | 659 | if (write_buffer(&p, end, &pd->pd_ctx_hndl)) goto out_err; | ||
3099 | 660 | if (write_buffer(&p, end, context_token)) goto out_err; | ||
3100 | 661 | |||
3101 | 662 | if (write(k5_fd, buf, p - buf) < p - buf) goto out_err; | ||
3102 | 663 | if (buf) free(buf); | ||
3103 | 664 | return 0; | ||
3104 | 665 | out_err: | ||
3105 | 666 | if (buf) free(buf); | ||
3106 | 667 | printerr(1, "Failed to write downcall!\n"); | ||
3107 | 668 | return -1; | ||
3108 | 669 | } | ||
3109 | 670 | |||
3110 | 671 | static int | ||
3111 | 672 | do_error_downcall(int k5_fd, uid_t uid, int err) | ||
3112 | 673 | { | ||
3113 | 674 | char buf[1024]; | ||
3114 | 675 | char *p = buf, *end = buf + 1024; | ||
3115 | 676 | unsigned int timeout = 0; | ||
3116 | 677 | int zero = 0; | ||
3117 | 678 | |||
3118 | 679 | printerr(1, "doing error downcall\n"); | ||
3119 | 680 | |||
3120 | 681 | if (WRITE_BYTES(&p, end, uid)) goto out_err; | ||
3121 | 682 | if (WRITE_BYTES(&p, end, timeout)) goto out_err; | ||
3122 | 683 | /* use seq_win = 0 to indicate an error: */ | ||
3123 | 684 | if (WRITE_BYTES(&p, end, zero)) goto out_err; | ||
3124 | 685 | if (WRITE_BYTES(&p, end, err)) goto out_err; | ||
3125 | 686 | |||
3126 | 687 | if (write(k5_fd, buf, p - buf) < p - buf) goto out_err; | ||
3127 | 688 | return 0; | ||
3128 | 689 | out_err: | ||
3129 | 690 | printerr(1, "Failed to write error downcall!\n"); | ||
3130 | 691 | return -1; | ||
3131 | 692 | } | ||
3132 | 693 | |||
3133 | 694 | /* | ||
3134 | 695 | * If the port isn't already set, do an rpcbind query to the remote server | ||
3135 | 696 | * using the program and version and get the port. | ||
3136 | 697 | * | ||
3137 | 698 | * Newer kernels send the value of the port= mount option in the "info" | ||
3138 | 699 | * file for the upcall or '0' for NFSv2/3. For NFSv4 it sends the value | ||
3139 | 700 | * of the port= option or '2049'. The port field in a new sockaddr should | ||
3140 | 701 | * reflect the value that was sent by the kernel. | ||
3141 | 702 | */ | ||
3142 | 703 | static int | ||
3143 | 704 | populate_port(struct sockaddr *sa, const socklen_t salen, | ||
3144 | 705 | const rpcprog_t program, const rpcvers_t version, | ||
3145 | 706 | const unsigned short protocol) | ||
3146 | 707 | { | ||
3147 | 708 | struct sockaddr_in *s4 = (struct sockaddr_in *) sa; | ||
3148 | 709 | #ifdef IPV6_SUPPORTED | ||
3149 | 710 | struct sockaddr_in6 *s6 = (struct sockaddr_in6 *) sa; | ||
3150 | 711 | #endif /* IPV6_SUPPORTED */ | ||
3151 | 712 | unsigned short port; | ||
3152 | 713 | |||
3153 | 714 | /* | ||
3154 | 715 | * Newer kernels send the port in the upcall. If we already have | ||
3155 | 716 | * the port, there's no need to look it up. | ||
3156 | 717 | */ | ||
3157 | 718 | switch (sa->sa_family) { | ||
3158 | 719 | case AF_INET: | ||
3159 | 720 | if (s4->sin_port != 0) { | ||
3160 | 721 | printerr(2, "DEBUG: port already set to %d\n", | ||
3161 | 722 | ntohs(s4->sin_port)); | ||
3162 | 723 | return 1; | ||
3163 | 724 | } | ||
3164 | 725 | break; | ||
3165 | 726 | #ifdef IPV6_SUPPORTED | ||
3166 | 727 | case AF_INET6: | ||
3167 | 728 | if (s6->sin6_port != 0) { | ||
3168 | 729 | printerr(2, "DEBUG: port already set to %d\n", | ||
3169 | 730 | ntohs(s6->sin6_port)); | ||
3170 | 731 | return 1; | ||
3171 | 732 | } | ||
3172 | 733 | break; | ||
3173 | 734 | #endif /* IPV6_SUPPORTED */ | ||
3174 | 735 | default: | ||
3175 | 736 | printerr(0, "ERROR: unsupported address family %d\n", | ||
3176 | 737 | sa->sa_family); | ||
3177 | 738 | return 0; | ||
3178 | 739 | } | ||
3179 | 740 | |||
3180 | 741 | /* | ||
3181 | 742 | * Newer kernels that send the port in the upcall set the value to | ||
3182 | 743 | * 2049 for NFSv4 mounts when one isn't specified. The check below is | ||
3183 | 744 | * only for kernels that don't send the port in the upcall. For those | ||
3184 | 745 | * we either have to do an rpcbind query or set it to the standard | ||
3185 | 746 | * port. Doing a query could be problematic (firewalls, etc), so take | ||
3186 | 747 | * the latter approach. | ||
3187 | 748 | */ | ||
3188 | 749 | if (program == 100003 && version == 4) { | ||
3189 | 750 | port = 2049; | ||
3190 | 751 | goto set_port; | ||
3191 | 752 | } | ||
3192 | 753 | |||
3193 | 754 | port = nfs_getport(sa, salen, program, version, protocol); | ||
3194 | 755 | if (!port) { | ||
3195 | 756 | printerr(0, "ERROR: unable to obtain port for prog %ld " | ||
3196 | 757 | "vers %ld\n", program, version); | ||
3197 | 758 | return 0; | ||
3198 | 759 | } | ||
3199 | 760 | |||
3200 | 761 | set_port: | ||
3201 | 762 | printerr(2, "DEBUG: setting port to %hu for prog %lu vers %lu\n", port, | ||
3202 | 763 | program, version); | ||
3203 | 764 | |||
3204 | 765 | switch (sa->sa_family) { | ||
3205 | 766 | case AF_INET: | ||
3206 | 767 | s4->sin_port = htons(port); | ||
3207 | 768 | break; | ||
3208 | 769 | #ifdef IPV6_SUPPORTED | ||
3209 | 770 | case AF_INET6: | ||
3210 | 771 | s6->sin6_port = htons(port); | ||
3211 | 772 | break; | ||
3212 | 773 | #endif /* IPV6_SUPPORTED */ | ||
3213 | 774 | } | ||
3214 | 775 | |||
3215 | 776 | return 1; | ||
3216 | 777 | } | ||
3217 | 778 | |||
3218 | 779 | /* | ||
3219 | 780 | * Create an RPC connection and establish an authenticated | ||
3220 | 781 | * gss context with a server. | ||
3221 | 782 | */ | ||
3222 | 783 | int create_auth_rpc_client(struct clnt_info *clp, | ||
3223 | 784 | CLIENT **clnt_return, | ||
3224 | 785 | AUTH **auth_return, | ||
3225 | 786 | uid_t uid, | ||
3226 | 787 | int authtype) | ||
3227 | 788 | { | ||
3228 | 789 | CLIENT *rpc_clnt = NULL; | ||
3229 | 790 | struct rpc_gss_sec sec; | ||
3230 | 791 | AUTH *auth = NULL; | ||
3231 | 792 | uid_t save_uid = -1; | ||
3232 | 793 | int retval = -1; | ||
3233 | 794 | OM_uint32 min_stat; | ||
3234 | 795 | char rpc_errmsg[1024]; | ||
3235 | 796 | int protocol; | ||
3236 | 797 | struct timeval timeout = {5, 0}; | ||
3237 | 798 | struct sockaddr *addr = (struct sockaddr *) &clp->addr; | ||
3238 | 799 | socklen_t salen; | ||
3239 | 800 | |||
3240 | 801 | /* Create the context as the user (not as root) */ | ||
3241 | 802 | save_uid = geteuid(); | ||
3242 | 803 | if (setfsuid(uid) != 0) { | ||
3243 | 804 | printerr(0, "WARNING: Failed to setfsuid for " | ||
3244 | 805 | "user with uid %d\n", uid); | ||
3245 | 806 | goto out_fail; | ||
3246 | 807 | } | ||
3247 | 808 | printerr(2, "creating context using fsuid %d (save_uid %d)\n", | ||
3248 | 809 | uid, save_uid); | ||
3249 | 810 | |||
3250 | 811 | sec.qop = GSS_C_QOP_DEFAULT; | ||
3251 | 812 | sec.svc = RPCSEC_GSS_SVC_NONE; | ||
3252 | 813 | sec.cred = GSS_C_NO_CREDENTIAL; | ||
3253 | 814 | sec.req_flags = 0; | ||
3254 | 815 | if (authtype == AUTHTYPE_KRB5) { | ||
3255 | 816 | sec.mech = (gss_OID)&krb5oid; | ||
3256 | 817 | sec.req_flags = GSS_C_MUTUAL_FLAG; | ||
3257 | 818 | } | ||
3258 | 819 | else { | ||
3259 | 820 | printerr(0, "ERROR: Invalid authentication type (%d) " | ||
3260 | 821 | "in create_auth_rpc_client\n", authtype); | ||
3261 | 822 | goto out_fail; | ||
3262 | 823 | } | ||
3263 | 824 | |||
3264 | 825 | |||
3265 | 826 | if (authtype == AUTHTYPE_KRB5) { | ||
3266 | 827 | #ifdef HAVE_SET_ALLOWABLE_ENCTYPES | ||
3267 | 828 | /* | ||
3268 | 829 | * Do this before creating rpc connection since we won't need | ||
3269 | 830 | * rpc connection if it fails! | ||
3270 | 831 | */ | ||
3271 | 832 | if (limit_krb5_enctypes(&sec)) { | ||
3272 | 833 | printerr(1, "WARNING: Failed while limiting krb5 " | ||
3273 | 834 | "encryption types for user with uid %d\n", | ||
3274 | 835 | uid); | ||
3275 | 836 | goto out_fail; | ||
3276 | 837 | } | ||
3277 | 838 | #endif | ||
3278 | 839 | } | ||
3279 | 840 | |||
3280 | 841 | /* create an rpc connection to the nfs server */ | ||
3281 | 842 | |||
3282 | 843 | printerr(2, "creating %s client for server %s\n", clp->protocol, | ||
3283 | 844 | clp->servername); | ||
3284 | 845 | |||
3285 | 846 | if ((strcmp(clp->protocol, "tcp")) == 0) { | ||
3286 | 847 | protocol = IPPROTO_TCP; | ||
3287 | 848 | } else if ((strcmp(clp->protocol, "udp")) == 0) { | ||
3288 | 849 | protocol = IPPROTO_UDP; | ||
3289 | 850 | } else { | ||
3290 | 851 | printerr(0, "WARNING: unrecognized protocol, '%s', requested " | ||
3291 | 852 | "for connection to server %s for user with uid %d\n", | ||
3292 | 853 | clp->protocol, clp->servername, uid); | ||
3293 | 854 | goto out_fail; | ||
3294 | 855 | } | ||
3295 | 856 | |||
3296 | 857 | switch (addr->sa_family) { | ||
3297 | 858 | case AF_INET: | ||
3298 | 859 | salen = sizeof(struct sockaddr_in); | ||
3299 | 860 | break; | ||
3300 | 861 | #ifdef IPV6_SUPPORTED | ||
3301 | 862 | case AF_INET6: | ||
3302 | 863 | salen = sizeof(struct sockaddr_in6); | ||
3303 | 864 | break; | ||
3304 | 865 | #endif /* IPV6_SUPPORTED */ | ||
3305 | 866 | default: | ||
3306 | 867 | printerr(1, "ERROR: Unknown address family %d\n", | ||
3307 | 868 | addr->sa_family); | ||
3308 | 869 | goto out_fail; | ||
3309 | 870 | } | ||
3310 | 871 | |||
3311 | 872 | if (!populate_port(addr, salen, clp->prog, clp->vers, protocol)) | ||
3312 | 873 | goto out_fail; | ||
3313 | 874 | |||
3314 | 875 | rpc_clnt = nfs_get_rpcclient(addr, salen, protocol, clp->prog, | ||
3315 | 876 | clp->vers, &timeout); | ||
3316 | 877 | if (!rpc_clnt) { | ||
3317 | 878 | snprintf(rpc_errmsg, sizeof(rpc_errmsg), | ||
3318 | 879 | "WARNING: can't create %s rpc_clnt to server %s for " | ||
3319 | 880 | "user with uid %d", | ||
3320 | 881 | protocol == IPPROTO_TCP ? "tcp" : "udp", | ||
3321 | 882 | clp->servername, uid); | ||
3322 | 883 | printerr(0, "%s\n", | ||
3323 | 884 | clnt_spcreateerror(rpc_errmsg)); | ||
3324 | 885 | goto out_fail; | ||
3325 | 886 | } | ||
3326 | 887 | |||
3327 | 888 | printerr(2, "creating context with server %s\n", clp->servicename); | ||
3328 | 889 | auth = authgss_create_default(rpc_clnt, clp->servicename, &sec); | ||
3329 | 890 | if (!auth) { | ||
3330 | 891 | /* Our caller should print appropriate message */ | ||
3331 | 892 | printerr(2, "WARNING: Failed to create krb5 context for " | ||
3332 | 893 | "user with uid %d for server %s\n", | ||
3333 | 894 | uid, clp->servername); | ||
3334 | 895 | goto out_fail; | ||
3335 | 896 | } | ||
3336 | 897 | |||
3337 | 898 | /* Success !!! */ | ||
3338 | 899 | rpc_clnt->cl_auth = auth; | ||
3339 | 900 | *clnt_return = rpc_clnt; | ||
3340 | 901 | *auth_return = auth; | ||
3341 | 902 | retval = 0; | ||
3342 | 903 | |||
3343 | 904 | out: | ||
3344 | 905 | if (sec.cred != GSS_C_NO_CREDENTIAL) | ||
3345 | 906 | gss_release_cred(&min_stat, &sec.cred); | ||
3346 | 907 | /* Restore euid to original value */ | ||
3347 | 908 | if (((int)save_uid != -1) && (setfsuid(save_uid) != (int)uid)) { | ||
3348 | 909 | printerr(0, "WARNING: Failed to restore fsuid" | ||
3349 | 910 | " to uid %d from %d\n", save_uid, uid); | ||
3350 | 911 | } | ||
3351 | 912 | return retval; | ||
3352 | 913 | |||
3353 | 914 | out_fail: | ||
3354 | 915 | /* Only destroy here if failure. Otherwise, caller is responsible */ | ||
3355 | 916 | if (rpc_clnt) clnt_destroy(rpc_clnt); | ||
3356 | 917 | |||
3357 | 918 | goto out; | ||
3358 | 919 | } | ||
3359 | 920 | |||
3360 | 921 | static char * | ||
3361 | 922 | user_cachedir(char *dirname, uid_t uid) | ||
3362 | 923 | { | ||
3363 | 924 | struct passwd *pw; | ||
3364 | 925 | char *ptr; | ||
3365 | 926 | |||
3366 | 927 | if ((pw = getpwuid(uid)) == NULL) { | ||
3367 | 928 | printerr(0, "user_cachedir: Failed to find '%d' uid" | ||
3368 | 929 | " for cache directory\n"); | ||
3369 | 930 | return NULL; | ||
3370 | 931 | } | ||
3371 | 932 | ptr = malloc(strlen(dirname)+strlen(pw->pw_name)+2); | ||
3372 | 933 | if (ptr) | ||
3373 | 934 | sprintf(ptr, "%s/%s", dirname, pw->pw_name); | ||
3374 | 935 | |||
3375 | 936 | return ptr; | ||
3376 | 937 | } | ||
3377 | 938 | /* | ||
3378 | 939 | * this code uses the userland rpcsec gss library to create a krb5 | ||
3379 | 940 | * context on behalf of the kernel | ||
3380 | 941 | */ | ||
3381 | 942 | static void | ||
3382 | 943 | process_krb5_upcall(struct clnt_info *clp, uid_t uid, int fd, char *tgtname, | ||
3383 | 944 | char *service) | ||
3384 | 945 | { | ||
3385 | 946 | CLIENT *rpc_clnt = NULL; | ||
3386 | 947 | AUTH *auth = NULL; | ||
3387 | 948 | struct authgss_private_data pd; | ||
3388 | 949 | gss_buffer_desc token; | ||
3389 | 950 | char **credlist = NULL; | ||
3390 | 951 | char **ccname; | ||
3391 | 952 | char **dirname, *dir, *userdir; | ||
3392 | 953 | int create_resp = -1; | ||
3393 | 954 | int err, downcall_err = -EACCES; | ||
3394 | 955 | |||
3395 | 956 | printerr(1, "handling krb5 upcall (%s)\n", clp->dirname); | ||
3396 | 957 | |||
3397 | 958 | if (tgtname) { | ||
3398 | 959 | if (clp->servicename) { | ||
3399 | 960 | free(clp->servicename); | ||
3400 | 961 | clp->servicename = strdup(tgtname); | ||
3401 | 962 | } | ||
3402 | 963 | } | ||
3403 | 964 | token.length = 0; | ||
3404 | 965 | token.value = NULL; | ||
3405 | 966 | memset(&pd, 0, sizeof(struct authgss_private_data)); | ||
3406 | 967 | |||
3407 | 968 | /* | ||
3408 | 969 | * If "service" is specified, then the kernel is indicating that | ||
3409 | 970 | * we must use machine credentials for this request. (Regardless | ||
3410 | 971 | * of the uid value or the setting of root_uses_machine_creds.) | ||
3411 | 972 | * If the service value is "*", then any service name can be used. | ||
3412 | 973 | * Otherwise, it specifies the service name that should be used. | ||
3413 | 974 | * (For now, the values of service will only be "*" or "nfs".) | ||
3414 | 975 | * | ||
3415 | 976 | * Restricting gssd to use "nfs" service name is needed for when | ||
3416 | 977 | * the NFS server is doing a callback to the NFS client. In this | ||
3417 | 978 | * case, the NFS server has to authenticate itself as "nfs" -- | ||
3418 | 979 | * even if there are other service keys such as "host" or "root" | ||
3419 | 980 | * in the keytab. | ||
3420 | 981 | * | ||
3421 | 982 | * Another case when the kernel may specify the service attribute | ||
3422 | 983 | * is when gssd is being asked to create the context for a | ||
3423 | 984 | * SETCLIENT_ID operation. In this case, machine credentials | ||
3424 | 985 | * must be used for the authentication. However, the service name | ||
3425 | 986 | * used for this case is not important. | ||
3426 | 987 | * | ||
3427 | 988 | */ | ||
3428 | 989 | printerr(2, "%s: service is '%s'\n", __func__, | ||
3429 | 990 | service ? service : "<null>"); | ||
3430 | 991 | if (uid != 0 || (uid == 0 && root_uses_machine_creds == 0 && | ||
3431 | 992 | service == NULL)) { | ||
3432 | 993 | /* Tell krb5 gss which credentials cache to use */ | ||
3433 | 994 | for (dirname = ccachesearch; *dirname != NULL; dirname++) { | ||
3434 | 995 | /* See if the user name is needed */ | ||
3435 | 996 | if (strncmp(*dirname, GSSD_USER_CRED_DIR, | ||
3436 | 997 | strlen(GSSD_USER_CRED_DIR)) == 0) { | ||
3437 | 998 | userdir = user_cachedir(*dirname, uid); | ||
3438 | 999 | if (userdir == NULL) | ||
3439 | 1000 | continue; | ||
3440 | 1001 | dir = userdir; | ||
3441 | 1002 | } else | ||
3442 | 1003 | dir = *dirname; | ||
3443 | 1004 | |||
3444 | 1005 | err = gssd_setup_krb5_user_gss_ccache(uid, clp->servername, dir); | ||
3445 | 1006 | |||
3446 | 1007 | if (userdir) { | ||
3447 | 1008 | free(userdir); | ||
3448 | 1009 | userdir = NULL; | ||
3449 | 1010 | } | ||
3450 | 1011 | if (err == -EKEYEXPIRED) | ||
3451 | 1012 | downcall_err = -EKEYEXPIRED; | ||
3452 | 1013 | else if (!err) | ||
3453 | 1014 | create_resp = create_auth_rpc_client(clp, &rpc_clnt, &auth, uid, | ||
3454 | 1015 | AUTHTYPE_KRB5); | ||
3455 | 1016 | if (create_resp == 0) | ||
3456 | 1017 | break; | ||
3457 | 1018 | } | ||
3458 | 1019 | } | ||
3459 | 1020 | if (create_resp != 0) { | ||
3460 | 1021 | if (uid == 0 && (root_uses_machine_creds == 1 || | ||
3461 | 1022 | service != NULL)) { | ||
3462 | 1023 | int nocache = 0; | ||
3463 | 1024 | int success = 0; | ||
3464 | 1025 | do { | ||
3465 | 1026 | gssd_refresh_krb5_machine_credential(clp->servername, | ||
3466 | 1027 | NULL, service); | ||
3467 | 1028 | /* | ||
3468 | 1029 | * Get a list of credential cache names and try each | ||
3469 | 1030 | * of them until one works or we've tried them all | ||
3470 | 1031 | */ | ||
3471 | 1032 | if (gssd_get_krb5_machine_cred_list(&credlist)) { | ||
3472 | 1033 | printerr(0, "ERROR: No credentials found " | ||
3473 | 1034 | "for connection to server %s\n", | ||
3474 | 1035 | clp->servername); | ||
3475 | 1036 | goto out_return_error; | ||
3476 | 1037 | } | ||
3477 | 1038 | for (ccname = credlist; ccname && *ccname; ccname++) { | ||
3478 | 1039 | gssd_setup_krb5_machine_gss_ccache(*ccname); | ||
3479 | 1040 | if ((create_auth_rpc_client(clp, &rpc_clnt, | ||
3480 | 1041 | &auth, uid, | ||
3481 | 1042 | AUTHTYPE_KRB5)) == 0) { | ||
3482 | 1043 | /* Success! */ | ||
3483 | 1044 | success++; | ||
3484 | 1045 | break; | ||
3485 | 1046 | } | ||
3486 | 1047 | printerr(2, "WARNING: Failed to create machine krb5 context " | ||
3487 | 1048 | "with credentials cache %s for server %s\n", | ||
3488 | 1049 | *ccname, clp->servername); | ||
3489 | 1050 | } | ||
3490 | 1051 | gssd_free_krb5_machine_cred_list(credlist); | ||
3491 | 1052 | if (!success) { | ||
3492 | 1053 | if(nocache == 0) { | ||
3493 | 1054 | nocache++; | ||
3494 | 1055 | printerr(2, "WARNING: Machine cache is prematurely expired or corrupted " | ||
3495 | 1056 | "trying to recreate cache for server %s\n", clp->servername); | ||
3496 | 1057 | } else { | ||
3497 | 1058 | printerr(1, "WARNING: Failed to create machine krb5 context " | ||
3498 | 1059 | "with any credentials cache for server %s\n", | ||
3499 | 1060 | clp->servername); | ||
3500 | 1061 | goto out_return_error; | ||
3501 | 1062 | } | ||
3502 | 1063 | } | ||
3503 | 1064 | } while(!success); | ||
3504 | 1065 | } else { | ||
3505 | 1066 | printerr(1, "WARNING: Failed to create krb5 context " | ||
3506 | 1067 | "for user with uid %d for server %s\n", | ||
3507 | 1068 | uid, clp->servername); | ||
3508 | 1069 | goto out_return_error; | ||
3509 | 1070 | } | ||
3510 | 1071 | } | ||
3511 | 1072 | |||
3512 | 1073 | if (!authgss_get_private_data(auth, &pd)) { | ||
3513 | 1074 | printerr(1, "WARNING: Failed to obtain authentication " | ||
3514 | 1075 | "data for user with uid %d for server %s\n", | ||
3515 | 1076 | uid, clp->servername); | ||
3516 | 1077 | goto out_return_error; | ||
3517 | 1078 | } | ||
3518 | 1079 | |||
3519 | 1080 | if (serialize_context_for_kernel(pd.pd_ctx, &token, &krb5oid, NULL)) { | ||
3520 | 1081 | printerr(0, "WARNING: Failed to serialize krb5 context for " | ||
3521 | 1082 | "user with uid %d for server %s\n", | ||
3522 | 1083 | uid, clp->servername); | ||
3523 | 1084 | goto out_return_error; | ||
3524 | 1085 | } | ||
3525 | 1086 | |||
3526 | 1087 | do_downcall(fd, uid, &pd, &token); | ||
3527 | 1088 | |||
3528 | 1089 | out: | ||
3529 | 1090 | if (token.value) | ||
3530 | 1091 | free(token.value); | ||
3531 | 1092 | #ifndef HAVE_LIBTIRPC | ||
3532 | 1093 | if (pd.pd_ctx_hndl.length != 0) | ||
3533 | 1094 | authgss_free_private_data(&pd); | ||
3534 | 1095 | #endif | ||
3535 | 1096 | if (auth) | ||
3536 | 1097 | AUTH_DESTROY(auth); | ||
3537 | 1098 | if (rpc_clnt) | ||
3538 | 1099 | clnt_destroy(rpc_clnt); | ||
3539 | 1100 | return; | ||
3540 | 1101 | |||
3541 | 1102 | out_return_error: | ||
3542 | 1103 | do_error_downcall(fd, uid, downcall_err); | ||
3543 | 1104 | goto out; | ||
3544 | 1105 | } | ||
3545 | 1106 | |||
3546 | 1107 | void | ||
3547 | 1108 | handle_krb5_upcall(struct clnt_info *clp) | ||
3548 | 1109 | { | ||
3549 | 1110 | uid_t uid; | ||
3550 | 1111 | |||
3551 | 1112 | if (read(clp->krb5_fd, &uid, sizeof(uid)) < (ssize_t)sizeof(uid)) { | ||
3552 | 1113 | printerr(0, "WARNING: failed reading uid from krb5 " | ||
3553 | 1114 | "upcall pipe: %s\n", strerror(errno)); | ||
3554 | 1115 | return; | ||
3555 | 1116 | } | ||
3556 | 1117 | |||
3557 | 1118 | return process_krb5_upcall(clp, uid, clp->krb5_fd, NULL, NULL); | ||
3558 | 1119 | } | ||
3559 | 1120 | |||
3560 | 1121 | void | ||
3561 | 1122 | handle_gssd_upcall(struct clnt_info *clp) | ||
3562 | 1123 | { | ||
3563 | 1124 | uid_t uid; | ||
3564 | 1125 | char *lbuf = NULL; | ||
3565 | 1126 | int lbuflen = 0; | ||
3566 | 1127 | char *p; | ||
3567 | 1128 | char *mech = NULL; | ||
3568 | 1129 | char *target = NULL; | ||
3569 | 1130 | char *service = NULL; | ||
3570 | 1131 | char *enctypes = NULL; | ||
3571 | 1132 | |||
3572 | 1133 | printerr(1, "handling gssd upcall (%s)\n", clp->dirname); | ||
3573 | 1134 | |||
3574 | 1135 | if (readline(clp->gssd_fd, &lbuf, &lbuflen) != 1) { | ||
3575 | 1136 | printerr(0, "WARNING: handle_gssd_upcall: " | ||
3576 | 1137 | "failed reading request\n"); | ||
3577 | 1138 | return; | ||
3578 | 1139 | } | ||
3579 | 1140 | printerr(2, "%s: '%s'\n", __func__, lbuf); | ||
3580 | 1141 | |||
3581 | 1142 | /* find the mechanism name */ | ||
3582 | 1143 | if ((p = strstr(lbuf, "mech=")) != NULL) { | ||
3583 | 1144 | mech = malloc(lbuflen); | ||
3584 | 1145 | if (!mech) | ||
3585 | 1146 | goto out; | ||
3586 | 1147 | if (sscanf(p, "mech=%s", mech) != 1) { | ||
3587 | 1148 | printerr(0, "WARNING: handle_gssd_upcall: " | ||
3588 | 1149 | "failed to parse gss mechanism name " | ||
3589 | 1150 | "in upcall string '%s'\n", lbuf); | ||
3590 | 1151 | goto out; | ||
3591 | 1152 | } | ||
3592 | 1153 | } else { | ||
3593 | 1154 | printerr(0, "WARNING: handle_gssd_upcall: " | ||
3594 | 1155 | "failed to find gss mechanism name " | ||
3595 | 1156 | "in upcall string '%s'\n", lbuf); | ||
3596 | 1157 | goto out; | ||
3597 | 1158 | } | ||
3598 | 1159 | |||
3599 | 1160 | /* read uid */ | ||
3600 | 1161 | if ((p = strstr(lbuf, "uid=")) != NULL) { | ||
3601 | 1162 | if (sscanf(p, "uid=%d", &uid) != 1) { | ||
3602 | 1163 | printerr(0, "WARNING: handle_gssd_upcall: " | ||
3603 | 1164 | "failed to parse uid " | ||
3604 | 1165 | "in upcall string '%s'\n", lbuf); | ||
3605 | 1166 | goto out; | ||
3606 | 1167 | } | ||
3607 | 1168 | } else { | ||
3608 | 1169 | printerr(0, "WARNING: handle_gssd_upcall: " | ||
3609 | 1170 | "failed to find uid " | ||
3610 | 1171 | "in upcall string '%s'\n", lbuf); | ||
3611 | 1172 | goto out; | ||
3612 | 1173 | } | ||
3613 | 1174 | |||
3614 | 1175 | /* read supported encryption types if supplied */ | ||
3615 | 1176 | if ((p = strstr(lbuf, "enctypes=")) != NULL) { | ||
3616 | 1177 | enctypes = malloc(lbuflen); | ||
3617 | 1178 | if (!enctypes) | ||
3618 | 1179 | goto out; | ||
3619 | 1180 | if (sscanf(p, "enctypes=%s", enctypes) != 1) { | ||
3620 | 1181 | printerr(0, "WARNING: handle_gssd_upcall: " | ||
3621 | 1182 | "failed to parse encryption types " | ||
3622 | 1183 | "in upcall string '%s'\n", lbuf); | ||
3623 | 1184 | goto out; | ||
3624 | 1185 | } | ||
3625 | 1186 | if (parse_enctypes(enctypes) != 0) { | ||
3626 | 1187 | printerr(0, "WARNING: handle_gssd_upcall: " | ||
3627 | 1188 | "parsing encryption types failed: errno %d\n", errno); | ||
3628 | 1189 | } | ||
3629 | 1190 | } | ||
3630 | 1191 | |||
3631 | 1192 | /* read target name */ | ||
3632 | 1193 | if ((p = strstr(lbuf, "target=")) != NULL) { | ||
3633 | 1194 | target = malloc(lbuflen); | ||
3634 | 1195 | if (!target) | ||
3635 | 1196 | goto out; | ||
3636 | 1197 | if (sscanf(p, "target=%s", target) != 1) { | ||
3637 | 1198 | printerr(0, "WARNING: handle_gssd_upcall: " | ||
3638 | 1199 | "failed to parse target name " | ||
3639 | 1200 | "in upcall string '%s'\n", lbuf); | ||
3640 | 1201 | goto out; | ||
3641 | 1202 | } | ||
3642 | 1203 | } | ||
3643 | 1204 | |||
3644 | 1205 | /* | ||
3645 | 1206 | * read the service name | ||
3646 | 1207 | * | ||
3647 | 1208 | * The presence of attribute "service=" indicates that machine | ||
3648 | 1209 | * credentials should be used for this request. If the value | ||
3649 | 1210 | * is "*", then any machine credentials available can be used. | ||
3650 | 1211 | * If the value is anything else, then machine credentials for | ||
3651 | 1212 | * the specified service name (always "nfs" for now) should be | ||
3652 | 1213 | * used. | ||
3653 | 1214 | */ | ||
3654 | 1215 | if ((p = strstr(lbuf, "service=")) != NULL) { | ||
3655 | 1216 | service = malloc(lbuflen); | ||
3656 | 1217 | if (!service) | ||
3657 | 1218 | goto out; | ||
3658 | 1219 | if (sscanf(p, "service=%s", service) != 1) { | ||
3659 | 1220 | printerr(0, "WARNING: handle_gssd_upcall: " | ||
3660 | 1221 | "failed to parse service type " | ||
3661 | 1222 | "in upcall string '%s'\n", lbuf); | ||
3662 | 1223 | goto out; | ||
3663 | 1224 | } | ||
3664 | 1225 | } | ||
3665 | 1226 | |||
3666 | 1227 | if (strcmp(mech, "krb5") == 0) | ||
3667 | 1228 | process_krb5_upcall(clp, uid, clp->gssd_fd, target, service); | ||
3668 | 1229 | else | ||
3669 | 1230 | printerr(0, "WARNING: handle_gssd_upcall: " | ||
3670 | 1231 | "received unknown gss mech '%s'\n", mech); | ||
3671 | 1232 | |||
3672 | 1233 | out: | ||
3673 | 1234 | free(lbuf); | ||
3674 | 1235 | free(mech); | ||
3675 | 1236 | free(enctypes); | ||
3676 | 1237 | free(target); | ||
3677 | 1238 | free(service); | ||
3678 | 1239 | return; | ||
3679 | 1240 | } | ||
3680 | 1241 | |||
3681 | 1242 | 0 | ||
3682 | === removed directory '.pc/16-mount.nfs.man-update-distinction-between-fstype.patch' | |||
3683 | === removed directory '.pc/16-mount.nfs.man-update-distinction-between-fstype.patch/utils' | |||
3684 | === removed directory '.pc/16-mount.nfs.man-update-distinction-between-fstype.patch/utils/mount' | |||
3685 | === removed file '.pc/16-mount.nfs.man-update-distinction-between-fstype.patch/utils/mount/mount.nfs.man' | |||
3686 | --- .pc/16-mount.nfs.man-update-distinction-between-fstype.patch/utils/mount/mount.nfs.man 2011-03-27 18:54:45 +0000 | |||
3687 | +++ .pc/16-mount.nfs.man-update-distinction-between-fstype.patch/utils/mount/mount.nfs.man 1970-01-01 00:00:00 +0000 | |||
3688 | @@ -1,86 +0,0 @@ | |||
3689 | 1 | .\"@(#)mount.nfs.8" | ||
3690 | 2 | .TH MOUNT.NFS 8 "5 Jun 2006" | ||
3691 | 3 | .SH NAME | ||
3692 | 4 | mount.nfs, mount.nfs4 \- mount a Network File System | ||
3693 | 5 | .SH SYNOPSIS | ||
3694 | 6 | .BI "mount.nfs" " remotetarget dir" " [\-rvVwfnsh ] [\-o " options "] | ||
3695 | 7 | .SH DESCRIPTION | ||
3696 | 8 | .BR mount.nfs | ||
3697 | 9 | is a part of | ||
3698 | 10 | .BR nfs (5) | ||
3699 | 11 | utilities package, which provides NFS client functionality. | ||
3700 | 12 | |||
3701 | 13 | .BR mount.nfs | ||
3702 | 14 | is meant to be used by the | ||
3703 | 15 | .BR mount (8) | ||
3704 | 16 | command for mounting NFS shares. This subcommand, however, can also be used as a standalone command with limited functionality. | ||
3705 | 17 | |||
3706 | 18 | .BR mount.nfs4 | ||
3707 | 19 | is used for mounting NFSv4 file system, while | ||
3708 | 20 | .BR mount.nfs | ||
3709 | 21 | is used to mount NFS file systems versions 3 or 2. | ||
3710 | 22 | .I remotetarget | ||
3711 | 23 | is a server share usually in the form of | ||
3712 | 24 | .BR servername:/path/to/share. | ||
3713 | 25 | .I dir | ||
3714 | 26 | is the directory on which the file system is to be mounted. | ||
3715 | 27 | |||
3716 | 28 | .SH OPTIONS | ||
3717 | 29 | .TP | ||
3718 | 30 | .BI "\-r" | ||
3719 | 31 | Mount file system readonly. | ||
3720 | 32 | .TP | ||
3721 | 33 | .BI "\-v" | ||
3722 | 34 | Be verbose. | ||
3723 | 35 | .TP | ||
3724 | 36 | .BI "\-V" | ||
3725 | 37 | Print version. | ||
3726 | 38 | .TP | ||
3727 | 39 | .BI "\-w" | ||
3728 | 40 | Mount file system read-write. | ||
3729 | 41 | .TP | ||
3730 | 42 | .BI "\-f" | ||
3731 | 43 | Fake mount. Don't actually call the mount system call. | ||
3732 | 44 | .TP | ||
3733 | 45 | .BI "\-n" | ||
3734 | 46 | Do not update | ||
3735 | 47 | .I /etc/mtab. | ||
3736 | 48 | By default, an entry is created in | ||
3737 | 49 | .I /etc/mtab | ||
3738 | 50 | for every mounted file system. Use this option to skip making an entry. | ||
3739 | 51 | .TP | ||
3740 | 52 | .BI "\-s" | ||
3741 | 53 | Tolerate sloppy mount options rather than fail. | ||
3742 | 54 | .TP | ||
3743 | 55 | .BI "\-h" | ||
3744 | 56 | Print help message. | ||
3745 | 57 | .TP | ||
3746 | 58 | .BI "nfsoptions" | ||
3747 | 59 | Refer to | ||
3748 | 60 | .BR nfs (5) | ||
3749 | 61 | or | ||
3750 | 62 | .BR mount (8) | ||
3751 | 63 | manual pages. | ||
3752 | 64 | |||
3753 | 65 | .SH NOTE | ||
3754 | 66 | For further information please refer | ||
3755 | 67 | .BR nfs (5) | ||
3756 | 68 | and | ||
3757 | 69 | .BR mount (8) | ||
3758 | 70 | manual pages. | ||
3759 | 71 | |||
3760 | 72 | .SH FILES | ||
3761 | 73 | .TP 18n | ||
3762 | 74 | .I /etc/fstab | ||
3763 | 75 | file system table | ||
3764 | 76 | .TP | ||
3765 | 77 | .I /etc/mtab | ||
3766 | 78 | table of mounted file systems | ||
3767 | 79 | |||
3768 | 80 | .PD | ||
3769 | 81 | .SH "SEE ALSO" | ||
3770 | 82 | .BR nfs (5), | ||
3771 | 83 | .BR mount (8), | ||
3772 | 84 | |||
3773 | 85 | .SH "AUTHOR" | ||
3774 | 86 | Amit Gud <agud@redhat.com> | ||
3775 | 87 | 0 | ||
3776 | === removed directory '.pc/17-multiarch-kerberos-paths.patch' | |||
3777 | === removed directory '.pc/17-multiarch-kerberos-paths.patch/aclocal' | |||
3778 | === removed file '.pc/17-multiarch-kerberos-paths.patch/aclocal/kerberos5.m4' | |||
3779 | --- .pc/17-multiarch-kerberos-paths.patch/aclocal/kerberos5.m4 2012-05-25 20:41:58 +0000 | |||
3780 | +++ .pc/17-multiarch-kerberos-paths.patch/aclocal/kerberos5.m4 1970-01-01 00:00:00 +0000 | |||
3781 | @@ -1,115 +0,0 @@ | |||
3782 | 1 | dnl Checks for Kerberos | ||
3783 | 2 | dnl NOTE: while we intend to do generic gss-api, currently we | ||
3784 | 3 | dnl have a requirement to get an initial Kerberos machine | ||
3785 | 4 | dnl credential. Thus, the requirement for Kerberos. | ||
3786 | 5 | dnl The Kerberos gssapi library will be dynamically loaded? | ||
3787 | 6 | AC_DEFUN([AC_KERBEROS_V5],[ | ||
3788 | 7 | AC_MSG_CHECKING(for Kerberos v5) | ||
3789 | 8 | AC_ARG_WITH(krb5, | ||
3790 | 9 | [AC_HELP_STRING([--with-krb5=DIR], [use Kerberos v5 installation in DIR])], | ||
3791 | 10 | [ case "$withval" in | ||
3792 | 11 | yes|no) | ||
3793 | 12 | krb5_with="" | ||
3794 | 13 | ;; | ||
3795 | 14 | *) | ||
3796 | 15 | krb5_with="$withval" | ||
3797 | 16 | ;; | ||
3798 | 17 | esac ] | ||
3799 | 18 | ) | ||
3800 | 19 | |||
3801 | 20 | for dir in $krb5_with /usr /usr/kerberos /usr/local /usr/local/krb5 \ | ||
3802 | 21 | /usr/krb5 /usr/heimdal /usr/local/heimdal /usr/athena ; do | ||
3803 | 22 | dnl This ugly hack brought on by the split installation of | ||
3804 | 23 | dnl MIT Kerberos on Fedora Core 1 | ||
3805 | 24 | K5CONFIG="" | ||
3806 | 25 | if test -f $dir/bin/krb5-config; then | ||
3807 | 26 | K5CONFIG=$dir/bin/krb5-config | ||
3808 | 27 | elif test -f "/usr/kerberos/bin/krb5-config"; then | ||
3809 | 28 | K5CONFIG="/usr/kerberos/bin/krb5-config" | ||
3810 | 29 | elif test -f "/usr/lib/mit/bin/krb5-config"; then | ||
3811 | 30 | K5CONFIG="/usr/lib/mit/bin/krb5-config" | ||
3812 | 31 | fi | ||
3813 | 32 | if test "$K5CONFIG" != ""; then | ||
3814 | 33 | KRBCFLAGS=`$K5CONFIG --cflags` | ||
3815 | 34 | KRBLIBS=`$K5CONFIG --libs` | ||
3816 | 35 | K5VERS=`$K5CONFIG --version | head -n 1 | awk '{split($(4),v,"."); if (v@<:@"3"@:>@ == "") v@<:@"3"@:>@ = "0"; print v@<:@"1"@:>@v@<:@"2"@:>@v@<:@"3"@:>@ }'` | ||
3817 | 36 | AC_DEFINE_UNQUOTED(KRB5_VERSION, $K5VERS, [Define this as the Kerberos version number]) | ||
3818 | 37 | if test -f $dir/include/gssapi/gssapi_krb5.h -a \ | ||
3819 | 38 | \( -f $dir/lib/libgssapi_krb5.a -o \ | ||
3820 | 39 | -f $dir/lib64/libgssapi_krb5.a -o \ | ||
3821 | 40 | -f $dir/lib64/libgssapi_krb5.so -o \ | ||
3822 | 41 | -f $dir/lib/libgssapi_krb5.so \) ; then | ||
3823 | 42 | AC_DEFINE(HAVE_KRB5, 1, [Define this if you have MIT Kerberos libraries]) | ||
3824 | 43 | KRBDIR="$dir" | ||
3825 | 44 | dnl If we are using MIT K5 1.3.1 and before, we *MUST* use the | ||
3826 | 45 | dnl private function (gss_krb5_ccache_name) to get correct | ||
3827 | 46 | dnl behavior of changing the ccache used by gssapi. | ||
3828 | 47 | dnl Starting in 1.3.2, we *DO NOT* want to use | ||
3829 | 48 | dnl gss_krb5_ccache_name, instead we want to set KRB5CCNAME | ||
3830 | 49 | dnl to get gssapi to use a different ccache | ||
3831 | 50 | if test $K5VERS -le 131; then | ||
3832 | 51 | AC_DEFINE(USE_GSS_KRB5_CCACHE_NAME, 1, [Define this if the private function, gss_krb5_cache_name, must be used to tell the Kerberos library which credentials cache to use. Otherwise, this is done by setting the KRB5CCNAME environment variable]) | ||
3833 | 52 | fi | ||
3834 | 53 | gssapi_lib=gssapi_krb5 | ||
3835 | 54 | break | ||
3836 | 55 | dnl The following ugly hack brought on by the split installation | ||
3837 | 56 | dnl of Heimdal Kerberos on SuSe | ||
3838 | 57 | elif test \( -f $dir/include/heim_err.h -o\ | ||
3839 | 58 | -f $dir/include/heimdal/heim_err.h \) -a \ | ||
3840 | 59 | -f $dir/lib/libroken.a; then | ||
3841 | 60 | AC_DEFINE(HAVE_HEIMDAL, 1, [Define this if you have Heimdal Kerberos libraries]) | ||
3842 | 61 | KRBDIR="$dir" | ||
3843 | 62 | gssapi_lib=gssapi | ||
3844 | 63 | break | ||
3845 | 64 | fi | ||
3846 | 65 | fi | ||
3847 | 66 | done | ||
3848 | 67 | dnl We didn't find a usable Kerberos environment | ||
3849 | 68 | if test "x$KRBDIR" = "x"; then | ||
3850 | 69 | if test "x$krb5_with" = "x"; then | ||
3851 | 70 | AC_MSG_ERROR(Kerberos v5 with GSS support not found: consider --disable-gss or --with-krb5=) | ||
3852 | 71 | else | ||
3853 | 72 | AC_MSG_ERROR(Kerberos v5 with GSS support not found at $krb5_with) | ||
3854 | 73 | fi | ||
3855 | 74 | fi | ||
3856 | 75 | AC_MSG_RESULT($KRBDIR) | ||
3857 | 76 | |||
3858 | 77 | dnl Check if -rpath=$(KRBDIR)/lib is needed | ||
3859 | 78 | echo "The current KRBDIR is $KRBDIR" | ||
3860 | 79 | if test "$KRBDIR/lib" = "/lib" -o "$KRBDIR/lib" = "/usr/lib" \ | ||
3861 | 80 | -o "$KRBDIR/lib" = "//lib" -o "$KRBDIR/lib" = "/usr//lib" ; then | ||
3862 | 81 | KRBLDFLAGS=""; | ||
3863 | 82 | elif /sbin/ldconfig -p | grep > /dev/null "=> $KRBDIR/lib/"; then | ||
3864 | 83 | KRBLDFLAGS=""; | ||
3865 | 84 | else | ||
3866 | 85 | KRBLDFLAGS="-Wl,-rpath=$KRBDIR/lib" | ||
3867 | 86 | fi | ||
3868 | 87 | |||
3869 | 88 | dnl Now check for functions within gssapi library | ||
3870 | 89 | AC_CHECK_LIB($gssapi_lib, gss_krb5_export_lucid_sec_context, | ||
3871 | 90 | AC_DEFINE(HAVE_LUCID_CONTEXT_SUPPORT, 1, [Define this if the Kerberos GSS library supports gss_krb5_export_lucid_sec_context]), ,$KRBLIBS) | ||
3872 | 91 | AC_CHECK_LIB($gssapi_lib, gss_krb5_set_allowable_enctypes, | ||
3873 | 92 | AC_DEFINE(HAVE_SET_ALLOWABLE_ENCTYPES, 1, [Define this if the Kerberos GSS library supports gss_krb5_set_allowable_enctypes]), ,$KRBLIBS) | ||
3874 | 93 | AC_CHECK_LIB($gssapi_lib, gss_krb5_ccache_name, | ||
3875 | 94 | AC_DEFINE(HAVE_GSS_KRB5_CCACHE_NAME, 1, [Define this if the Kerberos GSS library supports gss_krb5_ccache_name]), ,$KRBLIBS) | ||
3876 | 95 | |||
3877 | 96 | dnl Check for newer error message facility | ||
3878 | 97 | AC_CHECK_LIB($gssapi_lib, krb5_get_error_message, | ||
3879 | 98 | AC_DEFINE(HAVE_KRB5_GET_ERROR_MESSAGE, 1, [Define this if the function krb5_get_error_message is available]), ,$KRBLIBS) | ||
3880 | 99 | |||
3881 | 100 | dnl Check for function to specify addressless tickets | ||
3882 | 101 | AC_CHECK_LIB($gssapi_lib, krb5_get_init_creds_opt_set_addressless, | ||
3883 | 102 | AC_DEFINE(HAVE_KRB5_GET_INIT_CREDS_OPT_SET_ADDRESSLESS, 1, [Define this if the function krb5_get_init_creds_opt_set_addressless is available]), ,$KRBLIBS) | ||
3884 | 103 | |||
3885 | 104 | dnl If they specified a directory and it didn't work, give them a warning | ||
3886 | 105 | if test "x$krb5_with" != "x" -a "$krb5_with" != "$KRBDIR"; then | ||
3887 | 106 | AC_MSG_WARN(Using $KRBDIR instead of requested value of $krb5_with for Kerberos!) | ||
3888 | 107 | fi | ||
3889 | 108 | |||
3890 | 109 | AC_SUBST([KRBDIR]) | ||
3891 | 110 | AC_SUBST([KRBLIBS]) | ||
3892 | 111 | AC_SUBST([KRBCFLAGS]) | ||
3893 | 112 | AC_SUBST([KRBLDFLAGS]) | ||
3894 | 113 | AC_SUBST([K5VERS]) | ||
3895 | 114 | |||
3896 | 115 | ]) | ||
3897 | 116 | 0 | ||
3898 | === removed directory '.pc/18-osd_login-sbindir.patch' | |||
3899 | === removed directory '.pc/18-osd_login-sbindir.patch/utils' | |||
3900 | === removed directory '.pc/18-osd_login-sbindir.patch/utils/osd_login' | |||
3901 | === removed file '.pc/18-osd_login-sbindir.patch/utils/osd_login/Makefile.am' | |||
3902 | --- .pc/18-osd_login-sbindir.patch/utils/osd_login/Makefile.am 2012-06-22 15:04:56 +0000 | |||
3903 | +++ .pc/18-osd_login-sbindir.patch/utils/osd_login/Makefile.am 1970-01-01 00:00:00 +0000 | |||
3904 | @@ -1,12 +0,0 @@ | |||
3905 | 1 | ## Process this file with automake to produce Makefile.in | ||
3906 | 2 | |||
3907 | 3 | OSD_LOGIN_FILES= osd_login | ||
3908 | 4 | |||
3909 | 5 | EXTRA_DIST= $(OSD_LOGIN_FILES) | ||
3910 | 6 | |||
3911 | 7 | all-local: $(OSD_LOGIN_FILES) | ||
3912 | 8 | |||
3913 | 9 | install-data-hook: | ||
3914 | 10 | $(INSTALL) --mode 755 osd_login $(DESTDIR)/sbin/osd_login | ||
3915 | 11 | |||
3916 | 12 | MAINTAINERCLEANFILES = Makefile.in | ||
3917 | 13 | 0 | ||
3918 | === removed directory '.pc/19-iscsiadm-path.patch' | |||
3919 | === removed directory '.pc/19-iscsiadm-path.patch/utils' | |||
3920 | === removed directory '.pc/19-iscsiadm-path.patch/utils/osd_login' | |||
3921 | === removed file '.pc/19-iscsiadm-path.patch/utils/osd_login/osd_login' | |||
3922 | --- .pc/19-iscsiadm-path.patch/utils/osd_login/osd_login 2012-06-22 15:04:56 +0000 | |||
3923 | +++ .pc/19-iscsiadm-path.patch/utils/osd_login/osd_login 1970-01-01 00:00:00 +0000 | |||
3924 | @@ -1,118 +0,0 @@ | |||
3925 | 1 | #!/bin/bash | ||
3926 | 2 | # | ||
3927 | 3 | # osd_login : This script is part of the autologin feature | ||
3928 | 4 | # mandated by the pnfs-objects standard. | ||
3929 | 5 | # It is called from objlayoutdriver.ko in the kernel. | ||
3930 | 6 | |||
3931 | 7 | # Copyright (C) 2012, Sachin Bhamare <sbhamare@panasas.com> | ||
3932 | 8 | # Copyright (C) 2012, Boaz Harrosh <bharrosh@panasas.com> | ||
3933 | 9 | # | ||
3934 | 10 | # This program is free software; you can redistribute it and/or modify | ||
3935 | 11 | # it under the terms of the GNU General Public License version 2 as | ||
3936 | 12 | # published by the Free Software Foundation. | ||
3937 | 13 | # | ||
3938 | 14 | # This program is distributed in the hope that it will be useful, | ||
3939 | 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3940 | 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3941 | 17 | # GNU General Public License for more details. | ||
3942 | 18 | # | ||
3943 | 19 | # You should have received a copy of the GNU General Public License | ||
3944 | 20 | # along with this program; if not, write to the Free Software | ||
3945 | 21 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
3946 | 22 | # MA 02110-1301 USA | ||
3947 | 23 | |||
3948 | 24 | umask 022 | ||
3949 | 25 | |||
3950 | 26 | PATH="/sbin:/usr/sbin:/bin:/usr/bin" | ||
3951 | 27 | |||
3952 | 28 | iscsiadm=/sbin/iscsiadm | ||
3953 | 29 | |||
3954 | 30 | PARENT_PID=$BASHPID | ||
3955 | 31 | WATCHDOG_TIMEOUT=15 | ||
3956 | 32 | |||
3957 | 33 | protocol="" | ||
3958 | 34 | portal="" | ||
3959 | 35 | uri="" | ||
3960 | 36 | osdname="" | ||
3961 | 37 | systemid="" | ||
3962 | 38 | |||
3963 | 39 | usage() | ||
3964 | 40 | { | ||
3965 | 41 | echo "Usage: $0 -u <URI> -o <OSDNAME> -s <SYSTEMID>" | ||
3966 | 42 | echo "Options:" | ||
3967 | 43 | echo "-u target uri e.g. iscsi://<ip>:<port>" | ||
3968 | 44 | echo "-o osdname of the target OSD" | ||
3969 | 45 | echo "-s systemid of the target OSD" | ||
3970 | 46 | } | ||
3971 | 47 | |||
3972 | 48 | parse_cmdline() | ||
3973 | 49 | { | ||
3974 | 50 | argc=$# | ||
3975 | 51 | if [ $# -lt 3 ]; then | ||
3976 | 52 | usage | ||
3977 | 53 | exit 1 | ||
3978 | 54 | fi | ||
3979 | 55 | |||
3980 | 56 | # parse the input arguments | ||
3981 | 57 | while getopts "u:o:s:" options; do | ||
3982 | 58 | case $options in | ||
3983 | 59 | u ) uri=$OPTARG;; | ||
3984 | 60 | o ) osdname=$OPTARG;; | ||
3985 | 61 | s ) systemid=$OPTARG;; | ||
3986 | 62 | \? ) usage | ||
3987 | 63 | exit 1;; | ||
3988 | 64 | * ) usage | ||
3989 | 65 | exit 1;; | ||
3990 | 66 | esac | ||
3991 | 67 | done | ||
3992 | 68 | |||
3993 | 69 | echo "-u : $uri" | ||
3994 | 70 | echo "-o : $osdname" | ||
3995 | 71 | echo "-s : $systemid" | ||
3996 | 72 | |||
3997 | 73 | protocol=`echo $uri | awk -F ':' '{print $1}'` | ||
3998 | 74 | portal=`echo $uri | awk -F '//' '{print $2}'` | ||
3999 | 75 | } | ||
4000 | 76 | |||
4001 | 77 | watchdog() | ||
4002 | 78 | { | ||
4003 | 79 | timeout=$1 | ||
4004 | 80 | portal=$2 | ||
4005 | 81 | |||
4006 | 82 | sleep $timeout | ||
4007 | 83 | if kill -9 $PARENT_PID; then | ||
4008 | 84 | echo "watchdog : Timed out (>$timeout seconds) while login into $portal" | logger -t "osd_login" | ||
4009 | 85 | fi | ||
4010 | 86 | echo "watchdog: exiting .." | ||
4011 | 87 | exit 2 | ||
4012 | 88 | } | ||
4013 | 89 | |||
4014 | 90 | login_iscsi_osd() | ||
4015 | 91 | { | ||
4016 | 92 | echo "login into: $1" | ||
4017 | 93 | if ! $iscsiadm -m discovery -o nonpersistent -t sendtargets -p $1 --login; then | ||
4018 | 94 | echo "$iscsiadm -m discovery -t sendtargets -p $1 --login returned error $? !" | ||
4019 | 95 | sleep 1; | ||
4020 | 96 | fi | ||
4021 | 97 | } | ||
4022 | 98 | |||
4023 | 99 | echo "============= osd_login =========" | ||
4024 | 100 | echo "progname : $0" | ||
4025 | 101 | parse_cmdline "$@" | ||
4026 | 102 | echo "protocol: $protocol" | ||
4027 | 103 | echo "portal: $portal" | ||
4028 | 104 | |||
4029 | 105 | watchdog $WATCHDOG_TIMEOUT $portal & | ||
4030 | 106 | watchdog_pid=$! | ||
4031 | 107 | |||
4032 | 108 | case $protocol in | ||
4033 | 109 | iscsi) | ||
4034 | 110 | login_iscsi_osd $portal |& logger -t "osd_login" | ||
4035 | 111 | ;; | ||
4036 | 112 | *) | ||
4037 | 113 | echo "Error: protocol $protocol not supported !" | logger -t "osd_login" | ||
4038 | 114 | ;; | ||
4039 | 115 | esac | ||
4040 | 116 | |||
4041 | 117 | kill -9 $watchdog_pid | ||
4042 | 118 | exit 0 | ||
4043 | 119 | 0 | ||
4044 | === removed file '.pc/applied-patches' | |||
4045 | --- .pc/applied-patches 2012-06-22 15:04:56 +0000 | |||
4046 | +++ .pc/applied-patches 1970-01-01 00:00:00 +0000 | |||
4047 | @@ -1,8 +0,0 @@ | |||
4048 | 1 | 01-sm-notify-in-sbin.patch | ||
4049 | 2 | 02-524255-manpages.patch | ||
4050 | 3 | 03-handle-mtab-symlink.patch | ||
4051 | 4 | 11-532048-reduce-verbosity.patch | ||
4052 | 5 | 16-mount.nfs.man-update-distinction-between-fstype.patch | ||
4053 | 6 | 17-multiarch-kerberos-paths.patch | ||
4054 | 7 | 18-osd_login-sbindir.patch | ||
4055 | 8 | 19-iscsiadm-path.patch | ||
4056 | 9 | 0 | ||
4057 | === modified file 'aclocal/kerberos5.m4' | |||
4058 | --- aclocal/kerberos5.m4 2012-06-22 15:04:56 +0000 | |||
4059 | +++ aclocal/kerberos5.m4 2012-08-05 05:01:18 +0000 | |||
4060 | @@ -29,7 +29,6 @@ | |||
4061 | 29 | elif test -f "/usr/lib/mit/bin/krb5-config"; then | 29 | elif test -f "/usr/lib/mit/bin/krb5-config"; then |
4062 | 30 | K5CONFIG="/usr/lib/mit/bin/krb5-config" | 30 | K5CONFIG="/usr/lib/mit/bin/krb5-config" |
4063 | 31 | fi | 31 | fi |
4064 | 32 | MULTIARCH=`dpkg-architecture -qDEB_HOST_MULTIARCH 2>/dev/null || true` | ||
4065 | 33 | if test "$K5CONFIG" != ""; then | 32 | if test "$K5CONFIG" != ""; then |
4066 | 34 | KRBCFLAGS=`$K5CONFIG --cflags` | 33 | KRBCFLAGS=`$K5CONFIG --cflags` |
4067 | 35 | KRBLIBS=`$K5CONFIG --libs` | 34 | KRBLIBS=`$K5CONFIG --libs` |
4068 | @@ -39,7 +38,6 @@ | |||
4069 | 39 | \( -f $dir/lib/libgssapi_krb5.a -o \ | 38 | \( -f $dir/lib/libgssapi_krb5.a -o \ |
4070 | 40 | -f $dir/lib64/libgssapi_krb5.a -o \ | 39 | -f $dir/lib64/libgssapi_krb5.a -o \ |
4071 | 41 | -f $dir/lib64/libgssapi_krb5.so -o \ | 40 | -f $dir/lib64/libgssapi_krb5.so -o \ |
4072 | 42 | -f $dir/lib/$MULTIARCH/libgssapi_krb5.so -o \ | ||
4073 | 43 | -f $dir/lib/libgssapi_krb5.so \) ; then | 41 | -f $dir/lib/libgssapi_krb5.so \) ; then |
4074 | 44 | AC_DEFINE(HAVE_KRB5, 1, [Define this if you have MIT Kerberos libraries]) | 42 | AC_DEFINE(HAVE_KRB5, 1, [Define this if you have MIT Kerberos libraries]) |
4075 | 45 | KRBDIR="$dir" | 43 | KRBDIR="$dir" |
4076 | 46 | 44 | ||
4077 | === modified file 'debian/changelog' | |||
4078 | --- debian/changelog 2012-06-22 18:25:32 +0000 | |||
4079 | +++ debian/changelog 2012-08-05 05:01:18 +0000 | |||
4080 | @@ -1,3 +1,30 @@ | |||
4081 | 1 | nfs-utils (1:1.2.6-3ubuntu1) quantal; urgency=low | ||
4082 | 2 | |||
4083 | 3 | * Merge from Debian unstable. Remaining changes: | ||
4084 | 4 | - debian/nfs-common.{statd,statd-mounting,gssd,idmapd}.upstart, | ||
4085 | 5 | debian/control, debian/nfs-common.{preinst,postinst,prerm,postrm}, | ||
4086 | 6 | debian/rules: drop nfs-common init script in favor of upstart jobs, | ||
4087 | 7 | and build-depend on debhelper (>= 7.3.15ubuntu3) for correct upstart | ||
4088 | 8 | init handling. | ||
4089 | 9 | - Depend on rpcbind (>= 0.2.0-6ubuntu1) for upstart support. | ||
4090 | 10 | - debian/nfs-kernel-server.postinst: don't call "invoke-rc.d nfs-common" | ||
4091 | 11 | in the postinst, this is redundant anyway and the nfs-common init script | ||
4092 | 12 | is gone now. | ||
4093 | 13 | - nfs-kernel-server.init: Unmount nfsd fs when init script stops | ||
4094 | 14 | - Allow issuing options to rpc.nfsd | ||
4095 | 15 | - debian/nfs-common.defaults: always start idmapd automatically; drop | ||
4096 | 16 | the configuration option. | ||
4097 | 17 | - Move /var/lib/nfs/rpc_pipefs to /run/rpc_pipefs. This does not belong | ||
4098 | 18 | in /var/lib. | ||
4099 | 19 | |||
4100 | 20 | -- Logan Rosen <logatronico@gmail.com> Sun, 05 Aug 2012 00:56:05 -0400 | ||
4101 | 21 | |||
4102 | 22 | nfs-utils (1:1.2.6-3) unstable; urgency=low | ||
4103 | 23 | |||
4104 | 24 | * Iterate through exports.d to look for expors (Closes: #676604). | ||
4105 | 25 | |||
4106 | 26 | -- Luk Claes <luk@zomers.be> Tue, 10 Jul 2012 19:38:22 +0200 | ||
4107 | 27 | |||
4108 | 1 | nfs-utils (1:1.2.6-2ubuntu1) quantal; urgency=low | 28 | nfs-utils (1:1.2.6-2ubuntu1) quantal; urgency=low |
4109 | 2 | 29 | ||
4110 | 3 | * Merge from Debian unstable, remaining changes: | 30 | * Merge from Debian unstable, remaining changes: |
4111 | 4 | 31 | ||
4112 | === modified file 'debian/nfs-kernel-server.init' | |||
4113 | --- debian/nfs-kernel-server.init 2012-06-22 15:04:56 +0000 | |||
4114 | +++ debian/nfs-kernel-server.init 2012-08-05 05:01:18 +0000 | |||
4115 | @@ -61,7 +61,13 @@ | |||
4116 | 61 | # See how we were called. | 61 | # See how we were called. |
4117 | 62 | case "$1" in | 62 | case "$1" in |
4118 | 63 | start) | 63 | start) |
4120 | 64 | if [ -f /etc/exports ] && grep -q '^[[:space:]]*[^#]*/' /etc/exports | 64 | export_files="/etc/exports" |
4121 | 65 | for file in /etc/exports.d/*.exports ; do | ||
4122 | 66 | if [ -f "$file" ]; then | ||
4123 | 67 | export_files="$export_files $file" | ||
4124 | 68 | fi | ||
4125 | 69 | done | ||
4126 | 70 | if [ -f /etc/exports ] && grep -q '^[[:space:]]*[^#]*/' $export_files | ||
4127 | 65 | then | 71 | then |
4128 | 66 | do_modprobe nfsd | 72 | do_modprobe nfsd |
4129 | 67 | 73 | ||
4130 | 68 | 74 | ||
4131 | === modified file 'utils/exportfs/nfsd.man' | |||
4132 | --- utils/exportfs/nfsd.man 2012-05-25 20:41:58 +0000 | |||
4133 | +++ utils/exportfs/nfsd.man 2012-08-05 05:01:18 +0000 | |||
4134 | @@ -196,7 +196,6 @@ | |||
4135 | 196 | find out what number correspond to what tracing. | 196 | find out what number correspond to what tracing. |
4136 | 197 | 197 | ||
4137 | 198 | .SH SEE ALSO | 198 | .SH SEE ALSO |
4138 | 199 | .BR nfsd (8), | ||
4139 | 200 | .BR rpc.nfsd (8), | 199 | .BR rpc.nfsd (8), |
4140 | 201 | .BR exports (5), | 200 | .BR exports (5), |
4141 | 202 | .BR nfsstat (8), | 201 | .BR nfsstat (8), |
4142 | 203 | 202 | ||
4143 | === modified file 'utils/gssd/gss_util.c' | |||
4144 | --- utils/gssd/gss_util.c 2011-07-09 16:28:32 +0000 | |||
4145 | +++ utils/gssd/gss_util.c 2012-08-05 05:01:18 +0000 | |||
4146 | @@ -126,7 +126,7 @@ | |||
4147 | 126 | "gss_display_status called from %s\n", m); | 126 | "gss_display_status called from %s\n", m); |
4148 | 127 | break; | 127 | break; |
4149 | 128 | } else { | 128 | } else { |
4151 | 129 | printerr(2, "ERROR: GSS-API: (%s) error in %s(): %s\n", | 129 | printerr(0, "ERROR: GSS-API: (%s) error in %s(): %s\n", |
4152 | 130 | typestr, m, (char *)msg.value); | 130 | typestr, m, (char *)msg.value); |
4153 | 131 | } | 131 | } |
4154 | 132 | 132 | ||
4155 | 133 | 133 | ||
4156 | === modified file 'utils/gssd/gssd_proc.c' | |||
4157 | --- utils/gssd/gssd_proc.c 2012-05-25 20:41:58 +0000 | |||
4158 | +++ utils/gssd/gssd_proc.c 2012-08-05 05:01:18 +0000 | |||
4159 | @@ -676,7 +676,7 @@ | |||
4160 | 676 | unsigned int timeout = 0; | 676 | unsigned int timeout = 0; |
4161 | 677 | int zero = 0; | 677 | int zero = 0; |
4162 | 678 | 678 | ||
4164 | 679 | printerr(2, "doing error downcall\n"); | 679 | printerr(1, "doing error downcall\n"); |
4165 | 680 | 680 | ||
4166 | 681 | if (WRITE_BYTES(&p, end, uid)) goto out_err; | 681 | if (WRITE_BYTES(&p, end, uid)) goto out_err; |
4167 | 682 | if (WRITE_BYTES(&p, end, timeout)) goto out_err; | 682 | if (WRITE_BYTES(&p, end, timeout)) goto out_err; |
4168 | @@ -953,7 +953,7 @@ | |||
4169 | 953 | int create_resp = -1; | 953 | int create_resp = -1; |
4170 | 954 | int err, downcall_err = -EACCES; | 954 | int err, downcall_err = -EACCES; |
4171 | 955 | 955 | ||
4173 | 956 | printerr(2, "handling krb5 upcall (%s)\n", clp->dirname); | 956 | printerr(1, "handling krb5 upcall (%s)\n", clp->dirname); |
4174 | 957 | 957 | ||
4175 | 958 | if (tgtname) { | 958 | if (tgtname) { |
4176 | 959 | if (clp->servicename) { | 959 | if (clp->servicename) { |
4177 | @@ -1071,7 +1071,7 @@ | |||
4178 | 1071 | } | 1071 | } |
4179 | 1072 | 1072 | ||
4180 | 1073 | if (!authgss_get_private_data(auth, &pd)) { | 1073 | if (!authgss_get_private_data(auth, &pd)) { |
4182 | 1074 | printerr(2, "WARNING: Failed to obtain authentication " | 1074 | printerr(1, "WARNING: Failed to obtain authentication " |
4183 | 1075 | "data for user with uid %d for server %s\n", | 1075 | "data for user with uid %d for server %s\n", |
4184 | 1076 | uid, clp->servername); | 1076 | uid, clp->servername); |
4185 | 1077 | goto out_return_error; | 1077 | goto out_return_error; |
4186 | 1078 | 1078 | ||
4187 | === modified file 'utils/mount/fstab.c' | |||
4188 | --- utils/mount/fstab.c 2011-10-02 18:29:53 +0000 | |||
4189 | +++ utils/mount/fstab.c 2012-08-05 05:01:18 +0000 | |||
4190 | @@ -57,7 +57,7 @@ | |||
4191 | 57 | return var_mtab_does_not_exist; | 57 | return var_mtab_does_not_exist; |
4192 | 58 | } | 58 | } |
4193 | 59 | 59 | ||
4195 | 60 | int | 60 | static int |
4196 | 61 | mtab_is_a_symlink(void) { | 61 | mtab_is_a_symlink(void) { |
4197 | 62 | get_mtab_info(); | 62 | get_mtab_info(); |
4198 | 63 | return var_mtab_is_a_symlink; | 63 | return var_mtab_is_a_symlink; |
4199 | 64 | 64 | ||
4200 | === modified file 'utils/mount/fstab.h' | |||
4201 | --- utils/mount/fstab.h 2011-10-02 18:29:53 +0000 | |||
4202 | +++ utils/mount/fstab.h 2012-08-05 05:01:18 +0000 | |||
4203 | @@ -7,7 +7,6 @@ | |||
4204 | 7 | #define _PATH_FSTAB "/etc/fstab" | 7 | #define _PATH_FSTAB "/etc/fstab" |
4205 | 8 | #endif | 8 | #endif |
4206 | 9 | 9 | ||
4207 | 10 | int mtab_is_a_symlink(void); | ||
4208 | 11 | int mtab_is_writable(void); | 10 | int mtab_is_writable(void); |
4209 | 12 | int mtab_does_not_exist(void); | 11 | int mtab_does_not_exist(void); |
4210 | 13 | void reset_mtab_info(void); | 12 | void reset_mtab_info(void); |
4211 | 14 | 13 | ||
4212 | === modified file 'utils/mount/mount.c' | |||
4213 | --- utils/mount/mount.c 2011-07-09 16:28:32 +0000 | |||
4214 | +++ utils/mount/mount.c 2012-08-05 05:01:18 +0000 | |||
4215 | @@ -203,13 +203,6 @@ | |||
4216 | 203 | int flags; | 203 | int flags; |
4217 | 204 | mntFILE *mfp; | 204 | mntFILE *mfp; |
4218 | 205 | 205 | ||
4219 | 206 | /* Avoid writing if the mtab is a symlink to /proc/mounts, since | ||
4220 | 207 | that would create a file /proc/mounts in case the proc filesystem | ||
4221 | 208 | is not mounted, and the fchmod below would also fail. */ | ||
4222 | 209 | if (mtab_is_a_symlink()) { | ||
4223 | 210 | return EX_SUCCESS; | ||
4224 | 211 | } | ||
4225 | 212 | |||
4226 | 213 | lock_mtab(); | 206 | lock_mtab(); |
4227 | 214 | 207 | ||
4228 | 215 | mfp = nfs_setmntent (MOUNTED, "a+"); | 208 | mfp = nfs_setmntent (MOUNTED, "a+"); |
4229 | 216 | 209 | ||
4230 | === modified file 'utils/mount/mount.nfs.man' | |||
4231 | --- utils/mount/mount.nfs.man 2011-03-16 23:10:15 +0000 | |||
4232 | +++ utils/mount/mount.nfs.man 2012-08-05 05:01:18 +0000 | |||
4233 | @@ -15,20 +15,16 @@ | |||
4234 | 15 | .BR mount (8) | 15 | .BR mount (8) |
4235 | 16 | command for mounting NFS shares. This subcommand, however, can also be used as a standalone command with limited functionality. | 16 | command for mounting NFS shares. This subcommand, however, can also be used as a standalone command with limited functionality. |
4236 | 17 | 17 | ||
4237 | 18 | .BR mount.nfs4 | ||
4238 | 19 | is used for mounting NFSv4 file system, while | ||
4239 | 20 | .BR mount.nfs | ||
4240 | 21 | is used to mount NFS file systems versions 3 or 2. | ||
4241 | 18 | .I remotetarget | 22 | .I remotetarget |
4242 | 19 | is a server share usually in the form of | 23 | is a server share usually in the form of |
4243 | 20 | .BR servername:/path/to/share. | 24 | .BR servername:/path/to/share. |
4244 | 21 | .I dir | 25 | .I dir |
4245 | 22 | is the directory on which the file system is to be mounted. | 26 | is the directory on which the file system is to be mounted. |
4246 | 23 | 27 | ||
4247 | 24 | Under Linux 2.6.32 and later kernel versions, | ||
4248 | 25 | .BR mount.nfs | ||
4249 | 26 | can mount all NFS file system versions. Under earlier Linux kernel versions, | ||
4250 | 27 | .BR mount.nfs4 | ||
4251 | 28 | must be used for mounting NFSv4 file systems while | ||
4252 | 29 | .BR mount.nfs | ||
4253 | 30 | must be used for NFSv3 and v2. | ||
4254 | 31 | |||
4255 | 32 | .SH OPTIONS | 28 | .SH OPTIONS |
4256 | 33 | .TP | 29 | .TP |
4257 | 34 | .BI "\-r" | 30 | .BI "\-r" |
4258 | 35 | 31 | ||
4259 | === modified file 'utils/nfsd/nfsd.man' | |||
4260 | --- utils/nfsd/nfsd.man 2012-05-25 20:41:58 +0000 | |||
4261 | +++ utils/nfsd/nfsd.man 2012-08-05 05:01:18 +0000 | |||
4262 | @@ -94,7 +94,6 @@ | |||
4263 | 94 | database. | 94 | database. |
4264 | 95 | 95 | ||
4265 | 96 | .SH SEE ALSO | 96 | .SH SEE ALSO |
4266 | 97 | .BR nfsd (7), | ||
4267 | 98 | .BR rpc.mountd (8), | 97 | .BR rpc.mountd (8), |
4268 | 99 | .BR exports (5), | 98 | .BR exports (5), |
4269 | 100 | .BR exportfs (8), | 99 | .BR exportfs (8), |
4270 | 101 | 100 | ||
4271 | === modified file 'utils/osd_login/Makefile.am' | |||
4272 | --- utils/osd_login/Makefile.am 2012-05-25 20:41:58 +0000 | |||
4273 | +++ utils/osd_login/Makefile.am 2012-08-05 05:01:18 +0000 | |||
4274 | @@ -1,9 +1,12 @@ | |||
4275 | 1 | ## Process this file with automake to produce Makefile.in | 1 | ## Process this file with automake to produce Makefile.in |
4276 | 2 | 2 | ||
4282 | 3 | # These binaries go in /sbin (not /usr/sbin), and that cannot be | 3 | OSD_LOGIN_FILES= osd_login |
4283 | 4 | # overridden at config time. | 4 | |
4284 | 5 | sbindir = /sbin | 5 | EXTRA_DIST= $(OSD_LOGIN_FILES) |
4285 | 6 | 6 | ||
4286 | 7 | sbin_SCRIPTS = osd_login | 7 | all-local: $(OSD_LOGIN_FILES) |
4287 | 8 | |||
4288 | 9 | install-data-hook: | ||
4289 | 10 | $(INSTALL) --mode 755 osd_login $(DESTDIR)/sbin/osd_login | ||
4290 | 8 | 11 | ||
4291 | 9 | MAINTAINERCLEANFILES = Makefile.in | 12 | MAINTAINERCLEANFILES = Makefile.in |
4292 | 10 | 13 | ||
4293 | === modified file 'utils/osd_login/osd_login' | |||
4294 | --- utils/osd_login/osd_login 2012-05-25 20:41:58 +0000 | |||
4295 | +++ utils/osd_login/osd_login 2012-08-05 05:01:18 +0000 | |||
4296 | @@ -25,6 +25,8 @@ | |||
4297 | 25 | 25 | ||
4298 | 26 | PATH="/sbin:/usr/sbin:/bin:/usr/bin" | 26 | PATH="/sbin:/usr/sbin:/bin:/usr/bin" |
4299 | 27 | 27 | ||
4300 | 28 | iscsiadm=/sbin/iscsiadm | ||
4301 | 29 | |||
4302 | 28 | PARENT_PID=$BASHPID | 30 | PARENT_PID=$BASHPID |
4303 | 29 | WATCHDOG_TIMEOUT=15 | 31 | WATCHDOG_TIMEOUT=15 |
4304 | 30 | 32 | ||
4305 | @@ -88,8 +90,8 @@ | |||
4306 | 88 | login_iscsi_osd() | 90 | login_iscsi_osd() |
4307 | 89 | { | 91 | { |
4308 | 90 | echo "login into: $1" | 92 | echo "login into: $1" |
4311 | 91 | if ! iscsiadm -m discovery -o nonpersistent -t sendtargets -p $1 --login; then | 93 | if ! $iscsiadm -m discovery -o nonpersistent -t sendtargets -p $1 --login; then |
4312 | 92 | echo "iscsiadm -m discovery -t sendtargets -p $1 --login returned error $? !" | 94 | echo "$iscsiadm -m discovery -t sendtargets -p $1 --login returned error $? !" |
4313 | 93 | sleep 1; | 95 | sleep 1; |
4314 | 94 | fi | 96 | fi |
4315 | 95 | } | 97 | } |
4316 | 96 | 98 | ||
4317 | === modified file 'utils/statd/statd.c' | |||
4318 | --- utils/statd/statd.c 2010-04-06 16:11:22 +0000 | |||
4319 | +++ utils/statd/statd.c 2012-08-05 05:01:18 +0000 | |||
4320 | @@ -190,7 +190,7 @@ | |||
4321 | 190 | char *av[6]; | 190 | char *av[6]; |
4322 | 191 | int ac = 0; | 191 | int ac = 0; |
4323 | 192 | 192 | ||
4325 | 193 | av[ac++] = "/sbin/sm-notify"; | 193 | av[ac++] = "/usr/sbin/sm-notify"; |
4326 | 194 | if (run_mode & MODE_NODAEMON) | 194 | if (run_mode & MODE_NODAEMON) |
4327 | 195 | av[ac++] = "-d"; | 195 | av[ac++] = "-d"; |
4328 | 196 | if (outport) { | 196 | if (outport) { |
Thanks for your work.