busybox-1.4.0-conf.patch 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. --- busybox-1.4.0/applets/applets.c Fri Jan 19 22:23:11 2007
  2. +++ busybox-1.4.0-conf/applets/applets.c Wed Jan 24 10:15:49 2007
  3. @@ -340,20 +340,26 @@
  4. if (sct) {
  5. mode_t m = sct->m_mode;
  6. - if (sct->m_uid == ruid) /* same uid */
  7. + if (sct->m_uid == ruid)
  8. + /* same uid */
  9. m >>= 6;
  10. - else if ((sct->m_gid == rgid) || ingroup(ruid, sct->m_gid)) /* same group / in group */
  11. + else if ((sct->m_gid == rgid) || ingroup(ruid, sct->m_gid))
  12. + /* same group / in group */
  13. m >>= 3;
  14. if (!(m & S_IXOTH)) /* is x bit not set ? */
  15. bb_error_msg_and_die("you have no permission to run this applet!");
  16. - if ((sct->m_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) { /* *both* have to be set for sgid */
  17. - xsetgid(sct->m_gid);
  18. - } else xsetgid(rgid); /* no sgid -> drop */
  19. -
  20. - if (sct->m_mode & S_ISUID) xsetuid(sct->m_uid);
  21. - else xsetuid(ruid); /* no suid -> drop */
  22. + if (sct->m_gid != 0) {
  23. + /* _both_ have to be set for sgid */
  24. + if ((sct->m_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) {
  25. + xsetgid(sct->m_gid);
  26. + } else xsetgid(rgid); /* no sgid -> drop */
  27. + }
  28. + if (sct->m_uid != 0) {
  29. + if (sct->m_mode & S_ISUID) xsetuid(sct->m_uid);
  30. + else xsetuid(ruid); /* no suid -> drop */
  31. + }
  32. } else {
  33. /* default: drop all privileges */
  34. xsetgid(rgid);