diff options
Diffstat (limited to 'lib9p/srv.c')
-rw-r--r-- | lib9p/srv.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/lib9p/srv.c b/lib9p/srv.c index 6ab2ab2..8917084 100644 --- a/lib9p/srv.c +++ b/lib9p/srv.c @@ -174,17 +174,26 @@ static inline bool srv_check_perm(struct srv_req *ctx, struct lib9p_stat *stat, return mode & action; } -struct lib9p_srv_authinfo *srv_authinfo_new(struct lib9p_s uname, lib9p_nuid_t uid) { +struct lib9p_srv_authinfo *srv_authinfo_new(struct lib9p_s uname +#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L + , lib9p_nuid_t uid +#endif + ) { struct lib9p_srv_authinfo *ret = malloc(sizeof(struct lib9p_srv_authinfo) + uname.len); if (!ret) return NULL; +#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L ret->uid = uid; +#endif ret->uname.len = uname.len; ret->uname.utf8 = (void *)&ret[1]; memcpy(ret->uname.utf8, uname.utf8, uname.len); ret->refcount = 1; return ret; } +#if !(CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L) +#define srv_authinfo_new(name, num) srv_authinfo_new(name) +#endif struct lib9p_srv_authinfo *srv_authinfo_decref(struct lib9p_srv_authinfo *authinfo) { assert(authinfo); @@ -272,8 +281,8 @@ static inline void srv_fid_del(struct srv_req *ctx, lib9p_fid_t fid, bool remove if (remove) { if (pathinfo->parent_dir == fidinfo->path) { - lib9p_errorf(&ctx->basectx, - LIB9P_ERRNO_L_EBUSY, "cannot remove root"); + lib9p_error(&ctx->basectx, + LIB9P_ERRNO_L_EBUSY, "cannot remove root"); goto clunk; } struct srv_pathinfo *parent = map_load(&ctx->parent_sess->paths, pathinfo->parent_dir); @@ -375,7 +384,7 @@ static ssize_t srv_write_Rmsg(struct srv_req *req, struct lib9p_Rmsg_send_buf *r #define srv_nonrespond_errorf errorf static void srv_respond_error(struct srv_req *req) { -#if CONFIG_9P_ENABLE_9P2000_u +#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L assert(req->basectx.err_num); #endif assert(req->basectx.err_msg[0]); @@ -647,7 +656,7 @@ void lib9p_srv_worker(struct srv_req *ctx) { case LIB9P_TYP_Tstat: handler = (tmessage_handler)handle_Tstat; break; case LIB9P_TYP_Twstat: handler = (tmessage_handler)handle_Twstat; break; #if CONFIG_9P_ENABLE_9P2000_p9p - case LIB9P_TYP_Topenfd: handler = (tmessage_handler)handle_Topenfd; break + case LIB9P_TYP_Topenfd: handler = (tmessage_handler)handle_Topenfd; break; #endif #if CONFIG_9P_ENABLE_9P2000_e case LIB9P_TYP_Tsession: handler = (tmessage_handler)handle_Tsession; break; @@ -824,7 +833,7 @@ static void handle_Tattach(struct srv_req *ctx, LIB9P_ERRNO_L_EACCES, "FID provided as auth-file is for user=\"%.*s\" and cannot be used for user=\"%.*s\"", afid->authinfo->uname.len, afid->authinfo->uname.utf8, req->uname.len, req->uname.utf8); -#if CONFIG_9P_ENABLE_9P2000_u +#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L else if (afid->authinfo->uid != req->n_uid) lib9p_errorf(&ctx->basectx, LIB9P_ERRNO_L_EACCES, "FID provided as auth-file is for user=%"PRIu32" and cannot be used for user=%"PRIu32, |