[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/6] libnetfs: Hacks to allow pci to run with no cred
From: |
Damien Zammit |
Subject: |
[PATCH 3/6] libnetfs: Hacks to allow pci to run with no cred |
Date: |
Sun, 7 Mar 2021 17:39:07 +1100 |
---
libnetfs/dir-lookup.c | 30 +++++++++++++++++++++---------
libnetfs/dir-readdir.c | 3 ---
libnetfs/file-getcontrol.c | 13 ++++++-------
libnetfs/make-protid.c | 8 +-------
pci-arbiter/netfs_impl.c | 2 ++
5 files changed, 30 insertions(+), 26 deletions(-)
diff --git a/libnetfs/dir-lookup.c b/libnetfs/dir-lookup.c
index 23adeb33..9bf78225 100644
--- a/libnetfs/dir-lookup.c
+++ b/libnetfs/dir-lookup.c
@@ -50,9 +50,6 @@ netfs_S_dir_lookup (struct protid *dircred,
struct protid *newpi = NULL;
struct iouser *user;
- if (!dircred)
- return EOPNOTSUPP;
-
create = (flags & O_CREAT);
excl = (flags & O_EXCL);
@@ -73,6 +70,12 @@ netfs_S_dir_lookup (struct protid *dircred,
*do_retry = FS_RETRY_NORMAL;
*retry_name = '\0';
+ if (!dircred)
+ {
+ dircred = netfs_make_protid (netfs_make_peropen (netfs_root_node, flags,
0), 0);
+ dircred->po->path = filename;
+ }
+
if (*filename == '\0')
{
/* Set things up in the state expected by the code from gotit: on. */
@@ -423,15 +426,24 @@ netfs_S_dir_lookup (struct protid *dircred,
flags &= ~OPENONLY_STATE_MODES;
- err = iohelp_dup_iouser (&user, dircred->user);
- if (err)
- goto out;
+ if (dircred->user)
+ {
+ err = iohelp_dup_iouser (&user, dircred->user);
+ if (err)
+ goto out;
+ }
+ else
+ {
+ user = NULL;
+ err = 0;
+ }
+
+ newpi = netfs_make_protid (netfs_make_peropen (np, flags, dircred->po),
user);
- newpi = netfs_make_protid (netfs_make_peropen (np, flags, dircred->po),
- user);
if (! newpi)
{
- iohelp_free_iouser (user);
+ if (user)
+ iohelp_free_iouser (user);
err = errno;
goto out;
}
diff --git a/libnetfs/dir-readdir.c b/libnetfs/dir-readdir.c
index 3d40dfa5..83dbf2d4 100644
--- a/libnetfs/dir-readdir.c
+++ b/libnetfs/dir-readdir.c
@@ -36,9 +36,6 @@ netfs_S_dir_readdir (struct protid *user,
error_t err;
struct node *np;
- if (!user)
- return EOPNOTSUPP;
-
np = user->po->np;
pthread_mutex_lock (&np->lock);
diff --git a/libnetfs/file-getcontrol.c b/libnetfs/file-getcontrol.c
index 0e29ccf9..833fe196 100644
--- a/libnetfs/file-getcontrol.c
+++ b/libnetfs/file-getcontrol.c
@@ -31,13 +31,12 @@ netfs_S_file_getcontrol (struct protid *user,
error_t err;
struct port_info *pi;
- if (!user)
- return EOPNOTSUPP;
-
- err = fshelp_iscontroller (&netfs_root_node->nn_stat, user->user);
- if (err)
- return err;
-
+ if (user)
+ {
+ err = fshelp_iscontroller (&netfs_root_node->nn_stat, user->user);
+ if (err)
+ return err;
+ }
/* They've have the appropriate credentials; give it to them. */
err = ports_create_port (netfs_control_class, netfs_port_bucket,
sizeof (struct port_info), &pi);
diff --git a/libnetfs/make-protid.c b/libnetfs/make-protid.c
index 995ac1ea..2087f220 100644
--- a/libnetfs/make-protid.c
+++ b/libnetfs/make-protid.c
@@ -25,14 +25,8 @@ netfs_make_protid (struct peropen *po, struct iouser *cred)
{
struct protid *pi;
- if (cred)
- errno = ports_create_port (netfs_protid_class, netfs_port_bucket,
+ errno = ports_create_port (netfs_protid_class, netfs_port_bucket,
sizeof (struct protid), &pi);
- else
- errno = ports_create_port_noinstall (netfs_protid_class,
- netfs_port_bucket,
- sizeof (struct protid), &pi);
-
if (errno)
return 0;
diff --git a/pci-arbiter/netfs_impl.c b/pci-arbiter/netfs_impl.c
index e977dce3..22c35292 100644
--- a/pci-arbiter/netfs_impl.c
+++ b/pci-arbiter/netfs_impl.c
@@ -179,6 +179,8 @@ error_t
netfs_check_open_permissions (struct iouser * user, struct node * node,
int flags, int newnode)
{
+ if (!user)
+ return 0;
return entry_check_perms (user, node->nn->ln, flags);
}
--
2.30.1
- [PATCH: hurd x6], Damien Zammit, 2021/03/07
- [PATCH 2/6] pci-arbiter: Introduce machdev into this server, Damien Zammit, 2021/03/07
- [PATCH 3/6] libnetfs: Hacks to allow pci to run with no cred,
Damien Zammit <=
- [PATCH 4/6] rumpdisk: Don't pretend to be the arbiter anymore, Damien Zammit, 2021/03/07
- [PATCH 1/6] pci-arbiter: Fix brokenness, Damien Zammit, 2021/03/07
- [PATCH 6/6] pci-arbiter: Close correctly, Damien Zammit, 2021/03/07
- [PATCH 5/6] machdev,pci,rump: fix shutdown dosync, Damien Zammit, 2021/03/07
- Re: [PATCH: hurd x6], Samuel Thibault, 2021/03/07