gconf2 try's to remove /etc completely when purging

Bug #7894 reported by Debian Bug Importer
8
Affects Status Importance Assigned to Milestone
gconf2 (Debian)
Fix Released
Undecided
Unassigned
gconf2 (Ubuntu)
Invalid
High
Sebastien Bacher

Bug Description

Automatically imported from Debian bug report #270967 http://bugs.debian.org/270967

Revision history for this message
In , Sebastien Bacher (seb128) wrote : Re: Bug#270967: gconf2 try's to remove /etc completely when purging

severity 270967 important
tag 270967 + unreproducible moreinfo
thanks

Le vendredi 10 septembre 2004 à 11:45 +0200, Klaus Ethgen a écrit :

> When removing (purging) gconf2 it trys to remove /etc c ompletely!
>
> This will destroy the whole system if /etc can be removed on it and is not
> protected as on my system.

Hi,

Could you provide some details ? Are you sure that the /etc dir has been
deleted by gconf2 ?

The postrm command used on purge is:
"rmdir -p --ignore-fail-on-non-empty /etc/gconf/2" ... this only removes
empty dirs, /etc was empty on your box ?

I'm changing the severity to important for the moment, this problem is
not reproducible.

Thanks,

Sebastien Bacher

Revision history for this message
Debian Bug Importer (debzilla) wrote :

Automatically imported from Debian bug report #270967 http://bugs.debian.org/270967

Revision history for this message
Debian Bug Importer (debzilla) wrote :

Message-ID: <email address hidden>
Date: Fri, 10 Sep 2004 11:45:04 +0200
From: Klaus Ethgen <email address hidden>
To: Debian Bug Tracking System <email address hidden>
Subject: gconf2 try's to remove /etc completely when purging

-----BEGIN PGP SIGNED MESSAGE-----

Package: gconf2
Version: 2.6.3-2
Severity: critical

When removing (purging) gconf2 it trys to remove /etc c ompletely!

This will destroy the whole system if /etc can be removed on it and is not
protected as on my system.

- -- System Information:
Debian Release: 3.1
  APT prefers testing
  APT policy: (800, 'testing'), (70, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 2.4.27
Locale: LANG=de_DE, LC_CTYPE=de_DE (ignored: LC_ALL set to de_DE)

Versions of packages gconf2 depends on:
ii libatk1.0-0 1.6.1-3 The ATK accessibility toolkit
ii libc6 2.3.2.ds1-13 GNU C Library: Shared libraries an
pn libgconf2-4 Not found.
ii libglib2.0-0 2.4.6-2 The GLib library of C routines
ii libgtk2.0-0 2.4.9-1 The GTK+ graphical user interface
ii liborbit2 1:2.10.2-1.1 libraries for ORBit2 - a CORBA ORB
ii libpango1.0-0 1.4.1-2 Layout and rendering of internatio
ii libpopt0 1.7-4 lib for parsing cmdline parameters
ii libxml2 2.6.11-3 GNOME XML library
ii zlib1g 1:1.2.1.1-5 compression library - runtime

- -- no debconf information
- --
Klaus Ethgen http://www.ethgen.de/
pub 2048R/D1A4EDE5 2000-02-26 Klaus Ethgen <email address hidden>
Fingerprint: D7 67 71 C4 99 A6 D4 FE EA 40 30 57 3C 88 26 2B
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)

iQEVAwUBQUF3oJ+OKpjRpO3lAQHtYQgAgcBu3EjrpjAX76yd1bWn3YewyCMc7Enw
SqMkHHiKU4xz6htY6kgrdY0ROx+otThFQuPbQWHgobq1qioMahWzK9bcDlSBGomY
OVqqmobp5HX0Z40U0NTEZb8C3xtMcCvx++cwI8Vm0W74Rm1t1rG+RIDGQRZZ3eE2
YBmOfABMI+W4NyWvdDvrIcd2B4ehkA6McPDh/QjU/VeaSs8DGN3jXDTSWCT1Yokp
TQlJRl4/+OuPzQ9oTWGHA4Zyunu2fTuCsZ/Ww57yFG3N0G1i40LhDjytFbhUuCr7
+aDcexCxsBBE0/XYNElVEhuV03SZHiJJBooSSRgio2phARYT3LYr6Q==
=YrFu
-----END PGP SIGNATURE-----

Revision history for this message
In , Klaus Ethgen (klaus-ethgen) wrote :

-----BEGIN PGP SIGNED MESSAGE-----

Hi,

Am Fr den 10. Sep 2004 um 12:47 schriebst Du:
> Could you provide some details ? Are you sure that the /etc dir has been
> deleted by gconf2 ?

When I purged the package first it failed because /etc/gconf/2 was not found on
my system and then after I created it it prints:
rmdir: `/etc': Permission denied
when purging. /etc is not removable in my environment thank goodnes.

I did not check if it whould remove /etc if it whould be removable.

> "rmdir -p --ignore-fail-on-non-empty /etc/gconf/2" ... this only removes
> empty dirs, /etc was empty on your box ?

No, but see above.

Hmm.. I didn't look to the postrm afterwards. I only did a
echo "#!/bin/sh" > /var/lib/dpkg/info/gconf2.postrm
to remove it completely. But it is strange that the rmdir above give this
message.

Regards
   Klaus
- --
Klaus Ethgen http://www.ethgen.de/
pub 2048R/D1A4EDE5 2000-02-26 Klaus Ethgen <email address hidden>
Fingerprint: D7 67 71 C4 99 A6 D4 FE EA 40 30 57 3C 88 26 2B
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)

iQEVAwUBQUGPTZ+OKpjRpO3lAQHThwf/Vx8pLAadgvE68WILe1NxxIQKozzADYcU
0PZG4m/7z4IpQjuuefym0Z1ViBJY6rny8HXZwkp7NVmLK9//IDyrhPYIu5UX9hNZ
ivSL/z2hQW18pflVxf8KkS5kn9xXhcyLujSZ8avCJoRyQt+PvXbG/yZ7hqq2MVIo
zlooC15xNO+EIyOq/iQOqgqldQ0YhihHT9U+Dzuj64UtRZ8OdxPBPbwiZ43r+ihU
PV3zUKMfSg1Aq00Lqc8zrlHcbB0RQ/E/NV4NnpphOu/OAyeV+MKOVyYOhevp10um
tfGG/rCurWRV5TVcrWwdMZTbNX9Ycm/4nTCiuPZXL8O0omY08cafkg==
=VbXL
-----END PGP SIGNATURE-----

Revision history for this message
Sebastien Bacher (seb128) wrote :

The only removal on purge in gconf is this one:
gconf2.postrm: rmdir -p --ignore-fail-on-non-empty /etc/gconf/2

This only remove empty dirs ... NOTABUG imho

Revision history for this message
In , Sebastien Bacher (seb128) wrote :

Le vendredi 10 septembre 2004 à 13:26 +0200, Klaus Ethgen a écrit :

> When I purged the package first it failed because /etc/gconf/2 was not found on
> my system and then after I created it it prints:
> rmdir: `/etc': Permission denied
> when purging. /etc is not removable in my environment thank goodnes.

You've purged only this one ? Do you remember which version of the
package it was ?

I've just tried in a fresh pbuilder, no problem ...

> I did not check if it whould remove /etc if it whould be removable.

Can you still reproduce the problem ?

> to remove it completely. But it is strange that the rmdir above give this
> message.

Yes, I don't understand where is the problem, but that's not a gconf
problem ... if "rmdir -p --ignore-fail-on-non-empty /etc/gconf/2" wants
to remove /etc you have a problem but that with coreutils, not gconf.

Cheers,

Sebastien Bacher

Revision history for this message
In , Klaus Ethgen (klaus-ethgen) wrote :

-----BEGIN PGP SIGNED MESSAGE-----

Hi,

Am Fr den 10. Sep 2004 um 13:41 schriebst Du:
> You've purged only this one ? Do you remember which version of the
> package it was ?

No. But see below...

> Can you still reproduce the problem ?

Yes, I did on a other host (sid, newest version, all my hosts have "chattr +i /").
- ---
xxxx:~# dpkg --force-all --purge gconf2
dpkg: gconf2: dependency problems, but removing anyway as you request:
 libgnome2-common depends on gconf2 (>= 2.6.0-1).
 libgnomevfs2-common depends on gconf2 (>= 2.6.0).
 libgconf2-4 depends on gconf2 (>= 2.6.4-2).
(Reading database ... 94571 files and directories currently installed.)
Removing gconf2 ...
Purging configuration files for gconf2 ...
rmdir: `/etc': Permission denied
dpkg: error processing gconf2 (--purge):
 subprocess post-removal script returned error exit status 1
Errors were encountered while processing:
 gconf2
- ---

When there is somethink inside of /etc/gconf then no problem. But when there is
nothing more inside this bug happens.

When I then recreate /etc/gconfd/2 and make a "chattr -i /" the purge work well
without erasing something from /etc.

As the /etc gets not really deleted, i think the severity can be lowered to
'normal'.

Regards
   Klaus
- --
Klaus Ethgen http://www.ethgen.de/
pub 2048R/D1A4EDE5 2000-02-26 Klaus Ethgen <email address hidden>
Fingerprint: D7 67 71 C4 99 A6 D4 FE EA 40 30 57 3C 88 26 2B
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)

iQEVAwUBQUGWd5+OKpjRpO3lAQFOHgf+LB81o/fvb67fhujir8qxrwTBmnFiyEA1
1JkKHgLmTGlBCa0VgoDeW4NOHpFqxJnpGu+V7k9GklSfUhnVyqnTWG+6qCBCZCZ1
ZH9m6JV18VOe6uf43HTPAXQFLFjZshPs9d0Vh+Nm3qEqeAuGXUVwr9KDklghxn5U
bSFsJ7SH9GkW7l5HI+QL9puua9/MYxBotdmdmvLtYVmRDaSf1da0w3lH5PEKjfaN
JW4GCsqOJjk4Ju6FITJvafYfXXO/X17uTyrSYvgMn2oamWt0Ss3bMqjthLxOPCjy
d73zS7mFwuE44/SYVCJR91vSTYu2C5itospIv61exvaQzdMkjF4+FQ==
=fpP/
-----END PGP SIGNATURE-----

Revision history for this message
Debian Bug Importer (debzilla) wrote :

Message-Id: <1094813225.5593.37.camel@seb128>
Date: Fri, 10 Sep 2004 12:47:05 +0200
From: Sebastien Bacher <email address hidden>
To: Klaus Ethgen <email address hidden>, <email address hidden>
Cc: <email address hidden>
Subject: Re: Bug#270967: gconf2 try's to remove /etc completely when purging

severity 270967 important
tag 270967 + unreproducible moreinfo
thanks

Le vendredi 10 septembre 2004 =E0 11:45 +0200, Klaus Ethgen a =E9crit :

> When removing (purging) gconf2 it trys to remove /etc c ompletely!
>=20
> This will destroy the whole system if /etc can be removed on it and is no=
t
> protected as on my system.

Hi,=20

Could you provide some details ? Are you sure that the /etc dir has been
deleted by gconf2 ?

The postrm command used on purge is:
"rmdir -p --ignore-fail-on-non-empty /etc/gconf/2" ... this only removes
empty dirs, /etc was empty on your box ?=20

I'm changing the severity to important for the moment, this problem is
not reproducible.

Thanks,

Sebastien Bacher

Revision history for this message
In , Sebastien Bacher (seb128) wrote :

Le vendredi 10 septembre 2004 à 13:56 +0200, Klaus Ethgen a écrit :

> Yes, I did on a other host (sid, newest version, all my hosts have "chattr +i /").

Ok, I've the problem too.

$ chattr +i /
$ dpkg --purge libgconf2-4 gconf2

and I get the same error

The weird point is that running "sh /var/lib/dpkg/info/gconf2.postrm
purge" doesn't display any error, but the same line called by apt raises
an error ...

Anybody with an idea on this ?

BTW not a gconf problem ...

Thanks,

Sebastien Bacher

Revision history for this message
Debian Bug Importer (debzilla) wrote :

Message-ID: <20040910112312.GA25438@ikki>
Date: Fri, 10 Sep 2004 13:26:05 +0200
From: Klaus Ethgen <email address hidden>
To: Sebastien Bacher <email address hidden>
Cc: <email address hidden>, <email address hidden>
Subject: Re: Bug#270967: gconf2 try's to remove /etc completely when purging

-----BEGIN PGP SIGNED MESSAGE-----

Hi,

Am Fr den 10. Sep 2004 um 12:47 schriebst Du:
> Could you provide some details ? Are you sure that the /etc dir has been
> deleted by gconf2 ?

When I purged the package first it failed because /etc/gconf/2 was not found on
my system and then after I created it it prints:
rmdir: `/etc': Permission denied
when purging. /etc is not removable in my environment thank goodnes.

I did not check if it whould remove /etc if it whould be removable.

> "rmdir -p --ignore-fail-on-non-empty /etc/gconf/2" ... this only removes
> empty dirs, /etc was empty on your box ?

No, but see above.

Hmm.. I didn't look to the postrm afterwards. I only did a
echo "#!/bin/sh" > /var/lib/dpkg/info/gconf2.postrm
to remove it completely. But it is strange that the rmdir above give this
message.

Regards
   Klaus
- --
Klaus Ethgen http://www.ethgen.de/
pub 2048R/D1A4EDE5 2000-02-26 Klaus Ethgen <email address hidden>
Fingerprint: D7 67 71 C4 99 A6 D4 FE EA 40 30 57 3C 88 26 2B
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)

iQEVAwUBQUGPTZ+OKpjRpO3lAQHThwf/Vx8pLAadgvE68WILe1NxxIQKozzADYcU
0PZG4m/7z4IpQjuuefym0Z1ViBJY6rny8HXZwkp7NVmLK9//IDyrhPYIu5UX9hNZ
ivSL/z2hQW18pflVxf8KkS5kn9xXhcyLujSZ8avCJoRyQt+PvXbG/yZ7hqq2MVIo
zlooC15xNO+EIyOq/iQOqgqldQ0YhihHT9U+Dzuj64UtRZ8OdxPBPbwiZ43r+ihU
PV3zUKMfSg1Aq00Lqc8zrlHcbB0RQ/E/NV4NnpphOu/OAyeV+MKOVyYOhevp10um
tfGG/rCurWRV5TVcrWwdMZTbNX9Ycm/4nTCiuPZXL8O0omY08cafkg==
=VbXL
-----END PGP SIGNATURE-----

Revision history for this message
Debian Bug Importer (debzilla) wrote :

Message-Id: <1094816506.28916.3.camel@seb128>
Date: Fri, 10 Sep 2004 13:41:46 +0200
From: Sebastien Bacher <email address hidden>
To: Klaus Ethgen <email address hidden>
Cc: <email address hidden>
Subject: Re: Bug#270967: gconf2 try's to remove /etc completely when purging

Le vendredi 10 septembre 2004 =E0 13:26 +0200, Klaus Ethgen a =E9crit :

> When I purged the package first it failed because /etc/gconf/2 was not fo=
und on
> my system and then after I created it it prints:
> rmdir: `/etc': Permission denied
> when purging. /etc is not removable in my environment thank goodnes.

You've purged only this one ? Do you remember which version of the
package it was ?

I've just tried in a fresh pbuilder, no problem ...

> I did not check if it whould remove /etc if it whould be removable.

Can you still reproduce the problem ?

> to remove it completely. But it is strange that the rmdir above give this
> message.

Yes, I don't understand where is the problem, but that's not a gconf
problem ... if "rmdir -p --ignore-fail-on-non-empty /etc/gconf/2" wants
to remove /etc you have a problem but that with coreutils, not gconf.

Cheers,

Sebastien Bacher

Revision history for this message
Debian Bug Importer (debzilla) wrote :

Message-ID: <20040910115639.GA26286@ikki>
Date: Fri, 10 Sep 2004 13:56:39 +0200
From: Klaus Ethgen <email address hidden>
To: Sebastien Bacher <email address hidden>
Cc: <email address hidden>
Subject: Re: Bug#270967: gconf2 try's to remove /etc completely when purging

-----BEGIN PGP SIGNED MESSAGE-----

Hi,

Am Fr den 10. Sep 2004 um 13:41 schriebst Du:
> You've purged only this one ? Do you remember which version of the
> package it was ?

No. But see below...

> Can you still reproduce the problem ?

Yes, I did on a other host (sid, newest version, all my hosts have "chattr +i /").
- ---
xxxx:~# dpkg --force-all --purge gconf2
dpkg: gconf2: dependency problems, but removing anyway as you request:
 libgnome2-common depends on gconf2 (>= 2.6.0-1).
 libgnomevfs2-common depends on gconf2 (>= 2.6.0).
 libgconf2-4 depends on gconf2 (>= 2.6.4-2).
(Reading database ... 94571 files and directories currently installed.)
Removing gconf2 ...
Purging configuration files for gconf2 ...
rmdir: `/etc': Permission denied
dpkg: error processing gconf2 (--purge):
 subprocess post-removal script returned error exit status 1
Errors were encountered while processing:
 gconf2
- ---

When there is somethink inside of /etc/gconf then no problem. But when there is
nothing more inside this bug happens.

When I then recreate /etc/gconfd/2 and make a "chattr -i /" the purge work well
without erasing something from /etc.

As the /etc gets not really deleted, i think the severity can be lowered to
'normal'.

Regards
   Klaus
- --
Klaus Ethgen http://www.ethgen.de/
pub 2048R/D1A4EDE5 2000-02-26 Klaus Ethgen <email address hidden>
Fingerprint: D7 67 71 C4 99 A6 D4 FE EA 40 30 57 3C 88 26 2B
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)

iQEVAwUBQUGWd5+OKpjRpO3lAQFOHgf+LB81o/fvb67fhujir8qxrwTBmnFiyEA1
1JkKHgLmTGlBCa0VgoDeW4NOHpFqxJnpGu+V7k9GklSfUhnVyqnTWG+6qCBCZCZ1
ZH9m6JV18VOe6uf43HTPAXQFLFjZshPs9d0Vh+Nm3qEqeAuGXUVwr9KDklghxn5U
bSFsJ7SH9GkW7l5HI+QL9puua9/MYxBotdmdmvLtYVmRDaSf1da0w3lH5PEKjfaN
JW4GCsqOJjk4Ju6FITJvafYfXXO/X17uTyrSYvgMn2oamWt0Ss3bMqjthLxOPCjy
d73zS7mFwuE44/SYVCJR91vSTYu2C5itospIv61exvaQzdMkjF4+FQ==
=fpP/
-----END PGP SIGNATURE-----

Revision history for this message
Debian Bug Importer (debzilla) wrote :

Message-Id: <1094821212.28916.8.camel@seb128>
Date: Fri, 10 Sep 2004 15:00:12 +0200
From: Sebastien Bacher <email address hidden>
To: Klaus Ethgen <email address hidden>
Cc: <email address hidden>
Subject: Re: Bug#270967: gconf2 try's to remove /etc completely when purging

Le vendredi 10 septembre 2004 =E0 13:56 +0200, Klaus Ethgen a =E9crit :

> Yes, I did on a other host (sid, newest version, all my hosts have "chatt=
r +i /").

Ok, I've the problem too.

$ chattr +i /=20
$ dpkg --purge libgconf2-4 gconf2

and I get the same error

The weird point is that running "sh /var/lib/dpkg/info/gconf2.postrm
purge" doesn't display any error, but the same line called by apt raises
an error ...

Anybody with an idea on this ?

BTW not a gconf problem ...

Thanks,

Sebastien Bacher

Revision history for this message
In , Adrian Bunk (bunk) wrote : Why purging gconf2-common might erase your /etc

severity 270967 critical
thanks

Hi Sebastien,

I think I can answer the following question you raised:

<-- snip -->

The weird point is that running "sh /var/lib/dpkg/info/gconf2.postrm
purge" doesn't display any error, but the same line called by apt raises
an error ...

<-- snip -->

The problem is only triggered when /etc/gconf2/ is empty.

cu
Adrian

--

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed

Revision history for this message
In , Josselin Mouette (joss) wrote : Re: Bug#270967: Why purging gconf2-common might erase your /etc

severity 270967 normal
clone 270967 -1
retitle 270967 gconf2-common fails to purge when /etc isn't removable
reassign -1 coreutils
retitle -1 rmdir should check emptiness before permissions
thanks

Le lundi 30 janvier 2006 à 03:23 +0100, Adrian Bunk a écrit :
> severity 270967 critical
> thanks

This is by no means a critical bug. There's no way this script can wipe
out your /etc.

> Hi Sebastien,
>
> I think I can answer the following question you raised:
>
> <-- snip -->
>
> The weird point is that running "sh /var/lib/dpkg/info/gconf2.postrm
> purge" doesn't display any error, but the same line called by apt raises
> an error ...
>
> <-- snip -->
>
> The problem is only triggered when /etc/gconf2/ is empty.

This error message is triggered by rmdir trying to remove /etc.
Normally, rmdir -p --ignore-fail-on-non-empty will try to
remove /etc/gconf/2, then /etc/gconf, then /etc, and will stop with /etc
because it isn't empty.

On your system, the chattr -i prevents the removal of /etc, and rmdir
fails on "permission denied" instead of "directory not empty".

I'd say that, so that rmdir -p --ignore-fail-on-non-empty can work on
such systems, it should be made to check first if the directory is
empty, and then if it has the permissions to remove it. I'm creating a
clone report on coreutils, but maybe it is caused directly by the kernel
or libc - in which case it should still be possible to work around the
issue in coreutils.

Currently, rmdir --ignore-fail-on-non-empty seems to do the following:
      * call rmdir(2)
      * check errno
      * ignore ENOTEMPTY
Maybe it could be modified to do the following:
      * check if the directory is empty
      * call rmdir(2)
I don't know whether this would be acceptable. Depending on the
coreutils maintainers' advice and decision, I will modify - or not - the
gconf2 scripts.

Regards,
--
 .''`. Josselin Mouette /\./\
: :' : <email address hidden>
`. `' <email address hidden>
   `- Debian GNU/Linux -- The power of freedom

Revision history for this message
In , Bob Proulx (bob-proulx) wrote :

Josselin Mouette wrote:
> This error message is triggered by rmdir trying to remove /etc.
> Normally, rmdir -p --ignore-fail-on-non-empty will try to
> remove /etc/gconf/2, then /etc/gconf, then /etc, and will stop with /etc
> because it isn't empty.

I see in the gconf2-common.postrm that the following command is being
run:

        rm -f /etc/gconf/2/path
        rmdir -p --ignore-fail-on-non-empty /etc/gconf/2

Can that instead be changed to the following so as to avoid trying to
remove /etc at all?

        rm -f /etc/gconf/2/path
        rmdir --ignore-fail-on-non-empty /etc/gconf/2 /etc/gconf

It just seems simpler this way.

Meanwhile, I have removed the moreinfo and unreproducible tags and am
forwarding this upstream.

Bob

Revision history for this message
In , Bob Proulx (bob-proulx) wrote :

> Meanwhile, I have removed the moreinfo and unreproducible tags and am
> forwarding this upstream.

Actually I am doing that to the cloned bug 350541.

Bob

Revision history for this message
In , Bob Proulx (bob-proulx) wrote : rmdir --ignore-fail-on-non-empty fails with permission denied

Please maintain the CC to both the bug number and the mailing list
when responding. Thanks.

Reported to the Debian BTS:

  http://bugs.debian.org/350541

'rmdir --ignore-fail-on-non-empty' will ignore non-empty directories
unless it has insufficient permission to remove them, in which case it
fails. Can rmdir avoid failing in this case?

Here is a way to reproduce the issue. Root access is required in
order to have permission to set the immutable attribute. The
filesystem needs to be ext2-like in order to support it.

  # mkdir testdir
  # mkdir testdir/foo
  # mkdir testdir/foo/bar
  # mkdir testdir/foo/boo
  # chattr +i testdir
  # rmdir -p --ignore-fail-on-non-empty testdir/foo/bar ; echo $?
  rmdir: testdir/foo: Permission denied
  1

But without the immutable attribute:

  # chattr -i testdir
  # mkdir testdir/foo/bar
  # rmdir -p --ignore-fail-on-non-empty testdir/foo/bar ; echo $?
  0

This was found in a package postrm script which tried to clean up by
doing the following:

  rm -f /etc/gconf/2/path
  rmdir -p --ignore-fail-on-non-empty /etc/gconf/2
  rmdir: `/etc': Permission denied

Bob

----- Forwarded *TRIMMED* message from Josselin Mouette <email address hidden> -----

From: Josselin Mouette <email address hidden>
Subject: Bug#270967: Why purging gconf2-common might erase your /etc
Date: Mon, 30 Jan 2006 10:10:57 +0100

[...TRIMMED CONTENT, ORIGINAL IN ARCHIVE...]

This error message is triggered by rmdir trying to remove /etc.
Normally, rmdir -p --ignore-fail-on-non-empty will try to
remove /etc/gconf/2, then /etc/gconf, then /etc, and will stop with /etc
because it isn't empty.

On your system, the chattr -i prevents the removal of /etc, and rmdir
fails on "permission denied" instead of "directory not empty".

I'd say that, so that rmdir -p --ignore-fail-on-non-empty can work on
such systems, it should be made to check first if the directory is
empty, and then if it has the permissions to remove it. I'm creating a
clone report on coreutils, but maybe it is caused directly by the kernel
or libc - in which case it should still be possible to work around the
issue in coreutils.

Currently, rmdir --ignore-fail-on-non-empty seems to do the following:
      * call rmdir(2)
      * check errno
      * ignore ENOTEMPTY
Maybe it could be modified to do the following:
      * check if the directory is empty
      * call rmdir(2)
I don't know whether this would be acceptable. Depending on the
coreutils maintainers' advice and decision, I will modify - or not - the
gconf2 scripts.

Regards,
--
 .''`. Josselin Mouette /\./\
: :' : <email address hidden>
`. `' <email address hidden>
   `- Debian GNU/Linux -- The power of freedom

----- End forwarded message -----

Revision history for this message
In , Bob Proulx (bob-proulx) wrote :

Bob Proulx wrote:
> Please maintain the CC to both the bug number and the mailing list
> when responding. Thanks.

Which would have been great if I had not been confused by the cloning
of this bug into two different bugs. My bad. Please keep
<email address hidden> instead of <email address hidden> in the CC
list. Sorry about that.

> Reported to the Debian BTS:
>
> http://bugs.debian.org/350541

Bob

Revision history for this message
In , Jim Meyering (meyering) wrote :
Download full text (8.0 KiB)

<email address hidden> (Bob Proulx) wrote:
> Please maintain the CC to both the bug number and the mailing list
> when responding. Thanks.
>
> Reported to the Debian BTS:
>
> http://bugs.debian.org/350541
>
> 'rmdir --ignore-fail-on-non-empty' will ignore non-empty directories
> unless it has insufficient permission to remove them, in which case it
> fails. Can rmdir avoid failing in this case?
>
> Here is a way to reproduce the issue. Root access is required in
> order to have permission to set the immutable attribute. The
> filesystem needs to be ext2-like in order to support it.
>
> # mkdir testdir
> # mkdir testdir/foo
> # mkdir testdir/foo/bar
> # mkdir testdir/foo/boo
> # chattr +i testdir
> # rmdir -p --ignore-fail-on-non-empty testdir/foo/bar ; echo $?
> rmdir: testdir/foo: Permission denied
> 1

I've fixed it like this:
(but no test case yet -- volunteers welcome!)

 Improve "rmdir --ignore-fail-on-non-empty"
 * src/rmdir.c (remove_parents, main): With --ignore-fail-on-non-empty,
 suppress a diagnostic also for e.g., EACCES, which can happen
 with read-only media or when the parent directory has the immutable
 attribute (set via chattr +i).
 (errno_may_be_empty, ignorable_failure): New functions.
 * src/remove.c (is_empty_dir): Move function to ...
 * src/system.h (is_empty_dir): ...here, and make it inline.
 Suggested by Josselin Mouette in <http://bugs.debian.org/363011>
 via Bob Proulx.
 * NEWS: Mention the improvement.

Signed-off-by: Jim Meyering <email address hidden>
---
 ChangeLog | 14 ++++++++++++++
 NEWS | 10 +++++++++-
 THANKS | 1 +
 src/remove.c | 32 +-------------------------------
 src/rmdir.c | 36 +++++++++++++++++++++++++++++++-----
 src/system.h | 30 ++++++++++++++++++++++++++++++
 6 files changed, 86 insertions(+), 37 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 5e15325..017c307 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2008-01-30 Jim Meyering <email address hidden>
+
+ Improve "rmdir --ignore-fail-on-non-empty"
+ * src/rmdir.c (remove_parents, main): With --ignore-fail-on-non-empty,
+ suppress a diagnostic also for e.g., EACCES, which can happen
+ with read-only media or when the parent directory has the immutable
+ attribute (set via chattr +i).
+ (errno_may_be_empty, ignorable_failure): New functions.
+ * src/remove.c (is_empty_dir): Move function to ...
+ * src/system.h (is_empty_dir): ...here, and make it inline.
+ Suggested by Josselin Mouette in <http://bugs.debian.org/363011>
+ via Bob Proulx.
+ * NEWS: Mention the improvement.
+
 2008-01-29 Paul Eggert <email address hidden>

  Don't modify argv in dd.
diff --git a/NEWS b/NEWS
index f474141..0d2d97d 100644
--- a/NEWS
+++ b/NEWS
@@ -1,12 +1,20 @@
 GNU coreutils NEWS -*- outline -*-

-* Noteworthy changes in release 6.10 (2008-01-22) [stable]
+* Noteworthy changes in release 6.?? (2008-??-??) [stable]

 ** Bug fixes

   ls no longer segfaults on files in /proc when linked with an older version
   of libselinux. E.g., ls -l /proc/sys would dereference a NULL pointer.

+ "rmdir --ignore-fail-on-non-empty" detects and ignores the failure
+ in more cases wh...

Read more...

Revision history for this message
dino99 (9d9) wrote :

Was fixed on 1.5.4 release

Changed in gconf2 (Debian):
importance: Unknown → Undecided
status: Incomplete → New
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.