e2fsprogs-1.37-2.patch 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  1. diff -urN e2fsprogs-1.37/ChangeLog e2fsprogs-1.37-patched/ChangeLog
  2. --- e2fsprogs-1.37/ChangeLog 2005-03-21 21:37:01.000000000 -0600
  3. +++ e2fsprogs-1.37-patched/ChangeLog 2005-06-18 16:34:01.000000000 -0500
  4. @@ -1,3 +1,8 @@
  5. +2005-03-31 Theodore Ts'o <tytso@mit.edu>
  6. +
  7. + * configure.in: Add tests for __secure_getenv(), prctl(),
  8. + and sys/prctl.h
  9. +
  10. 2005-03-21 Theodore Ts'o <tytso@mit.edu>
  11. * Release of E2fsprogs 1.37
  12. diff -urN e2fsprogs-1.37/configure e2fsprogs-1.37-patched/configure
  13. --- e2fsprogs-1.37/configure 2005-02-05 14:53:55.000000000 -0600
  14. +++ e2fsprogs-1.37-patched/configure 2005-06-18 16:34:01.000000000 -0500
  15. @@ -10713,7 +10713,8 @@
  16. -for ac_header in stdlib.h unistd.h stdarg.h stdint.h errno.h malloc.h mntent.h paths.h dirent.h getopt.h setjmp.h signal.h termios.h linux/fd.h linux/major.h sys/disklabel.h sys/ioctl.h sys/mkdev.h sys/queue.h sys/sockio.h sys/socket.h sys/sysmacros.h sys/time.h sys/stat.h sys/types.h sys/wait.h sys/resource.h net/if_dl.h netinet/in.h
  17. +
  18. +for ac_header in stdlib.h unistd.h stdarg.h stdint.h errno.h malloc.h mntent.h paths.h dirent.h getopt.h setjmp.h signal.h termios.h linux/fd.h linux/major.h sys/disklabel.h sys/ioctl.h sys/mkdev.h sys/prctl.h sys/queue.h sys/sockio.h sys/socket.h sys/sysmacros.h sys/time.h sys/stat.h sys/types.h sys/wait.h sys/resource.h net/if_dl.h netinet/in.h
  19. do
  20. as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
  21. if eval "test \"\${$as_ac_Header+set}\" = set"; then
  22. @@ -13816,7 +13817,9 @@
  23. -for ac_func in chflags getrusage llseek lseek64 open64 getmntinfo strtoull strcasecmp srandom fchown mallinfo fdatasync strnlen strptime sysconf pathconf posix_memalign memalign valloc
  24. +
  25. +
  26. +for ac_func in chflags getrusage llseek lseek64 open64 getmntinfo strtoull strcasecmp srandom fchown mallinfo fdatasync strnlen strptime sysconf pathconf posix_memalign memalign valloc __secure_getenv prctl
  27. do
  28. as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
  29. echo "$as_me:$LINENO: checking for $ac_func" >&5
  30. diff -urN e2fsprogs-1.37/configure.in e2fsprogs-1.37-patched/configure.in
  31. --- e2fsprogs-1.37/configure.in 2005-02-05 14:53:55.000000000 -0600
  32. +++ e2fsprogs-1.37-patched/configure.in 2005-06-18 16:34:01.000000000 -0500
  33. @@ -525,7 +525,7 @@
  34. else
  35. AC_CHECK_PROGS(BUILD_CC, gcc cc)
  36. fi
  37. -AC_CHECK_HEADERS(stdlib.h unistd.h stdarg.h stdint.h errno.h malloc.h mntent.h paths.h dirent.h getopt.h setjmp.h signal.h termios.h linux/fd.h linux/major.h sys/disklabel.h sys/ioctl.h sys/mkdev.h sys/queue.h sys/sockio.h sys/socket.h sys/sysmacros.h sys/time.h sys/stat.h sys/types.h sys/wait.h sys/resource.h net/if_dl.h netinet/in.h)
  38. +AC_CHECK_HEADERS(stdlib.h unistd.h stdarg.h stdint.h errno.h malloc.h mntent.h paths.h dirent.h getopt.h setjmp.h signal.h termios.h linux/fd.h linux/major.h sys/disklabel.h sys/ioctl.h sys/mkdev.h sys/prctl.h sys/queue.h sys/sockio.h sys/socket.h sys/sysmacros.h sys/time.h sys/stat.h sys/types.h sys/wait.h sys/resource.h net/if_dl.h netinet/in.h)
  39. AC_CHECK_HEADERS(sys/disk.h sys/mount.h,,,
  40. [[
  41. #if HAVE_SYS_QUEUE_H
  42. @@ -628,7 +628,7 @@
  43. [#include <sys/types.h>
  44. #include <sys/socket.h>])
  45. dnl
  46. -AC_CHECK_FUNCS(chflags getrusage llseek lseek64 open64 getmntinfo strtoull strcasecmp srandom fchown mallinfo fdatasync strnlen strptime sysconf pathconf posix_memalign memalign valloc)
  47. +AC_CHECK_FUNCS(chflags getrusage llseek lseek64 open64 getmntinfo strtoull strcasecmp srandom fchown mallinfo fdatasync strnlen strptime sysconf pathconf posix_memalign memalign valloc __secure_getenv prctl)
  48. dnl
  49. dnl Check to see if -lsocket is required (solaris) to make something
  50. dnl that uses socket() to compile; this is needed for the UUID library
  51. diff -urN e2fsprogs-1.37/debian/changelog e2fsprogs-1.37-patched/debian/changelog
  52. --- e2fsprogs-1.37/debian/changelog 2005-03-21 21:37:01.000000000 -0600
  53. +++ e2fsprogs-1.37-patched/debian/changelog 2005-06-18 16:34:01.000000000 -0500
  54. @@ -1,3 +1,20 @@
  55. +e2fsprogs (1.37-2) unstable; urgency=low
  56. +
  57. + * Fix filefrag so that it works non ext2/3 filesystems again.
  58. + (Closes: #303509)
  59. + * Make sure we include stdlib.h to fix a core dump bug in mke2fs on the
  60. + IA64 architecture (or other platforms where sizeof(ptr) > sizeof(int))
  61. + (Closes: #302200)
  62. + * Add missing return values so that we don't return garbage in certain
  63. + error cases in ext2fs_write_new_inode() and ext2fs_read_int_block().
  64. + * Fix minor spelling typo in the mke2fs man page
  65. + * Avoid doing the LOW_DTIME checks if the superblock last mount time
  66. + indicates that the system clock may not be set correctly.
  67. + * Add further paranoia checks to the blkid, ext2fs, and ss libraries to
  68. + make them safe to call from setuid or setgid applications.
  69. +
  70. + -- Theodore Y. Ts'o <tytso@mit.edu> Sat, 9 Apr 2005 11:08:04 -0400
  71. +
  72. e2fsprogs (1.37-1) unstable; urgency=low
  73. * New upstream release.
  74. diff -urN e2fsprogs-1.37/e2fsck/ChangeLog e2fsprogs-1.37-patched/e2fsck/ChangeLog
  75. --- e2fsprogs-1.37/e2fsck/ChangeLog 2005-03-21 21:37:01.000000000 -0600
  76. +++ e2fsprogs-1.37-patched/e2fsck/ChangeLog 2005-06-18 16:34:01.000000000 -0500
  77. @@ -1,3 +1,9 @@
  78. +2005-04-06 Theodore Ts'o <tytso@mit.edu>
  79. +
  80. + * pass1.c (e2fsck_pass1): If the superblock last mount time (not
  81. + just the last write time) looks insane, then assume that
  82. + we can't do the LOW_DTIME checks.
  83. +
  84. 2005-03-21 Theodore Ts'o <tytso@mit.edu>
  85. * Release of E2fsprogs 1.37
  86. diff -urN e2fsprogs-1.37/e2fsck/pass1.c e2fsprogs-1.37-patched/e2fsck/pass1.c
  87. --- e2fsprogs-1.37/e2fsck/pass1.c 2005-03-21 16:31:21.000000000 -0600
  88. +++ e2fsprogs-1.37-patched/e2fsck/pass1.c 2005-06-18 16:34:01.000000000 -0500
  89. @@ -518,7 +518,8 @@
  90. if (ctx->progress)
  91. if ((ctx->progress)(ctx, 1, 0, ctx->fs->group_desc_count))
  92. return;
  93. - if (fs->super->s_wtime < fs->super->s_inodes_count)
  94. + if ((fs->super->s_wtime < fs->super->s_inodes_count) ||
  95. + (fs->super->s_mtime < fs->super->s_inodes_count))
  96. busted_fs_time = 1;
  97. while (1) {
  98. diff -urN e2fsprogs-1.37/e2fsprogs.lsm e2fsprogs-1.37-patched/e2fsprogs.lsm
  99. --- e2fsprogs-1.37/e2fsprogs.lsm 2005-03-21 21:37:01.000000000 -0600
  100. +++ e2fsprogs-1.37-patched/e2fsprogs.lsm 2005-06-18 16:34:01.000000000 -0500
  101. @@ -8,7 +8,7 @@
  102. Author: tytso@mit.edu (Theodore Tso)
  103. Maintained-by: tytso@mit.edu (Theodore Tso)
  104. Primary-site: download.sourceforge.net /pub/sourceforge/e2fsprogs
  105. - 3192kB e2fsprogs-1.37.tar.gz
  106. + 3432kB e2fsprogs-1.37.tar.gz
  107. 452kB e2fsprogs-libs-1.37.tar.gz
  108. 1kB e2fsprogs-1.37.lsm
  109. Alternate-site:
  110. diff -urN e2fsprogs-1.37/lib/blkid/ChangeLog e2fsprogs-1.37-patched/lib/blkid/ChangeLog
  111. --- e2fsprogs-1.37/lib/blkid/ChangeLog 2005-03-21 21:32:51.000000000 -0600
  112. +++ e2fsprogs-1.37-patched/lib/blkid/ChangeLog 2005-06-18 16:34:01.000000000 -0500
  113. @@ -1,3 +1,12 @@
  114. +2005-03-31 Theodore Ts'o <tytso@mit.edu>
  115. +
  116. + * cache.c (blkid_get_cache): Use a much more paranoid
  117. + safe_getenv() function which will ignore the BLKID_FILE
  118. + environment varaible if the application program is setgid
  119. + or on a Linux system, if kernel doesn't think the process
  120. + is eligible to create a core dump. Also if glibc has
  121. + __secure_getenv(), then use it.
  122. +
  123. 2005-03-21 Theodore Ts'o <tytso@mit.edu>
  124. * Release of E2fsprogs 1.37
  125. diff -urN e2fsprogs-1.37/lib/blkid/cache.c e2fsprogs-1.37-patched/lib/blkid/cache.c
  126. --- e2fsprogs-1.37/lib/blkid/cache.c 2005-03-21 21:11:36.000000000 -0600
  127. +++ e2fsprogs-1.37-patched/lib/blkid/cache.c 2005-06-18 16:34:01.000000000 -0500
  128. @@ -10,12 +10,48 @@
  129. * %End-Header%
  130. */
  131. +#if HAVE_UNISTD_H
  132. +#include <unistd.h>
  133. +#endif
  134. +#ifdef HAVE_ERRNO_H
  135. +#include <errno.h>
  136. +#endif
  137. #include <stdlib.h>
  138. #include <string.h>
  139. +#ifdef HAVE_SYS_PRCTL_H
  140. +#include <sys/prctl.h>
  141. +#else
  142. +#define PR_GET_DUMPABLE 3
  143. +#endif
  144. +#if (!defined(HAVE_PRCTL) && defined(linux))
  145. +#include <sys/syscall.h>
  146. +#endif
  147. #include "blkidP.h"
  148. int blkid_debug_mask = 0;
  149. +
  150. +static char *safe_getenv(const char *arg)
  151. +{
  152. + if ((getuid() != geteuid()) || (getgid() != getgid()))
  153. + return NULL;
  154. +#if HAVE_PRCTL
  155. + if (prctl(PR_GET_DUMPABLE) == 0)
  156. + return NULL;
  157. +#else
  158. +#if (defined(linux) && defined(SYS_prctl))
  159. + if (syscall(SYS_prctl, PR_GET_DUMPABLE) == 0)
  160. + return NULL;
  161. +#endif
  162. +#endif
  163. +
  164. +#ifdef HAVE___SECURE_GETENV
  165. + return __secure_getenv("BLKID_FILE");
  166. +#else
  167. + return getenv("BLKID_FILE");
  168. +#endif
  169. +}
  170. +
  171. int blkid_get_cache(blkid_cache *ret_cache, const char *filename)
  172. {
  173. blkid_cache cache;
  174. @@ -41,8 +77,8 @@
  175. if (filename && !strlen(filename))
  176. filename = 0;
  177. - if (!filename && (getuid() == geteuid()))
  178. - filename = getenv("BLKID_FILE");
  179. + if (!filename)
  180. + filename = safe_getenv("BLKID_FILE");
  181. if (!filename)
  182. filename = BLKID_CACHE_FILE;
  183. cache->bic_filename = blkid_strdup(filename);
  184. diff -urN e2fsprogs-1.37/lib/e2p/ChangeLog e2fsprogs-1.37-patched/lib/e2p/ChangeLog
  185. --- e2fsprogs-1.37/lib/e2p/ChangeLog 2005-03-21 21:37:01.000000000 -0600
  186. +++ e2fsprogs-1.37-patched/lib/e2p/ChangeLog 2005-06-18 16:34:01.000000000 -0500
  187. @@ -1,3 +1,15 @@
  188. +2005-04-09 Theodore Ts'o <tytso@mit.edu>
  189. +
  190. + * ls.c: Add stdlib.h header file since list_super2() uses the
  191. + free() function.
  192. +
  193. +2005-03-30 Theodore Ts'o <tytso@mit.edu>
  194. +
  195. + * ostype.c (e2p_os2string): Check to make sure malloc() is
  196. + successful before attempting to copy into it. Add
  197. + #include of stdlib.h to fix a core dump bug on the IA64
  198. + architecture. (Addresses Debian Bug #302200)
  199. +
  200. 2005-03-21 Theodore Ts'o <tytso@mit.edu>
  201. * Release of E2fsprogs 1.37
  202. diff -urN e2fsprogs-1.37/lib/e2p/ls.c e2fsprogs-1.37-patched/lib/e2p/ls.c
  203. --- e2fsprogs-1.37/lib/e2p/ls.c 2005-03-19 14:59:40.000000000 -0600
  204. +++ e2fsprogs-1.37-patched/lib/e2p/ls.c 2005-06-18 16:34:01.000000000 -0500
  205. @@ -12,6 +12,7 @@
  206. */
  207. #include <stdio.h>
  208. +#include <stdlib.h>
  209. #include <sys/types.h>
  210. #include <string.h>
  211. #include <grp.h>
  212. diff -urN e2fsprogs-1.37/lib/e2p/ostype.c e2fsprogs-1.37-patched/lib/e2p/ostype.c
  213. --- e2fsprogs-1.37/lib/e2p/ostype.c 2005-03-19 00:17:09.000000000 -0600
  214. +++ e2fsprogs-1.37-patched/lib/e2p/ostype.c 2005-06-18 16:34:01.000000000 -0500
  215. @@ -9,6 +9,7 @@
  216. #include "e2p.h"
  217. #include <string.h>
  218. +#include <stdlib.h>
  219. const char *os_tab[] =
  220. { "Linux",
  221. @@ -32,7 +33,8 @@
  222. os = "(unknown os)";
  223. ret = malloc(strlen(os)+1);
  224. - strcpy(ret, os);
  225. + if (ret)
  226. + strcpy(ret, os);
  227. return ret;
  228. }
  229. diff -urN e2fsprogs-1.37/lib/ext2fs/ChangeLog e2fsprogs-1.37-patched/lib/ext2fs/ChangeLog
  230. --- e2fsprogs-1.37/lib/ext2fs/ChangeLog 2005-03-21 21:37:01.000000000 -0600
  231. +++ e2fsprogs-1.37-patched/lib/ext2fs/ChangeLog 2005-06-18 16:34:01.000000000 -0500
  232. @@ -1,3 +1,16 @@
  233. +2005-04-09 Theodore Ts'o <tytso@mit.edu>
  234. +
  235. + * inode.c (ext2fs_write_new_inode),
  236. + ind_block.c (ext2fs_read_ind_block): Add missing return
  237. + value in error return case. (Otherwise we return garbage
  238. + instead of the error code.)
  239. +
  240. +2005-03-31 Theodore Ts'o <tytso@mit.edu>
  241. +
  242. + * test_io.c (test_open): If called by a setuid/setgid or an
  243. + otherwise privileged program, be paranoid and ignore the
  244. + TEST_IO_* environment variables.
  245. +
  246. 2005-03-21 Theodore Ts'o <tytso@mit.edu>
  247. * Release of E2fsprogs 1.37
  248. diff -urN e2fsprogs-1.37/lib/ext2fs/Makefile.in e2fsprogs-1.37-patched/lib/ext2fs/Makefile.in
  249. --- e2fsprogs-1.37/lib/ext2fs/Makefile.in 2005-03-18 22:50:32.000000000 -0600
  250. +++ e2fsprogs-1.37-patched/lib/ext2fs/Makefile.in 2005-06-18 16:49:05.000000000 -0500
  251. @@ -400,6 +400,7 @@
  252. $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
  253. $(srcdir)/ext2_fs.h $(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_io.h \
  254. $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h
  255. +ind_block.o: ext2_err.c
  256. initialize.o: $(srcdir)/initialize.c $(srcdir)/ext2_fs.h \
  257. $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
  258. $(srcdir)/ext2_fs.h $(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_io.h \
  259. diff -urN e2fsprogs-1.37/lib/ext2fs/ext2fs.h e2fsprogs-1.37-patched/lib/ext2fs/ext2fs.h
  260. --- e2fsprogs-1.37/lib/ext2fs/ext2fs.h 2005-03-20 21:31:41.000000000 -0600
  261. +++ e2fsprogs-1.37-patched/lib/ext2fs/ext2fs.h 2005-06-18 16:33:06.000000000 -0500
  262. @@ -61,7 +61,7 @@
  263. #include <stdio.h>
  264. #include <stdlib.h>
  265. -#if EXT2_FLAT_INCLUDES
  266. +#ifdef EXT2_FLAT_INCLUDES
  267. #include "e2_types.h"
  268. #include "ext2_fs.h"
  269. #else
  270. @@ -76,14 +76,14 @@
  271. typedef __s64 e2_blkcnt_t;
  272. typedef __u32 ext2_dirhash_t;
  273. -#if EXT2_FLAT_INCLUDES
  274. +#ifdef EXT2_FLAT_INCLUDES
  275. #include "com_err.h"
  276. #include "ext2_io.h"
  277. #include "ext2_err.h"
  278. #else
  279. #include <et/com_err.h>
  280. -#include <ext2fs/ext2_io.h>
  281. #include <ext2fs/ext2_err.h>
  282. +#include <ext2fs/ext2_io.h>
  283. #endif
  284. /*
  285. @@ -245,7 +245,7 @@
  286. io_channel image_io;
  287. };
  288. -#if EXT2_FLAT_INCLUDES
  289. +#ifdef EXT2_FLAT_INCLUDES
  290. #include "e2_bitops.h"
  291. #else
  292. #include <ext2fs/bitops.h>
  293. diff -urN e2fsprogs-1.37/lib/ext2fs/ind_block.c e2fsprogs-1.37-patched/lib/ext2fs/ind_block.c
  294. --- e2fsprogs-1.37/lib/ext2fs/ind_block.c 2005-01-05 22:15:49.000000000 -0600
  295. +++ e2fsprogs-1.37-patched/lib/ext2fs/ind_block.c 2005-06-18 16:34:01.000000000 -0500
  296. @@ -32,7 +32,7 @@
  297. else {
  298. retval = io_channel_read_blk(fs->io, blk, 1, buf);
  299. if (retval)
  300. - retval;
  301. + return retval;
  302. }
  303. #ifdef EXT2FS_ENABLE_SWAPFS
  304. if (fs->flags & (EXT2_FLAG_SWAP_BYTES | EXT2_FLAG_SWAP_BYTES_READ)) {
  305. diff -urN e2fsprogs-1.37/lib/ext2fs/inode.c e2fsprogs-1.37-patched/lib/ext2fs/inode.c
  306. --- e2fsprogs-1.37/lib/ext2fs/inode.c 2005-03-21 00:10:13.000000000 -0600
  307. +++ e2fsprogs-1.37-patched/lib/ext2fs/inode.c 2005-06-18 16:34:01.000000000 -0500
  308. @@ -724,7 +724,6 @@
  309. struct ext2_inode *inode)
  310. {
  311. struct ext2_inode *buf;
  312. - errcode_t retval;
  313. int size = EXT2_INODE_SIZE(fs->super);
  314. struct ext2_inode_large *large_inode;
  315. @@ -743,7 +742,7 @@
  316. large_inode->i_extra_isize = sizeof(struct ext2_inode_large) -
  317. EXT2_GOOD_OLD_INODE_SIZE;
  318. - retval = ext2fs_write_inode_full(fs, ino, buf, size);
  319. + return ext2fs_write_inode_full(fs, ino, buf, size);
  320. }
  321. diff -urN e2fsprogs-1.37/lib/ext2fs/test_io.c e2fsprogs-1.37-patched/lib/ext2fs/test_io.c
  322. --- e2fsprogs-1.37/lib/ext2fs/test_io.c 2004-12-06 16:45:50.000000000 -0600
  323. +++ e2fsprogs-1.37-patched/lib/ext2fs/test_io.c 2005-06-18 16:34:01.000000000 -0500
  324. @@ -22,6 +22,14 @@
  325. #if HAVE_SYS_TYPES_H
  326. #include <sys/types.h>
  327. #endif
  328. +#ifdef HAVE_SYS_PRCTL_H
  329. +#include <sys/prctl.h>
  330. +#else
  331. +#define PR_GET_DUMPABLE 3
  332. +#endif
  333. +#if (!defined(HAVE_PRCTL) && defined(linux))
  334. +#include <sys/syscall.h>
  335. +#endif
  336. #include "ext2_fs.h"
  337. #include "ext2fs.h"
  338. @@ -132,6 +140,27 @@
  339. abort();
  340. }
  341. +static char *safe_getenv(const char *arg)
  342. +{
  343. + if ((getuid() != geteuid()) || (getgid() != getgid()))
  344. + return NULL;
  345. +#if HAVE_PRCTL
  346. + if (prctl(PR_GET_DUMPABLE) == 0)
  347. + return NULL;
  348. +#else
  349. +#if (defined(linux) && defined(SYS_prctl))
  350. + if (syscall(SYS_prctl, PR_GET_DUMPABLE) == 0)
  351. + return NULL;
  352. +#endif
  353. +#endif
  354. +
  355. +#ifdef HAVE___SECURE_GETENV
  356. + return __secure_getenv("BLKID_FILE");
  357. +#else
  358. + return getenv("BLKID_FILE");
  359. +#endif
  360. +}
  361. +
  362. static errcode_t test_open(const char *name, int flags, io_channel *channel)
  363. {
  364. io_channel io = NULL;
  365. @@ -178,25 +207,25 @@
  366. data->write_byte = test_io_cb_write_byte;
  367. data->outfile = NULL;
  368. - if ((value = getenv("TEST_IO_LOGFILE")) != NULL)
  369. + if ((value = safe_getenv("TEST_IO_LOGFILE")) != NULL)
  370. data->outfile = fopen(value, "w");
  371. if (!data->outfile)
  372. data->outfile = stderr;
  373. data->flags = 0;
  374. - if ((value = getenv("TEST_IO_FLAGS")) != NULL)
  375. + if ((value = safe_getenv("TEST_IO_FLAGS")) != NULL)
  376. data->flags = strtoul(value, NULL, 0);
  377. data->block = 0;
  378. - if ((value = getenv("TEST_IO_BLOCK")) != NULL)
  379. + if ((value = safe_getenv("TEST_IO_BLOCK")) != NULL)
  380. data->block = strtoul(value, NULL, 0);
  381. data->read_abort_count = 0;
  382. - if ((value = getenv("TEST_IO_READ_ABORT")) != NULL)
  383. + if ((value = safe_getenv("TEST_IO_READ_ABORT")) != NULL)
  384. data->read_abort_count = strtoul(value, NULL, 0);
  385. data->write_abort_count = 0;
  386. - if ((value = getenv("TEST_IO_WRITE_ABORT")) != NULL)
  387. + if ((value = safe_getenv("TEST_IO_WRITE_ABORT")) != NULL)
  388. data->write_abort_count = strtoul(value, NULL, 0);
  389. *channel = io;
  390. diff -urN e2fsprogs-1.37/lib/ss/ChangeLog e2fsprogs-1.37-patched/lib/ss/ChangeLog
  391. --- e2fsprogs-1.37/lib/ss/ChangeLog 2005-03-21 21:37:01.000000000 -0600
  392. +++ e2fsprogs-1.37-patched/lib/ss/ChangeLog 2005-06-18 16:34:01.000000000 -0500
  393. @@ -1,3 +1,10 @@
  394. +2005-03-31 Theodore Ts'o <tytso@mit.edu>
  395. +
  396. + * get_readline.c (ss_get_readline), pager.c (ss_page_stdin): If
  397. + called by a setuid/setgid or an otherwise privileged
  398. + program, be paranoid and ignore the PAGER and
  399. + SS_READLINE_PATH environment variables.
  400. +
  401. 2005-03-21 Theodore Ts'o <tytso@mit.edu>
  402. * Release of E2fsprogs 1.37
  403. diff -urN e2fsprogs-1.37/lib/ss/get_readline.c e2fsprogs-1.37-patched/lib/ss/get_readline.c
  404. --- e2fsprogs-1.37/lib/ss/get_readline.c 2003-12-07 11:11:38.000000000 -0600
  405. +++ e2fsprogs-1.37-patched/lib/ss/get_readline.c 2005-06-18 16:34:01.000000000 -0500
  406. @@ -50,7 +50,7 @@
  407. if (info->readline_handle)
  408. return;
  409. - libpath = getenv("SS_READLINE_PATH");
  410. + libpath = ss_safe_getenv("SS_READLINE_PATH");
  411. if (!libpath)
  412. libpath = DEFAULT_LIBPATH;
  413. if (*libpath == 0 || !strcmp(libpath, "none"))
  414. diff -urN e2fsprogs-1.37/lib/ss/pager.c e2fsprogs-1.37-patched/lib/ss/pager.c
  415. --- e2fsprogs-1.37/lib/ss/pager.c 2003-12-07 11:11:38.000000000 -0600
  416. +++ e2fsprogs-1.37-patched/lib/ss/pager.c 2005-06-18 16:34:01.000000000 -0500
  417. @@ -28,11 +28,40 @@
  418. #include <sys/types.h>
  419. #include <sys/file.h>
  420. #include <signal.h>
  421. +#ifdef HAVE_SYS_PRCTL_H
  422. +#include <sys/prctl.h>
  423. +#else
  424. +#define PR_GET_DUMPABLE 3
  425. +#endif
  426. +#if (!defined(HAVE_PRCTL) && defined(linux))
  427. +#include <sys/syscall.h>
  428. +#endif
  429. static char MORE[] = "more";
  430. extern char *_ss_pager_name;
  431. extern char *getenv PROTOTYPE((const char *));
  432. +char *ss_safe_getenv(const char *arg)
  433. +{
  434. + if ((getuid() != geteuid()) || (getgid() != getgid()))
  435. + return NULL;
  436. +#if HAVE_PRCTL
  437. + if (prctl(PR_GET_DUMPABLE) == 0)
  438. + return NULL;
  439. +#else
  440. +#if (defined(linux) && defined(SYS_prctl))
  441. + if (syscall(SYS_prctl, PR_GET_DUMPABLE) == 0)
  442. + return NULL;
  443. +#endif
  444. +#endif
  445. +
  446. +#ifdef HAVE___SECURE_GETENV
  447. + return __secure_getenv("BLKID_FILE");
  448. +#else
  449. + return getenv("BLKID_FILE");
  450. +#endif
  451. +}
  452. +
  453. /*
  454. * this needs a *lot* of work....
  455. *
  456. @@ -89,7 +118,7 @@
  457. sigdelset(&mask, SIGINT);
  458. sigprocmask(SIG_SETMASK, &mask, 0);
  459. if (_ss_pager_name == (char *)NULL) {
  460. - if ((_ss_pager_name = getenv("PAGER")) == (char *)NULL)
  461. + if ((_ss_pager_name = ss_safe_getenv("PAGER")) == (char *)NULL)
  462. _ss_pager_name = MORE;
  463. }
  464. (void) execlp(_ss_pager_name, _ss_pager_name, (char *) NULL);
  465. diff -urN e2fsprogs-1.37/lib/ss/ss_internal.h e2fsprogs-1.37-patched/lib/ss/ss_internal.h
  466. --- e2fsprogs-1.37/lib/ss/ss_internal.h 2003-12-07 11:11:38.000000000 -0600
  467. +++ e2fsprogs-1.37-patched/lib/ss/ss_internal.h 2005-06-18 16:34:01.000000000 -0500
  468. @@ -89,6 +89,7 @@
  469. void ss_list_requests(int, char const * const *, int, pointer);
  470. int ss_execute_command(int sci_idx, char *argv[]);
  471. int ss_pager_create(void);
  472. +char *ss_safe_getenv(const char *arg);
  473. char **ss_rl_completion(const char *text, int start, int end);
  474. extern ss_data **_ss_table;
  475. diff -urN e2fsprogs-1.37/misc/ChangeLog e2fsprogs-1.37-patched/misc/ChangeLog
  476. --- e2fsprogs-1.37/misc/ChangeLog 2005-03-21 21:37:01.000000000 -0600
  477. +++ e2fsprogs-1.37-patched/misc/ChangeLog 2005-06-18 16:34:01.000000000 -0500
  478. @@ -1,3 +1,13 @@
  479. +2005-04-09 Theodore Ts'o <tytso@mit.edu>
  480. +
  481. + * filefrag.c (frag_report): Don't abort filefrag if
  482. + EXT3_IOC_GETFLAGS ioctl is not supported, so that filefrag
  483. + can work on non-ext2/3 filesystems, as advertised.
  484. + (Addresses Debian Bug: #303509)
  485. +
  486. + * mke2fs.8.in: Fix minor spelling typo. (Addresses SourceForge
  487. + Bug #1177804)
  488. +
  489. 2005-03-21 Theodore Ts'o <tytso@mit.edu>
  490. * Release of E2fsprogs 1.37
  491. diff -urN e2fsprogs-1.37/misc/filefrag.c e2fsprogs-1.37-patched/misc/filefrag.c
  492. --- e2fsprogs-1.37/misc/filefrag.c 2005-03-18 19:25:28.000000000 -0600
  493. +++ e2fsprogs-1.37-patched/misc/filefrag.c 2005-06-18 16:34:01.000000000 -0500
  494. @@ -110,11 +110,8 @@
  495. close(fd);
  496. return;
  497. }
  498. - if (ioctl(fd, EXT3_IOC_GETFLAGS, &flags) < 0) {
  499. - perror("EXT3_IOC_GETFLAGS");
  500. - close(fd);
  501. - return;
  502. - }
  503. + if (ioctl(fd, EXT3_IOC_GETFLAGS, &flags) < 0)
  504. + flags = 0;
  505. if (flags & EXT3_EXTENTS_FL) {
  506. printf("File is stored in extents format\n");
  507. is_ext2 = 0;
  508. diff -urN e2fsprogs-1.37/misc/mke2fs.8.in e2fsprogs-1.37-patched/misc/mke2fs.8.in
  509. --- e2fsprogs-1.37/misc/mke2fs.8.in 2005-01-05 10:12:19.000000000 -0600
  510. +++ e2fsprogs-1.37-patched/misc/mke2fs.8.in 2005-06-18 16:34:01.000000000 -0500
  511. @@ -305,7 +305,7 @@
  512. .B \-M
  513. Set the last mounted directory for the filesystem. This might be useful
  514. for the sake of utilities that key off of the last mounted directory to
  515. -determine where the filesytem should be mounted.
  516. +determine where the filesystem should be mounted.
  517. .TP
  518. .B \-n
  519. causes mke2fs to not actually create a filesystem, but display what it
  520. diff -urN e2fsprogs-1.37/tests/ChangeLog e2fsprogs-1.37-patched/tests/ChangeLog
  521. --- e2fsprogs-1.37/tests/ChangeLog 2005-03-21 21:37:01.000000000 -0600
  522. +++ e2fsprogs-1.37-patched/tests/ChangeLog 2005-06-18 16:34:01.000000000 -0500
  523. @@ -1,3 +1,8 @@
  524. +2005-04-09 Theodore Ts'o <tytso@mit.edu>
  525. +
  526. + * test_script.in: Make the test script driver exit with a non-zero
  527. + status if there are any failed tests.
  528. +
  529. 2005-03-21 Theodore Ts'o <tytso@mit.edu>
  530. * Release of E2fsprogs 1.37
  531. diff -urN e2fsprogs-1.37/tests/test_script.in e2fsprogs-1.37-patched/tests/test_script.in
  532. --- e2fsprogs-1.37/tests/test_script.in 2005-01-17 18:13:38.000000000 -0600
  533. +++ e2fsprogs-1.37-patched/tests/test_script.in 2005-06-18 16:34:01.000000000 -0500
  534. @@ -59,3 +59,4 @@
  535. echo "$num_ok tests succeeded $num_failed tests failed"
  536. +test "$num_failed" -eq 0 || exit 1