Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/mountd/mountd.c
Show First 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | |||||
#include <limits.h> | #include <limits.h> | ||||
#include <netdb.h> | #include <netdb.h> | ||||
#include <pwd.h> | #include <pwd.h> | ||||
#include <signal.h> | #include <signal.h> | ||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include <unistd.h> | #include <unistd.h> | ||||
#include <vis.h> | |||||
#include "pathnames.h" | #include "pathnames.h" | ||||
#include "mntopts.h" | #include "mntopts.h" | ||||
#ifdef DEBUG | #ifdef DEBUG | ||||
#include <stdarg.h> | #include <stdarg.h> | ||||
#endif | #endif | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 1,462 Lines • ▼ Show 20 Lines | get_exportlist_one(int passno) | ||||
struct grouplist *grp, *tgrp, *savgrp; | struct grouplist *grp, *tgrp, *savgrp; | ||||
struct dirlist *dirhead; | struct dirlist *dirhead; | ||||
struct statfs fsb; | struct statfs fsb; | ||||
struct expcred anon; | struct expcred anon; | ||||
char *cp, *endcp, *dirp, *hst, *usr, *dom, savedc; | char *cp, *endcp, *dirp, *hst, *usr, *dom, savedc; | ||||
char *err_msg = NULL; | char *err_msg = NULL; | ||||
int len, has_host, got_nondir, dirplen, netgrp; | int len, has_host, got_nondir, dirplen, netgrp; | ||||
uint64_t exflags; | uint64_t exflags; | ||||
char unvis_dir[PATH_MAX + 1]; | |||||
int unvis_len; | |||||
v4root_phase = 0; | v4root_phase = 0; | ||||
anon.cr_groups = NULL; | anon.cr_groups = NULL; | ||||
dirhead = (struct dirlist *)NULL; | dirhead = (struct dirlist *)NULL; | ||||
*unvis_dir = '\0'; | |||||
rmacklem: Although this looks correct, I think
unvis_dir[0] = '\0';
is more readable.
| |||||
dan.mcgregor_usask.caAuthorUnsubmitted Done Inline ActionsSure, I could also initialize it on line 1565, but that doesn't seem to match the existing style of this file. Both do the same thing, but readability is important. dan.mcgregor_usask.ca: Sure, I could also initialize it on line 1565, but that doesn't seem to match the existing… | |||||
while (get_line()) { | while (get_line()) { | ||||
if (debug) | if (debug) | ||||
warnx("got line %s", line); | warnx("got line %s", line); | ||||
cp = line; | cp = line; | ||||
nextfield(&cp, &endcp); | nextfield(&cp, &endcp); | ||||
if (*cp == '#') | if (*cp == '#') | ||||
goto nextline; | goto nextline; | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | while (len > 0) { | ||||
if (do_opt(&cp, &endcp, ep, grp, &has_host, | if (do_opt(&cp, &endcp, ep, grp, &has_host, | ||||
&exflags, &anon)) { | &exflags, &anon)) { | ||||
getexp_err(ep, tgrp, NULL); | getexp_err(ep, tgrp, NULL); | ||||
goto nextline; | goto nextline; | ||||
} | } | ||||
} else if (*cp == '/') { | } else if (*cp == '/') { | ||||
savedc = *endcp; | savedc = *endcp; | ||||
*endcp = '\0'; | *endcp = '\0'; | ||||
unvis_len = strnunvis(unvis_dir, sizeof(unvis_dir), cp); | |||||
rmacklemUnsubmitted Done Inline ActionsI think unvis_len should be checked for >= 0 if (unvis_len < 0) { getexp_err(ep, tgrp, "Cannot strunvis decode dir"); goto nextline; } rmacklem: I think unvis_len should be checked for >= 0
(or != -1), since that is what is returned if… | |||||
dan.mcgregor_usask.caAuthorUnsubmitted Done Inline ActionsMakes sense. I'll update this review in the next hour or so. dan.mcgregor_usask.ca: Makes sense. I'll update this review in the next hour or so. | |||||
if (v4root_phase > 1) { | if (v4root_phase > 1) { | ||||
if (dirp != NULL) { | if (dirp != NULL) { | ||||
getexp_err(ep, tgrp, "Multiple V4 dirs"); | getexp_err(ep, tgrp, "Multiple V4 dirs"); | ||||
goto nextline; | goto nextline; | ||||
} | } | ||||
} | } | ||||
if (check_dirpath(cp, &err_msg) && | if (check_dirpath(unvis_dir, &err_msg) && | ||||
check_statfs(cp, &fsb, &err_msg)) { | check_statfs(unvis_dir, &fsb, &err_msg)) { | ||||
if ((fsb.f_flags & MNT_AUTOMOUNTED) != 0) | if ((fsb.f_flags & MNT_AUTOMOUNTED) != 0) | ||||
syslog(LOG_ERR, "Warning: exporting of " | syslog(LOG_ERR, "Warning: exporting of " | ||||
"automounted fs %s not supported", cp); | "automounted fs %s not supported", unvis_dir); | ||||
if (got_nondir) { | if (got_nondir) { | ||||
getexp_err(ep, tgrp, "dirs must be first"); | getexp_err(ep, tgrp, "dirs must be first"); | ||||
goto nextline; | goto nextline; | ||||
} | } | ||||
if (v4root_phase == 1) { | if (v4root_phase == 1) { | ||||
if (dirp != NULL) { | if (dirp != NULL) { | ||||
getexp_err(ep, tgrp, "Multiple V4 dirs"); | getexp_err(ep, tgrp, "Multiple V4 dirs"); | ||||
goto nextline; | goto nextline; | ||||
} | } | ||||
if (strlen(v4root_dirpath) == 0) { | if (strlen(v4root_dirpath) == 0) { | ||||
strlcpy(v4root_dirpath, cp, | strlcpy(v4root_dirpath, unvis_dir, | ||||
sizeof (v4root_dirpath)); | sizeof (v4root_dirpath)); | ||||
} else if (strcmp(v4root_dirpath, cp) | } else if (strcmp(v4root_dirpath, unvis_dir) | ||||
!= 0) { | != 0) { | ||||
syslog(LOG_ERR, | syslog(LOG_ERR, | ||||
"different V4 dirpath %s", cp); | "different V4 dirpath %s", unvis_dir); | ||||
getexp_err(ep, tgrp, NULL); | getexp_err(ep, tgrp, NULL); | ||||
goto nextline; | goto nextline; | ||||
} | } | ||||
dirp = cp; | dirp = unvis_dir; | ||||
v4root_phase = 2; | v4root_phase = 2; | ||||
got_nondir = 1; | got_nondir = 1; | ||||
ep = get_exp(); | ep = get_exp(); | ||||
} else { | } else { | ||||
if (ep) { | if (ep) { | ||||
if (fsidcmp(&ep->ex_fs, &fsb.f_fsid) | if (fsidcmp(&ep->ex_fs, &fsb.f_fsid) | ||||
!= 0) { | != 0) { | ||||
getexp_err(ep, tgrp, | getexp_err(ep, tgrp, | ||||
Show All 21 Lines | while (len > 0) { | ||||
warnx("found ep fs=0x%x,0x%x", | warnx("found ep fs=0x%x,0x%x", | ||||
fsb.f_fsid.val[0], | fsb.f_fsid.val[0], | ||||
fsb.f_fsid.val[1]); | fsb.f_fsid.val[1]); | ||||
} | } | ||||
/* | /* | ||||
* Add dirpath to export mount point. | * Add dirpath to export mount point. | ||||
*/ | */ | ||||
dirp = add_expdir(&dirhead, cp, len); | dirp = add_expdir(&dirhead, unvis_dir, unvis_len); | ||||
dirplen = len; | dirplen = unvis_len; | ||||
} | } | ||||
} else { | } else { | ||||
if (err_msg != NULL) { | if (err_msg != NULL) { | ||||
getexp_err(ep, tgrp, err_msg); | getexp_err(ep, tgrp, err_msg); | ||||
free(err_msg); | free(err_msg); | ||||
err_msg = NULL; | err_msg = NULL; | ||||
} else { | } else { | ||||
getexp_err(ep, tgrp, | getexp_err(ep, tgrp, | ||||
▲ Show 20 Lines • Show All 2,308 Lines • Show Last 20 Lines |
Although this looks correct, I think
is more readable.