+ register char *cpoptarg, *cpoptend;
+
+ while (cpopt && *cpopt) {
+ if (cpoptend = index(cpopt, ','))
+ *cpoptend++ = '\0';
+ if (cpoptarg = index(cpopt, '='))
+ *cpoptarg++ = '\0';
+ if (!strcmp(cpopt, "ro") || !strcmp(cpopt, "o")) {
+ if (fep && (fep->ex_exflags & MNT_EXRDONLY) == 0)
+ syslog(LOG_WARNING, "ro failed for %s",
+ ep->ex_dirp);
+ else
+ *exflagsp |= MNT_EXRDONLY;
+ } else if (!strcmp(cpopt, "root") || !strcmp(cpopt, "r")) {
+ if (cpoptarg && isdigit(*cpoptarg)) {
+ *rootuidp = atoi(cpoptarg);
+ if (fep && fep->ex_rootuid != *rootuidp)
+ syslog(LOG_WARNING,
+ "uid failed for %s",
+ ep->ex_dirp);
+ } else
+ syslog(LOG_WARNING,
+ "uid failed for %s",
+ ep->ex_dirp);
+ } else
+ syslog(LOG_WARNING, "opt %s ignored for %s", cpopt,
+ ep->ex_dirp);
+ cpopt = cpoptend;
+ }
+}
+
+#define STRSIZ (RPCMNT_NAMELEN+RPCMNT_PATHLEN+50)
+/*
+ * Routines that maintain the remote mounttab
+ */
+void get_mountlist()
+{
+ register struct mountlist *mlp, **mlpp;
+ register char *eos, *dirp;
+ int len;
+ char str[STRSIZ];
+ FILE *mlfile;
+
+ if (((mlfile = fopen(_PATH_RMOUNTLIST, "r")) == NULL) &&
+ ((mlfile = fopen(_PATH_RMOUNTLIST, "w")) == NULL)) {
+ syslog(LOG_WARNING, "Can't open %s", _PATH_RMOUNTLIST);
+ return;
+ }
+ mlpp = &mlhead;
+ while (fgets(str, STRSIZ, mlfile) != NULL) {
+ if ((dirp = index(str, '\t')) == NULL &&
+ (dirp = index(str, ' ')) == NULL)
+ continue;
+ mlp = (struct mountlist *)malloc(sizeof (*mlp));
+ len = dirp-str;
+ if (len > RPCMNT_NAMELEN)
+ len = RPCMNT_NAMELEN;
+ bcopy(str, mlp->ml_host, len);
+ mlp->ml_host[len] = '\0';
+ while (*dirp == '\t' || *dirp == ' ')
+ dirp++;
+ if ((eos = index(dirp, '\t')) == NULL &&
+ (eos = index(dirp, ' ')) == NULL &&
+ (eos = index(dirp, '\n')) == NULL)
+ len = strlen(dirp);
+ else
+ len = eos-dirp;
+ if (len > RPCMNT_PATHLEN)
+ len = RPCMNT_PATHLEN;
+ bcopy(dirp, mlp->ml_dirp, len);
+ mlp->ml_dirp[len] = '\0';
+ mlp->ml_next = (struct mountlist *)0;
+ *mlpp = mlp;
+ mlpp = &mlp->ml_next;
+ }
+ fclose(mlfile);
+}
+
+void del_mlist(hostp, dirp)
+ register char *hostp, *dirp;
+{
+ register struct mountlist *mlp, **mlpp;
+ FILE *mlfile;
+ int fnd = 0;
+
+ mlpp = &mlhead;
+ mlp = mlhead;
+ while (mlp) {
+ if (!strcmp(mlp->ml_host, hostp) &&
+ (!dirp || !strcmp(mlp->ml_dirp, dirp))) {
+ fnd = 1;
+ *mlpp = mlp->ml_next;
+ free((caddr_t)mlp);
+ }
+ mlpp = &mlp->ml_next;
+ mlp = mlp->ml_next;
+ }
+ if (fnd) {
+ if ((mlfile = fopen(_PATH_RMOUNTLIST, "w")) == NULL) {
+ syslog(LOG_WARNING, "Can't update %s", _PATH_RMOUNTLIST);
+ return;