Lines 206-212
Link Here
|
206 |
void out_of_mem(void); |
206 |
void out_of_mem(void); |
207 |
void parsecred(char *, struct xucred *); |
207 |
void parsecred(char *, struct xucred *); |
208 |
int parsesec(char *, struct exportlist *); |
208 |
int parsesec(char *, struct exportlist *); |
209 |
int put_exlist(struct dirlist *, XDR *, struct dirlist *, int *, int); |
209 |
int put_exlist(struct dirlist *, XDR *, struct dirlist *, int *, int, |
|
|
210 |
struct sockaddr *saddr); |
210 |
void *sa_rawaddr(struct sockaddr *sa, int *nbytes); |
211 |
void *sa_rawaddr(struct sockaddr *sa, int *nbytes); |
211 |
int sacmp(struct sockaddr *sa1, struct sockaddr *sa2, |
212 |
int sacmp(struct sockaddr *sa1, struct sockaddr *sa2, |
212 |
struct sockaddr *samask); |
213 |
struct sockaddr *samask); |
Lines 241-246
Link Here
|
241 |
int got_sighup = 0; |
242 |
int got_sighup = 0; |
242 |
int xcreated = 0; |
243 |
int xcreated = 0; |
243 |
|
244 |
|
|
|
245 |
int restrict_exports = 0; |
246 |
#define EXP_VIS 0x00 /* showmount unrestricted */ |
247 |
#define EXP_HIDDEN 0x01 /* all exports hidden */ |
248 |
#define EXP_HOST 0x02 /* show only client's exports */ |
249 |
|
244 |
char *svcport_str = NULL; |
250 |
char *svcport_str = NULL; |
245 |
static int mallocd_svcport = 0; |
251 |
static int mallocd_svcport = 0; |
246 |
static int *sock_fd; |
252 |
static int *sock_fd; |
Lines 312-318
Link Here
|
312 |
else |
318 |
else |
313 |
close(s); |
319 |
close(s); |
314 |
|
320 |
|
315 |
while ((c = getopt(argc, argv, "2deh:lnop:rS")) != -1) |
321 |
while ((c = getopt(argc, argv, "2deh:lnop:rSx:")) != -1) |
316 |
switch (c) { |
322 |
switch (c) { |
317 |
case '2': |
323 |
case '2': |
318 |
force_v2 = 1; |
324 |
force_v2 = 1; |
Lines 367-372
Link Here
|
367 |
case 'S': |
373 |
case 'S': |
368 |
suspend_nfsd = 1; |
374 |
suspend_nfsd = 1; |
369 |
break; |
375 |
break; |
|
|
376 |
case 'x': |
377 |
if (strcmp(optarg, "host") == 0) |
378 |
restrict_exports = EXP_HOST; |
379 |
else if (strcmp(optarg, "hide") == 0) |
380 |
restrict_exports = EXP_HIDDEN; |
381 |
else if (strcmp(optarg, "visible") != 0) |
382 |
usage(); |
383 |
break; |
370 |
default: |
384 |
default: |
371 |
usage(); |
385 |
usage(); |
372 |
}; |
386 |
}; |
Lines 925-931
Link Here
|
925 |
{ |
939 |
{ |
926 |
fprintf(stderr, |
940 |
fprintf(stderr, |
927 |
"usage: mountd [-2] [-d] [-e] [-l] [-n] [-p <port>] [-r] " |
941 |
"usage: mountd [-2] [-d] [-e] [-l] [-n] [-p <port>] [-r] " |
928 |
"[-S] [-h <bindip>] [export_file ...]\n"); |
942 |
"[-S] [-x <exportsopt>] [-h <bindip>] [export_file ...]\n"); |
929 |
exit(1); |
943 |
exit(1); |
930 |
} |
944 |
} |
931 |
|
945 |
|
Lines 1071-1082
Link Here
|
1071 |
sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL); |
1085 |
sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL); |
1072 |
return; |
1086 |
return; |
1073 |
case MOUNTPROC_DUMP: |
1087 |
case MOUNTPROC_DUMP: |
1074 |
if (!svc_sendreply(transp, (xdrproc_t)xdr_mlist, (caddr_t)NULL)) |
1088 |
if (restrict_exports != EXP_HIDDEN) { |
1075 |
syslog(LOG_ERR, "can't send reply"); |
1089 |
if (!svc_sendreply(transp, (xdrproc_t)xdr_mlist, |
1076 |
else if (dolog) |
1090 |
(caddr_t)(!restrict_exports ? NULL : |
|
|
1091 |
(lookup_failed ? &numerichost : &host)))) |
1092 |
syslog(LOG_ERR, "can't send reply"); |
1093 |
else if (dolog) |
1094 |
syslog(LOG_NOTICE, |
1095 |
"dump request succeeded from %s", |
1096 |
numerichost); |
1097 |
} else { |
1098 |
if (!svc_sendreply(transp, (xdrproc_t)xdr_void, NULL)) |
1099 |
syslog(LOG_ERR, "can't send reply"); |
1077 |
syslog(LOG_NOTICE, |
1100 |
syslog(LOG_NOTICE, |
1078 |
"dump request succeeded from %s", |
1101 |
"dump request denied from %s", |
1079 |
numerichost); |
1102 |
numerichost); |
|
|
1103 |
} |
1080 |
return; |
1104 |
return; |
1081 |
case MOUNTPROC_UMNT: |
1105 |
case MOUNTPROC_UMNT: |
1082 |
if (sport >= IPPORT_RESERVED && resvport_only) { |
1106 |
if (sport >= IPPORT_RESERVED && resvport_only) { |
Lines 1126-1139
Link Here
|
1126 |
numerichost); |
1150 |
numerichost); |
1127 |
return; |
1151 |
return; |
1128 |
case MOUNTPROC_EXPORT: |
1152 |
case MOUNTPROC_EXPORT: |
1129 |
if (!svc_sendreply(transp, (xdrproc_t)xdr_explist, (caddr_t)NULL)) |
1153 |
if (restrict_exports != EXP_HIDDEN) { |
1130 |
if (!svc_sendreply(transp, (xdrproc_t)xdr_explist_brief, |
1154 |
if (!svc_sendreply(transp, (xdrproc_t)xdr_explist, |
1131 |
(caddr_t)NULL)) |
1155 |
(caddr_t)(!restrict_exports ? NULL : saddr))) |
|
|
1156 |
if (!svc_sendreply(transp, |
1157 |
(xdrproc_t)xdr_explist_brief, |
1158 |
(caddr_t)(!restrict_exports ? NULL : |
1159 |
saddr))) |
1160 |
syslog(LOG_ERR, "can't send reply"); |
1161 |
if (dolog) |
1162 |
syslog(LOG_NOTICE, |
1163 |
"export request succeeded from %s", |
1164 |
numerichost); |
1165 |
} else { |
1166 |
if (!svc_sendreply(transp, (xdrproc_t)xdr_void, NULL)) |
1132 |
syslog(LOG_ERR, "can't send reply"); |
1167 |
syslog(LOG_ERR, "can't send reply"); |
1133 |
if (dolog) |
|
|
1134 |
syslog(LOG_NOTICE, |
1168 |
syslog(LOG_NOTICE, |
1135 |
"export request succeeded from %s", |
1169 |
"export request denied from %s", |
1136 |
numerichost); |
1170 |
numerichost); |
|
|
1171 |
} |
1137 |
return; |
1172 |
return; |
1138 |
default: |
1173 |
default: |
1139 |
svcerr_noproc(transp); |
1174 |
svcerr_noproc(transp); |
Lines 1190-1196
Link Here
|
1190 |
} |
1225 |
} |
1191 |
|
1226 |
|
1192 |
int |
1227 |
int |
1193 |
xdr_mlist(XDR *xdrsp, caddr_t cp __unused) |
1228 |
xdr_mlist(XDR *xdrsp, caddr_t cp) |
1194 |
{ |
1229 |
{ |
1195 |
struct mountlist *mlp; |
1230 |
struct mountlist *mlp; |
1196 |
int true = 1; |
1231 |
int true = 1; |
Lines 1199-1204
Link Here
|
1199 |
|
1234 |
|
1200 |
mlp = mlhead; |
1235 |
mlp = mlhead; |
1201 |
while (mlp) { |
1236 |
while (mlp) { |
|
|
1237 |
/* restrict to host only if specified in cp */ |
1238 |
if (cp != (caddr_t)NULL) { |
1239 |
if (strcmp(&mlp->ml_host[0], (char *)cp)) { |
1240 |
mlp = mlp->ml_next; |
1241 |
continue; |
1242 |
} |
1243 |
} |
1202 |
if (!xdr_bool(xdrsp, &true)) |
1244 |
if (!xdr_bool(xdrsp, &true)) |
1203 |
return (0); |
1245 |
return (0); |
1204 |
strp = &mlp->ml_host[0]; |
1246 |
strp = &mlp->ml_host[0]; |
Lines 1218-1224
Link Here
|
1218 |
* Xdr conversion for export list |
1260 |
* Xdr conversion for export list |
1219 |
*/ |
1261 |
*/ |
1220 |
int |
1262 |
int |
1221 |
xdr_explist_common(XDR *xdrsp, caddr_t cp __unused, int brief) |
1263 |
xdr_explist_common(XDR *xdrsp, caddr_t cp, int brief) |
1222 |
{ |
1264 |
{ |
1223 |
struct exportlist *ep; |
1265 |
struct exportlist *ep; |
1224 |
int false = 0; |
1266 |
int false = 0; |
Lines 1232-1242
Link Here
|
1232 |
while (ep) { |
1274 |
while (ep) { |
1233 |
putdef = 0; |
1275 |
putdef = 0; |
1234 |
if (put_exlist(ep->ex_dirl, xdrsp, ep->ex_defdir, |
1276 |
if (put_exlist(ep->ex_dirl, xdrsp, ep->ex_defdir, |
1235 |
&putdef, brief)) |
1277 |
&putdef, brief, (struct sockaddr *)cp)) |
1236 |
goto errout; |
1278 |
goto errout; |
1237 |
if (ep->ex_defdir && putdef == 0 && |
1279 |
if (ep->ex_defdir && putdef == 0 && |
1238 |
put_exlist(ep->ex_defdir, xdrsp, (struct dirlist *)NULL, |
1280 |
put_exlist(ep->ex_defdir, xdrsp, (struct dirlist *)NULL, |
1239 |
&putdef, brief)) |
1281 |
&putdef, brief, (struct sockaddr *)cp)) |
1240 |
goto errout; |
1282 |
goto errout; |
1241 |
ep = ep->ex_next; |
1283 |
ep = ep->ex_next; |
1242 |
} |
1284 |
} |
Lines 1255-1272
Link Here
|
1255 |
*/ |
1297 |
*/ |
1256 |
int |
1298 |
int |
1257 |
put_exlist(struct dirlist *dp, XDR *xdrsp, struct dirlist *adp, int *putdefp, |
1299 |
put_exlist(struct dirlist *dp, XDR *xdrsp, struct dirlist *adp, int *putdefp, |
1258 |
int brief) |
1300 |
int brief, struct sockaddr *saddr) |
1259 |
{ |
1301 |
{ |
1260 |
struct grouplist *grp; |
1302 |
struct grouplist *grp; |
1261 |
struct hostlist *hp; |
1303 |
struct hostlist *hp; |
1262 |
int true = 1; |
1304 |
int true = 1; |
1263 |
int false = 0; |
1305 |
int false = 0; |
|
|
1306 |
int defset, hostset; |
1264 |
int gotalldir = 0; |
1307 |
int gotalldir = 0; |
1265 |
char *strp; |
1308 |
char *strp; |
1266 |
|
1309 |
|
1267 |
if (dp) { |
1310 |
if (dp) { |
1268 |
if (put_exlist(dp->dp_left, xdrsp, adp, putdefp, brief)) |
1311 |
if (put_exlist(dp->dp_left, xdrsp, adp, putdefp, brief, saddr)) |
1269 |
return (1); |
1312 |
return (1); |
|
|
1313 |
|
1314 |
if (saddr != NULL && |
1315 |
!chk_host(dp, saddr, &defset, &hostset, NULL, NULL)) |
1316 |
goto skipentry; |
1317 |
|
1270 |
if (!xdr_bool(xdrsp, &true)) |
1318 |
if (!xdr_bool(xdrsp, &true)) |
1271 |
return (1); |
1319 |
return (1); |
1272 |
strp = dp->dp_dirp; |
1320 |
strp = dp->dp_dirp; |
Lines 1311-1317
Link Here
|
1311 |
} |
1359 |
} |
1312 |
if (!xdr_bool(xdrsp, &false)) |
1360 |
if (!xdr_bool(xdrsp, &false)) |
1313 |
return (1); |
1361 |
return (1); |
1314 |
if (put_exlist(dp->dp_right, xdrsp, adp, putdefp, brief)) |
1362 |
|
|
|
1363 |
skipentry: |
1364 |
if (put_exlist(dp->dp_right, xdrsp, adp, putdefp, brief, saddr)) |
1315 |
return (1); |
1365 |
return (1); |
1316 |
} |
1366 |
} |
1317 |
return (0); |
1367 |
return (0); |