From 723e6faed90970bd6f3c7e5b5e1d2eef8b440ab9 Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Fri, 9 Sep 2005 09:29:23 +0000 Subject: [PATCH] * Remove the init script check of the cache file system and instead improve the check in afsd. The init script check used stat, which is in /usr/bin and therefore not fair game for init scripts. --- debian/changelog | 3 +++ debian/openafs-client.init | 16 ---------------- debian/patches/cache-checks | 32 ++++++++++++++++++++++++++++++++ src/afsd/afsd.c | 12 +++++++++--- 4 files changed, 44 insertions(+), 19 deletions(-) create mode 100644 debian/patches/cache-checks diff --git a/debian/changelog b/debian/changelog index 3105b3c60..e0102d681 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,9 @@ openafs (1.4rc3-1) unstable; urgency=low * When kill_all_afs is enabled in /etc/openafs/afs.conf, only kill AFS processes if the runlevel is 0 or 6. You really only want this when the system is shutting down. (Closes: #325347) + * Remove the init script check of the cache file system and instead + improve the check in afsd. The init script check used stat, which is + in /usr/bin and therefore not fair game for init scripts. * Translation updates. - Portuguese (Brazil), thanks André Luís Lopes. diff --git a/debian/openafs-client.init b/debian/openafs-client.init index d77afc226..6461c8239 100755 --- a/debian/openafs-client.init +++ b/debian/openafs-client.init @@ -121,21 +121,6 @@ choose_afsd_options() { fi } -# Make sure that the cache file system type is ext2 or ext3. No other file -# system is supported for the cache, and generally bad things happen if a -# different one is used. -check_cache_fstype() { - CACHEPATH=`awk -F: '{print $2}' < /etc/openafs/cacheinfo` - FSTYPE=`stat -f -c '%T' "$CACHEPATH"` - if [ x"$FSTYPE" != x"ext2/ext3" ] ; then - echo "" - echo "ERROR: AFS cache at $CACHEPATH is on a $FSTYPE file system" >&2 - echo "ERROR: Only ext2 or ext3 may be used for an AFS cache" >&2 - echo "Aborting startup of AFS" >&2 - exit 1 - fi -} - # Start afsd. Be careful not to start it if another one is already running, # as that has a bad tendency to hang the system. start_client() { @@ -143,7 +128,6 @@ start_client() { echo "." else choose_afsd_options - check_cache_fstype echo " afsd." start-stop-daemon --start --quiet --exec /usr/sbin/afsd \ -- $AFSD_OPTIONS diff --git a/debian/patches/cache-checks b/debian/patches/cache-checks new file mode 100644 index 000000000..6360217f2 --- /dev/null +++ b/debian/patches/cache-checks @@ -0,0 +1,32 @@ +Die rather than just warn if the AFS cache fails any of its sanity checks, +diagnose use of tmpfs, and reject any file system type other than ext2 or +ext3. Submitted upstream as #20947. + +--- openafs/src/afsd/afsd.c (revision 1849) ++++ openafs/src/afsd/afsd.c (local) +@@ -1069,7 +1069,11 @@ + return "cannot use reiserfs as cache partition"; + } else if (statfsbuf.f_type == 0x58465342) { /* XFS_SUPER_MAGIC */ + return "cannot use xfs as cache partition"; +- } ++ } else if (statfsbuf.f_type == 0x01021994) { /* TMPFS_SUPER_MAGIC */ ++ return "cannot use tmpfs as cache partition"; ++ } else if (statfsbuf.f_type != 0xEF53) { ++ return "must use ext2 or ext3 for cache partition"; ++ } + } + #endif + +@@ -1665,8 +1669,10 @@ + sprintf(fullpn_VFile, "%s/", cacheBaseDir); + vFilePtr = fullpn_VFile + strlen(fullpn_VFile); + +- if (!(cacheFlags & AFSCALL_INIT_MEMCACHE) && (fsTypeMsg = CheckCacheBaseDir(cacheBaseDir))) { +- printf("%s: WARNING: Cache dir check failed (%s)\n", rn, fsTypeMsg); ++ if (!(cacheFlags & AFSCALL_INIT_MEMCACHE) ++ && (fsTypeMsg = CheckCacheBaseDir(cacheBaseDir))) { ++ printf("%s: ERROR: Cache dir check failed (%s)\n", rn, fsTypeMsg); ++ exit(1); + } + #if 0 + fputs(AFS_GOVERNMENT_MESSAGE, stdout); diff --git a/src/afsd/afsd.c b/src/afsd/afsd.c index 05b3032b8..30ff42f6c 100644 --- a/src/afsd/afsd.c +++ b/src/afsd/afsd.c @@ -1069,7 +1069,11 @@ CheckCacheBaseDir(char *dir) return "cannot use reiserfs as cache partition"; } else if (statfsbuf.f_type == 0x58465342) { /* XFS_SUPER_MAGIC */ return "cannot use xfs as cache partition"; - } + } else if (statfsbuf.f_type == 0x01021994) { /* TMPFS_SUPER_MAGIC */ + return "cannot use tmpfs as cache partition"; + } else if (statfsbuf.f_type != 0xEF53) { + return "must use ext2 or ext3 for cache partition"; + } } #endif @@ -1665,8 +1669,10 @@ mainproc(as, arock) sprintf(fullpn_VFile, "%s/", cacheBaseDir); vFilePtr = fullpn_VFile + strlen(fullpn_VFile); - if (!(cacheFlags & AFSCALL_INIT_MEMCACHE) && (fsTypeMsg = CheckCacheBaseDir(cacheBaseDir))) { - printf("%s: WARNING: Cache dir check failed (%s)\n", rn, fsTypeMsg); + if (!(cacheFlags & AFSCALL_INIT_MEMCACHE) + && (fsTypeMsg = CheckCacheBaseDir(cacheBaseDir))) { + printf("%s: ERROR: Cache dir check failed (%s)\n", rn, fsTypeMsg); + exit(1); } #if 0 fputs(AFS_GOVERNMENT_MESSAGE, stdout); -- 2.39.5