void qword_print(FILE *f, char *str);
void qword_printhex(FILE *f, char *str, int slen);
void qword_printint(FILE *f, int num);
-void qword_eol(FILE *f);
+int qword_eol(FILE *f);
int readline(int fd, char **buf, int *lenp);
int qword_get(char **bpp, char *dest, int bufsize);
int qword_get_int(char **bpp, int *anint);
fprintf(f, "%d ", num);
}
-void qword_eol(FILE *f)
+int qword_eol(FILE *f)
{
fprintf(f,"\n");
- fflush(f);
+ return fflush(f);
}
char fsidstr[8];
__u16 dev;
__u32 inode;
+ int err;
f = fopen("/proc/net/rpc/nfsd.export/channel", "w");
} else
qword_printint(f, 1);
- qword_eol(f);
+ err = qword_eol(f);
fclose(f);
if (stat(exp->ex_path, &stb) != 0)
} else
qword_printint(f, 1);
- qword_eol(f);
+ err = qword_eol(f) || err;
}
qword_print(f,exp->ex_client);
qword_printint(f,0);
qword_print(f, exp->ex_path);
} else
qword_printint(f, 1);
- qword_eol(f);
+ err = qword_eol(f) || err;
fclose(f);
- return 0;
+ return err;
}
int
printerr(2, "%d ", num);
}
-void qword_eol(FILE *f)
+int qword_eol(FILE *f)
{
+ int err;
fprintf(f,"\n");
- fflush(f);
+ err = fflush(f);
printerr(2, "\n");
+ return err;
}
void qword_print(FILE *f, char *str);
void qword_printhex(FILE *f, char *str, int slen);
void qword_printint(FILE *f, int num);
-void qword_eol(FILE *f);
+int qword_eol(FILE *f);
int readline(int fd, char **buf, int *lenp);
int qword_get(char **bpp, char *dest, int bufsize);
int qword_get_int(char **bpp, int *anint);
FILE *f;
int i;
char *fname = NULL;
+ int err;
printerr(1, "doing downcall\n");
if ((fname = mech2file(mech)) == NULL)
qword_printint(f, cred->cr_groups[i]);
qword_print(f, fname);
qword_printhex(f, context_token->value, context_token->length);
- qword_eol(f);
+ err = qword_eol(f);
fclose(f);
- return 0;
+ return err;
out_err:
printerr(0, "WARNING: downcall failed\n");
return -1;
* Record is terminated with newline.
*
*/
-void cache_export_ent(char *domain, struct exportent *exp);
+int cache_export_ent(char *domain, struct exportent *exp);
char *lbuf = NULL;
* % echo $domain $path $[now+30*60] $options $anonuid $anongid $fsid > /proc/net/rpc/nfsd.export/channel
*/
-void cache_export_ent(char *domain, struct exportent *exp)
+int cache_export_ent(char *domain, struct exportent *exp)
{
-
+ int err;
FILE *f = fopen("/proc/net/rpc/nfsd.export/channel", "w");
if (!f)
- return;
+ return -1;
qword_print(f, domain);
qword_print(f, exp->e_path);
qword_printint(f, exp->e_anonuid);
qword_printint(f, exp->e_anongid);
qword_printint(f, exp->e_fsid);
- qword_eol(f);
+ err = qword_eol(f);
fclose(f);
+ return err;
}
-void cache_export(nfs_export *exp)
+int cache_export(nfs_export *exp)
{
+ int err;
FILE *f;
f = fopen("/proc/net/rpc/auth.unix.ip/channel", "w");
if (!f)
- return;
+ return -1;
qword_print(f, "nfsd");
qword_print(f, inet_ntoa(exp->m_client->m_addrlist[0]));
qword_printint(f, time(0)+30*60);
qword_print(f, exp->m_client->m_hostname);
- qword_eol(f);
+ err = qword_eol(f);
fclose(f);
- cache_export_ent(exp->m_client->m_hostname, &exp->m_export);
+ err = cache_export_ent(exp->m_client->m_hostname, &exp->m_export)
+ || err;
+ return err;
}
/* Get a filehandle.
qword_print(f, exp->m_client->m_hostname);
qword_print(f, p);
qword_printint(f, len);
- qword_eol(f);
+ failed = qword_eol(f);
- failed = (fgets(buf, sizeof(buf), f) == NULL);
+ if (!failed)
+ failed = (fgets(buf, sizeof(buf), f) == NULL);
fclose(f);
if (failed)
return NULL;
extern void cache_open(void);
extern struct nfs_fh_len *cache_get_filehandle(nfs_export *exp, int len, char *p);
-extern void cache_export(nfs_export *exp);
+extern int cache_export(nfs_export *exp);
extern void my_svc_run(void);
*/
struct nfs_fh_len *fh;
- cache_export(exp);
+ if (cache_export(exp)) {
+ *error = NFSERR_ACCES;
+ return NULL;
+ }
fh = cache_get_filehandle(exp, v3?64:32, p);
if (fh == NULL)
*error = NFSERR_ACCES;