* Re: fun with nilfs_cleanerd
[not found] ` <201105261110.15660.dexen.devries-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2011-05-26 10:03 ` Ryusuke Konishi
0 siblings, 0 replies; 2+ messages in thread
From: Ryusuke Konishi @ 2011-05-26 10:03 UTC (permalink / raw)
To: dexen.devries-Re5JQEeQqe8AvxtiuMwx3w; +Cc: linux-nilfs-u79uwXL29TY76Z2rM5mHXA
Hi,
On Thu, 26 May 2011 11:10:07 +0200, dexen deVries wrote:
> Hi list,
>
> in /etc/rc.d/rc.local I have a command starting cleanerd for root filesystem:
> # /sbin/nilfs_cleanerd -c /etc/nilfs_cleanerd-root.conf /dev/sda3
>
> At first I wanted a separate config for root filesystem, but now same was to be
> used for both / and /home. So I've removed the metion of the config file, and
> the command became:
>
> # /sbin/nilfs_cleanerd -c /dev/sda3
>
> (note the -c !)
> ...ended up with nilfs_cleanerd spewing countless errors into /var/log/syslog,
> like:
>
> May 26 11:05:08 coil nilfs_cleanerd[18902]: ��: unknown keyword
> May 26 11:05:08 coil nilfs_cleanerd[18902]: cˮ���: unknown keyword
> May 26 11:05:08 coil nilfs_cleanerd[18902]: A�;^C�S-�g^W�^Fɂ: unknown keyword
> May 26 11:05:08 coil nilfs_cleanerd[18902]: too long line
>
>
> nilfs_cleanerd using whole partition as the config file == fun! ;-)
Okay, so non-regular files should be rejected for the config option ;)
The following patch will resolve this.
Thanks,
Ryusuke Konishi
---
From: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
nilfs_cleanerd: reject configuration file other than regular file
The current config file option accepts any types of node other than
regular files. Thus,
# /sbin/nilfs_cleanerd -c /dev/sda3
will let cleaner daemon read the device as a configuration file. This
patch prevents the unwanted result.
Reported-by: dexen deVries <dexen.devries@gmail.com>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
---
sbin/cleanerd/cldconfig.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/sbin/cleanerd/cldconfig.c b/sbin/cleanerd/cldconfig.c
index 46a15ac..1e0d066 100644
--- a/sbin/cleanerd/cldconfig.c
+++ b/sbin/cleanerd/cldconfig.c
@@ -684,6 +684,14 @@ static int nilfs_cldconfig_do_read(struct nilfs_cldconfig *config,
int nilfs_cldconfig_read(struct nilfs_cldconfig *config, const char *path,
struct nilfs *nilfs)
{
+ struct stat stbuf;
+
+ if (stat(path, &stbuf) < 0 || !S_ISREG(stbuf.st_mode)) {
+ syslog(LOG_ERR, "%s: bad configuration file", path);
+ errno = EINVAL;
+ return -1;
+ }
+
nilfs_cldconfig_set_default(config, nilfs);
if (nilfs_cldconfig_do_read(config, path, nilfs) < 0)
syslog(LOG_WARNING, "%s: cannot read", path);
--
1.7.3.5
^ permalink raw reply related [flat|nested] 2+ messages in thread