diff options
author | Thomas Bushnell <thomas@gnu.org> | 1996-11-18 23:51:17 +0000 |
---|---|---|
committer | Thomas Bushnell <thomas@gnu.org> | 1996-11-18 23:51:17 +0000 |
commit | 1e156105080b6168f7fd22574dda6140dc5454de (patch) | |
tree | 3dfdcc6f84b81e2a983621d4fd2f696c62d11528 | |
parent | d79de6fd652140aa4d9a5fd9405466f8cc0d6386 (diff) |
Mon Nov 18 17:06:39 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* netfs.h (netfs_report_access): Return error_t.
* file-check-access.c (netfs_S_file_check_access): Deal with
errors from netfs_report_access.
Sat Nov 16 17:17:50 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* io-restrict-auth.c (netfs_S_io_restrict_auth): Fix several typos.
* fsys-getroot.c (netfs_S_fsys_getroot): iohelp_make_iouser ->
iohelp_create_iouser. New arg syntax for fshelp_fetch_root.
Fri Nov 15 13:39:03 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* netfs.h (struct protid): Replace member `credential' with `user'
of new type. All uses of old `credential' member changed to
use `user' member.
Change all functions that used to take `struct netcred' args to
take `struct iouser' args. All callers changed.
(netfs_copy_credential, netfs_dropy_credential,
netfs_make_credential): Delete functions.
* dir-lookup.c (netfs_S_dir_lookup): netfs_copy_credential ->
iohelp_dup_iouser.
* dir-mkfile.c (netfs_S_dir_mkfile): Likewise.
* file-exec.c (netfs_S_file_exec): Likewise.
* io-duplicate.c (netfs_S_io_duplicate): Likewise.
* release-protid.c (netfs_release_protid): netfs_drop_credential
-> iohelp_free_iouser.
* dir-lookup.c (netfs_S_dir_lookup): Omit uses of
netfs_interpret_credential; do it with new structures.
* file-exec.c (netfs_S_file_exec): Likewise.
* file-getcontrol.c (netfs_S_file_getcontrol): Likewise.
* file-set-translator.c (netfs_S_file_set_translator): Likewise;
using fshelp_isowner for permission check.
* io-restrict-auth.c (netfs_S_io_restrict_auth): Likewise; guts
rewritten.
* dir-lookup.c (netfs_S_dir_lookup): netfs_make_credential ->
iohelp_make_iouser.
* fsys-getroot.c (netfs_S_fsys_getroot): Likewise.
* fsys-syncfs.c (netfs_S_fsys_syncfs): Likewise.
* io-reauthenticate.c (netfs_S_io_reauthenticate): Use
iohelp_reauth instead of doing it by hand.
37 files changed, 213 insertions, 228 deletions
diff --git a/libnetfs/ChangeLog b/libnetfs/ChangeLog index 6ec28ba3..952c2ec8 100644 --- a/libnetfs/ChangeLog +++ b/libnetfs/ChangeLog @@ -1,3 +1,47 @@ +Mon Nov 18 17:06:39 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu> + + * netfs.h (netfs_report_access): Return error_t. + * file-check-access.c (netfs_S_file_check_access): Deal with + errors from netfs_report_access. + +Sat Nov 16 17:17:50 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu> + + * io-restrict-auth.c (netfs_S_io_restrict_auth): Fix several typos. + + * fsys-getroot.c (netfs_S_fsys_getroot): iohelp_make_iouser -> + iohelp_create_iouser. New arg syntax for fshelp_fetch_root. + +Fri Nov 15 13:39:03 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu> + + * netfs.h (struct protid): Replace member `credential' with `user' + of new type. All uses of old `credential' member changed to + use `user' member. + Change all functions that used to take `struct netcred' args to + take `struct iouser' args. All callers changed. + (netfs_copy_credential, netfs_dropy_credential, + netfs_make_credential): Delete functions. + * dir-lookup.c (netfs_S_dir_lookup): netfs_copy_credential -> + iohelp_dup_iouser. + * dir-mkfile.c (netfs_S_dir_mkfile): Likewise. + * file-exec.c (netfs_S_file_exec): Likewise. + * io-duplicate.c (netfs_S_io_duplicate): Likewise. + * release-protid.c (netfs_release_protid): netfs_drop_credential + -> iohelp_free_iouser. + * dir-lookup.c (netfs_S_dir_lookup): Omit uses of + netfs_interpret_credential; do it with new structures. + * file-exec.c (netfs_S_file_exec): Likewise. + * file-getcontrol.c (netfs_S_file_getcontrol): Likewise. + * file-set-translator.c (netfs_S_file_set_translator): Likewise; + using fshelp_isowner for permission check. + * io-restrict-auth.c (netfs_S_io_restrict_auth): Likewise; guts + rewritten. + * dir-lookup.c (netfs_S_dir_lookup): netfs_make_credential -> + iohelp_make_iouser. + * fsys-getroot.c (netfs_S_fsys_getroot): Likewise. + * fsys-syncfs.c (netfs_S_fsys_syncfs): Likewise. + * io-reauthenticate.c (netfs_S_io_reauthenticate): Use + iohelp_reauth instead of doing it by hand. + Mon Oct 21 21:56:33 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu> * netfs.h: Add extern inline protection. diff --git a/libnetfs/dir-link.c b/libnetfs/dir-link.c index 35cc6f7a..1c31b8f9 100644 --- a/libnetfs/dir-link.c +++ b/libnetfs/dir-link.c @@ -34,7 +34,7 @@ netfs_S_dir_link (struct protid *diruser, struct protid *fileuser, char *name, return EXDEV; /* Note that nothing is locked here */ - err = netfs_attempt_link (diruser->credential, diruser->po->np, + err = netfs_attempt_link (diruser->user, diruser->po->np, fileuser->po->np, name, excl); if (!err) mach_port_deallocate (mach_task_self (), fileuser->pi.port_right); diff --git a/libnetfs/dir-lookup.c b/libnetfs/dir-lookup.c index 9ca623f3..36ca3cf7 100644 --- a/libnetfs/dir-lookup.c +++ b/libnetfs/dir-lookup.c @@ -140,7 +140,7 @@ netfs_S_dir_lookup (struct protid *diruser, } else /* Attempt a lookup on the next pathname component. */ - error = netfs_attempt_lookup (diruser->credential, dnp, filename, &np); + error = netfs_attempt_lookup (diruser->user, dnp, filename, &np); /* At this point, DNP is unlocked */ @@ -154,7 +154,7 @@ netfs_S_dir_lookup (struct protid *diruser, mode &= ~(S_IFMT | S_ISPARE | S_ISVTX); mode |= S_IFREG; mutex_lock (&dnp->lock); - error = netfs_attempt_create_file (diruser->credential, dnp, + error = netfs_attempt_create_file (diruser->user, dnp, filename, mode, &np); newnode = 1; @@ -172,7 +172,7 @@ netfs_S_dir_lookup (struct protid *diruser, if (error) goto out; - error = netfs_validate_stat (np, diruser->credential); + error = netfs_validate_stat (np, diruser->user); if (error) goto out; @@ -184,8 +184,6 @@ netfs_S_dir_lookup (struct protid *diruser, || fshelp_translated (&np->transbox))) { mach_port_t dirport; - uid_t *uids, *gids; - int nuids, ngids; /* A callback function for short-circuited translators. S_ISLNK and S_IFSOCK are handled elsewhere. */ @@ -196,7 +194,7 @@ netfs_S_dir_lookup (struct protid *diruser, struct node *np = cookie1; error_t err; - err = netfs_validate_stat (np, diruser->credential); + err = netfs_validate_stat (np, diruser->user); if (err) return err; @@ -232,7 +230,8 @@ netfs_S_dir_lookup (struct protid *diruser, newpi = netfs_make_protid (netfs_make_peropen (dnp, 0, diruser->po->dotdotport), - netfs_make_credential (0, 0, 0, 0)); + iohelp_create_iouser (make_idvec (), + make_idvec ())); dirport = ports_get_right (newpi); mach_port_insert_right (mach_task_self (), dirport, dirport, MACH_MSG_TYPE_MAKE_SEND); @@ -240,18 +239,16 @@ netfs_S_dir_lookup (struct protid *diruser, if (np != dnp) mutex_unlock (&dnp->lock); - netfs_interpret_credential (diruser->credential, &uids, &nuids, - &gids, &ngids); error = fshelp_fetch_root (&np->transbox, &diruser->po->dotdotport, - dirport, uids, nuids, gids, ngids, + dirport, + diruser->user, lastcomp ? flags : 0, (np->istranslated ? _netfs_translator_callback1 : short_circuited_callback1), _netfs_translator_callback2, do_retry, retry_name, retry_port); - free (uids); - free (gids); + if (error != ENOENT) { netfs_nrele (dnp); @@ -301,7 +298,7 @@ netfs_S_dir_lookup (struct protid *diruser, newnamelen = nextnamelen + linklen + 1; linkbuf = alloca (newnamelen); - error = netfs_attempt_readlink (diruser->credential, np, linkbuf); + error = netfs_attempt_readlink (diruser->user, np, linkbuf); if (error) goto out; @@ -357,14 +354,14 @@ netfs_S_dir_lookup (struct protid *diruser, if (mustbedir) { - netfs_validate_stat (np, diruser->credential); + netfs_validate_stat (np, diruser->user); if (!S_ISDIR (np->nn_stat.st_mode)) { error = ENOTDIR; goto out; } } - error = netfs_check_open_permissions (diruser->credential, np, + error = netfs_check_open_permissions (diruser->user, np, flags, newnode); if (error) goto out; @@ -373,7 +370,7 @@ netfs_S_dir_lookup (struct protid *diruser, newpi = netfs_make_protid (netfs_make_peropen (np, flags, diruser->po->dotdotport), - netfs_copy_credential (diruser->credential)); + iohelp_dup_iouser (diruser->user)); *retry_port = ports_get_right (newpi); ports_port_deref (newpi); diff --git a/libnetfs/dir-mkdir.c b/libnetfs/dir-mkdir.c index fdfde30c..33feb25f 100644 --- a/libnetfs/dir-mkdir.c +++ b/libnetfs/dir-mkdir.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1995 Free Software Foundation, Inc. + Copyright (C) 1995, 1996 Free Software Foundation, Inc. Written by Michael I. Bushnell, p/BSG. This file is part of the GNU Hurd. @@ -33,7 +33,7 @@ netfs_S_dir_mkdir (struct protid *user, char *name, mode_t mode) mode |= S_IFDIR; mutex_lock (&user->po->np->lock); - err = netfs_attempt_mkdir (user->credential, user->po->np, name, mode); + err = netfs_attempt_mkdir (user->user, user->po->np, name, mode); mutex_unlock (&user->po->np->lock); return err; } diff --git a/libnetfs/dir-mkfile.c b/libnetfs/dir-mkfile.c index 89212daa..5062427f 100644 --- a/libnetfs/dir-mkfile.c +++ b/libnetfs/dir-mkfile.c @@ -31,7 +31,7 @@ netfs_S_dir_mkfile (struct protid *diruser, int flags, mode_t mode, struct protid *newpi; mutex_lock (&diruser->po->np->lock); - err = netfs_attempt_mkfile (diruser->credential, diruser->po->np, mode, &np); + err = netfs_attempt_mkfile (diruser->user, diruser->po->np, mode, &np); if (!err) { @@ -39,7 +39,7 @@ netfs_S_dir_mkfile (struct protid *diruser, int flags, mode_t mode, flags &= OPENONLY_STATE_MODES; newpi = netfs_make_protid (netfs_make_peropen (np, flags, diruser->po->dotdotport), - netfs_copy_credential (diruser->credential)); + iohelp_dup_iouser (diruser->user)); *newfile = ports_get_right (newpi); *newfiletype = MACH_MSG_TYPE_MAKE_SEND; ports_port_deref (newpi); diff --git a/libnetfs/dir-readdir.c b/libnetfs/dir-readdir.c index 85719302..e7313428 100644 --- a/libnetfs/dir-readdir.c +++ b/libnetfs/dir-readdir.c @@ -45,11 +45,11 @@ netfs_S_dir_readdir (struct protid *user, if ((user->po->openstat & O_READ) == 0) err = EBADF; if (!err) - err = netfs_validate_stat (np, user->credential); + err = netfs_validate_stat (np, user->user); if (!err && (np->nn_stat.st_mode & S_IFMT) != S_IFDIR) err = ENOTDIR; if (!err) - err = netfs_get_dirents (user->credential, np, entry, nentries, data, + err = netfs_get_dirents (user->user, np, entry, nentries, data, datacnt, bufsiz, amt); mutex_unlock (&np->lock); return err; diff --git a/libnetfs/dir-rename.c b/libnetfs/dir-rename.c index 6898c5e9..0215376b 100644 --- a/libnetfs/dir-rename.c +++ b/libnetfs/dir-rename.c @@ -34,7 +34,7 @@ netfs_S_dir_rename (struct protid *fromdiruser, char *fromname, return EXDEV; /* Note that nothing is locked here */ - err = netfs_attempt_rename (fromdiruser->credential, fromdiruser->po->np, + err = netfs_attempt_rename (fromdiruser->user, fromdiruser->po->np, fromname, todiruser->po->np, toname, excl); if (!err) mach_port_deallocate (mach_task_self (), todiruser->pi.port_right); diff --git a/libnetfs/dir-rmdir.c b/libnetfs/dir-rmdir.c index 4f9e962a..9a5941d3 100644 --- a/libnetfs/dir-rmdir.c +++ b/libnetfs/dir-rmdir.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1995 Free Software Foundation, Inc. + Copyright (C) 1995, 1996 Free Software Foundation, Inc. Written by Michael I. Bushnell, p/BSG. This file is part of the GNU Hurd. @@ -30,7 +30,7 @@ netfs_S_dir_rmdir (struct protid *diruser, char *name) return EOPNOTSUPP; mutex_lock (&diruser->po->np->lock); - err = netfs_attempt_rmdir (diruser->credential, diruser->po->np, name); + err = netfs_attempt_rmdir (diruser->user, diruser->po->np, name); mutex_unlock (&diruser->po->np->lock); return err; } diff --git a/libnetfs/dir-unlink.c b/libnetfs/dir-unlink.c index 4bf8798e..8077514a 100644 --- a/libnetfs/dir-unlink.c +++ b/libnetfs/dir-unlink.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1995 Free Software Foundation, Inc. + Copyright (C) 1995, 1996 Free Software Foundation, Inc. Written by Michael I. Bushnell, p/BSG. This file is part of the GNU Hurd. @@ -27,7 +27,7 @@ netfs_S_dir_unlink (struct protid *user, char *name) error_t err; mutex_lock (&user->po->np->lock); - err = netfs_attempt_unlink (user->credential, user->po->np, name); + err = netfs_attempt_unlink (user->user, user->po->np, name); mutex_unlock (&user->po->np->lock); return err; } diff --git a/libnetfs/file-chauthor.c b/libnetfs/file-chauthor.c index 1ed305bb..ec7f6177 100644 --- a/libnetfs/file-chauthor.c +++ b/libnetfs/file-chauthor.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1995 Free Software Foundation, Inc. + Copyright (C) 1995, 1996 Free Software Foundation, Inc. Written by Michael I. Bushnell, p/BSG. This file is part of the GNU Hurd. @@ -31,7 +31,7 @@ netfs_S_file_chauthor (struct protid *user, return EOPNOTSUPP; mutex_lock (&user->po->np->lock); - err = netfs_attempt_chauthor (user->credential, user->po->np, author); + err = netfs_attempt_chauthor (user->user, user->po->np, author); mutex_unlock (&user->po->np->lock); return err; } diff --git a/libnetfs/file-check-access.c b/libnetfs/file-check-access.c index c3c278d7..8e36ede1 100644 --- a/libnetfs/file-check-access.c +++ b/libnetfs/file-check-access.c @@ -25,11 +25,13 @@ error_t netfs_S_file_check_access (struct protid *user, int *types) { + error_t err; + if (!user) return EOPNOTSUPP; mutex_lock (&user->po->np->lock); - netfs_report_access (user->credential, user->po->np, types); + err = netfs_report_access (user->user, user->po->np, types); mutex_unlock (&user->po->np->lock); - return 0; + return err; } diff --git a/libnetfs/file-chflags.c b/libnetfs/file-chflags.c index 3bb96938..068a1cea 100644 --- a/libnetfs/file-chflags.c +++ b/libnetfs/file-chflags.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1995 Free Software Foundation, Inc. + Copyright (C) 1995, 1996 Free Software Foundation, Inc. Written by Michael I. Bushnell, p/BSG. This file is part of the GNU Hurd. @@ -31,7 +31,7 @@ netfs_S_file_chflags (struct protid *user, return EOPNOTSUPP; mutex_lock (&user->po->np->lock); - err = netfs_attempt_chflags (user->credential, user->po->np, flags); + err = netfs_attempt_chflags (user->user, user->po->np, flags); mutex_unlock (&user->po->np->lock); return err; } diff --git a/libnetfs/file-chmod.c b/libnetfs/file-chmod.c index ac725c6c..92b3437e 100644 --- a/libnetfs/file-chmod.c +++ b/libnetfs/file-chmod.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1995 Free Software Foundation, Inc. + Copyright (C) 1995, 1996 Free Software Foundation, Inc. Written by Michael I. Bushnell, p/BSG. This file is part of the GNU Hurd. @@ -31,7 +31,7 @@ netfs_S_file_chmod (struct protid *user, return EOPNOTSUPP; mutex_lock (&user->po->np->lock); - err = netfs_attempt_chmod (user->credential, user->po->np, mode); + err = netfs_attempt_chmod (user->user, user->po->np, mode); mutex_unlock (&user->po->np->lock); return err; } diff --git a/libnetfs/file-chown.c b/libnetfs/file-chown.c index d3484ba0..4b724048 100644 --- a/libnetfs/file-chown.c +++ b/libnetfs/file-chown.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1995 Free Software Foundation, Inc. + Copyright (C) 1995, 1996 Free Software Foundation, Inc. Written by Michael I. Bushnell, p/BSG. This file is part of the GNU Hurd. @@ -32,7 +32,7 @@ netfs_S_file_chown (struct protid *user, return EOPNOTSUPP; mutex_lock (&user->po->np->lock); - err = netfs_attempt_chown (user->credential, user->po->np, + err = netfs_attempt_chown (user->user, user->po->np, owner, group); mutex_unlock (&user->po->np->lock); return err; diff --git a/libnetfs/file-exec.c b/libnetfs/file-exec.c index 7268e7c7..1409fd63 100644 --- a/libnetfs/file-exec.c +++ b/libnetfs/file-exec.c @@ -73,7 +73,7 @@ netfs_S_file_exec (struct protid *cred, mode = np->nn_stat.st_mode; uid = np->nn_stat.st_uid; gid = np->nn_stat.st_gid; - err = netfs_validate_stat (np, cred->credential); + err = netfs_validate_stat (np, cred->user); mutex_unlock (&np->lock); if (err) @@ -94,17 +94,11 @@ netfs_S_file_exec (struct protid *cred, error_t get_file_ids (struct idvec *uidsvec, struct idvec *gidsvec) { error_t err; - uid_t *uids, *gids; - int nuids, ngids; - netfs_interpret_credential (cred->credential, &uids, &nuids, - &gids, &ngids); - - err = idvec_merge_ids (uidsvec, uids, nuids); + err = idvec_merge (uidsvec, cred->user->uids); if (! err) - err = idvec_merge_ids (gidsvec, gids, ngids); - free (uids); - free (gids); + err = idvec_merge (gidsvec, cred->user->gids); + return err; } err = @@ -130,7 +124,7 @@ netfs_S_file_exec (struct protid *cred, struct protid *newpi = netfs_make_protid (netfs_make_peropen (np, O_READ, cred->po->dotdotport), - netfs_copy_credential (cred->credential)); + iohelp_dup_iouser (cred->user)); err = exec_exec (_netfs_exec, ports_get_right (newpi), MACH_MSG_TYPE_MAKE_SEND, diff --git a/libnetfs/file-get-translator.c b/libnetfs/file-get-translator.c index 18e05fe6..d3c6342c 100644 --- a/libnetfs/file-get-translator.c +++ b/libnetfs/file-get-translator.c @@ -37,7 +37,7 @@ netfs_S_file_get_translator (struct protid *user, np = user->po->np; mutex_lock (&np->lock); - err = netfs_validate_stat (np, user->credential); + err = netfs_validate_stat (np, user->user); if (err) { @@ -53,7 +53,7 @@ netfs_S_file_get_translator (struct protid *user, vm_allocate (mach_task_self (), (vm_address_t *)trans, len, 1); bcopy (_HURD_SYMLINK, *trans, sizeof _HURD_SYMLINK); - err = netfs_attempt_readlink (user->credential, np, + err = netfs_attempt_readlink (user->user, np, *trans + sizeof _HURD_SYMLINK); if (!err) { diff --git a/libnetfs/file-getcontrol.c b/libnetfs/file-getcontrol.c index ccbd7541..c33d524f 100644 --- a/libnetfs/file-getcontrol.c +++ b/libnetfs/file-getcontrol.c @@ -29,34 +29,21 @@ netfs_S_file_getcontrol (struct protid *user, { error_t err; struct port_info *pi; - uid_t *uids, *gids; - int nuids, ngids; - int i; if (!user) return EOPNOTSUPP; - mutex_lock (&user->po->np->lock); - netfs_interpret_credential (user->credential, &uids, &nuids, &gids, &ngids); - mutex_unlock (&user->po->np->lock); - free (gids); - - for (i = 0; i < nuids; i++) - if (uids[i] == 0) - { - /* They've got root; give it to them. */ - free (uids); - err = ports_create_port (netfs_control_class, netfs_port_bucket, - sizeof (struct port_info), &pi); - if (err) - return err; - *control = ports_get_right (pi); - *controltype = MACH_MSG_TYPE_MAKE_SEND; - ports_port_deref (pi); - return 0; - } - - /* Not got root. */ - free (uids); - return EPERM; + if (!idvec_contains (user->user->uids, 0)) + return EPERM; + + /* They've got root; give it to them. */ + err = ports_create_port (netfs_control_class, netfs_port_bucket, + sizeof (struct port_info), &pi); + if (err) + return err; + + *control = ports_get_right (pi); + *controltype = MACH_MSG_TYPE_MAKE_SEND; + ports_port_deref (pi); + return 0; } diff --git a/libnetfs/file-set-size.c b/libnetfs/file-set-size.c index 7463ccfe..7b253e04 100644 --- a/libnetfs/file-set-size.c +++ b/libnetfs/file-set-size.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1995 Free Software Foundation, Inc. + Copyright (C) 1995, 1996 Free Software Foundation, Inc. Written by Michael I. Bushnell, p/BSG. This file is part of the GNU Hurd. @@ -31,7 +31,7 @@ netfs_S_file_set_size (struct protid *user, return EOPNOTSUPP; mutex_lock (&user->po->np->lock); - err = netfs_attempt_set_size (user->credential, user->po->np, size); + err = netfs_attempt_set_size (user->user, user->po->np, size); mutex_unlock (&user->po->np->lock); return err; } diff --git a/libnetfs/file-set-translator.c b/libnetfs/file-set-translator.c index 4307924a..f09230d6 100644 --- a/libnetfs/file-set-translator.c +++ b/libnetfs/file-set-translator.c @@ -33,8 +33,6 @@ netfs_S_file_set_translator (struct protid *user, { struct node *np; error_t err = 0; - uid_t *uids, *gids; - int nuids, ngids; int i; mach_port_t control; @@ -53,21 +51,14 @@ netfs_S_file_set_translator (struct protid *user, if (active_flags & FS_TRANS_SET) { /* Validate--user must be owner */ - netfs_interpret_credential (user->credential, &uids, &nuids, - &gids, &ngids); - err = netfs_validate_stat (np, user->credential); + err = netfs_validate_stat (np, user->user); if (err) goto out; - for (i = 0; i < nuids; i++) - if (uids[i] == 0 || uids[i] == np->nn_stat.st_uid) - break; - if (i == nuids) - { - mutex_unlock (&np->lock); - return EBUSY; - } - + err = fshelp_isowner (&np->nn_stat, user->user); + if (err) + goto out; + err = fshelp_fetch_control (&np->transbox, &control); if (err) goto out; @@ -87,7 +78,7 @@ netfs_S_file_set_translator (struct protid *user, if ((passive_flags & FS_TRANS_SET) && (passive_flags & FS_TRANS_EXCL)) { - err = netfs_validate_stat (np, user->credential); + err = netfs_validate_stat (np, user->user); if (!err && np->istranslated) err = EBUSY; if (err) @@ -148,7 +139,7 @@ netfs_S_file_set_translator (struct protid *user, } minor = strtol (arg, 0, 0); - err = netfs_attempt_mkdev (user->credential, np, + err = netfs_attempt_mkdev (user->user, np, newmode, makedev (major, minor)); if (err == EOPNOTSUPP) goto fallback; @@ -163,15 +154,15 @@ netfs_S_file_set_translator (struct protid *user, return EINVAL; } - err = netfs_attempt_mksymlink (user->credential, np, arg); + err = netfs_attempt_mksymlink (user->user, np, arg); if (err == EOPNOTSUPP) goto fallback; break; default: - err = netfs_validate_stat (np, user->credential); + err = netfs_validate_stat (np, user->user); if (!err) - err = netfs_attempt_chmod (user->credential, np, + err = netfs_attempt_chmod (user->user, np, ((np->nn_stat.st_mode & ~S_IFMT) | newmode)); if (err == EOPNOTSUPP) @@ -180,7 +171,7 @@ netfs_S_file_set_translator (struct protid *user, case 0: fallback: - err = netfs_set_translator (user->credential, np, + err = netfs_set_translator (user->user, np, passive, passivelen); break; } diff --git a/libnetfs/file-statfs.c b/libnetfs/file-statfs.c index 52e95272..180d29fc 100644 --- a/libnetfs/file-statfs.c +++ b/libnetfs/file-statfs.c @@ -31,7 +31,7 @@ netfs_S_file_statfs (struct protid *user, return EOPNOTSUPP; mutex_lock (&user->po->np->lock); - err = netfs_attempt_statfs (user->credential, user->po->np, st); + err = netfs_attempt_statfs (user->user, user->po->np, st); mutex_unlock (&user->po->np->lock); return err; } diff --git a/libnetfs/file-sync.c b/libnetfs/file-sync.c index 95bc0529..99492ed8 100644 --- a/libnetfs/file-sync.c +++ b/libnetfs/file-sync.c @@ -32,7 +32,7 @@ netfs_S_file_sync (struct protid *user, return EOPNOTSUPP; mutex_lock (&user->po->np->lock); - err = netfs_attempt_sync (user->credential, user->po->np, wait); + err = netfs_attempt_sync (user->user, user->po->np, wait); mutex_unlock (&user->po->np->lock); return err; } diff --git a/libnetfs/file-syncfs.c b/libnetfs/file-syncfs.c index 13af70ff..28e34a3a 100644 --- a/libnetfs/file-syncfs.c +++ b/libnetfs/file-syncfs.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1995 Free Software Foundation, Inc. + Copyright (C) 1995, 1996 Free Software Foundation, Inc. Written by Michael I. Bushnell, p/BSG. This file is part of the GNU Hurd. @@ -34,7 +34,7 @@ netfs_S_file_syncfs (struct protid *user, /* Translators not yet supported by netfs. XXX */ mutex_lock (&user->po->np->lock); - err = netfs_attempt_syncfs (user->credential, wait); + err = netfs_attempt_syncfs (user->user, wait); mutex_unlock (&user->po->np->lock); return err; } diff --git a/libnetfs/file-utimes.c b/libnetfs/file-utimes.c index f641c8da..abe2f6c4 100644 --- a/libnetfs/file-utimes.c +++ b/libnetfs/file-utimes.c @@ -38,7 +38,7 @@ netfs_S_file_utimes (struct protid *user, return EOPNOTSUPP; mutex_lock (&user->po->np->lock); - err = netfs_attempt_utimes (user->credential, user->po->np, &atime, &mtime); + err = netfs_attempt_utimes (user->user, user->po->np, &atime, &mtime); mutex_unlock (&user->po->np->lock); return err; } diff --git a/libnetfs/fsys-getroot.c b/libnetfs/fsys-getroot.c index f7f40385..a0de21c6 100644 --- a/libnetfs/fsys-getroot.c +++ b/libnetfs/fsys-getroot.c @@ -37,16 +37,22 @@ netfs_S_fsys_getroot (mach_port_t cntl, { struct port_info *pt = ports_lookup_port (netfs_port_bucket, cntl, netfs_control_class); - struct netcred *cred; + struct iouser *cred; error_t err; struct protid *newpi; mode_t type; + struct idvec *uvec, *gvec; if (!pt) return EOPNOTSUPP; ports_port_deref (pt); - cred = netfs_make_credential (uids, nuids, gids, ngids); + uvec = make_idvec (); + gvec = make_idvec (); + idvec_set_ids (uvec, uids, nuids); + idvec_set_ids (gvec, gids, ngids); + + cred = iohelp_create_iouser (uvec, gvec); flags &= O_HURD; @@ -62,14 +68,14 @@ netfs_S_fsys_getroot (mach_port_t cntl, && !(flags & O_NOTRANS)) { err = fshelp_fetch_root (&netfs_root_node->transbox, - &dotdot, dotdot, uids, nuids, - gids, ngids, flags, + &dotdot, dotdot, cred, flags, _netfs_translator_callback1, _netfs_translator_callback2, do_retry, retry_name, retry_port); if (err != ENOENT) { mutex_unlock (&netfs_root_node->lock); + iohelp_free_iouser (cred); if (!err) *retry_port_type = MACH_MSG_TYPE_MOVE_SEND; return err; @@ -84,10 +90,12 @@ netfs_S_fsys_getroot (mach_port_t cntl, err = netfs_attempt_readlink (cred, netfs_root_node, pathbuf); - mutex_unlock (&netfs_root_node->lock); if (err) goto out; + mutex_unlock (&netfs_root_node->lock); + iohelp_free_iouser (cred); + if (pathbuf[0] == '/') { *do_retry = FS_RETRY_MAGICAL; @@ -110,8 +118,8 @@ netfs_S_fsys_getroot (mach_port_t cntl, if ((type == S_IFSOCK || type == S_IFBLK || type == S_IFCHR || type == S_IFIFO) && (flags & (O_READ|O_WRITE|O_EXEC))) { - mutex_unlock (&netfs_root_node->lock); - return EOPNOTSUPP; + err = EOPNOTSUPP; + goto out; } err = netfs_check_open_permissions (cred, netfs_root_node, flags, 0); @@ -131,6 +139,8 @@ netfs_S_fsys_getroot (mach_port_t cntl, ports_port_deref (newpi); out: + if (err) + iohelp_free_iouser (cred); mutex_unlock (&netfs_root_node->lock); return err; } diff --git a/libnetfs/fsys-syncfs.c b/libnetfs/fsys-syncfs.c index b652890e..3c52ee2b 100644 --- a/libnetfs/fsys-syncfs.c +++ b/libnetfs/fsys-syncfs.c @@ -26,12 +26,14 @@ netfs_S_fsys_syncfs (mach_port_t cntl, int wait, int children) { - struct netcred *cred; + struct iouser *cred; uid_t root = 0; error_t err; - cred = netfs_make_credential (&root, 1, &root, 1); + cred = iohelp_make_iouser (make_idvec (), make_idvec ()); + idvec_set_ids (cred->uids, &root, 1); + idvec_set_ids (cred->gids, &root, 1); err = netfs_attempt_syncfs (cred, wait); - netfs_drop_credential (cred); + iohelp_free_iouser (cred); return err; } diff --git a/libnetfs/io-duplicate.c b/libnetfs/io-duplicate.c index ba3954af..a41af9bf 100644 --- a/libnetfs/io-duplicate.c +++ b/libnetfs/io-duplicate.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1995 Free Software Foundation, Inc. + Copyright (C) 1995, 1996 Free Software Foundation, Inc. Written by Michael I. Bushnell, p/BSG. This file is part of the GNU Hurd. @@ -30,7 +30,7 @@ netfs_S_io_duplicate (struct protid *user, mutex_lock (&user->po->np->lock); newpi = netfs_make_protid (user->po, - netfs_copy_credential (user->credential)); + iohelp_dup_iouser (user->user)); *newport = ports_get_right (newpi); mutex_unlock (&user->po->np->lock); *newporttp = MACH_MSG_TYPE_MAKE_SEND; diff --git a/libnetfs/io-identity.c b/libnetfs/io-identity.c index 0656b4dc..e259a0f7 100644 --- a/libnetfs/io-identity.c +++ b/libnetfs/io-identity.c @@ -38,7 +38,7 @@ netfs_S_io_identity (struct protid *cred, np = cred->po->np; mutex_lock (&np->lock); - err = netfs_validate_stat (np, cred->credential); + err = netfs_validate_stat (np, cred->user); if (err) { mutex_unlock (&np->lock); diff --git a/libnetfs/io-read.c b/libnetfs/io-read.c index 54914935..09887153 100644 --- a/libnetfs/io-read.c +++ b/libnetfs/io-read.c @@ -50,7 +50,7 @@ netfs_S_io_read (struct protid *user, } *datalen = amount; - err = netfs_attempt_read (user->credential, user->po->np, + err = netfs_attempt_read (user->user, user->po->np, offset == -1 ? user->po->filepointer : offset, datalen, *data); if (offset == -1 && !err) diff --git a/libnetfs/io-readable.c b/libnetfs/io-readable.c index 13b0346d..ad6bf3c1 100644 --- a/libnetfs/io-readable.c +++ b/libnetfs/io-readable.c @@ -1,6 +1,6 @@ /* - Copyright (C) 1995 Free Software Foundation, Inc. + Copyright (C) 1995, 1996 Free Software Foundation, Inc. Written by Michael I. Bushnell, p/BSG. This file is part of the GNU Hurd. @@ -36,7 +36,7 @@ netfs_S_io_readable (struct protid *user, return EINVAL; mutex_lock (&user->po->np->lock); - err = netfs_validate_stat (user->po->np, user->credential); + err = netfs_validate_stat (user->po->np, user->user); if (!err) { if (user->po->np->nn_stat.st_size > user->po->filepointer) diff --git a/libnetfs/io-reauthenticate.c b/libnetfs/io-reauthenticate.c index dff3af8f..c88e773d 100644 --- a/libnetfs/io-reauthenticate.c +++ b/libnetfs/io-reauthenticate.c @@ -25,21 +25,12 @@ error_t netfs_S_io_reauthenticate (struct protid *user, mach_port_t rend_port) { struct protid *newpi; - uid_t gubuf[20], ggbuf[20], aubuf[20], agbuf[20]; - uid_t *gen_uids, *gen_gids, *aux_uids, *aux_gids; - u_int genuidlen, gengidlen, auxuidlen, auxgidlen; error_t err; mach_port_t newright; if (!user) return EOPNOTSUPP; - genuidlen = gengidlen = auxuidlen = auxgidlen = 20; - gen_uids = gubuf; - gen_gids = ggbuf; - aux_uids = aubuf; - aux_gids = agbuf; - mutex_lock (&user->po->np->lock); newpi = netfs_make_protid (user->po, 0); @@ -47,43 +38,17 @@ netfs_S_io_reauthenticate (struct protid *user, mach_port_t rend_port) err = mach_port_insert_right (mach_task_self (), newright, newright, MACH_MSG_TYPE_MAKE_SEND); assert_perror (err); - do - err = auth_server_authenticate (netfs_auth_server_port, - rend_port, - MACH_MSG_TYPE_COPY_SEND, - newright, - MACH_MSG_TYPE_COPY_SEND, - &gen_uids, &genuidlen, - &aux_uids, &auxuidlen, - &gen_gids, &gengidlen, - &aux_uids, &auxuidlen); - while (err == EINTR); + + newpi->user = iohelp_reauth (netfs_auth_server_port, rend_port, newright, 1); + mach_port_deallocate (mach_task_self (), rend_port); mach_port_deallocate (mach_task_self (), newright); - if (err) - newpi->credential = netfs_make_credential (0, 0, 0, 0); - else - newpi->credential = netfs_make_credential (gen_uids, genuidlen, - gen_gids, gengidlen); - mach_port_move_member (mach_task_self (), newpi->pi.port_right, netfs_port_bucket->portset); mutex_unlock (&user->po->np->lock); ports_port_deref (newpi); - if (gen_uids != gubuf) - vm_deallocate (mach_task_self (), (vm_address_t) gen_uids, - genuidlen * sizeof (uid_t)); - if (aux_uids != aubuf) - vm_deallocate (mach_task_self (), (vm_address_t) aux_uids, - auxuidlen * sizeof (uid_t)); - if (gen_gids != ggbuf) - vm_deallocate (mach_task_self (), (vm_address_t) gen_gids, - gengidlen * sizeof (uid_t)); - if (aux_gids != agbuf) - vm_deallocate (mach_task_self (), (vm_address_t) aux_gids, - auxgidlen * sizeof (uid_t)); return 0; } diff --git a/libnetfs/io-restrict-auth.c b/libnetfs/io-restrict-auth.c index 1a175a35..9d1fda3c 100644 --- a/libnetfs/io-restrict-auth.c +++ b/libnetfs/io-restrict-auth.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1995 Free Software Foundation, Inc. + Copyright (C) 1995, 1996 Free Software Foundation, Inc. Written by Michael I. Bushnell, p/BSG. This file is part of the GNU Hurd. @@ -40,28 +40,34 @@ netfs_S_io_restrict_auth (struct protid *user, gid_t *gids, mach_msg_type_number_t ngids) { - uid_t *newuids, *newgids, *olduids, *oldgids; - int i, newnuids, newngids, oldnuids, oldngids; + struct idvec *uvec, *gvec; + int i; struct protid *newpi; if (!user) return EOPNOTSUPP; - mutex_lock (&user->po->np->lock); - netfs_interpret_credential (user->credential, &olduids, &oldnuids, - &oldgids, &oldngids); - newuids = alloca (sizeof (uid_t) * oldnuids); - newgids = alloca (sizeof (gid_t) * oldngids); - for (i = newnuids = 0; i < oldnuids; i++) - if (listmember (uids, olduids[i], nuids)) - newuids[newnuids++] = olduids[i]; - for (i = newngids = 0; i < oldngids; i++) - if (listmember (gids, oldgids[i], ngids)) - newgids[newngids++] = oldgids[i]; + uvec = make_idvec (); + gvec = make_idvec (); + + if (idvec_contains (user->user->uids, 0)) + { + idvec_set_ids (uvec, uids, nuids); + idvec_set_ids (gvec, gids, ngids); + } + else + { + for (i = 0; i < user->user->uids->num; i++) + if (listmember (uids, user->user->uids->ids[i], nuids)) + idvec_add (uvec, user->user->uids->ids[i]); + + for (i = 0; i < user->user->gids->num; i++) + if (listmember (gids, user->user->gids->ids[i], ngids)) + idvec_add (gvec, user->user->gids->ids[i]); + } - newpi = netfs_make_protid (user->po, - netfs_make_credential (newuids, newnuids, - newgids, newngids)); + mutex_lock (&user->po->np->lock); + newpi = netfs_make_protid (user->po, iohelp_create_iouser (uvec, gvec)); *newport = ports_get_right (newpi); mutex_unlock (&user->po->np->lock); diff --git a/libnetfs/io-seek.c b/libnetfs/io-seek.c index 55d924c8..1e517ff4 100644 --- a/libnetfs/io-seek.c +++ b/libnetfs/io-seek.c @@ -47,7 +47,7 @@ netfs_S_io_seek (struct protid *user, break; case SEEK_END: - err = netfs_validate_stat (user->po->np, user->credential); + err = netfs_validate_stat (user->po->np, user->user); if (!err) user->po->filepointer = user->po->np->nn_stat.st_size + offset; break; diff --git a/libnetfs/io-stat.c b/libnetfs/io-stat.c index 0e4f5d6f..1bc1b17f 100644 --- a/libnetfs/io-stat.c +++ b/libnetfs/io-stat.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1995 Free Software Foundation, Inc. + Copyright (C) 1995, 1996 Free Software Foundation, Inc. Written by Michael I. Bushnell, p/BSG. This file is part of the GNU Hurd. @@ -32,7 +32,7 @@ netfs_S_io_stat (struct protid *fileuser, return EOPNOTSUPP; mutex_lock (&fileuser->po->np->lock); - err = netfs_validate_stat (fileuser->po->np, fileuser->credential); + err = netfs_validate_stat (fileuser->po->np, fileuser->user); if (!err) bcopy (&fileuser->po->np->nn_stat, statbuf, sizeof (struct stat)); mutex_unlock (&fileuser->po->np->lock); diff --git a/libnetfs/io-write.c b/libnetfs/io-write.c index c299d15c..26c3c297 100644 --- a/libnetfs/io-write.c +++ b/libnetfs/io-write.c @@ -51,7 +51,7 @@ netfs_S_io_write (struct protid *user, { if (user->po->openstat & O_APPEND) { - err = netfs_validate_stat (np, user->credential); + err = netfs_validate_stat (np, user->user); if (err) { mutex_unlock (&np->lock); @@ -62,7 +62,7 @@ netfs_S_io_write (struct protid *user, off = user->po->filepointer; } - err = netfs_attempt_write (user->credential, np, off, amount, data); + err = netfs_attempt_write (user->user, np, off, amount, data); if (offset == -1 && !err) user->po->filepointer += *amount; mutex_unlock (&np->lock); diff --git a/libnetfs/make-protid.c b/libnetfs/make-protid.c index 7d9240a1..bf18283c 100644 --- a/libnetfs/make-protid.c +++ b/libnetfs/make-protid.c @@ -21,7 +21,7 @@ #include "netfs.h" struct protid * -netfs_make_protid (struct peropen *po, struct netcred *cred) +netfs_make_protid (struct peropen *po, struct iouser *cred) { struct protid *pi; @@ -38,7 +38,7 @@ netfs_make_protid (struct peropen *po, struct netcred *cred) po->refcnt++; pi->po = po; - pi->credential = cred; + pi->user = cred; pi->shared_object = MACH_PORT_NULL; pi->mapped = 0; return pi; diff --git a/libnetfs/netfs.h b/libnetfs/netfs.h index cad8e042..bb9bcc32 100644 --- a/libnetfs/netfs.h +++ b/libnetfs/netfs.h @@ -39,7 +39,7 @@ struct protid struct port_info pi; /* User identification */ - struct netcred *credential; + struct iouser *user; /* Object this refers to */ struct peropen *po; @@ -92,18 +92,18 @@ struct node /* The user must define this function. Make sure that NP->nn_stat is filled with current information. CRED identifies the user responsible for the operation. */ -error_t netfs_validate_stat (struct node *NP, struct netcred *cred); +error_t netfs_validate_stat (struct node *NP, struct iouser *cred); /* The user must define this function. This should attempt a chmod call for the user specified by CRED on node NODE, to change the owner to UID and the group to GID. */ -error_t netfs_attempt_chown (struct netcred *cred, struct node *np, +error_t netfs_attempt_chown (struct iouser *cred, struct node *np, uid_t uid, uid_t gid); /* The user must define this function. This should attempt a chauthor call for the user specified by CRED on node NODE, to change the author to AUTHOR. */ -error_t netfs_attempt_chauthor (struct netcred *cred, struct node *np, +error_t netfs_attempt_chauthor (struct iouser *cred, struct node *np, uid_t author); /* The user must define this function. This should attempt a chmod @@ -113,83 +113,83 @@ error_t netfs_attempt_chauthor (struct netcred *cred, struct node *np, types. If such a transition is attempted which is impossible, then return EOPNOTSUPP. */ -error_t netfs_attempt_chmod (struct netcred *cred, struct node *np, +error_t netfs_attempt_chmod (struct iouser *cred, struct node *np, mode_t mode); /* The user must define this function. Attempt to turn NODE (user CRED) into a symlink with target NAME. */ -error_t netfs_attempt_mksymlink (struct netcred *cred, struct node *np, +error_t netfs_attempt_mksymlink (struct iouser *cred, struct node *np, char *name); /* The user must define this function. Attempt to turn NODE (user CRED) into a device. TYPE is either S_IFBLK or S_IFCHR. */ -error_t netfs_attempt_mkdev (struct netcred *cred, struct node *np, +error_t netfs_attempt_mkdev (struct iouser *cred, struct node *np, mode_t type, dev_t indexes); /* The user must define this function. Attempt to set the passive translator record for FILE to ARGZ (of length ARGZLEN) for user CRED. */ -error_t netfs_set_translator (struct netcred *cred, struct node *np, +error_t netfs_set_translator (struct iouser *cred, struct node *np, char *argz, size_t argzlen); /* The user must define this function. This should attempt a chflags call for the user specified by CRED on node NODE, to change the flags to FLAGS. */ -error_t netfs_attempt_chflags (struct netcred *cred, struct node *np, +error_t netfs_attempt_chflags (struct iouser *cred, struct node *np, int flags); /* The user must define this function. This should attempt a utimes call for the user specified by CRED on node NODE, to change the atime to ATIME and the mtime to MTIME. */ -error_t netfs_attempt_utimes (struct netcred *cred, struct node *np, +error_t netfs_attempt_utimes (struct iouser *cred, struct node *np, struct timespec *atime, struct timespec *mtime); /* The user must define this function. This should attempt to set the size of the file NODE (for user CRED) to SIZE bytes long. */ -error_t netfs_attempt_set_size (struct netcred *cred, struct node *np, +error_t netfs_attempt_set_size (struct iouser *cred, struct node *np, off_t size); /* The user must define this function. This should attempt to fetch filesystem status information for the remote filesystem, for the user CRED. */ -error_t netfs_attempt_statfs (struct netcred *cred, struct node *np, +error_t netfs_attempt_statfs (struct iouser *cred, struct node *np, struct statfs *st); /* The user must define this function. This should sync the file NP completely to disk, for the user CRED. If WAIT is set, return only after sync is completely finished. */ -error_t netfs_attempt_sync (struct netcred *cred, struct node *np, +error_t netfs_attempt_sync (struct iouser *cred, struct node *np, int wait); /* The user must define this function. This should sync the entire remote filesystem. If WAIT is set, return only after sync is completely finished. */ -error_t netfs_attempt_syncfs (struct netcred *cred, int wait); +error_t netfs_attempt_syncfs (struct iouser *cred, int wait); /* The user must define this function. Lookup NAME in DIR for USER; set *NP to the found name upon return. If the name was not found, then return ENOENT. On any error, clear *NP. (*NP, if found, should be locked, this call should unlock DIR no matter what.) */ -error_t netfs_attempt_lookup (struct netcred *user, struct node *dir, +error_t netfs_attempt_lookup (struct iouser *user, struct node *dir, char *name, struct node **np); /* The user must define this function. Delete NAME in DIR for USER. */ -error_t netfs_attempt_unlink (struct netcred *user, struct node *dir, +error_t netfs_attempt_unlink (struct iouser *user, struct node *dir, char *name); /* Note that in this one call, neither of the specific nodes are locked. */ -error_t netfs_attempt_rename (struct netcred *user, struct node *fromdir, +error_t netfs_attempt_rename (struct iouser *user, struct node *fromdir, char *fromname, struct node *todir, char *toname, int excl); /* The user must define this function. Attempt to create a new directory named NAME in DIR for USER with mode MODE. */ -error_t netfs_attempt_mkdir (struct netcred *user, struct node *dir, +error_t netfs_attempt_mkdir (struct iouser *user, struct node *dir, char *name, mode_t mode); /* The user must define this function. Attempt to remove directory named NAME in DIR for USER. */ -error_t netfs_attempt_rmdir (struct netcred *user, +error_t netfs_attempt_rmdir (struct iouser *user, struct node *dir, char *name); @@ -197,76 +197,63 @@ error_t netfs_attempt_rmdir (struct netcred *user, NAME to FILE for USER. Note that neither DIR nor FILE are locked. If EXCL is set, do not delete the target, but return EEXIST if NAME is already found in DIR. */ -error_t netfs_attempt_link (struct netcred *user, struct node *dir, +error_t netfs_attempt_link (struct iouser *user, struct node *dir, struct node *file, char *name, int excl); /* The user must define this function. Attempt to create an anonymous file related to DIR for USER with MODE. Set *NP to the returned file upon success. No matter what, unlock DIR. */ -error_t netfs_attempt_mkfile (struct netcred *user, struct node *dir, +error_t netfs_attempt_mkfile (struct iouser *user, struct node *dir, mode_t mode, struct node **np); /* The user must define this function. Attempt to create a file named NAME in DIR for USER with MODE. Set *NP to the new node upon return. On any error, clear *NP. *NP should be locked on success; no matter what, unlock DIR before returning. */ -error_t netfs_attempt_create_file (struct netcred *user, struct node *dir, +error_t netfs_attempt_create_file (struct iouser *user, struct node *dir, char *name, mode_t mode, struct node **np); /* The user must define this function. Read the contents of NP (a symlink), for USER, into BUF. */ -error_t netfs_attempt_readlink (struct netcred *user, struct node *np, +error_t netfs_attempt_readlink (struct iouser *user, struct node *np, char *buf); /* The user must define this function. Node NP is being opened by USER, with FLAGS. NEWNODE is nonzero if we just created this node. Return an error if we should not permit the open to complete because of a permission restriction. */ -error_t netfs_check_open_permissions (struct netcred *user, struct node *np, +error_t netfs_check_open_permissions (struct iouser *user, struct node *np, int flags, int newnode); /* The user must define this function. Read from the file NP for user CRED starting at OFFSET and continuing for up to *LEN bytes. Put the data at DATA. Set *LEN to the amount successfully read upon return. */ -error_t netfs_attempt_read (struct netcred *cred, struct node *np, +error_t netfs_attempt_read (struct iouser *cred, struct node *np, off_t offset, size_t *len, void *data); /* The user must define this function. Write to the file NP for user CRED starting at OFSET and continuing for up to *LEN bytes from DATA. Set *LEN to the amount seccessfully written upon return. */ -error_t netfs_attempt_write (struct netcred *cred, struct node *np, +error_t netfs_attempt_write (struct iouser *cred, struct node *np, off_t offset, size_t *len, void *data); /* The user must define this function. Return the valid access types (bitwise OR of O_READ, O_WRITE, and O_EXEC) in *TYPES for file NP and user CRED. */ -void netfs_report_access (struct netcred *cred, struct node *np, - int *types); +error_t netfs_report_access (struct iouser *cred, struct node *np, + int *types); -/* The user must define this function. Malloc and fill two arrays with - the uids and gids from the specified credential. */ -void netfs_interpret_credential (struct netcred *cred, uid_t **uids, - int *nuids, uid_t **gids, int *ngids); - -/* The user must define this function. Return a (virtual or physical) - copy of CRED. */ -struct netcred *netfs_copy_credential (struct netcred *cred); - -/* The user must define this function. The specified credential is - not in use any more. */ -void netfs_drop_credential (struct netcred *cred); - -/* The user must define this function. Create a new credential +/* The user must define this function. Create a new user from the specified UID and GID arrays. */ -struct netcred *netfs_make_credential (uid_t *uids, int nuids, +struct iouser *netfs_make_user (uid_t *uids, int nuids, uid_t *gids, int ngids); /* The user must define this function. Node NP is all done; free all its associated storage. */ void netfs_node_norefs (struct node *np); -error_t netfs_get_dirents (struct netcred *, struct node *, int, int, char **, +error_t netfs_get_dirents (struct iouser *, struct node *, int, int, char **, mach_msg_type_number_t *, vm_size_t, int *); /* Option parsing */ @@ -314,7 +301,7 @@ extern int netfs_maxsymlinks; void netfs_init (void); void netfs_server_loop (void); -struct protid *netfs_make_protid (struct peropen *, struct netcred *); +struct protid *netfs_make_protid (struct peropen *, struct iouser *); struct peropen *netfs_make_peropen (struct node *, int, mach_port_t); void netfs_drop_node (struct node *); void netfs_release_protid (void *); diff --git a/libnetfs/release-protid.c b/libnetfs/release-protid.c index 3585021f..6654123e 100644 --- a/libnetfs/release-protid.c +++ b/libnetfs/release-protid.c @@ -25,7 +25,7 @@ netfs_release_protid (void *arg) { struct protid *user = arg; - netfs_drop_credential (user->credential); + iohelp_free_iouser (user->user); if (user->shared_object) mach_port_deallocate (mach_task_self (), user->shared_object); if (user->mapped) |