diff options
author | Michael I. Bushnell <mib@gnu.org> | 1996-04-02 14:17:23 +0000 |
---|---|---|
committer | Michael I. Bushnell <mib@gnu.org> | 1996-04-02 14:17:23 +0000 |
commit | 0c06d5bb0f5a4892b9076bdbef9b68923919b8d8 (patch) | |
tree | c890251c85359a9f617ec6a2dbf27c5b7868d2ae | |
parent | 219931ab8c0863311aa7f1970df1e26914a58365 (diff) |
(netfs_report_access): Support new calling convention wrt TYPES.
-rw-r--r-- | nfs/ops.c | 42 |
1 files changed, 23 insertions, 19 deletions
@@ -959,6 +959,9 @@ netfs_report_access (struct netcred *cred, here we err on the side of denying access, and that we always have to check everything. */ + if (*types == 0) + return; + len = 1; err = netfs_attempt_read (cred, np, 0, &len, &byte); if (err) @@ -967,28 +970,29 @@ netfs_report_access (struct netcred *cred, return; } - *types = O_READ | O_EXEC; - assert (len == 1 || len == 0); - if (len == 1) - { - err = netfs_attempt_write (cred, np, 0, &len, &byte); - if (!err) - *types |= O_WRITE; - } - else + if (*types & O_WRITE) { - /* Oh, ugh. We have to try and write a byte and then truncate - back. God help us if the file becomes unwritable in-between. - But because of the use of this function (by setuid programs - wanting to see if they should write user's files) we must - check this and not just return a presumptive error. */ - byte = 0; - err = netfs_attempt_write (cred, np, 0, &len, &byte); - if (!err) - *types |= O_WRITE; - netfs_attempt_set_size (cred, np, 0); + if (len == 1) + { + err = netfs_attempt_write (cred, np, 0, &len, &byte); + if (err) + *types &= ~O_WRITE; + } + else + { + /* Oh, ugh. We have to try and write a byte and then truncate + back. God help us if the file becomes unwritable in-between. + But because of the use of this function (by setuid programs + wanting to see if they should write user's files) we must + check this and not just return a presumptive error. */ + byte = 0; + err = netfs_attempt_write (cred, np, 0, &len, &byte); + if (err) + *types &= ~O_WRITE; + netfs_attempt_set_size (cred, np, 0); + } } } |