[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 40/87: libdiskfs: add permission check to file_chflags
From: |
Samuel Thibault |
Subject: |
[hurd] 40/87: libdiskfs: add permission check to file_chflags |
Date: |
Sun, 09 Nov 2014 11:05:02 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch upstream
in repository hurd.
commit 944cfdbe6cff4e8025a730228b48c1a21b4a2e33
Author: Justus Winter <address@hidden>
Date: Tue Jun 10 14:22:31 2014 +0200
libdiskfs: add permission check to file_chflags
Only root is allowed to change the high 16 bits. The TODO entry says
otherwise, but that must be a mistake. For reference, see the glibc
sources, sysdeps/mach/hurd/bits/stat.h.
* libdiskfs/file-chflags.c (diskfs_S_file_chflags): Add permission
check.
* TODO (libdiskfs): Remove entry.
---
TODO | 2 --
libdiskfs/file-chflags.c | 8 ++++++++
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/TODO b/TODO
index d2500dc..0387e9f 100644
--- a/TODO
+++ b/TODO
@@ -108,8 +108,6 @@ See `tasks', the exported task list.
Rename the rest to libhurdutil or somesuch.
** libdiskfs
-*** file_chflags does not do proper permission checking (non-root isn't
- supposed to be able to change the low bits)
*** Add the short-circuited-but-not-builtin translator startup code from
dir-lookup to fsys_getroot. Compare and match carefully these two
routines and then share common code.
diff --git a/libdiskfs/file-chflags.c b/libdiskfs/file-chflags.c
index 01dc495..a29ff07 100644
--- a/libdiskfs/file-chflags.c
+++ b/libdiskfs/file-chflags.c
@@ -23,8 +23,15 @@ kern_return_t
diskfs_S_file_chflags (struct protid *cred,
int flags)
{
+#define HI(X) ((X) & 0xffff0000u)
CHANGE_NODE_FIELD (cred,
({
+ /* Only root is allowed to change the high 16
+ bits. */
+ if ((HI (flags) != HI (np->dn_stat.st_flags))
+ && ! idvec_contains (cred->user->uids, 0))
+ return EPERM;
+
err = fshelp_isowner (&np->dn_stat, cred->user);
if (!err)
err = diskfs_validate_flags_change (np, flags);
@@ -37,4 +44,5 @@ diskfs_S_file_chflags (struct protid *cred,
diskfs_notice_filechange(np, FILE_CHANGED_META,
0, 0);
}));
+#undef HI
}
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] 27/87: Add the random translator to prog-subdirs, (continued)
- [hurd] 27/87: Add the random translator to prog-subdirs, Samuel Thibault, 2014/11/09
- [hurd] 33/87: Merge procfs into the Hurd repository, Samuel Thibault, 2014/11/09
- [hurd] 34/87: Add the procfs translator to prog-subdirs, Samuel Thibault, 2014/11/09
- [hurd] 36/87: ftpfs: fix error handling in refresh_dir, Samuel Thibault, 2014/11/09
- [hurd] 29/87: hurd: fix receiver lookup in termctty_open_terminal, Samuel Thibault, 2014/11/09
- [hurd] 35/87: Add mach_debug defs rules, Samuel Thibault, 2014/11/09
- [hurd] 37/87: libshouldbeinlibc: fix dead initialization in fmt_named_interval, Samuel Thibault, 2014/11/09
- [hurd] 32/87: Prepare the procfs translator to be merged into the Hurd sources, Samuel Thibault, 2014/11/09
- [hurd] 38/87: trans/fakeroot: fix error handling, Samuel Thibault, 2014/11/09
- [hurd] 39/87: libports: avoid realloc(3) corner case, Samuel Thibault, 2014/11/09
- [hurd] 40/87: libdiskfs: add permission check to file_chflags,
Samuel Thibault <=
- [hurd] 31/87: Merge branch 'merge-random', Samuel Thibault, 2014/11/09
- [hurd] 41/87: libdiskfs: expose the ST_NOATIME flag, Samuel Thibault, 2014/11/09
- [hurd] 43/87: ext2fs: use correct type for block numbers, Samuel Thibault, 2014/11/09
- [hurd] 42/87: libdiskfs: fix deadlock, Samuel Thibault, 2014/11/09
- [hurd] 44/87: libpipe: fix calls to pipe_send with no data, Samuel Thibault, 2014/11/09
- [hurd] 24/87: ext2fs: fix type of retry_dotdot, Samuel Thibault, 2014/11/09
- [hurd] 23/87: ext2fs: fix type of blockaddr, Samuel Thibault, 2014/11/09
- [hurd] 30/87: utils/settrans: implement settrans --start, Samuel Thibault, 2014/11/09
- [hurd] 25/87: Prepare the random translator to be merged into the Hurd sources, Samuel Thibault, 2014/11/09
- [hurd] 46/87: libpipe: fix spurious calls to pipe_send, Samuel Thibault, 2014/11/09