xattr_security.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Security xattr support for devpts.
  3. *
  4. * Author: Stephen Smalley <sds@epoch.ncsc.mil>
  5. * Copyright (c) 2004 Red Hat, Inc., James Morris <jmorris@redhat.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the Free
  9. * Software Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. */
  12. #include <linux/string.h>
  13. #include <linux/fs.h>
  14. #include <linux/security.h>
  15. #include <linux/xattr.h>
  16. static size_t
  17. devpts_xattr_security_list(struct inode *inode, char *list, size_t list_len,
  18. const char *name, size_t name_len)
  19. {
  20. return security_inode_listsecurity(inode, list, list_len);
  21. }
  22. static int
  23. devpts_xattr_security_get(struct inode *inode, const char *name,
  24. void *buffer, size_t size)
  25. {
  26. if (strcmp(name, "") == 0)
  27. return -EINVAL;
  28. return security_inode_getsecurity(inode, name, buffer, size);
  29. }
  30. static int
  31. devpts_xattr_security_set(struct inode *inode, const char *name,
  32. const void *value, size_t size, int flags)
  33. {
  34. if (strcmp(name, "") == 0)
  35. return -EINVAL;
  36. return security_inode_setsecurity(inode, name, value, size, flags);
  37. }
  38. struct xattr_handler devpts_xattr_security_handler = {
  39. .prefix = XATTR_SECURITY_PREFIX,
  40. .list = devpts_xattr_security_list,
  41. .get = devpts_xattr_security_get,
  42. .set = devpts_xattr_security_set,
  43. };